Browse Source

增加代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.3.2^2
zouap 3 years ago
parent
commit
007d8c7784
2 changed files with 8 additions and 84 deletions
  1. +3
    -1
      routers/search.go
  2. +5
    -83
      templates/explore/search_new.tmpl

+ 3
- 1
routers/search.go View File

@@ -32,7 +32,9 @@ func InitESClient() {

func Search(ctx *context.Context) {
keyword := strings.Trim(ctx.Query("q"), " ")
ctx.Data["keyword"] = keyword
ctx.Data["Keyword"] = keyword
ctx.Data["SortType"] = "newest"

ctx.HTML(200, "explore/search_new")
}



+ 5
- 83
templates/explore/search_new.tmpl View File

@@ -6,7 +6,7 @@
<div class="ui two column centered grid">
<form class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty" style="margin-top:1.2rem">
<div class="ui fluid action input">
<input name="q" value="{{.keyword}}" placeholder="搜索..." autofocus="">
<input name="q" value="{{.Keyword}}" placeholder="搜索..." autofocus="">
<input type="hidden" name="topic" value="">
<input type="hidden" name="tab" value="">
<input type="hidden" name="sort" value="hot">
@@ -58,16 +58,7 @@
<i class="dropdown icon"></i>
</span>
<div class="menu">
<a class="{{if eq .SortType "newest"}}active{{end}} item" href="{{$.Link}}?sort=newest&q={{$.Keyword}}&topic={{$.Topic}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.latest"}}</a>
<a class="{{if eq .SortType "oldest"}}active{{end}} item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}&topic={{$.Topic}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.oldest"}}</a>
<a class="{{if eq .SortType "alphabetically"}}active{{end}} item" href="{{$.Link}}?sort=alphabetically&q={{$.Keyword}}&topic={{$.Topic}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
<a class="{{if eq .SortType "reversealphabetically"}}active{{end}} item" href="{{$.Link}}?sort=reversealphabetically&q={{$.Keyword}}&topic={{$.Topic}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
<a class="{{if eq .SortType "recentupdate"}}active{{end}} item" href="{{$.Link}}?sort=recentupdate&q={{$.Keyword}}&topic={{$.Topic}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.recentupdate"}}</a>
<a class="{{if eq .SortType "leastupdate"}}active{{end}} item" href="{{$.Link}}?sort=leastupdate&q={{$.Keyword}}&topic={{$.Topic}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.leastupdate"}}</a>
<a class="{{if eq .SortType "moststars"}}active{{end}} item" href="{{$.Link}}?sort=moststars&q={{$.Keyword}}&topic={{$.Topic}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.moststars"}}</a>
<a class="{{if eq .SortType "feweststars"}}active{{end}} item" href="{{$.Link}}?sort=feweststars&q={{$.Keyword}}&topic={{$.Topic}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.feweststars"}}</a>
<a class="{{if eq .SortType "mostforks"}}active{{end}} item" href="{{$.Link}}?sort=mostforks&q={{$.Keyword}}&topic={{$.Topic}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.mostforks"}}</a>
<a class="{{if eq .SortType "fewestforks"}}active{{end}} item" href="{{$.Link}}?sort=fewestforks&q={{$.Keyword}}&topic={{$.Topic}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.fewestforks"}}</a>
</div>
</div>

@@ -78,83 +69,14 @@
<div class="ui very relaxed divided list">
<!--项目-->
<div class="item">
{{if .RelAvatarLink}}
<img class="ui avatar image" src="{{.RelAvatarLink}}">
{{end}}
<div class="content">
<div class="ui header">
<!--a class="name" href="/OpenI/Paddle"> <span class="highlight">OpenI</span> <span>/</span> <strong>Paddle</strong></a>
<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-->
<a class="name" href="{{.Link}}">
{{if or $.PageIsExplore $.PageIsProfileStarList }}{{if .Owner}}{{.Owner.Name}} <span>/</span> {{end}}{{end}}<strong>{{.Name}}</strong>
{{if .IsArchived}}<i class="archive icon archived-icon"></i>{{end}}
</a>
{{if .IsPrivate}}
<span class="middle text gold">{{svg "octicon-lock" 16}}</span>
{{else if .IsFork}}
<span class="middle">{{svg "octicon-repo-forked" 16}}</span>
{{else if .IsMirror}}
<span class="middle">{{svg "octicon-repo-clone" 16}}</span>
{{else if .Owner}}
{{if .Owner.Visibility.IsPrivate}}
<span class="text gold">{{svg "octicon-lock" 16}}</span>
{{end}}
{{end}}
</div>

<div class="description">
{{if .DescriptionHTML}}<p class="has-emoji">{{.DescriptionHTML}}</p>{{end}}
{{if .Topics }}
<div class="ui tags">
{{range .Topics}}
{{if ne . "" }}<a href="{{AppSubUrl}}/explore/repos?q={{.}}&topic={{$.Topic}}"><div class="ui small label topic">{{.}}</div></a>{{end}}
{{end}}
</div>
{{end}}
<p class="time">
{{svg "octicon-eye" 16}} {{.NumWatches}}
<span class="am-ml-10"></span>
{{svg "octicon-git-branch" 16}} {{.NumForks}}
<span class="am-ml-10"></span>
{{svg "octicon-star" 16}} {{.NumStars}}
<span class="am-ml-10"></span>
{{$.i18n.Tr "org.repo_updated"}} {{TimeSinceUnix .UpdatedUnix $.i18n.Lang}}
{{if .PrimaryLanguage }}
<span class="text grey"><i class="color-icon" style="background-color: {{.PrimaryLanguage.Color}}"></i>{{ .PrimaryLanguage.Language }}</span>
{{end}}
</p>
</div>
</div>
</div>

<!--数据集-->
<div class="item">

<div class="content">
<div class="ui right metas">
{{if .Task}}
<span class="text grey">{{svg "octicon-tasklist" 16}} {{$.i18n.Tr (printf "dataset.task.%s" .Task)}}</span>
{{end}}
{{if .Category}}
<span class="text grey">{{svg "octicon-tag" 16}}{{$.i18n.Tr (printf "dataset.category.%s" .Category)}}</span>
{{end}}
<span class="text grey">{{svg "octicon-flame" 16}} {{.DownloadTimes}}</span>
</div>
<div class="ui header">
<a class="name" href="/OpenI/Paddle"> zeizei <span>/</span> <strong><span class="highlight">OpenI</span>_test</strong></a>
<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>
</div>
<div class="description">
{{if .Description}}
<p class="has-emoji">{{.Description}}</p>
{{else if .Repo.DescriptionHTML}}
<p class="has-emoji">{{.Repo.DescriptionHTML}}</p>
{{end}}
<p class="time">{{$.i18n.Tr "org.repo_updated"}} {{TimeSinceUnix .UpdatedUnix $.i18n.Lang}}</p>
</div>
</div>
</div>

<!--任务、合并请求-->


Loading…
Cancel
Save