Skip to content

Commit

Permalink
update docs && close #43
Browse files Browse the repository at this point in the history
  • Loading branch information
dongweiming committed Dec 22, 2019
1 parent 91f5a8f commit ab140bc
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 25 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ My Blog Using Sanic

[查看文档 📖](https://dongweiming.github.io/lyanna/)

## 版本提示

3.0版本开始已经使用了最新的Python3.8语法,所以如果你不方便升级CPython请使用2.X版本

## Overview

这是一个使用asyncio生态开发的个人技术博客。具体如下:
Expand All @@ -16,21 +20,24 @@ My Blog Using Sanic
* 缓存: aiomcache
* KV数据库: aioredis
* 任务队列: arq
* 代码质量: mypy/flake8/isort/bandit

其他aio扩展: Sanic-Auth、Sanic-wtf、sanic-session、aiotask-context、asyncblink、sanic-sentry、sanic-jwt、aiosmtplib

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

管理后台使用 ElementUI + Vue-CLI + Vue-Router + Vuex
管理后台使用: ElementUI + Vue-CLI + Vue-Router + Vuex

<p align="center">
<img width="600" src="./screenshot/admin.png" >
</p>

Inspired by [vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)

[动态](https://www.dongwm.com/activities) 使用: Vue-CLI + Vue-Router + Vuex

## Features

* 可以通过后台对文章、标签等做增删改查
Expand All @@ -51,11 +58,14 @@ Inspired by [vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
* 支持评论提及邮件
* 支持 Github Cards. 具体用法请看 [这里](#github-cards)
* 文章内容(除代码部分之外)自动「盘古之白」
* 支持文章专题
* 支持「文章专题」
* 支持「动态」
* 可对评论回应
* 支持用Docker Compose本地开发
* 支持kubernetes上运行
* Widget系统,内置aboutme、blogroll、most\_viewed、latest\_comments、tagcloud、html等widget
* 导航栏项可以设置icon(如RSS)
* 导航栏项可以设置icon和颜色(如RSS)
* 支持配置CDN域名服务静态文件

## Github Cards

Expand Down
9 changes: 9 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 3.0 (2019-12-22)

1. Use Python 3.8 syntax
2. Activity feature. like douban user's status
3. Configuration file uses YAML format
4. Use isort/bandit/autopep8
5. Use mypy
6. Support reply comment

## 2.7.1 (2019-11-27)

1. Update recent comments in realtime
Expand Down
18 changes: 17 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 配置项

全部配置项都在 config.py 中可以找到
全部配置项都在 config.py 中可以找到。但是从3.0版本开始不再使用`local_settings.py`存放配置,统一使用`config.yaml`,具体可以看`config.yaml.tmpl`样板文件中的设置项

## DB_URL

Expand Down Expand Up @@ -179,3 +179,19 @@ Redis Sentinel集群架构,本项指定主机端口号。另外也支持从环
- 默认值: `False`

文章页可以显示发布文章的用户信息(名字、头像),目前还不提供链接到用户详情页

## USE_FFMPEG

动态可以上传视频,如果服务器上安装了ffmpeg可以在上传后自动截取封面并且获得视频大小,这样让用户访问体验更好。本项会自动根据是否安装ffmpeg决定,为了在启动时给博主提示,改变此项无意义

## CDN_DOMAIN

- 默认值: `''`

为了更好地访问效果,博客内的静态文件(Javascript/css/img/fonts等)地址可以使用CDN的域名,默认不开启

## ACTIVITY_THEME

- 默认值: `rainbow`

指定动态页面渲染代码块用的highlight.js主题的名字,默认引入`https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/rainbow.min.css`
13 changes: 8 additions & 5 deletions docs/features.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 功能

支持如下功能
支持如下功能:

* 可以通过后台对文章、标签等做增删改查
* 后台支持Markdown编辑/预览
Expand All @@ -16,12 +16,15 @@
* 支持定制导航栏
* 支持RSS/Sitemap
* 相关文章推荐(根据相似标签)
* 响应式网站设计
* 响应式设计
* 支持评论提及邮件
* 支持 Github Cards
* 支持 Github Cards. 具体用法请看 [这里](#github-cards)
* 文章内容(除代码部分之外)自动「盘古之白」
* 支持文章专题
* 支持「文章专题」
* 支持「动态」
* 可对评论回应
* 支持用Docker Compose本地开发
* 支持kubernetes上运行
* Widget系统,内置aboutme、blogroll、most\_viewed、latest\_comments、tagcloud、html等widget
* 导航栏项可以设置icon(如RSS)
* 导航栏项可以设置icon和颜色(如RSS)
* 支持配置CDN域名服务静态文件
41 changes: 41 additions & 0 deletions docs/front-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,44 @@
```
python manage.py build-css
```

## 「动态」页面(/activities)

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

```bash
cd activity # 在 activity 子目录下
❯ yarn install
```

接着启动开发环境:

```bash
❯ yarn serve
```

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

生产环境需要构建:

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

## 其他说明

管理后台和动态使用了一些通用组件和功能,放在了common目录下:

```bash
❯ tree common -L 2
common
└── src
├── api.js # API统一在这里
├── store # Vuex
└── utils # 功能函数

3 directories, 1 file
```

为了优化网页打开速度,Vue等库使用Webpack的externals参数项(在vue.config.js中)直接在模板中引入外部CDN(cdn.jsdelivr.net)的内容
10 changes: 10 additions & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ python app.py

如果你要部署到自己的服务器上,可以参考 [部署](deploying.md)

## v3.0不兼容问题

在v3.0添加了动态功能,如果之前你已经使用的版本>2.7,可以通过如下命令修改:

```bash
python manage.py migrate-for-v30
```

如果版本<=2.7看下面👇

## v2.7不兼容问题

在v2.5时有做了很多修改,如果之前你已经使用的版本>=2.5,可以通过如下命令修改:
Expand Down
7 changes: 4 additions & 3 deletions forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import markupsafe
from sanic.log import logger
from sanic_wtf import SanicForm as _SanicForm
from wtforms import (BooleanField, PasswordField, SelectField,
SelectMultipleField, StringField, SubmitField,
TextAreaField)
from wtforms import (
BooleanField, PasswordField, SelectField,
SelectMultipleField, StringField, SubmitField, TextAreaField,
)
from wtforms.validators import DataRequired
from wtforms.widgets import HiddenInput

Expand Down
6 changes: 3 additions & 3 deletions models/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import math
import subprocess
from pathlib import Path
from dataclasses import asdict, dataclass, field
from pathlib import Path
from pickle import dumps, loads
from typing import Any, Dict, List, Optional, Tuple, Union

from tortoise import fields

from config import USE_FFMPEG, UPLOAD_FOLDER
from config import UPLOAD_FOLDER, USE_FFMPEG

from .base import BaseModel
from .blog import Post
Expand All @@ -18,8 +18,8 @@
from .mc import cache, clear_mc
from .mixin import ContentMixin
from .react import ReactMixin
from .user import User
from .signals import post_created
from .user import User
from .utils import cached_property

PER_PAGE = 10
Expand Down
2 changes: 1 addition & 1 deletion models/mixin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import markupsafe
from aioredis.commands import Redis

from .utils import get_redis
from .markdown import markdown
from .utils import get_redis


class ContentMixin:
Expand Down
3 changes: 2 additions & 1 deletion models/react.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from collections import defaultdict
from typing import List, Dict, DefaultDict, Any
from typing import Any, DefaultDict, Dict, List

from tortoise import fields

Expand Down
2 changes: 1 addition & 1 deletion models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import struct
import threading
import time
from functools import wraps
from dataclasses import dataclass
from functools import wraps
from typing import Dict, Iterator, List, Union
from urllib.parse import unquote

Expand Down
6 changes: 4 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
from mako.lookup import TemplateLookup
from tortoise.query_utils import Q

from config import (BLOG_URL, MAIL_PASSWORD, MAIL_PORT, MAIL_SERVER,
MAIL_USERNAME, REDIS_URL, SITE_TITLE)
from config import (
BLOG_URL, MAIL_PASSWORD, MAIL_PORT, MAIL_SERVER,
MAIL_USERNAME, REDIS_URL, SITE_TITLE,
)
from ext import init_db
from models.blog import RK_PAGEVIEW, RK_VISITED_POST_IDS, Post
from models.mention import EMAIL_SUBJECT, Mention
Expand Down
2 changes: 1 addition & 1 deletion views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from ext import mako
from forms import PostForm, TopicForm, UserForm
from models import Post, PostTag, SpecialTopic, Tag, User
from models.signals import post_created
from models.activity import create_status
from models.signals import post_created
from models.user import generate_password
from models.utils import generate_id
from views.request import Request
Expand Down
6 changes: 4 additions & 2 deletions views/blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
from config import ACTIVITY_THEME, PER_PAGE, AttrDict, partials
from ext import mako
from models import Post, PostTag, SpecialTopic, Tag
from models.blog import (MC_KEY_ARCHIVE, MC_KEY_ARCHIVES, MC_KEY_TAG,
MC_KEY_TAGS, get_most_viewed_posts)
from models.blog import (
MC_KEY_ARCHIVE, MC_KEY_ARCHIVES, MC_KEY_TAG,
MC_KEY_TAGS, get_most_viewed_posts,
)
from models.comment import get_latest_comments
from models.mc import cache
from models.utils import Pagination
Expand Down
4 changes: 2 additions & 2 deletions views/j.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Callable, List, Dict, Any
from typing import Any, Callable, Dict, List

import mistune
from sanic import Blueprint
from sanic.response import json
from sanic_mako import render_template_def

from config import DEBUG
from models import Comment, Post, ReactItem, Activity
from models import Activity, Comment, Post, ReactItem
from models.consts import K_POST

bp = Blueprint('j', url_prefix='/j')
Expand Down

0 comments on commit ab140bc

Please sign in to comment.