-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
www
committed
Sep 2, 2021
1 parent
15a9f2c
commit 481de6b
Showing
17 changed files
with
236 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const Base = require('./base'); | ||
|
||
class Search extends Base | ||
{ | ||
async search() { | ||
const url = this.ctx.url; | ||
if(!~url.indexOf('/search/')) { | ||
this.$redirect(url.replace('/search', '/search/'), 301); | ||
return false; | ||
} | ||
|
||
const keyword = this.ctx.query.keyword; | ||
let [list, pagination] = [[], '']; | ||
|
||
if(!keyword) { | ||
this.$assign('title', '搜索' + ' - ' + this.site.webname); | ||
this.$assign('search_title', '搜索'); | ||
} else { | ||
const condition = {}; | ||
condition['concat(a.title, a.writer, a.keywords, a.description)'] = ['like', '%' + keyword + '%']; | ||
[list, pagination] = await this.$model.article.getSearchList(condition); | ||
|
||
this.$assign('title', keyword + ' - ' + this.site.webname); | ||
this.$assign('search_title', keyword); | ||
this.$assign('description', `关于 《${keyword}》的博文文章`); | ||
this.$assign('keywords', keyword); | ||
} | ||
|
||
this.$assign('keyword', keyword); | ||
this.$assign('list', list); | ||
this.$assign('pagination', pagination); | ||
await this.$fetch(); | ||
} | ||
} | ||
|
||
module.exports = Search; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const {Pagination} = require('jj.js'); | ||
|
||
class Search extends Pagination | ||
{ | ||
init(opts) { | ||
super.init({ | ||
pageSize: 10, | ||
...opts | ||
}); | ||
return this; | ||
} | ||
} | ||
|
||
module.exports = Search; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{{extend './layout.htm'}} | ||
|
||
{{block 'header'}} | ||
<div class="container jumbotron"> | ||
<h1>{{search_title}}</h1> | ||
<p>{{description}}</p> | ||
</div> | ||
{{/block}} | ||
|
||
{{block 'content'}} | ||
<div class="container row"> | ||
<main class="main"> | ||
<div class="list"> | ||
{{each list item}} | ||
<dl class="list-item"> | ||
<dt><h3 class="title"><a href="{{url(':article', {id: item.id})}}">{{item.title}}</a></h3></dt> | ||
<dd> | ||
{{item.description}} | ||
</dd> | ||
<ul> | ||
<li>分类: <a href="{{url(':cate', {cate: item.cate_dir})}}">{{item.cate_name}}</a></li> | ||
<li>时间: {{item.add_time | dateFormat 'YYYY-mm-dd'}}</li> | ||
<li>浏览: {{item.click}}</li> | ||
<li>关键词: {{item.keywords}}</li> | ||
</ul> | ||
</dl>{{/each}} | ||
</div> | ||
{{if pagination}}<hr class="m-hr">{{/if}} | ||
{{@pagination}} | ||
</main> | ||
{{include './aside.htm'}} | ||
</div> | ||
{{/block}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.