diff --git a/README.md b/README.md index e26d1bd5..5658b3bd 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,12 @@ The aim of this project is to write a fully featured nyaa replacement in golang that anyone will be able to deploy locally or remotely. +## [Roadmap](https://trello.com/b/gMJBwoRq/nyaa-pantsu-cat-roadmap) +The Roadmap will give you an overview of the features and tasks that the project are currently discussing, working on and have completed. +If you are looking for a feature that is not listed just make a GitHub Issue and it will get added to the trello board. + +You can view the public trello board [here](https://trello.com/b/gMJBwoRq/nyaa-pantsu-cat-roadmap) or click on the "Roadmap". + # Requirements * Golang diff --git a/main.go b/main.go index a22da754..c58d68f0 100644 --- a/main.go +++ b/main.go @@ -27,8 +27,8 @@ func RunServer(conf *config.Config) { // Set up server, srv := &http.Server{ - WriteTimeout: 24 * time.Second, - ReadTimeout: 8 * time.Second, + WriteTimeout: 5 * time.Second, + ReadTimeout: 5 * time.Second, } l, err := network.CreateHTTPListener(conf) log.CheckError(err) diff --git a/public/css/style.css b/public/css/style.css index 4e766db8..4c71284d 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -224,6 +224,7 @@ div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:last-of-typ #mainmenu .badgemenu { padding-top: 0; + margin-right: -50px; /* don't ask */ } /* PROFILE PAGE */ diff --git a/router/faqHandler.go b/router/faqHandler.go index af77167e..c1be82b3 100644 --- a/router/faqHandler.go +++ b/router/faqHandler.go @@ -8,11 +8,8 @@ import ( ) func FaqHandler(w http.ResponseWriter, r *http.Request) { - searchForm := NewSearchForm() - searchForm.HideAdvancedSearch = true - languages.SetTranslationFromRequest(faqTemplate, r, "en-us") - err := faqTemplate.ExecuteTemplate(w, "index.html", FaqTemplateVariables{Navigation{}, searchForm, GetUser(r), r.URL, mux.CurrentRoute(r)}) + err := faqTemplate.ExecuteTemplate(w, "index.html", FaqTemplateVariables{Navigation{}, NewSearchForm(), GetUser(r), r.URL, mux.CurrentRoute(r)}) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/router/modpanel.go b/router/modpanel.go index 35a720c1..73ac081b 100644 --- a/router/modpanel.go +++ b/router/modpanel.go @@ -98,6 +98,14 @@ func (f *ReassignForm) ExecuteAction() (int, error) { return num, nil } +// Helper that creates a search form without items/page field +// these need to be used when the templateVariables don't include `Navigation` +func NewPanelSearchForm() SearchForm { + form := NewSearchForm() + form.ShowItemsPerPage = false + return form +} + func IndexModPanel(w http.ResponseWriter, r *http.Request) { currentUser := GetUser(r) @@ -110,7 +118,7 @@ func IndexModPanel(w http.ResponseWriter, r *http.Request) { torrentReports, _, _ := reportService.GetAllTorrentReports(offset, 0) languages.SetTranslationFromRequest(panelIndex, r, "en-us") - htv := PanelIndexVbs{torrents, model.TorrentReportsToJSON(torrentReports), users, comments, NewSearchForm(), currentUser, r.URL} + htv := PanelIndexVbs{torrents, model.TorrentReportsToJSON(torrentReports), users, comments, NewPanelSearchForm(), currentUser, r.URL} err := panelIndex.ExecuteTemplate(w, "admin_index.html", htv) log.CheckError(err) } else { @@ -137,9 +145,9 @@ func TorrentsListPanel(w http.ResponseWriter, r *http.Request) { searchParam, torrents, _, err := search.SearchByQuery(r, pagenum) searchForm := SearchForm{ - SearchParam: searchParam, - Category: searchParam.Category.String(), - HideAdvancedSearch: false, + SearchParam: searchParam, + Category: searchParam.Category.String(), + ShowItemsPerPage: true, } languages.SetTranslationFromRequest(panelTorrentList, r, "en-us") @@ -256,7 +264,7 @@ func TorrentEditModPanel(w http.ResponseWriter, r *http.Request) { uploadForm.Category = torrentJson.Category + "_" + torrentJson.SubCategory uploadForm.Status = torrentJson.Status uploadForm.Description = string(torrentJson.Description) - htv := PanelTorrentEdVbs{uploadForm, NewSearchForm(), currentUser, form.NewErrors(), form.NewInfos(), r.URL} + htv := PanelTorrentEdVbs{uploadForm, NewPanelSearchForm(), currentUser, form.NewErrors(), form.NewInfos(), r.URL} err := panelTorrentEd.ExecuteTemplate(w, "admin_index.html", htv) log.CheckError(err) @@ -295,7 +303,7 @@ func TorrentPostEditModPanel(w http.ResponseWriter, r *http.Request) { } } languages.SetTranslationFromRequest(panelTorrentEd, r, "en-us") - htv := PanelTorrentEdVbs{uploadForm, NewSearchForm(), currentUser, err, infos, r.URL} + htv := PanelTorrentEdVbs{uploadForm, NewPanelSearchForm(), currentUser, err, infos, r.URL} err_ := panelTorrentEd.ExecuteTemplate(w, "admin_index.html", htv) log.CheckError(err_) } @@ -358,7 +366,7 @@ func TorrentReassignModPanel(w http.ResponseWriter, r *http.Request) { } languages.SetTranslationFromRequest(panelTorrentReassign, r, "en-us") - htv := PanelTorrentReassignVbs{ReassignForm{}, NewSearchForm(), currentUser, form.NewErrors(), form.NewInfos(), r.URL} + htv := PanelTorrentReassignVbs{ReassignForm{}, NewPanelSearchForm(), currentUser, form.NewErrors(), form.NewInfos(), r.URL} err := panelTorrentReassign.ExecuteTemplate(w, "admin_index.html", htv) log.CheckError(err) } @@ -385,7 +393,7 @@ func TorrentPostReassignModPanel(w http.ResponseWriter, r *http.Request) { } } - htv := PanelTorrentReassignVbs{rForm, NewSearchForm(), currentUser, err, infos, r.URL} + htv := PanelTorrentReassignVbs{rForm, NewPanelSearchForm(), currentUser, err, infos, r.URL} err_ := panelTorrentReassign.ExecuteTemplate(w, "admin_index.html", htv) log.CheckError(err_) } diff --git a/router/notFoundHandler.go b/router/notFoundHandler.go index ed41e902..5480068f 100644 --- a/router/notFoundHandler.go +++ b/router/notFoundHandler.go @@ -10,11 +10,8 @@ import ( func NotFoundHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotFound) - searchForm := NewSearchForm() - searchForm.HideAdvancedSearch = true - languages.SetTranslationFromRequest(notFoundTemplate, r, "en-us") - err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, searchForm, GetUser(r), r.URL, mux.CurrentRoute(r)}) + err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, NewSearchForm(), GetUser(r), r.URL, mux.CurrentRoute(r)}) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/router/searchHandler.go b/router/searchHandler.go index 57bfe1f1..1fe0e125 100644 --- a/router/searchHandler.go +++ b/router/searchHandler.go @@ -38,9 +38,9 @@ func SearchHandler(w http.ResponseWriter, r *http.Request) { navigationTorrents := Navigation{nbTorrents, int(searchParam.Max), pagenum, "search_page"} // Convert back to strings for now. searchForm := SearchForm{ - SearchParam: searchParam, - Category: searchParam.Category.String(), - HideAdvancedSearch: false, + SearchParam: searchParam, + Category: searchParam.Category.String(), + ShowItemsPerPage: true, } htv := HomeTemplateVariables{b, searchForm, navigationTorrents, GetUser(r), r.URL, mux.CurrentRoute(r)} diff --git a/router/templateVariables.go b/router/templateVariables.go index 0f94509a..d3217fe2 100644 --- a/router/templateVariables.go +++ b/router/templateVariables.go @@ -196,14 +196,15 @@ type Navigation struct { type SearchForm struct { common.SearchParam - Category string - HideAdvancedSearch bool + Category string + ShowItemsPerPage bool } // Some Default Values to ease things out func NewSearchForm() SearchForm { return SearchForm{ Category: "_", + ShowItemsPerPage: true, } } diff --git a/router/userHandler.go b/router/userHandler.go index 5370896c..2017250a 100755 --- a/router/userHandler.go +++ b/router/userHandler.go @@ -66,9 +66,7 @@ func UserProfileHandler(w http.ResponseWriter, r *http.Request) { err["errors"] = append(err["errors"], errUser.Error()) } languages.SetTranslationFromRequest(viewUserDeleteTemplate, r, "en-us") - searchForm := NewSearchForm() - searchForm.HideAdvancedSearch = true - htv := UserVerifyTemplateVariables{err, searchForm, Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)} + htv := UserVerifyTemplateVariables{err, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)} errorTmpl := viewUserDeleteTemplate.ExecuteTemplate(w, "index.html", htv) if errorTmpl != nil { http.Error(w, errorTmpl.Error(), http.StatusInternalServerError) @@ -81,9 +79,7 @@ func UserProfileHandler(w http.ResponseWriter, r *http.Request) { if unfollow != nil { infosForm["infos"] = append(infosForm["infos"], fmt.Sprintf(T("user_unfollowed_msg"), userProfile.Username)) } - searchForm := NewSearchForm() - searchForm.HideAdvancedSearch = true - htv := UserProfileVariables{&userProfile, infosForm, searchForm, Navigation{}, currentUser, r.URL, mux.CurrentRoute(r)} + htv := UserProfileVariables{&userProfile, infosForm, NewSearchForm(), Navigation{}, currentUser, r.URL, mux.CurrentRoute(r)} err := viewProfileTemplate.ExecuteTemplate(w, "index.html", htv) if err != nil { @@ -91,11 +87,8 @@ func UserProfileHandler(w http.ResponseWriter, r *http.Request) { } } } else { - searchForm := NewSearchForm() - searchForm.HideAdvancedSearch = true - languages.SetTranslationFromRequest(notFoundTemplate, r, "en-us") - err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, searchForm, GetUser(r), r.URL, mux.CurrentRoute(r)}) + err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, NewSearchForm(), GetUser(r), r.URL, mux.CurrentRoute(r)}) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } @@ -113,21 +106,16 @@ func UserDetailsHandler(w http.ResponseWriter, r *http.Request) { b := form.UserForm{} modelHelper.BindValueForm(&b, r) languages.SetTranslationFromRequest(viewProfileEditTemplate, r, "en-us") - searchForm := NewSearchForm() - searchForm.HideAdvancedSearch = true availableLanguages := languages.GetAvailableLanguages() - htv := UserProfileEditVariables{&userProfile, b, form.NewErrors(), form.NewInfos(), availableLanguages, searchForm, Navigation{}, currentUser, r.URL, mux.CurrentRoute(r)} + htv := UserProfileEditVariables{&userProfile, b, form.NewErrors(), form.NewInfos(), availableLanguages, NewSearchForm(), Navigation{}, currentUser, r.URL, mux.CurrentRoute(r)} err := viewProfileEditTemplate.ExecuteTemplate(w, "index.html", htv) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } } } else { - searchForm := NewSearchForm() - searchForm.HideAdvancedSearch = true - languages.SetTranslationFromRequest(notFoundTemplate, r, "en-us") - err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, searchForm, GetUser(r), r.URL, mux.CurrentRoute(r)}) + err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, NewSearchForm(), GetUser(r), r.URL, mux.CurrentRoute(r)}) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } @@ -185,21 +173,15 @@ func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) { http.Error(w, errorTmpl.Error(), http.StatusInternalServerError) } } else { - searchForm := NewSearchForm() - searchForm.HideAdvancedSearch = true - languages.SetTranslationFromRequest(notFoundTemplate, r, "en-us") - err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, searchForm, GetUser(r), r.URL, mux.CurrentRoute(r)}) + err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, NewSearchForm(), GetUser(r), r.URL, mux.CurrentRoute(r)}) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } } } else { - searchForm := NewSearchForm() - searchForm.HideAdvancedSearch = true - languages.SetTranslationFromRequest(notFoundTemplate, r, "en-us") - err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, searchForm, GetUser(r), r.URL, mux.CurrentRoute(r)}) + err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, NewSearchForm(), GetUser(r), r.URL, mux.CurrentRoute(r)}) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/templates/FAQ.html b/templates/FAQ.html index 28703d9e..9178f6a1 100644 --- a/templates/FAQ.html +++ b/templates/FAQ.html @@ -37,6 +37,9 @@

{{T "magnet_link_should_look_like"}} magnet:?xt=urn:btih:[hash]&dn=[name]&tr=[tracker]&tr=[...]

+

{{T "how_do_i_link_my_old_account"}}

+

{{T "answer_how_do_i_link_my_old_account"}}

+

{{T "which_trackers_do_you_recommend"}}

{{T "answer_which_trackers_do_you_recommend"}}

udp://tracker.doko.moe:6969
diff --git a/templates/_badgemenu.html b/templates/_badgemenu.html index 136f6ee3..bf3d25aa 100644 --- a/templates/_badgemenu.html +++ b/templates/_badgemenu.html @@ -7,6 +7,7 @@ {{ .Username }}