Browse Source

增加代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.3.2^2
zouap 4 years ago
parent
commit
33dbad6654
6 changed files with 38 additions and 30 deletions
  1. +12
    -11
      public/home/search.js
  2. +16
    -13
      routers/search.go
  3. +2
    -2
      templates/base/head_navbar.tmpl
  4. +2
    -2
      templates/base/head_navbar_fluid.tmpl
  5. +2
    -2
      templates/base/head_navbar_pro.tmpl
  6. +4
    -0
      web_src/less/openi.less

+ 12
- 11
public/home/search.js View File

@@ -118,6 +118,7 @@ function searchItem(type,sortType){
function search(){
console.log("enter here 1.");
currentSearchKeyword = document.getElementById("keyword_input").value;
$('#searchForm').addClass("hiddenSearch");
initPageInfo();
if(!isEmpty(currentSearchKeyword)){
currentSearchSortBy = sortBy[10];
@@ -345,7 +346,7 @@ function displayDataSetResult(page,jsonResult,onlyReturnNum,keyword){
html += " <span class=\"text grey\"><i class=\"ri-fire-line\"></i> " +recordMap["download_times"] + "</span> ";
html +=" </div>";
html += " <div class=\"ui header\">";
html += " <a class=\"name\" href=\"/" +recordMap["repoUrl"] +"/datasets?type=0\">" + recordMap["title"] + "</a>";
html += " <a class=\"name\" href=\"/" +recordMap["repoUrl"] +"/datasets?type=0\" target=\"_blank\">" + recordMap["title"] + "</a>";
html +=" <span class=\"middle\"><svg class=\"svg octicon-repo-clone\" width=\"16\" height=\"16\" aria-hidden=\"true\"><use xlink:href=\"#octicon-repo-clone\"></use></svg></span>";
html +=" </div>";
html += " <div class=\"description\">";
@@ -390,7 +391,7 @@ function displayOrgResult(page,jsonResult,onlyReturnNum,keyword){
html += "<img class=\"ui avatar image\" src=\"" + recordMap["avatar"] + "\"></img>";
html += " <div class=\"content\">";
html += " <div class=\"ui header\">";
html += " <a class=\"name\" href=\"/" + recordMap["real_name"] +"\">" + recordMap["name"] + "&nbsp;&nbsp;" + recordMap["full_name"] + "</a>";
html += " <a class=\"name\" href=\"/" + recordMap["real_name"] +"\" target=\"_blank\">" + recordMap["name"] + "&nbsp;&nbsp;" + recordMap["full_name"] + "</a>";
html +=" </div>";
html += " <div class=\"description\">";
html += " <p class=\"has-emoji\"> " + recordMap["description"] + "</p>";
@@ -440,7 +441,7 @@ function displayUserResult(page,jsonResult,onlyReturnNum,keyword){
html += "<img class=\"ui avatar image\" src=\"" + recordMap["avatar"] + "\"></img>";
html += " <div class=\"content\">";
html += " <div class=\"ui header\">";
html += " <a class=\"name\" href=\"/" + recordMap["real_name"] +"\">" + recordMap["name"] + "&nbsp;&nbsp;" + recordMap["full_name"] + "</a>";
html += " <a class=\"name\" href=\"/" + recordMap["real_name"] +"\" target=\"_blank\">" + recordMap["name"] + "&nbsp;&nbsp;" + recordMap["full_name"] + "</a>";
html +=" </div>";
html += " <div class=\"description\">";
html += " <p class=\"has-emoji\"> " + recordMap["description"] + "</p>";
@@ -478,20 +479,20 @@ function setIssueOrPrInnerHtml(data,path){
html += "<div class=\"item\">";
html += " <div class=\"content\">";
html += " <div class=\"ui header\">";
html += " <a class=\"name\" href=\"/" + recordMap["repoUrl"] +"/" + path + "/" + recordMap["index"] + "\">" + recordMap["name"] + "</a>";
html += " <a class=\"name\" href=\"/" + recordMap["repoUrl"] +"/" + path + "/" + recordMap["index"] + "\" target=\"_blank\">" + recordMap["name"] + "</a>";
html +=" </div>";
html += " <div class=\"description\">";
html += " <p class=\"has-emoji\"> " + recordMap["content"] + "</p>";
html +=" <p class=\"time\">";
html +=" <i class=\"ri-code-box-line\"></i>";
html +=" <a class=\"am-text grey\" href=\"/" + recordMap["repoUrl"] +"/" + path + "/" + recordMap["index"] + "\"> " + recordMap["repoUrl"] +"#" + recordMap["index"] + "</a>&nbsp;&nbsp;&nbsp;&nbsp;";
html +=" <i class=\"ri-information-line am-ml-10\"></i> ";
html +=" <a class=\"am-text grey\" href=\"/" + recordMap["repoUrl"] +"/" + path + "/" + recordMap["index"] + "\" target=\"_blank\"> " + recordMap["repoUrl"] +"#" + recordMap["index"] + "</a>&nbsp;&nbsp;&nbsp;&nbsp;";
html +=" <i class=\"ri-information-line am-ml-10\"></i>&nbsp;";
if(recordMap["is_closed"] != null && (!(recordMap["is_closed"]) || recordMap["is_closed"]=="f")){
html += "开启中";
}else{
html += "已关闭";
}
html +=" &nbsp;&nbsp;&nbsp;&nbsp;<i class=\"ri-message-2-line am-ml-10\"></i> " + recordMap["num_comments"];
html +=" &nbsp;&nbsp;&nbsp;&nbsp;<i class=\"ri-message-2-line am-ml-10\"></i>&nbsp;" + recordMap["num_comments"];
html +=" <span class=\"am-ml-10\">&nbsp;&nbsp;</span>&nbsp;&nbsp;最后更新于 "+ recordMap["updated_html"];
@@ -558,7 +559,7 @@ function displayRepoResult(page,jsonResult,onlyReturnNum,keyword){
}
html += " <div class=\"content\">";
html += " <div class=\"ui header\">";
html += " <a class=\"name\" href=\"/" + recordMap["owner_name"] + "/" + recordMap["real_name"] +"\"> <span>" + recordMap["owner_name"] +"</span> <span>/</span> <strong>" + recordMap["alias"] + "</strong></a>";
html += " <a class=\"name\" href=\"/" + recordMap["owner_name"] + "/" + recordMap["real_name"] +"\" target=\"_blank\"> <span>" + recordMap["owner_name"] +"</span> <span>/</span> <strong>" + recordMap["alias"] + "</strong></a>";
if(recordMap["is_private"]){
html +=" <span class=\"middle text gold\"><svg class=\"svg octicon-lock\" width=\"16\" height=\"16\" aria-hidden=\"true\"><use xlink:href=\"#octicon-lock\" /></svg></span>";
}
@@ -569,12 +570,12 @@ function displayRepoResult(page,jsonResult,onlyReturnNum,keyword){
if(!isEmpty(recordMap["topics"]) && recordMap["topics"] !="null"){
for(var j = 0; j < recordMap["topics"].length;j++){
//function searchLabel(tableName,keyword,sortBy="",ascending=false)
html +=" <a href=\"javascript:searchLabel('repository','" + recordMap["topics"][j] + "','updated_unix.keyword',false);\"><div class=\"ui small label topic\">"+ recordMap["hightTopics"][j] + "</div></a>";
html +=" <a href=\"javascript:searchLabel('repository','" + recordMap["topics"][j] + "','updated_unix.keyword',false);\" ><div class=\"ui small label topic\">"+ recordMap["hightTopics"][j] + "</div></a>";
}
}
html +=" </div>";
html +=" <p class=\"time\">";
html +=" <i class=\"icon fa-eye\">" +recordMap["num_watches"] + "</i>&nbsp;&nbsp;<i class=\"ri-star-line\"></i>" + recordMap["num_stars"] + "&nbsp;&nbsp;<i class=\"ri-git-branch-line am-ml-10\"></i>" + recordMap["num_forks"] +"&nbsp;&nbsp;";
html +=" <i class=\"icon fa-eye\"></i>&nbsp;" + recordMap["num_watches"] + "&nbsp;&nbsp;<i class=\"ri-star-line\"></i>&nbsp;" + recordMap["num_stars"] + "&nbsp;&nbsp;<i class=\"ri-git-branch-line am-ml-10\"></i>&nbsp;" + recordMap["num_forks"] +"&nbsp;&nbsp;";
html +="&nbsp;&nbsp;&nbsp;&nbsp;最后更新于 " + recordMap["updated_html"];
if(!isEmpty(recordMap["lang"])){
var lang = recordMap["lang"]
@@ -582,7 +583,7 @@ function displayRepoResult(page,jsonResult,onlyReturnNum,keyword){
if(tmpLang.length>0){
lang = tmpLang[0]
}
html +=" <span class=\"text grey am-ml-10\"><i class=\"color-icon\" style=\"background-color: #3572A5\"></i>" + lang + "</span>";
html +=" <span class=\"text grey am-ml-10\"><i class=\"color-icon\" style=\"background-color: #3572A5\"></i>&nbsp;" + lang + "</span>";
}
html +=" </p>";
html +=" </div>";


+ 16
- 13
routers/search.go View File

@@ -329,19 +329,22 @@ func searchRepo(ctx *context.Context, TableName string, Key string, Page int, Pa
}
}

// func sortRepo(Result []map[string]interface{}, SortBy string, ascending bool){
// orderBy :=""
// switch SortBy {
// case "updated_unix.keyword":
// orderBy = "updated_unix"
// case "num_stars":
// orderBy = "num_stars"
// case "num_forks":
// orderBy = models.SearchOrderByForksReverse
// case "num_watches":
// orderBy = models.SearchOrderByWatches
// }
// }
func sortRepo(Result []map[string]interface{}, SortBy string, ascending bool) {
orderBy := ""
switch SortBy {
case "updated_unix.keyword":
orderBy = "updated_unix"
case "num_stars":
orderBy = "num_stars"
case "num_forks":
orderBy = "num_forks"
case "num_watches":
orderBy = "num_watches"
}
sort.Slice(Result, func(i, j int) bool {
return Result[i][orderBy].() < Result[j].Index
})
}

func makePrivateRepo(repos models.RepositoryList, res *SearchRes, keyword string) {



+ 2
- 2
templates/base/head_navbar.tmpl View File

@@ -95,7 +95,7 @@

{{if .IsSigned}}
<div class="right stackable menu">
<form class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<form id="searchForm" class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<div class="ui fluid action input" style="background:#363840 ;border-radius: 5px;width: 200px;height:30px;border: #888888 solid 1px;">
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search_pro"}}..."
style="transition: background-color 5000s ease-in-out 0s;-webkit-text-fill-color:#888888;background:#363840 ;color:#888888;border: none;outline: none;">
@@ -199,7 +199,7 @@
<!--a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io">{{.i18n.Tr "help"}}</a-->
<div class="right stackable menu">
<form class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<form id="searchForm" class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<div class="ui fluid action input" style="background:#363840 ;border-radius: 5px;width: 200px;height:30px;border: #888888 solid 1px;">
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search_pro"}}..."
style="transition: background-color 5000s ease-in-out 0s;-webkit-text-fill-color:#888888;background:#363840 ;color:#888888;border: none;outline: none;">


+ 2
- 2
templates/base/head_navbar_fluid.tmpl View File

@@ -93,7 +93,7 @@

{{if .IsSigned}}
<div class="right stackable menu">
<form class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<form id="searchForm" class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<div class="ui fluid action input" style="background:#363840 ;border-radius: 5px;width: 200px;height:30px;border: #888888 solid 1px;">
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search_pro"}}..."
style="transition: background-color 5000s ease-in-out 0s;-webkit-text-fill-color:#888888;background:#363840 ;color:#888888;border: none;outline: none;">
@@ -196,7 +196,7 @@

<!--a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io">{{.i18n.Tr "help"}}</a-->
<div class="right stackable menu">
<form class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<form id="searchForm" class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<div class="ui fluid action input" style="background:#363840 ;border-radius: 5px;width: 200px;height:30px;border: #888888 solid 1px;">
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search_pro"}}..."
style="transition: background-color 5000s ease-in-out 0s;-webkit-text-fill-color:#888888;background:#363840 ;color:#888888;border: none;outline: none;">


+ 2
- 2
templates/base/head_navbar_pro.tmpl View File

@@ -96,7 +96,7 @@

{{if .IsSigned}}
<div class="right stackable menu">
<form class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<form id="searchForm" class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<div class="ui fluid action input" style="background:#363840 ;border-radius: 5px;width: 200px;height:30px;border: #888888 solid 1px;">
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search_pro"}}..."
style="transition: background-color 5000s ease-in-out 0s;-webkit-text-fill-color:#888888;background:#363840 ;color:#888888;border: none;outline: none;">
@@ -199,7 +199,7 @@

<!--a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io">{{.i18n.Tr "help"}}</a-->
<div class="right stackable menu">
<form class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<form id="searchForm" class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin:auto" action="/all/search/">
<div class="ui fluid action input" style="background:#363840 ;border-radius: 5px;width: 200px;height:30px;border: #888888 solid 1px;">
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search_pro"}}..."
style="transition: background-color 5000s ease-in-out 0s;-webkit-text-fill-color:#888888;background:#363840 ;color:#888888;border: none;outline: none;">


+ 4
- 0
web_src/less/openi.less View File

@@ -878,6 +878,10 @@ display: block;
font-family: SourceHanSansSC-medium;
}

.hiddenSearch{
margin: auto;
display: none;
}

#tipmsg {
display: none;


Loading…
Cancel
Save