diff --git a/controllers/search/search.go b/controllers/search/search.go index f746ca60..063683ca 100644 --- a/controllers/search/search.go +++ b/controllers/search/search.go @@ -15,6 +15,14 @@ import ( "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 func SearchHandler(c *gin.Context) { var err error @@ -41,7 +49,7 @@ func SearchHandler(c *gin.Context) { if err != nil { userID = 0 } - + searchParam, torrents, nbTorrents, err := search.AuthorizedQuery(c, pagenum, currentUser.CurrentOrAdmin(uint(userID))) if err != nil { c.AbortWithError(http.StatusInternalServerError, err) diff --git a/controllers/user/router.go b/controllers/user/router.go index 44adf77f..0ae20d89 100644 --- a/controllers/user/router.go +++ b/controllers/user/router.go @@ -32,8 +32,8 @@ func init() { userRoutes.GET("/:id/:username/edit", UserDetailsHandler) userRoutes.POST("/:id/:username/edit", UserProfileFormHandler) userRoutes.GET("/:id/:username/apireset", UserAPIKeyResetHandler) - userRoutes.GET("/:id/:username/search", searchController.SearchHandler) - userRoutes.GET("/:id/:username/search/:page", searchController.SearchHandler) + userRoutes.GET("/:id/:username/search", searchController.UserSearchHandler) + userRoutes.GET("/:id/:username/search/:page", searchController.UserSearchHandler) userRoutes.GET("/:id/:username/feed", feedController.RSSHandler) userRoutes.GET("/:id/:username/feed/:page", feedController.RSSHandler) } diff --git a/public/js/main.js b/public/js/main.js index 6624005e..95e400f3 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -113,7 +113,7 @@ function resetCookies() { var cookieValue = getCookieValue(cookieName) 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;" - if(cookieName != session) + if(cookieName != "session") document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + farFutureString + ";domain=" + domain else document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + farFutureString //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) { 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]) document.getElementById("theme").href = "/css/themes/" + CurrentTheme + ".css";