diff --git a/README.md b/README.md index 7d5a109d..e26d1bd5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ that anyone will be able to deploy locally or remotely. # Installation Ubuntu 17.04 fails to build, use a different OS or docker -* Install [Golang](https://golang.org/doc/install) +* Install [Golang](https://golang.org/doc/install) (version >=1.8) * `go get github.com/ewhal/nyaa` * `go build` * Download DB and place it in your root folder named as "nyaa.db" diff --git a/config/email.go b/config/email.go index 4bdc3566..f64ba5ca 100644 --- a/config/email.go +++ b/config/email.go @@ -16,4 +16,4 @@ const ( EmailTimeout = 10 * time.Second ) -var EmailTokenHashKey = []byte("CHANGE_THIS_BEFORE_DEPLOYING_YOU_RETARD") +var EmailTokenHashKey = []byte("CHANGE_THIS_BEFORE_DEPLOYING_YOU_GIT") diff --git a/main.go b/main.go index 48368b9e..5b56615a 100644 --- a/main.go +++ b/main.go @@ -38,8 +38,8 @@ func RunServer(conf *config.Config) { // Set up server, srv := &http.Server{ - WriteTimeout: 15 * time.Second, - ReadTimeout: 15 * time.Second, + WriteTimeout: 24 * time.Second, + ReadTimeout: 8 * time.Second, } l, err := network.CreateHTTPListener(conf) log.CheckError(err) diff --git a/router/modpanel.go b/router/modpanel.go index 61006e83..5446e00b 100644 --- a/router/modpanel.go +++ b/router/modpanel.go @@ -33,7 +33,8 @@ func IndexModPanel(w http.ResponseWriter, r *http.Request) { languages.SetTranslationFromRequest(panelIndex, r, "en-us") htv := PanelIndexVbs{torrents, model.TorrentReportsToJSON(torrentReports), users, comments, NewSearchForm(), currentUser, r.URL} - _ = panelIndex.ExecuteTemplate(w, "admin_index.html", htv) + err := panelIndex.ExecuteTemplate(w, "admin_index.html", htv) + log.CheckError(err) } else { http.Error(w, "admins only", http.StatusForbidden) } @@ -217,7 +218,8 @@ func TorrentPostEditModPanel(w http.ResponseWriter, r *http.Request) { } languages.SetTranslationFromRequest(panelTorrentEd, r, "en-us") htv := PanelTorrentEdVbs{uploadForm, NewSearchForm(), currentUser, err, infos, r.URL} - _ = panelTorrentEd.ExecuteTemplate(w, "admin_index.html", htv) + err_ := panelTorrentEd.ExecuteTemplate(w, "admin_index.html", htv) + log.CheckError(err_) } func CommentDeleteModPanel(w http.ResponseWriter, r *http.Request) { diff --git a/router/rssHandler.go b/router/rssHandler.go index 1a1346e0..ff82f887 100644 --- a/router/rssHandler.go +++ b/router/rssHandler.go @@ -6,7 +6,6 @@ import ( "github.com/ewhal/nyaa/util/search" "github.com/gorilla/feeds" "net/http" - "strconv" "time" ) @@ -31,7 +30,7 @@ func RSSHandler(w http.ResponseWriter, r *http.Request) { for i, torrent := range torrents { torrentJSON := torrent.ToJSON() feed.Items[i] = &feeds.Item{ - Id: "https://" + config.WebAddress + "/view/" + strconv.FormatUint(uint64(torrents[i].ID), 10), + Id: "https://" + config.WebAddress + "/view/" + torrentJSON.ID, Title: torrent.Name, Link: &feeds.Link{Href: string(torrentJSON.Magnet)}, Description: string(torrentJSON.Description), diff --git a/router/templateFunctions.go b/router/templateFunctions.go index 0946dce8..d1b3fe54 100644 --- a/router/templateFunctions.go +++ b/router/templateFunctions.go @@ -26,6 +26,16 @@ var FuncMap = template.FuncMap{ } return "error" }, + "genViewTorrentRoute": func(torrent_id uint) string { + // Helper for when you have an uint while genRoute("view_torrent", ...) takes a string + // FIXME better solution? + s := strconv.FormatUint(uint64(torrent_id), 10) + url, err := Router.Get("view_torrent").URL("id", s) + if err == nil { + return url.String() + } + return "error" + }, "genNav": func(nav Navigation, currentUrl *url.URL, pagesSelectable int) template.HTML { var ret = "" if (nav.TotalItem > 0) { diff --git a/router/wrapHandler.go b/router/wrapHandler.go index d0170f44..1f98325d 100644 --- a/router/wrapHandler.go +++ b/router/wrapHandler.go @@ -46,4 +46,4 @@ func (wh *wrappedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func wrapHandler(handler http.Handler) http.Handler { return &wrappedHandler{handler} -} \ No newline at end of file +} diff --git a/service/torrent/torrent.go b/service/torrent/torrent.go index caa776f7..7c5eade4 100644 --- a/service/torrent/torrent.go +++ b/service/torrent/torrent.go @@ -129,9 +129,10 @@ func getTorrentsOrderBy(parameters *serviceBase.WhereParams, orderBy string, lim if conditions != "" { dbQuery = dbQuery + " WHERE " + conditions } - if strings.Contains(conditions, "torrent_name") { + /* This makes all queries take roughly the same amount of time (lots)... + if strings.Contains(conditions, "torrent_name") && offset > 0 { dbQuery = "WITH t AS (SELECT * FROM torrents WHERE " + conditions + ") SELECT * FROM t" - } + }*/ if orderBy == "" { // default OrderBy orderBy = "torrent_id DESC" diff --git a/templates/admin/panelindex.html b/templates/admin/panelindex.html index b718ffca..4385dba3 100644 --- a/templates/admin/panelindex.html +++ b/templates/admin/panelindex.html @@ -7,9 +7,12 @@ Uploader Action -{{ range .Torrents}} -{{ .Name }}{{ .UploaderID }} -{{ T "delete" }} +{{range .Torrents}} + + {{ .Name }} (Edit) + {{ .UploaderID }} + {{ T "delete" }} + {{end}}