Skip to content

Commit

Permalink
Some minor modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
dongweiming committed Nov 27, 2019
1 parent 2c00929 commit 570d11a
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ My Blog Using Sanic
其他aio扩展: Sanic-Auth、Sanic-wtf、sanic-session、aiotask-context、asyncblink、sanic-sentry、sanic-jwt、aiosmtplib

<p align="center">
<img width="600" src="./screenshot/blog.png" >
<img width="600" src="./docs/widget.png" >
</p>

管理后台使用 ElementUI + Vue-CLI + Vue-Router + Vuex
Expand Down
3 changes: 2 additions & 1 deletion admin/src/views/post/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export default {
listLoading: true,
listQuery: {
page: 1,
limit: 10
limit: 10,
with_tag: 1
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion admin/src/views/topic/components/TopicDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export default {
this.fetchData(id)
params['special_id'] = id
} else {
this.topicForm = Object.assign({}, defaultForm)
// FIXME
this.topicForm.posts = []
}
getPostList(params).then(response => {
Expand Down
1 change: 1 addition & 0 deletions config.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ partials:
- name: latest_comments
title: 最新评论
count: 5
max_length: 65
- name: blogroll
title: 友情链接
links:
Expand Down
15 changes: 8 additions & 7 deletions docs/front-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,45 @@
使用 Webpack+ES6+Sass ,首先需要安装依赖:

```bash
yarn install
yarn install
```

接着启动开发环境:

```bash
yarn start
yarn start
```

修改src目录下代码即可看到效果

生产环境需要构建:

```bash
yarn build
yarn build
```

## 后台

使用 ElementUI+Vue-CLI+Vue-Router+Vuex+Webpack+ES6+Sass ,需要安装依赖:

```bash
cd admin # 在 admin 子目录下
yarn install
cd admin # 在 admin 子目录下
yarn install
```

接着启动开发环境:

```bash
yarn serve
yarn serve
```

修改src目录下代码即可看到效果

生产环境需要构建:

```
yarn build
❯ yarn build
❯ cp -rp dist/static/* ../static/ # 把新生成的文件拷贝到static目录下
```

## 博客的CSS
Expand Down
1 change: 1 addition & 0 deletions docs/widget.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ partials:
- name: latest_comments
title: 最新评论
count: 5 # 限制最新评论数量,必选
max_length: 65 # 限制评论内容长度
```

## most_viewed
Expand Down
Binary file modified docs/widget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed screenshot/blog.png
Binary file not shown.
2 changes: 1 addition & 1 deletion static/css/admin/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/css/index.min.css

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions static/css/topic.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,21 @@ html {
.recent-topics .title {
font-size: 1rem;
}
.topic-title {
font-size: 1.2rem;
}
.topic-intro {
font-size: 12px;
}
}

@media screen and (max-width: 768px) {
.recent-topics {
padding: 0 30px 30px 30px;
}
.topic-title {
font-size: 1.5em;
}
}

.topic-title {
Expand Down
2 changes: 1 addition & 1 deletion static/css/topic.min.css

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions static/css/widget.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.widget {
margin-top: 2rem;
margin-top: 1rem;
}

.widget h5 {
color: #4a4a4a;
padding-bottom: 1em;
padding-bottom: .5em;
}

.widget p {
Expand All @@ -26,6 +26,7 @@

.widget .list-inline a {
color: #666;
font-size: 14px;
}

.widget .list-inline a:hover, .widget .list-inline a:active {
Expand Down
2 changes: 1 addition & 1 deletion static/js/admin/app.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion templates/partials/sidebar/latest_comments.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<% from models.utils import trunc_utf8 %>
<%page args="partial"/>
<section class="widget blogroll">
<h5>${ partial.title if 'title' in partial else 'Recent Comments' }</h5>
Expand All @@ -12,7 +13,7 @@ <h5>${ partial.title if 'title' in partial else 'Recent Comments' }</h5>
</div>
<div class="body">
<span><a class="user" href="${ comment.user.link }" target="_blank">${ comment.user.name }</a> </span>
<div class="content"><p>${ comment.content }</p>
<div class="content"><p>${ trunc_utf8(comment.content, partial.max_length) if 'max_length' in partial else comment.content }</p>
</div>
</div>

Expand Down
3 changes: 2 additions & 1 deletion views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async def list_posts(request):
limit = int(request.args.get('limit')) or PER_PAGE
page = int(request.args.get('page')) or 1
special_id = int(request.args.get('special_id') or 0)
with_tag = int(request.args.get('with_tag') or 0)
offset = (page - 1) * limit
_posts = await Post.filter().order_by('-id').offset(offset).limit(limit)
total = await Post.filter().count()
Expand All @@ -64,7 +65,7 @@ async def list_posts(request):
dct = post.to_dict()
if post.id in exclude_ids:
continue
if limit < 100:
if with_tag:
author = await post.author
dct['author_name'] = author.name
tags = await post.tags
Expand Down

0 comments on commit 570d11a

Please sign in to comment.