Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge pull request #692 from NyaaPantsu/revert-690-user-torrent-edit

Revert "New User Edit Panel"
Cette révision appartient à :
alucard0134 2017-05-22 19:10:21 -05:00 révisé par GitHub
révision 1c5ff84614
17 fichiers modifiés avec 115 ajouts et 279 suppressions

Voir le fichier

@ -11,15 +11,12 @@ import (
"github.com/NyaaPantsu/nyaa/service/torrent"
"github.com/NyaaPantsu/nyaa/util"
"github.com/NyaaPantsu/nyaa/util/log"
msg "github.com/NyaaPantsu/nyaa/util/messages"
"github.com/gorilla/mux"
)
func HomeHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
page := vars["page"]
messages := msg.GetMessages(r)
deleteVar := r.URL.Query()["deleted"]
// db params url
var err error
@ -31,9 +28,7 @@ func HomeHandler(w http.ResponseWriter, r *http.Request) {
maxPerPage = 50 // default Value maxPerPage
}
}
if (deleteVar != nil) {
messages.AddInfoTf("infos", "torrent_deleted", "")
}
pagenum := 1
if page != "" {
pagenum, err = strconv.Atoi(html.EscapeString(page))
@ -73,7 +68,6 @@ func HomeHandler(w http.ResponseWriter, r *http.Request) {
htv := HomeTemplateVariables{
CommonTemplateVariables: common,
ListTorrents: torrentsJson,
Infos: messages.GetAllInfos(),
}
err = homeTemplate.ExecuteTemplate(w, "index.html", htv)

Voir le fichier

@ -256,7 +256,7 @@ func TorrentPostEditModPanel(w http.ResponseWriter, r *http.Request) {
if torrent.ID > 0 {
errUp := uploadForm.ExtractEditInfo(r)
if errUp != nil {
messages.AddErrorT("errors", "fail_torrent_update")
messages.AddError("errors", "Failed to update torrent!")
}
if !messages.HasErrors() {
// update some (but not all!) values
@ -268,7 +268,7 @@ func TorrentPostEditModPanel(w http.ResponseWriter, r *http.Request) {
torrent.Description = uploadForm.Description
torrent.Uploader = nil // GORM will create a new user otherwise (wtf?!)
db.ORM.Save(&torrent)
messages.AddInfoT("infos", "torrent_updated")
messages.AddInfo("infos", "Torrent details updated.")
}
}
htv := PanelTorrentEdVbs{NewPanelCommonVariables(r), uploadForm, messages.GetAllErrors(), messages.GetAllInfos()}
@ -325,9 +325,9 @@ func TorrentPostReassignModPanel(w http.ResponseWriter, r *http.Request) {
} else {
count, err2 := rForm.ExecuteAction()
if err2 != nil {
messages.AddErrorT("errors", "something_went_wrong")
messages.AddError("errors", "Something went wrong")
} else {
messages.AddInfoTf("infos", "nb_torrents_updated", count)
messages.AddInfof("infos", "%d torrents updated.", count)
}
}
@ -356,13 +356,13 @@ func torrentManyAction(r *http.Request) {
messages := msg.GetMessages(r) // new util for errors and infos
if action == "" {
messages.AddErrorT("errors", "no_action_selected")
messages.AddError("errors", "You have to tell what you want to do with your selection!")
}
if action == "move" && r.FormValue("moveto") == "" { // We need to check the form value, not the int one because hidden is 0
messages.AddErrorT("errors", "no_move_location_selected")
messages.AddError("errors", "Thou has't to telleth whither thee wanteth to moveth thy selection!")
}
if len(torrentsSelected) == 0 {
messages.AddErrorT("errors", "select_one_element")
messages.AddError("errors", "You need to select at least 1 element!")
}
if !messages.HasErrors() {
for _, torrent_id := range torrentsSelected {
@ -373,22 +373,22 @@ func torrentManyAction(r *http.Request) {
if config.TorrentStatus[moveTo] {
torrent.Status = moveTo
db.ORM.Save(&torrent)
messages.AddInfoTf("infos", "torrent_moved", torrent.Name)
messages.AddInfof("infos", "Torrent %s moved!", torrent.Name)
} else {
messages.AddErrorTf("errors", "no_status_exist", moveTo)
messages.AddErrorf("errors", "No such status %d exist!", moveTo)
}
case "delete":
_, err := torrentService.DeleteTorrent(torrent_id)
if err != nil {
messages.ImportFromError("errors", err)
} else {
messages.AddInfoTf("infos", "torrent_deleted", torrent.Name)
messages.AddInfof("infos", "Torrent %s deleted!", torrent.Name)
}
default:
messages.AddErrorTf("errors", "no_action_exist", action)
messages.AddErrorf("errors", "No such action %s exist!", action)
}
} else {
messages.AddErrorTf("errors", "torrent_not_exist", torrent_id)
messages.AddErrorf("errors", "Torrent with ID %s doesn't exist!", torrent_id)
}
}
}

Voir le fichier

@ -53,9 +53,6 @@ func init() {
Router.HandleFunc("/feed/{page}", RSSHandler).Name("feed_page")
Router.Handle("/view/{id}", wrapHandler(gzipViewHandler)).Methods("GET").Name("view_torrent")
Router.HandleFunc("/view/{id}", PostCommentHandler).Methods("POST").Name("post_comment")
Router.HandleFunc("/torrent/", TorrentEditUserPanel).Methods("GET").Name("user_torrent_edit")
Router.HandleFunc("/torrent/", TorrentPostEditUserPanel).Methods("POST").Name("user_torrent_edit")
Router.HandleFunc("/torrent/delete", TorrentDeleteUserPanel).Methods("GET").Name("user_torrent_delete")
Router.HandleFunc("/upload", UploadHandler).Name("upload")
Router.HandleFunc("/user/register", UserRegisterFormHandler).Name("user_register").Methods("GET")
Router.HandleFunc("/user/login", UserLoginFormHandler).Name("user_login").Methods("GET")

Voir le fichier

@ -4,7 +4,6 @@ import (
"github.com/NyaaPantsu/nyaa/model"
"github.com/NyaaPantsu/nyaa/util"
"github.com/NyaaPantsu/nyaa/util/log"
msg "github.com/NyaaPantsu/nyaa/util/messages"
"github.com/NyaaPantsu/nyaa/util/search"
"github.com/gorilla/mux"
"html"
@ -15,7 +14,6 @@ import (
func SearchHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
page := vars["page"]
messages := msg.GetMessages(r)
// db params url
var err error
@ -32,7 +30,6 @@ func SearchHandler(w http.ResponseWriter, r *http.Request) {
}
}
searchParam, torrents, nbTorrents, err := search.SearchByQuery(r, pagenum)
if err != nil {
util.SendError(w, err, 400)
@ -49,7 +46,7 @@ func SearchHandler(w http.ResponseWriter, r *http.Request) {
Category: searchParam.Category.String(),
ShowItemsPerPage: true,
}
htv := HomeTemplateVariables{common, b, messages.GetAllInfos()}
htv := HomeTemplateVariables{common, b}
err = searchTemplate.ExecuteTemplate(w, "index.html", htv)
if err != nil {

Voir le fichier

@ -23,7 +23,6 @@ var homeTemplate,
viewProfileNotifTemplate,
viewProfileEditTemplate,
viewUserDeleteTemplate,
userTorrentEd,
notFoundTemplate,
changeLanguageTemplate,
databaseDumpTemplate *template.Template
@ -116,11 +115,6 @@ func ReloadTemplates() {
name: "user_delete",
file: filepath.Join("user", "delete_success.html"),
},
templateLoader{
templ: &userTorrentEd,
name: "user_torrent_edit",
file: filepath.Join("user", "torrent_edit.html"),
},
templateLoader{
templ: &notFoundTemplate,
name: "404",

Voir le fichier

@ -162,9 +162,6 @@ var FuncMap = template.FuncMap{
// because time.* isn't available in templates...
return t.Format(time.RFC3339)
},
"GetCategories": func(keepParent bool) map[string]string {
return categories.GetCategoriesSelect(keepParent)
},
"CategoryName": func(category string, sub_category string) string {
s := category + "_" + sub_category

Voir le fichier

@ -71,17 +71,9 @@ type UserProfileNotifVariables struct {
Infos map[string][]string
}
type UserTorrentEdVbs struct {
CommonTemplateVariables
Upload UploadForm
FormErrors map[string][]string
FormInfos map[string][]string
}
type HomeTemplateVariables struct {
CommonTemplateVariables
ListTorrents []model.TorrentJSON
Infos map[string][]string
}
type DatabaseDumpTemplateVariables struct {

Voir le fichier

@ -9,10 +9,8 @@ import (
"github.com/NyaaPantsu/nyaa/db"
"github.com/NyaaPantsu/nyaa/model"
"github.com/NyaaPantsu/nyaa/service"
"github.com/NyaaPantsu/nyaa/service/captcha"
"github.com/NyaaPantsu/nyaa/service/notifier"
"github.com/NyaaPantsu/nyaa/service/report"
"github.com/NyaaPantsu/nyaa/service/torrent"
"github.com/NyaaPantsu/nyaa/service/user/permission"
"github.com/NyaaPantsu/nyaa/util/languages"
@ -70,13 +68,13 @@ func PostCommentHandler(w http.ResponseWriter, r *http.Request) {
if userPermission.NeedsCaptcha(currentUser) {
userCaptcha := captcha.Extract(r)
if !captcha.Authenticate(userCaptcha) {
messages.AddErrorT("errors", "bad_captcha")
messages.AddError("errors", "Bad captcha!")
}
}
content := p.Sanitize(r.FormValue("comment"))
if strings.TrimSpace(content) == "" {
messages.AddErrorT("errors", "comment_empty")
messages.AddError("errors", "Comment empty!")
}
if !messages.HasErrors() {
userID := currentUser.ID
@ -106,7 +104,7 @@ func ReportTorrentHandler(w http.ResponseWriter, r *http.Request) {
if userPermission.NeedsCaptcha(currentUser) {
userCaptcha := captcha.Extract(r)
if !captcha.Authenticate(userCaptcha) {
messages.AddErrorT("errors", "bad_captcha")
messages.AddError("errors", "Bad captcha!")
}
}
if !messages.HasErrors() {
@ -127,82 +125,3 @@ func ReportTorrentHandler(w http.ResponseWriter, r *http.Request) {
}
ViewHandler(w,r)
}
func TorrentEditUserPanel(w http.ResponseWriter, r *http.Request) {
id := r.URL.Query().Get("id")
torrent, _ := torrentService.GetTorrentById(id)
messages:= msg.GetMessages(r)
currentUser := GetUser(r)
if userPermission.CurrentOrAdmin(currentUser, torrent.UploaderID) {
torrentJson := torrent.ToJSON()
uploadForm := NewUploadForm()
uploadForm.Name = torrentJson.Name
uploadForm.Category = torrentJson.Category + "_" + torrentJson.SubCategory
uploadForm.Status = torrentJson.Status
uploadForm.WebsiteLink = string(torrentJson.WebsiteLink)
uploadForm.Description = string(torrentJson.Description)
htv := UserTorrentEdVbs{NewCommonVariables(r), uploadForm, messages.GetAllErrors(), messages.GetAllInfos()}
err := userTorrentEd.ExecuteTemplate(w, "index.html", htv)
log.CheckError(err)
} else {
NotFoundHandler(w, r)
}
}
func TorrentPostEditUserPanel(w http.ResponseWriter, r *http.Request) {
var uploadForm UploadForm
id := r.URL.Query().Get("id")
messages := msg.GetMessages(r)
torrent, _ := torrentService.GetTorrentById(id)
currentUser := GetUser(r)
if torrent.ID > 0 && userPermission.CurrentOrAdmin(currentUser, torrent.UploaderID) {
errUp := uploadForm.ExtractEditInfo(r)
if errUp != nil {
messages.AddErrorT("errors", "fail_torrent_update")
}
if !messages.HasErrors() {
status := model.TorrentStatusNormal
if uploadForm.Remake { // overrides trusted
status = model.TorrentStatusRemake
} else if currentUser.IsTrusted() {
status = model.TorrentStatusTrusted
}
// update some (but not all!) values
torrent.Name = uploadForm.Name
torrent.Category = uploadForm.CategoryID
torrent.SubCategory = uploadForm.SubCategoryID
torrent.Status = status
torrent.WebsiteLink = uploadForm.WebsiteLink
torrent.Description = uploadForm.Description
torrent.Uploader = nil // GORM will create a new user otherwise (wtf?!)
db.ORM.Save(&torrent)
messages.AddInfoT("infos", "torrent_updated")
}
htv := UserTorrentEdVbs{NewCommonVariables(r), uploadForm, messages.GetAllErrors(), messages.GetAllInfos()}
err_ := userTorrentEd.ExecuteTemplate(w, "index.html", htv)
log.CheckError(err_)
} else {
NotFoundHandler(w, r)
}
}
func TorrentDeleteUserPanel(w http.ResponseWriter, r *http.Request) {
id := r.URL.Query().Get("id")
currentUser := GetUser(r)
torrent, _ := torrentService.GetTorrentById(id)
if userPermission.CurrentOrAdmin(currentUser, torrent.UploaderID) {
_, err := torrentService.DeleteTorrent(id)
if (err == nil) {
//delete reports of torrent
whereParams := serviceBase.CreateWhereParams("torrent_id = ?", id)
reports, _, _ := reportService.GetTorrentReportsOrderBy(&whereParams, "", 0, 0)
for _, report := range reports {
reportService.DeleteTorrentReport(report.ID)
}
}
url, _ := Router.Get("home").URL()
http.Redirect(w, r, url.String()+"?deleted", http.StatusSeeOther)
} else {
NotFoundHandler(w, r)
}
}

Voir le fichier

@ -1,9 +1,41 @@
{{define "search_common"}}
<select name="c" class="form-control input-sm" value>
<option value="_">{{call $.T "all_categories"}}</option>
{{ range $name_cat, $id_cat := (GetCategories true) }}
<option value="{{ $id_cat }}" {{if eq $.Search.Category $id_cat }}selected{{end}}>{{call $.T $name_cat }}</option>
{{ end }}
{{ if Sukebei }}
<option value="1_" {{if eq .Search.Category "1_"}}selected{{end}}>{{call $.T "art"}}</option>
<option value="1_1" {{if eq .Search.Category "1_1"}}selected{{end}}>{{call $.T "art_anime"}}</option>
<option value="1_2" {{if eq .Search.Category "1_2"}}selected{{end}}>{{call $.T "art_doujinshi"}}</option>
<option value="1_3" {{if eq .Search.Category "1_3"}}selected{{end}}>{{call $.T "art_games"}}</option>
<option value="1_4" {{if eq .Search.Category "1_4"}}selected{{end}}>{{call $.T "art_manga"}}</option>
<option value="1_5" {{if eq .Search.Category "1_5"}}selected{{end}}>{{call $.T "art_pictures"}}</option>
<option value="2_" {{if eq .Search.Category "2_"}}selected{{end}}>{{call $.T "real_life"}}</option>
<option value="2_1" {{if eq .Search.Category "2_1"}}selected{{end}}>{{call $.T "real_life_photobooks_and_pictures"}}</option>
<option value="2_2" {{if eq .Search.Category "2_2"}}selected{{end}}>{{call $.T "real_life_videos"}}</option>
{{ else }}
<option value="3_" {{if eq .Search.Category "3_"}}selected{{end}}>{{call $.T "anime"}}</option>
<option value="3_12" {{if eq .Search.Category "3_12"}}selected{{end}}>{{call $.T "anime_amv"}}</option>
<option value="3_5" {{if eq .Search.Category "3_5"}}selected{{end}}>{{call $.T "anime_english_translated"}}</option>
<option value="3_13" {{if eq .Search.Category "3_13"}}selected{{end}}>{{call $.T "anime_non_english_translated"}}</option>
<option value="3_6" {{if eq .Search.Category "3_6"}}selected{{end}}>{{call $.T "anime_raw"}}</option>
<option value="2_" {{if eq .Search.Category "2_"}}selected{{end}}>{{call $.T "audio"}}</option>
<option value="2_3" {{if eq .Search.Category "2_3"}}selected{{end}}>{{call $.T "audio_lossless"}}</option>
<option value="2_4" {{if eq .Search.Category "2_4"}}selected{{end}}>{{call $.T "audio_lossy"}}</option>
<option value="4_" {{if eq .Search.Category "4_"}}selected{{end}}>{{call $.T "literature"}}</option>
<option value="4_7" {{if eq .Search.Category "4_7"}}selected{{end}}>{{call $.T "literature_english_translated"}}</option>
<option value="4_8" {{if eq .Search.Category "4_8"}}selected{{end}}>{{call $.T "literature_raw"}}</option>
<option value="4_14" {{if eq .Search.Category "4_14"}}selected{{end}}>{{call $.T "literature_non_english_translated"}}</option>
<option value="5_" {{if eq .Search.Category "5_"}}selected{{end}}>{{call $.T "live_action"}}</option>
<option value="5_9" {{if eq .Search.Category "5_9"}}selected{{end}}>{{call $.T "live_action_english_translated"}}</option>
<option value="5_10" {{if eq .Search.Category "5_10"}}selected{{end}}>{{call $.T "live_action_idol_pv"}}</option>
<option value="5_18" {{if eq .Search.Category "5_18"}}selected{{end}}>{{call $.T "live_action_non_english_translated"}}</option>
<option value="5_11" {{if eq .Search.Category "5_11"}}selected{{end}}>{{call $.T "live_action_raw"}}</option>
<option value="6_" {{if eq .Search.Category "6_"}}selected{{end}}>{{call $.T "pictures"}}</option>
<option value="6_15" {{if eq .Search.Category "6_15"}}selected{{end}}>{{call $.T "pictures_graphics"}}</option>
<option value="6_16" {{if eq .Search.Category "6_16"}}selected{{end}}>{{call $.T "pictures_photos"}}</option>
<option value="1_" {{if eq .Search.Category "1_"}}selected{{end}}>{{call $.T "software"}}</option>
<option value="1_1" {{if eq .Search.Category "1_1"}}selected{{end}}>{{call $.T "software_applications"}}</option>
<option value="1_2" {{if eq .Search.Category "1_2"}}selected{{end}}>{{call $.T "software_games"}}</option>
{{ end }}
</select>
<select name="s" class="form-control input-sm">
<option value="0">{{call $.T "show_all"}}</option>

Voir le fichier

@ -16,8 +16,40 @@
<label for="c">{{call $.T "category"}}</label>
<select name="c" class="form-control input-sm">
<option value="">{{call $.T "select_a_torrent_category"}}</option>
{{ range $name_cat, $id_cat := (GetCategories false) }}
<option value="{{ $id_cat }}" {{if eq $.Upload.Category $id_cat }}selected{{end}}>{{call $.T $name_cat }}</option>
{{ if Sukebei }}
<option value="1_" {{if eq .Category "1_"}}selected{{end}}>{{call $.T "art"}}</option>
<option value="1_1" {{if eq .Category "1_1"}}selected{{end}}>{{call $.T "art_anime"}}</option>
<option value="1_2" {{if eq .Category "1_2"}}selected{{end}}>{{call $.T "art_doujinshi"}}</option>
<option value="1_3" {{if eq .Category "1_3"}}selected{{end}}>{{call $.T "art_games"}}</option>
<option value="1_4" {{if eq .Category "1_4"}}selected{{end}}>{{call $.T "art_manga"}}</option>
<option value="1_5" {{if eq .Category "1_5"}}selected{{end}}>{{call $.T "art_pictures"}}</option>
<option value="2_" {{if eq .Category "2_"}}selected{{end}}>{{call $.T "real_life"}}</option>
<option value="2_1" {{if eq .Category "2_1"}}selected{{end}}>{{call $.T "real_life_photobooks_and_Pictures"}}</option>
<option value="2_2" {{if eq .Category "2_2"}}selected{{end}}>{{call $.T "real_life_videos"}}</option>
{{ else }}
<option value="3_" {{if eq .Category "3_"}}selected{{end}}>{{call $.T "anime"}}</option>
<option value="3_12" {{if eq .Category "3_12"}}selected{{end}}>{{call $.T "anime_amv"}}</option>
<option value="3_5" {{if eq .Category "3_5"}}selected{{end}}>{{call $.T "anime_english_translated"}}</option>
<option value="3_13" {{if eq .Category "3_13"}}selected{{end}}>{{call $.T "anime_non_english_translated"}}</option>
<option value="3_6" {{if eq .Category "3_6"}}selected{{end}}>{{call $.T "anime_raw"}}</option>
<option value="2_" {{if eq .Category "2_"}}selected{{end}}>{{call $.T "audio"}}</option>
<option value="2_3" {{if eq .Category "2_3"}}selected{{end}}>{{call $.T "audio_lossless"}}</option>
<option value="2_4" {{if eq .Category "2_4"}}selected{{end}}>{{call $.T "audio_lossy"}}</option>
<option value="4_" {{if eq .Category "4_"}}selected{{end}}>{{call $.T "literature"}}</option>
<option value="4_7" {{if eq .Category "4_7"}}selected{{end}}>{{call $.T "literature_english_translated"}}</option>
<option value="4_8" {{if eq .Category "4_8"}}selected{{end}}>{{call $.T "literature_raw"}}</option>
<option value="4_14" {{if eq .Category "4_14"}}selected{{end}}>{{call $.T "literature_non_english_translated"}}</option>
<option value="5_" {{if eq .Category "5_"}}selected{{end}}>{{call $.T "live_action"}}</option>
<option value="5_9" {{if eq .Category "5_9"}}selected{{end}}>{{call $.T "live_action_english_translated"}}</option>
<option value="5_10" {{if eq .Category "5_10"}}selected{{end}}>{{call $.T "live_action_idol_pv"}}</option>
<option value="5_18" {{if eq .Category "5_18"}}selected{{end}}>{{call $.T "live_action_non_english_translated"}}</option>
<option value="5_11" {{if eq .Category "5_11"}}selected{{end}}>{{call $.T "live_action_raw"}}</option>
<option value="6_" {{if eq .Category "6_"}}selected{{end}}>{{call $.T "pictures"}}</option>
<option value="6_15" {{if eq .Category "6_15"}}selected{{end}}>{{call $.T "pictures_graphics"}}</option>
<option value="6_16" {{if eq .Category "6_16"}}selected{{end}}>{{call $.T "pictures_photos"}}</option>
<option value="1_" {{if eq .Category "1_"}}selected{{end}}>{{call $.T "software"}}</option>
<option value="1_1" {{if eq .Category "1_1"}}selected{{end}}>{{call $.T "software_applications"}}</option>
<option value="1_2" {{if eq .Category "1_2"}}selected{{end}}>{{call $.T "software_games"}}</option>
{{ end }}
</select>
</div>

Voir le fichier

@ -12,9 +12,7 @@ Your browser does not support the audio element.
</audio>
<span id="mascot" class="visible-lg"></span>
{{ 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}}
<div class="blockBody">
<nav>
<ul class="list-inline text-center" aria-label="Page navigation">

Voir le fichier

@ -23,10 +23,34 @@
</div>
<div class="form-group">
<label for="c">{{call $.T "category"}}</label>
<select name="c" class="form-control input-sm">
<select name="c" id="c" class="form-control input-sm" required>
<option value="">{{call $.T "select_a_torrent_category"}}</option>
{{ range $name_cat, $id_cat := (GetCategories false) }}
<option value="{{ $id_cat }}" {{if eq $.Upload.Category $id_cat }}selected{{end}}>{{call $.T $name_cat }}</option>
{{ if Sukebei }}
<option value="1_1" {{if eq .Category "1_1"}}selected{{end}}>{{call $.T "art_anime"}}</option>
<option value="1_2" {{if eq .Category "1_2"}}selected{{end}}>{{call $.T "art_doujinshi"}}</option>
<option value="1_3" {{if eq .Category "1_3"}}selected{{end}}>{{call $.T "art_games"}}</option>
<option value="1_4" {{if eq .Category "1_4"}}selected{{end}}>{{call $.T "art_manga"}}</option>
<option value="1_5" {{if eq .Category "1_5"}}selected{{end}}>{{call $.T "art_pictures"}}</option>
<option value="2_1" {{if eq .Category "2_1"}}selected{{end}}>{{call $.T "real_life_photobooks_and_Pictures"}}</option>
<option value="2_2" {{if eq .Category "2_2"}}selected{{end}}>{{call $.T "real_life_videos"}}</option>
{{ else }}
<option value="3_12" {{if eq .Category "3_12"}}selected{{end}}>{{call $.T "anime_amv"}}</option>
<option value="3_5" {{if eq .Category "3_5"}}selected{{end}}>{{call $.T "anime_english_translated"}}</option>
<option value="3_13" {{if eq .Category "3_13"}}selected{{end}}>{{call $.T "anime_non_english_translated"}}</option>
<option value="3_6" {{if eq .Category "3_6"}}selected{{end}}>{{call $.T "anime_raw"}}</option>
<option value="2_3" {{if eq .Category "2_3"}}selected{{end}}>{{call $.T "audio_lossless"}}</option>
<option value="2_4" {{if eq .Category "2_4"}}selected{{end}}>{{call $.T "audio_lossy"}}</option>
<option value="4_7" {{if eq .Category "4_7"}}selected{{end}}>{{call $.T "literature_english_translated"}}</option>
<option value="4_8" {{if eq .Category "4_8"}}selected{{end}}>{{call $.T "literature_raw"}}</option>
<option value="4_14" {{if eq .Category "4_14"}}selected{{end}}>{{call $.T "literature_non_english_translated"}}</option>
<option value="5_9" {{if eq .Category "5_9"}}selected{{end}}>{{call $.T "live_action_english_translated"}}</option>
<option value="5_10" {{if eq .Category "5_10"}}selected{{end}}>{{call $.T "live_action_idol_pv"}}</option>
<option value="5_18" {{if eq .Category "5_18"}}selected{{end}}>{{call $.T "live_action_non_english_translated"}}</option>
<option value="5_11" {{if eq .Category "5_11"}}selected{{end}}>{{call $.T "live_action_raw"}}</option>
<option value="6_15" {{if eq .Category "6_15"}}selected{{end}}>{{call $.T "pictures_graphics"}}</option>
<option value="6_16" {{if eq .Category "6_16"}}selected{{end}}>{{call $.T "pictures_photos"}}</option>
<option value="1_1" {{if eq .Category "1_1"}}selected{{end}}>{{call $.T "software_applications"}}</option>
<option value="1_2" {{if eq .Category "1_2"}}selected{{end}}>{{call $.T "software_games"}}</option>
{{ end }}
</select>
<p class="help-block">{{ call $.T "please_include_our_tracker" }}</p>

Voir le fichier

@ -1,54 +0,0 @@
{{define "title"}}Torrent Edit{{end}}
{{define "content"}}
<div class="blockBody">
{{with .Upload}}
<form enctype="multipart/form-data" role="upload" method="POST">
{{ range (index $.FormInfos "infos")}}
<div class="alert alert-info"><a class="panel-close close" data-dismiss="alert">×</a><i class="glyphicon glyphicon-info-sign"></i> {{ . }}</div>
{{end}}
{{ range (index $.FormErrors "errors")}}
<div class="alert alert-danger"><a class="panel-close close" data-dismiss="alert">×</a><i class="glyphicon glyphicon-exclamation-sign"></i> {{ . }}</div>
{{end}}
<div class="form-group">
<label for="name">{{call $.T "name"}}</label>
<input type="text" name="name" class="form-control" placeholder="{{call $.T "file_name"}}" value="{{.Name}}" required>
</div>
<div class="form-group">
<label for="c">{{call $.T "category"}}</label>
<select name="c" class="form-control input-sm">
<option value="">{{call $.T "select_a_torrent_category"}}</option>
{{ range $name_cat, $id_cat := (GetCategories false) }}
<option value="{{ $id_cat }}" {{if eq $.Upload.Category $id_cat }}selected{{end}}>{{call $.T $name_cat }}</option>
{{ end }}
</select>
</div>
<div class="form-group">
<input type="checkbox" name="remake" id="remake" >
<label for="remake">{{call $.T "mark_as_remake"}}</label>
</div>
<div class="form-group">
<label for="website_link">{{call $.T "website_link"}}</label>
<input name="website_link" id="website_link" class="form-control" type="text" value="{{.WebsiteLink}}">
</div>
<div class="form-group">
<label for="desc">{{call $.T "torrent_description"}}</label>
<p class="help-block">{{call $.T "description_markdown_notice"}}</p>
<textarea name="desc" class="form-control torrent-desc" rows="10">{{.Description}}</textarea>
</div>
<button type="submit" class="btn btn-success">{{call $.T "save_changes"}}</button>
<br>
<br>
</form>
{{end}}
</div>
{{end}}
{{define "js_footer"}}
<script type="text/javascript" charset="utf-8" src="{{.URL.Parse "/js/uploadPage.js"}}"></script>
<script type="text/javascript" charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/markdown.js/0.5.0/markdown.min.js"></script>
<script type="text/javascript" charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/to-markdown/3.0.4/to-markdown.js"></script>
<script type="text/javascript" charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-markdown/2.10.0/js/bootstrap-markdown.js"></script>
<script>
$(".torrent-desc").markdown({resize: "both"})
</script>
{{end}}

Voir le fichier

@ -53,9 +53,6 @@
{{ if HasAdmin $.User}}
<a href="{{ genRoute "mod_tdelete" }}?id={{ .ID }}" class="btn btn-danger btn-lg" onclick="if (!confirm('{{ call $.T "are_you_sure" }}')) return false;"><i class="glyphicon glyphicon-trash"></i></a>
<a href="{{ genRoute "mod_tedit" }}?id={{ .ID }}" class="btn btn-warning btn-lg"><i class="glyphicon glyphicon-pencil"></i></a>
{{ else if CurrentUserIdentical $.User .UploaderID }}
<a href="{{ genRoute "user_torrent_delete" }}?id={{ .ID }}" class="btn btn-danger btn-lg" onclick="if (!confirm('{{ call $.T "are_you_sure" }}')) return false;"><i class="glyphicon glyphicon-trash"></i></a>
<a href="{{ genRoute "user_torrent_edit" }}?id={{ .ID }}" class="btn btn-warning btn-lg"><i class="glyphicon glyphicon-pencil"></i></a>
{{end}}
</div>
<div style="clear: both;"></div>

Voir le fichier

@ -838,61 +838,5 @@
{
"id": "new_comment_on_torrent",
"translation": "New comment on torrent: \"%s\""
},
{
"id": "no_action_selected",
"translation": "You have to tell what you want to do with your selection!"
},
{
"id": "no_move_location_selected",
"translation": "Thou has't to telleth whither thee wanteth to moveth thy selection!"
},
{
"id": "select_one_element",
"translation": "You need to select at least 1 element!"
},
{
"id": "torrent_moved",
"translation": "Torrent %s moved!"
},
{
"id": "no_status_exist",
"translation": "No such status %d exist!"
},
{
"id": "torrent_deleted",
"translation": "Torrent %s deleted!"
},
{
"id": "no_action_exist",
"translation": "No such action %s exist!"
},
{
"id": "torrent_not_exist",
"translation": "Torrent with ID %s doesn't exist!"
},
{
"id": "something_went_wrong",
"translation": "Something went wrong"
},
{
"id": "nb_torrents_updated",
"translation": "%d torrents updated."
},
{
"id": "torrent_updated",
"translation": "Torrent details updated."
},
{
"id": "fail_torrent_update",
"translation": "Failed to update torrent!"
},
{
"id": "bad_captcha",
"translation": "Bad captcha!"
},
{
"id": "comment_empty",
"translation": "Comment empty!"
}
]

Voir le fichier

@ -58,14 +58,3 @@ func CategoryExists(category string) bool {
_, exists := GetCategories()[category]
return exists
}
func GetCategoriesSelect(keepParent bool) map[string]string {
categories := GetCategories()
catSelect := make(map[string]string, len(categories))
for k, v := range categories {
if len(k) > 2 || keepParent {
catSelect[v] = k
}
}
return catSelect
}

Voir le fichier

@ -3,8 +3,6 @@ import (
"github.com/gorilla/context"
"fmt"
"net/http"
"github.com/nicksnyder/go-i18n/i18n"
"github.com/NyaaPantsu/nyaa/util/languages"
)
const MessagesKey = "messages"
@ -13,7 +11,6 @@ type Messages struct {
Errors map[string][]string
Infos map[string][]string
r *http.Request
T i18n.TranslateFunc
}
func GetMessages(r *http.Request) *Messages {
@ -21,8 +18,7 @@ func GetMessages(r *http.Request) *Messages {
return rv.(*Messages)
} else {
context.Set(r, MessagesKey, &Messages{})
T, _ := languages.GetTfuncAndLanguageFromRequest(r)
return &Messages{make(map[string][]string),make(map[string][]string), r, T}
return &Messages{make(map[string][]string),make(map[string][]string), r}
}
}
@ -36,12 +32,6 @@ func (mes *Messages) AddError(name string, msg string) {
func (mes *Messages) AddErrorf( name string, msg string, args ...interface{}) {
mes.AddError(name, fmt.Sprintf(msg, args...))
}
func (mes *Messages) AddErrorTf( name string, id string, args ...interface{}) {
mes.AddErrorf(name, mes.T(id), args...)
}
func (mes *Messages) AddErrorT( name string, id string) {
mes.AddError(name, mes.T(id))
}
func (mes *Messages) ImportFromError(name string, err error) {
mes.AddError(name, err.Error())
}
@ -56,12 +46,6 @@ func (mes *Messages) AddInfo(name string, msg string) {
func (mes *Messages) AddInfof(name string, msg string, args ...interface{}) {
mes.AddInfo(name, fmt.Sprintf(msg, args...))
}
func (mes *Messages) AddInfoTf(name string, id string, args ...interface{}) {
mes.AddInfof(name, mes.T(id), args...)
}
func (mes *Messages) AddInfoT(name string, id string) {
mes.AddInfo(name, mes.T(id))
}
func (mes *Messages) ClearErrors() {
mes.Infos = nil