pelican-themes¶
简介¶
pelican-themes 是一个命令行工具,用于管理Pelican主题。有关主题的配置,请参考 设置章节中的主题 。
用法¶
可选参数:¶
- -h, --help
显示帮助信息并退出
- -l, --list
显示已安装的主题
- -i theme_path, --install theme_path
安装一个或多个主题
- -r theme_name, --remove theme_name
移除一个或多个主题
- -s theme_path, --symlink theme_path
和
--install相同,区别在于此选项仅会创建一个符号链接到给定的目录,而不会将主题完整拷贝。一般用于主题的开发- -v, --verbose
开启详细输出
- --version
显示此工具的版本信息
例子¶
列出已安装主题¶
在 pelican-themes 中使用 -l 或 --list 选项,查看可用主题:
$ pelican-themes -l
notmyidea
two-column@
simple
$ pelican-themes --list
notmyidea
two-column@
simple
在上面的例子中,可以看到有三个主题可供使用: notmyidea 、 simple 、和 two-column 。
主题 two-column 后有一个 @ ,这是因为该主题没有被拷贝到Pelican的主题路径下,而只是为其创建了一个符号链接 (详见 创建符号链接 )。
当然,你可以将 --list 选项和 -v 或 --verbose 结合起来,从而得到更详细的输出:
$ pelican-themes -v -l
/usr/local/lib/python2.6/dist-packages/pelican-2.6.0-py2.6.egg/pelican/themes/notmyidea
/usr/local/lib/python2.6/dist-packages/pelican-2.6.0-py2.6.egg/pelican/themes/two-column (symbolic link to `/home/skami/Dev/Python/pelican-themes/two-column')
/usr/local/lib/python2.6/dist-packages/pelican-2.6.0-py2.6.egg/pelican/themes/simple
安装主题¶
使用 -i 或 --install 选项可以安装一个或多个主题。此选项将一个或多个到达主题的路径作为参数,同样可以结合 --verbose 选项:
# pelican-themes --install ~/Dev/Python/pelican-themes/notmyidea-cms --verbose
# pelican-themes --install ~/Dev/Python/pelican-themes/notmyidea-cms\
~/Dev/Python/pelican-themes/martyalchin \
--verbose
# pelican-themes -vi ~/Dev/Python/pelican-themes/two-column
移除主题¶
pelican-themes 命令同样可用于移除Pelican主题文件夹下的主题。 -r 或 --remove 选项以一个或多个主题的名称为参数,同样也可以结合 --verbose 选项使用。
# pelican-themes --remove two-column
# pelican-themes -r martyachin notmyidea-cmd -v
创建符号链接¶
pelican-themes 也可以通过创建符号链接来安装主题,如此便无需完整拷贝主题。
使用 -s 或 --symlink 选项来为主题创建符号链接,用法和 --install 选项相同:
# pelican-themes --symlink ~/Dev/Python/pelican-themes/two-column
在上面的例子中, two-column 主题就已经在Pelican主题目录下创建了符号链接,也可以正常使用。如此,当我们修改主题后就无需重新进行安装。
这对主题的开发是很有用的:
$ sudo pelican-themes -s ~/Dev/Python/pelican-themes/two-column
$ pelican ~/Blog/content -o /tmp/out -t two-column
$ firefox /tmp/out/index.html
$ vim ~/Dev/Pelican/pelican-themes/two-column/static/css/main.css
$ pelican ~/Blog/content -o /tmp/out -t two-column
$ cp /tmp/bg.png ~/Dev/Pelican/pelican-themes/two-column/static/img/bg.png
$ pelican ~/Blog/content -o /tmp/out -t two-column
$ vim ~/Dev/Pelican/pelican-themes/two-column/templates/index.html
$ pelican ~/Blog/content -o /tmp/out -t two-column
同时执行多个操作¶
--install 、 --remove 和 --symlink 可以同时使用,不会冲突,因此可以在同一行命令中同时做多个操作:
# pelican-themes --remove notmyidea-cms two-column \
--install ~/Dev/Python/pelican-themes/notmyidea-cms-fr \
--symlink ~/Dev/Python/pelican-themes/two-column \
--verbose
在上面的例子中,用 notmyidea-cms-fr 替换了 notmyidea-cms 主题。