Reverting changes on nav.Route
Changed error 500 to 404
Cette révision appartient à :
Parent
6534d02977
révision
b980ff8fc8
2 fichiers modifiés avec 11 ajouts et 3 suppressions
|
@ -5,10 +5,13 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"math"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/utils/log"
|
||||
"github.com/NyaaPantsu/nyaa/utils/search"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// SearchHandler : Controller for displaying search result page, accepting common search arguments
|
||||
|
@ -24,11 +27,11 @@ func SearchHandler(c *gin.Context) {
|
|||
if page != "" {
|
||||
pagenum, err = strconv.Atoi(html.EscapeString(page))
|
||||
if !log.CheckError(err) {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
}
|
||||
if pagenum <= 0 {
|
||||
NotFoundHandler(c)
|
||||
c.AbortWithError(http.StatusNotFound, errors.New("Can't find a page with negative value"))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +42,11 @@ func SearchHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
maxPages := math.Ceil(float64(nbTorrents) / float64(searchParam.Max))
|
||||
if pagenum > int(maxPages) {
|
||||
c.AbortWithError(http.StatusNotFound, errors.New("Page superior to the maximum number of pages"))
|
||||
}
|
||||
|
||||
// Convert back to strings for now.
|
||||
// TODO Deprecate fully SearchParam and only use TorrentParam
|
||||
category := ""
|
||||
|
|
|
@ -117,7 +117,7 @@ func templateFunctions(vars jet.VarMap) jet.VarMap {
|
|||
}
|
||||
for i := startValue; i <= endValue; i++ {
|
||||
pageNum := strconv.Itoa(i)
|
||||
url := "/search/" + pageNum
|
||||
url := nav.Route + "/" + pageNum
|
||||
ret = ret + "<a aria-label=\"Page " + strconv.Itoa(i) + "\" href=\"" + url + "?" + currentUrl.RawQuery + "\">" + "<li"
|
||||
if i == nav.CurrentPage {
|
||||
ret = ret + " class=\"active\""
|
||||
|
|
Référencer dans un nouveau ticket