Total Pageviews

Wednesday 3 August 2016

基于python3的静态博客程序yasbe

首先安装python3
(apt-get install python3 python3-pip python3-setuptools for debian/ubuntu,
yum install python3 python3-pip python3-setuptools for centos/fedora)

pip3 install mako
pip3 install toml
pip3 install mistune
git clone https://github.com/underr/yasbe yasbe-site
cd yasbe-site

root@AR:/usr/local/yasbe-site# ls
config_ex.toml LICENSE   posts      static  
Makefile  README.md  tmpl    yasbe.py

root@AR:/usr/local/yasbe-site# cp config_ex.toml config.toml
root@AR:/usr/local/yasbe-site# python3 yasbe.py (这个就是生成/更新静态网站的命令)
root@AR:/usr/local/yasbe-site# ls
config_ex.toml LICENSE   posts      static  www
config.toml Makefile  README.md  tmpl    yasbe.py
(生成了www目录)
root@AR:/usr/local/yasbe-site# cd www
root@AR:/usr/local/yasbe-site/www# ls
index.html  static  test  
(/usr/local/yasbe-site/www/里面有index.html文件,可见/usr/local/yasbe-site/www/就是静态网站的根目录)
root@AR:/usr/local/yasbe-site/www# cd ..
root@AR:/usr/local/yasbe-site# cd posts
root@AR:/usr/local/yasbe-site/posts# ls
2015-06-04-test.md
root@AR:/usr/local/yasbe-site/posts# nano 2016-08-03-test-1.md 
root@AR:/usr/local/yasbe-site/posts# cat 2016-08-03-test-1.md
# 测试1

这是测试1.
root@AR:/usr/local/yasbe-site/posts# cd ..
root@AR:/usr/local/yasbe-site# python3 yasbe.py
root@AR:/usr/local/yasbe-site# nano config.toml
(把title_mode的值改为original。这样源贴的文件名可以使用中文)
root@AR:/usr/local/yasbe-site# ls posts
2015-06-04-test.md    2016-08-03-test-2.md  2016-08-03-空中浩劫.md
2016-08-03-test-1.md  2016-08-03-测试-3.md  2016-08-03-稀奇古怪的中国经济.md
root@AR:/usr/local/yasbe-site#

演示站点:http://yb.smt.biz.st
项目地址:https://github.com/underr/yasbe
奇怪的是这个程序里的md文件竟然不支持插入html code,这个帖子http://yb.smt.biz.st/空中浩劫/中插入的视频竟然不能显示。

附录:我打开/usr/local/yasbe-site/www/空中浩劫/index.html一看,发现括号被转义成了>
把&gt; 相应的改为<或>即可。