ABlog 命令¶
ablog 命令是为了简化博客操作,即建立、提供和查看博客页面,以及启动一个新的博客
$ ablog
usage: ablog [-h] [-v] {start,build,clean,serve,post,deploy} ...
ABlog for blogging with Sphinx
optional arguments:
-h, --help show this help message and exit
-v, --version print ABlog version and exit
subcommands:
{start,build,clean,serve,post,deploy}
start start a new blog project
build build your blog project
clean clean your blog build files
serve serve and view your project
post create a blank post
deploy deploy your website build files
See 'ablog <command> -h' for more information on a specific command.
下面是你能做的所有事情:
启动新项目¶
ablog start 命令可以快速建立一个博客项目。请看 ABlog 快速入门 了解它是如何工作的,以及它为你准备了什么
$ ablog start -h
usage: ablog start [-h]
Start a new blog project by answering a few questions. You will end up with a
configuration file and sample pages.
optional arguments:
-h, --help show this help message and exit
建立网站¶
在你的项目文件夹中运行 ablog build,可以构建你的网站 HTML 页面:”
$ ablog build -h
usage: ablog build [-h] [-a] [-b BUILDER] [-s SOURCEDIR] [-w WEBSITE]
[-d DOCTREES] [-T] [-P]
Path options can be set in conf.py. Default values of paths are relative to
conf.py.
optional arguments:
-h, --help show this help message and exit
-a write all files; default is to only write new and changed
files
-b BUILDER builder to use, default `ablog_builder` or dirhtml
-s SOURCEDIR root path for source files, default is path to the folder that
contains conf.py
-w WEBSITE path for website, default is _website when `ablog_website` is
not set in conf.py
-d DOCTREES path for the cached environment and doctree files, default
.doctrees when `ablog_doctrees` is not set in conf.py
-T show full traceback on exception
-P run pdb on exception
在本地服务和查看¶
在建立你的网站后,运行 ablog serve,将启动一个 Python 服务器,并打开浏览器标签查看你的网站
$ ablog serve -h
usage: ablog serve [-h] [-w WEBSITE] [-p PORT] [-n] [-r] [--patterns]
Serve options can be set in conf.py. Default values of paths are relative to
conf.py.
optional arguments:
-h, --help show this help message and exit
-w WEBSITE path for website, default is _website when `ablog_website` is
not set in conf.py
-p PORT port number for HTTP server; default is 8000
-n do not open website in a new browser tab
-r rebuild when a file matching patterns change or get added
--patterns patterns for triggering rebuilds
部署到 GitHub Pages¶
运行 ablog deploy 会将你的网站推送到 GitHub
$ ablog deploy -h
usage: ablog deploy [-h] [-w WEBSITE] [-p REPODIR] [-g GITHUB_PAGES]
[-m MESSAGE] [-f] [--push-quietly]
[--github-token GITHUB_TOKEN]
Path options can be set in conf.py. Default values of paths are relative to
conf.py.
optional arguments:
-h, --help show this help message and exit
-w WEBSITE path for website, default is _website when
`ablog_website` is not set in conf.py
-p REPODIR path to the location of repository to be deployed,
e.g. `../username.github.io`, default is folder
containing `conf.py`
-g GITHUB_PAGES GitHub username for deploying to GitHub pages
-m MESSAGE commit message
-f owerwrite last commit, i.e. `commit --amend; push -f`
--push-quietly be more quiet when pushing changes
--github-token GITHUB_TOKEN
environment variable name storing GitHub access token
Create a Post¶
最后,ablog post 将制作一个新的帖子模板文件
$ ablog post -h
usage: ablog post [-h] [-t TITLE] filename
positional arguments:
filename filename, e.g. my-nth-post (.rst appended)
optional arguments:
-h, --help show this help message and exit
-t TITLE post title; default is formed from filename
清理构建文件¶
如果有需要,则运行 ablog clean 将删除构建文件并使用 -D 选项进行深度清理
$ ablog clean -h
usage: ablog clean [-h] [-d DOCTREES] [-w WEBSITE] [-D]
Path options can be set in conf.py. Default values of paths are relative to
conf.py.
optional arguments:
-h, --help show this help message and exit
-d DOCTREES path for the cached environment and doctree files, default
.doctrees when `ablog_doctrees` is not set in conf.py
-w WEBSITE path for website, default is _website when `ablog_website` is
not set in conf.py
-D deep clean, remove cached environment and doctree files
Updated on Tue Apr 7 00:00:00 2015
增加了 ablog clean 和 ablog deploy 命令。