Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0
Cette révision appartient à :
akuma06 2017-05-21 01:06:40 +02:00
Parent 42de73fa78
révision 5f60970eb9
5 fichiers modifiés avec 28 ajouts et 7 suppressions

Voir le fichier

@ -98,6 +98,7 @@ type UserProfileVariables struct {
}
type UserProfileNotifVariables struct {
Infos map[string][]string
Search SearchForm
Navigation Navigation
User *model.User

Voir le fichier

@ -7,10 +7,12 @@ import (
"github.com/NyaaPantsu/nyaa/model"
"github.com/NyaaPantsu/nyaa/service/captcha"
"github.com/NyaaPantsu/nyaa/service/notifier"
"github.com/NyaaPantsu/nyaa/service/user"
"github.com/NyaaPantsu/nyaa/service/user/form"
"github.com/NyaaPantsu/nyaa/service/user/permission"
"github.com/NyaaPantsu/nyaa/util/languages"
msg "github.com/NyaaPantsu/nyaa/util/messages"
"github.com/NyaaPantsu/nyaa/util/modelHelper"
"github.com/gorilla/mux"
)
@ -327,8 +329,14 @@ func UserFollowHandler(w http.ResponseWriter, r *http.Request) {
func UserNotificationsHandler(w http.ResponseWriter, r *http.Request) {
currentUser := GetUser(r)
if currentUser.ID > 0 {
languages.SetTranslationFromRequest(viewProfileNotifTemplate, r)
htv := UserProfileNotifVariables{NewSearchForm(), NewNavigation(), currentUser, r.URL, mux.CurrentRoute(r)}
messages := msg.GetMessages(r)
T := languages.SetTranslationFromRequest(viewProfileNotifTemplate, r)
if r.URL.Query()["clear"] != nil {
notifierService.DeleteAllNotifications(currentUser.ID)
messages.AddInfo("infos", T("notifications_cleared"))
currentUser.Notifications = []model.Notification{}
}
htv := UserProfileNotifVariables{messages.GetAllInfos(), NewSearchForm(), NewNavigation(), currentUser, r.URL, mux.CurrentRoute(r)}
err := viewProfileNotifTemplate.ExecuteTemplate(w, "index.html", htv)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)

Voir le fichier

@ -9,6 +9,7 @@ import (
"github.com/NyaaPantsu/nyaa/db"
"github.com/NyaaPantsu/nyaa/model"
"github.com/NyaaPantsu/nyaa/service/captcha"
"github.com/NyaaPantsu/nyaa/service/notifier"
"github.com/NyaaPantsu/nyaa/service/torrent"
"github.com/NyaaPantsu/nyaa/service/user/permission"
"github.com/NyaaPantsu/nyaa/util"
@ -22,19 +23,24 @@ func ViewHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id := vars["id"]
messages := msg.GetMessages(r)
user := GetUser(r)
if (r.URL.Query()["success"] != nil) {
messages.AddInfo("infos", "Torrent uploaded successfully!")
}
torrent, err := torrentService.GetTorrentById(id)
if (r.URL.Query()["notif"] != nil) {
notifierService.ToggleReadNotification(torrent.Identifier(), user.ID)
}
if err != nil {
NotFoundHandler(w, r)
return
}
b := torrent.ToJSON()
captchaID := ""
user := GetUser(r)
if userPermission.NeedsCaptcha(user) {
captchaID = captcha.GetID()
}

Voir le fichier

@ -1,15 +1,17 @@
{{define "profile_notifications_content"}}
{{with .User}}
<div style="padding: 0.5rem; background: grey;">
<a href="" class="btn btn-danger pull-right"><i class="glyphicon glyphicon-trash"></i> Clear Notifications</a>
<a href="{{ genRoute "user_notifications" }}?clear" class="btn btn-danger pull-right"><i class="glyphicon glyphicon-trash"></i> Clear Notifications</a>
<div style="clear: both;"></div>
</div>
{{ range (index $.Infos "infos")}}
<div class="alert alert-info"><a class="panel-close close" data-dismiss="alert">×</a><i class="glyphicon glyphicon-info-sign"></i> {{ . }}</div>
{{end}}
<table class="table table-hover table-striped">
{{ range .Notifications }}
<tr><td>
<div style="margin: 1rem;">
<i class="glyphicon glyphicon-bell pull-left" style="margin: -0.5rem;"></i>
<a href="{{ .Url }}"><h3>{{ .Content }}</h3></a>
<div style="padding: 0 1rem 1rem;">
<a href="{{ .Url }}?notif"><h3><i class="glyphicon glyphicon-bell profile-usertitle-name" ></i>{{ .Content }}</h3></a>
</div>
</td></tr>
{{end}}

Voir le fichier

@ -759,6 +759,10 @@
"id": "no_database_dumps_available",
"translation": "No database dumps are available at this moment."
},
{
"id": "notifications_cleared",
"translation": "Notifications erased!"
},
{
"id": "my_notifications",
"translation": "My Notifications"