Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.3.2^2
zouap 3 years ago
parent
commit
581d260e3a
3 changed files with 10 additions and 7 deletions
  1. +3
    -3
      public/home/search.js
  2. +1
    -0
      routers/routes/routes.go
  3. +6
    -4
      routers/search.go

+ 3
- 3
public/home/search.js View File

@@ -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";


+ 1
- 0
routers/routes/routes.go View File

@@ -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() {


+ 6
- 4
routers/search.go View File

@@ -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")
}



Loading…
Cancel
Save