diff --git a/public/home/search.js b/public/home/search.js index 4ba0a5ced..2a7d46b65 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -85,7 +85,7 @@ var pageSize = 15; var currentSearchTableName ="repository"; var currentSearchKeyword=""; var currentSearchSortBy=""; -var currentSearchAscending=false; +var currentSearchAscending="false"; var OnlySearchLabel=false; var startIndex =1; var endIndex = 5; @@ -122,7 +122,7 @@ function search(){ initPageInfo(); if(!isEmpty(currentSearchKeyword)){ currentSearchSortBy = sortBy[10]; - currentSearchAscending = false; + currentSearchAscending = "false"; OnlySearchLabel =false; page(currentPage); if(currentSearchTableName != "repository"){ @@ -169,7 +169,7 @@ function initDiv(isSearchLabel=false){ } } -function searchLabel(tableName,keyword,sortBy="",ascending=false){ +function searchLabel(tableName,keyword,sortBy="",ascending="false"){ console.log("enter label search."); initDiv(true); //document.getElementById("search_div").style.display="none"; diff --git a/routers/routes/routes.go b/routers/routes/routes.go index dc131a638..743572b21 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -324,6 +324,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/recommend/org", routers.RecommendOrgFromPromote) m.Get("/recommend/repo", routers.RecommendRepoFromPromote) m.Post("/all/search/", routers.Search) + m.Get("/all/search/", routers.EmptySearch) m.Get("/all/dosearch/", routers.SearchApi) m.Get("/home/term", routers.HomeTerm) m.Group("/explore", func() { diff --git a/routers/search.go b/routers/search.go index 3b9035f5b..9c494dc1a 100644 --- a/routers/search.go +++ b/routers/search.go @@ -33,15 +33,17 @@ func InitESClient() { } } -func Search(ctx *context.Context) { +func EmptySearch(ctx *context.Context) { log.Info("search template.") - if ctx.Query("q") == "" { + ctx.Data["Keyword"] = "" + ctx.HTML(200, tplHome) +} - } +func Search(ctx *context.Context) { + log.Info("search template.") keyword := strings.Trim(ctx.Query("q"), " ") ctx.Data["Keyword"] = keyword ctx.Data["SortType"] = "newest" - ctx.HTML(200, "explore/search_new") }