Merge pull request #555 from ElegantMonkey/rss-pagination
Add pagination to RSS feed.
Cette révision appartient à :
révision
7938d822df
2 fichiers modifiés avec 18 ajouts et 1 suppressions
|
@ -72,6 +72,7 @@ func init() {
|
|||
Router.HandleFunc("/api/update", ApiUpdateHandler).Methods("PUT")
|
||||
Router.HandleFunc("/faq", FaqHandler).Name("faq")
|
||||
Router.HandleFunc("/feed", RSSHandler).Name("feed")
|
||||
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("/upload", UploadHandler).Name("upload")
|
||||
|
|
|
@ -4,13 +4,29 @@ import (
|
|||
"github.com/ewhal/nyaa/config"
|
||||
"github.com/ewhal/nyaa/util"
|
||||
"github.com/ewhal/nyaa/util/search"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/gorilla/feeds"
|
||||
"html"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func RSSHandler(w http.ResponseWriter, r *http.Request) {
|
||||
_, torrents, err := search.SearchByQueryNoCount(r, 1)
|
||||
vars := mux.Vars(r)
|
||||
page := vars["page"]
|
||||
|
||||
var err error
|
||||
pagenum := 1
|
||||
if page != "" {
|
||||
pagenum, err = strconv.Atoi(html.EscapeString(page))
|
||||
if err != nil {
|
||||
util.SendError(w, err, 400)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
_, torrents, err := search.SearchByQueryNoCount(r, pagenum)
|
||||
if err != nil {
|
||||
util.SendError(w, err, 400)
|
||||
return
|
||||
|
|
Référencer dans un nouveau ticket