catg

a python static blog generator


License
MIT
Install
pip install catg==0.5

Documentation

cat

python家的静态博客生成器
cat

安装(pip install catg)

$ pip install catg

生成blog

$ ca init

(注: 以下所有命令需在blog/下运行)

添加新博文

$ ca new post
\_title:
\_date[YYYY-MM-DD]:
\_tags[tag1 tag2]:

预览博客

$ ca runserver
访问 http://127.0.0.1:5000 即可预览博客

部署博客

要求使用github pages进行部署

1. 注册一个github账号

2. 创建一个仓库, 仓库名: github用户名.github.io

3. 配置config.pyGIT_URL为创建仓库的git地址(https协议)

4. 本地运行$ ca upload部署博客

5. 访问 http://github用户名.github.io 即可看到你的博客(可能需要等一会)

默认主题 cat

cat

配置博客

采用python类的语法进行配置(都是程序员嘛,就像nginx配置一样😄 ), 示例:

"""
默认配置
--> DEBUG: debug模式
--> FLATPAGES_AUTO_RELOAD
--> FLATPAGES_EXTENSION ==> flask-flatpages 配置
"""
class Config:
    DEBUG = True
    FLATPAGES_AUTO_RELOAD = DEBUG
    FLATPAGES_EXTENSION = '.md'

"""
个人配置
--> BLOG_TITLE: 博客标题
--> BLOG_URL: 博客URL地址
--> BLOG_DESCRIPTION: 博客描述
--> BLOG_KEYWORDS: 这个博客的关键字
--> BLOG_THEME: 博客主题
--> GIT_URL: 部署至github仓库的url
"""
class MyConfig(Config):
    BLOG_TITLE = "cat^0^python家的静态博客生成器"
    BLOG_URL = "http://127.0.0.1:5000"
    BLOG_DESCRIPTION = "python static blog generator"
    BLOG_KEYWORDS = "python static blog cat"
    GIT_URL = "https://github.com/neo1218/neo1218.github.io.git"

"""有效配置名称"""
config = {
    'default': MyConfig
}

编写主题

使用 html(jinja2模版), css, js 编写主题, 可以编写的页面如下表:

路由 描述 参数 页面
/index/ 首页 latests(所有文章,按时间排序), tags(所有标签), archieve(文章归档), blog_title(博客标题), blog_description(博客描述), blog_keywords(博客关键字) index.html
/path:path/ 博文页 post(文章) post.html
/tags/string:tag/ 标签页 posts(含tag标签的所有文章) tags.html
/archive/string:year/ 归档页 posts(该年月归档下的所有文章) archive.html

更换主题

  1. 查看cat主题收录列表,找到自己喜爱的主题
  2. clone github上相应主题到theme目录下
  3. 运行ca upgrade theme_name更新主题(theme_name为theme目录下相应主题的目录名)

更新日志

  • 2016年2月10日: 修复ca uploadbug, 该功能可以使用!(待测试)