Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fix JS theme toggler, resetCookies() JS, user search (#1634)

* Fix JS theme toggler

* fix check

* Fix user search USERID parameter not working

* User search controller now calls UserSearchHandler

* rollback this

* Update search.go
Cette révision appartient à :
kilo 2017-10-04 17:45:31 +02:00 révisé par GitHub
Parent 5496d6e19d
révision 96cfb24d59
3 fichiers modifiés avec 13 ajouts et 5 suppressions

Voir le fichier

@ -15,6 +15,14 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
// UserSearchHandler : Controller called when search done through user profile URL, userID parameters are accessed differently so we need this
func UserSearchHandler(c *gin.Context) {
query := c.Request.URL.Query()
query.Set("userID", c.Param("id"))
c.Request.URL.RawQuery = query.Encode()
SearchHandler(c)
}
// SearchHandler : Controller for displaying search result page, accepting common search arguments // SearchHandler : Controller for displaying search result page, accepting common search arguments
func SearchHandler(c *gin.Context) { func SearchHandler(c *gin.Context) {
var err error var err error
@ -41,7 +49,7 @@ func SearchHandler(c *gin.Context) {
if err != nil { if err != nil {
userID = 0 userID = 0
} }
searchParam, torrents, nbTorrents, err := search.AuthorizedQuery(c, pagenum, currentUser.CurrentOrAdmin(uint(userID))) searchParam, torrents, nbTorrents, err := search.AuthorizedQuery(c, pagenum, currentUser.CurrentOrAdmin(uint(userID)))
if err != nil { if err != nil {
c.AbortWithError(http.StatusInternalServerError, err) c.AbortWithError(http.StatusInternalServerError, err)

Voir le fichier

@ -32,8 +32,8 @@ func init() {
userRoutes.GET("/:id/:username/edit", UserDetailsHandler) userRoutes.GET("/:id/:username/edit", UserDetailsHandler)
userRoutes.POST("/:id/:username/edit", UserProfileFormHandler) userRoutes.POST("/:id/:username/edit", UserProfileFormHandler)
userRoutes.GET("/:id/:username/apireset", UserAPIKeyResetHandler) userRoutes.GET("/:id/:username/apireset", UserAPIKeyResetHandler)
userRoutes.GET("/:id/:username/search", searchController.SearchHandler) userRoutes.GET("/:id/:username/search", searchController.UserSearchHandler)
userRoutes.GET("/:id/:username/search/:page", searchController.SearchHandler) userRoutes.GET("/:id/:username/search/:page", searchController.UserSearchHandler)
userRoutes.GET("/:id/:username/feed", feedController.RSSHandler) userRoutes.GET("/:id/:username/feed", feedController.RSSHandler)
userRoutes.GET("/:id/:username/feed/:page", feedController.RSSHandler) userRoutes.GET("/:id/:username/feed/:page", feedController.RSSHandler)
} }

Voir le fichier

@ -113,7 +113,7 @@ function resetCookies() {
var cookieValue = getCookieValue(cookieName) var cookieValue = getCookieValue(cookieName)
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;" document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
document.cookie = cookieName + "=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;" document.cookie = cookieName + "=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
if(cookieName != session) if(cookieName != "session")
document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + farFutureString + ";domain=" + domain document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + farFutureString + ";domain=" + domain
else document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + farFutureString else document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + farFutureString
//Remove cookie from both current & general path, then re-create it to ensure domain is correct //Remove cookie from both current & general path, then re-create it to ensure domain is correct
@ -201,7 +201,7 @@ function startupCode() {
function toggleTheme(e) { function toggleTheme(e) {
var CurrentTheme = document.getElementById("theme").href var CurrentTheme = document.getElementById("theme").href
CurrentTheme = CurrentTheme.substring(CurrentTheme.indexOf("/css/") + 5, CurrentTheme.indexOf(".css")) CurrentTheme = CurrentTheme.substring(CurrentTheme.indexOf("/themes/") + 8, CurrentTheme.indexOf(".css"))
CurrentTheme = (CurrentTheme == UserTheme[0] ? UserTheme[1] : UserTheme[0]) CurrentTheme = (CurrentTheme == UserTheme[0] ? UserTheme[1] : UserTheme[0])
document.getElementById("theme").href = "/css/themes/" + CurrentTheme + ".css"; document.getElementById("theme").href = "/css/themes/" + CurrentTheme + ".css";