11package controller
22
33import (
4+ "html"
5+
46 "github.com/studygolang/studygolang/context"
57 "github.com/studygolang/studygolang/logic"
68
@@ -31,11 +33,12 @@ func (SearchController) Search(ctx echo.Context) error {
3133 "q" : q ,
3234 "f" : field ,
3335 }
34- if err == nil {
35- uri := "/search?q=" + q + "&f=" + field + "&"
36- paginator := logic .NewPaginatorWithPerPage (p , rows )
37- data ["pageHtml" ] = paginator .SetTotal (int64 (respBody .NumFound )).GetPageHtml (uri )
36+ if err != nil {
37+ return render (ctx , "500.html" , nil )
3838 }
39+ uri := "/search?q=" + html .EscapeString (q ) + "&f=" + field + "&"
40+ paginator := logic .NewPaginatorWithPerPage (p , rows )
41+ data ["pageHtml" ] = paginator .SetTotal (int64 (respBody .NumFound )).GetPageHtml (uri )
3942
4043 return render (ctx , "search.html" , data )
4144}
@@ -60,11 +63,12 @@ func (SearchController) TagList(ctx echo.Context) error {
6063 "users" : users ,
6164 "nodes" : nodes ,
6265 }
63- if err == nil {
64- uri := "/tag/" + q + "?"
65- paginator := logic .NewPaginatorWithPerPage (p , rows )
66- data ["pageHtml" ] = paginator .SetTotal (int64 (respBody .NumFound )).GetPageHtml (uri )
66+ if err != nil {
67+ return render (ctx , "500.html" , nil )
6768 }
69+ uri := "/tag/" + q + "?"
70+ paginator := logic .NewPaginatorWithPerPage (p , rows )
71+ data ["pageHtml" ] = paginator .SetTotal (int64 (respBody .NumFound )).GetPageHtml (uri )
6872
6973 return render (ctx , "feed/tag.html" , data )
7074}
0 commit comments