Pages

Thursday, 9 January 2014

在linux vps上搭建基于python的静态博客程序-staticjinja

pip install staticjinja easywatch
mkdir -p staticjinja-site/templates
cd staticjinja-site/templates/
nano index.html
内容为:
<h2>homepage</h2>
cd ..

as3:~/staticjinja-site/templates# cd ..
as3:~/staticjinja-site# nohup python -m staticjinja > /dev/null &
as3:~/staticjinja-site# ls
index.html  templates
as3:~/staticjinja-site#
新出现了index.html文件,它是由templates里面的index.html文件转换并推送而来。
可见~/staticjinja-site/就是静态网站的根目录。

发贴方法:
as3:~/staticjinja-site# cd templates
as3:~/staticjinja-site/templates# nano test1.html
格式为:
<h2>test1</h2>
这是测试1.


保存更改,网站就自动更新了。这是easywatch在起作用。
as3:~/staticjinja-site/templates# cd ..
as3:~/staticjinja-site# ls
index.html  templates  test1.html  test2.html
(在~/staticjinja-site/templates/里新建的test1.html,test2.html文件自动推送到了
~/staticjinja-site/)
as3:~/staticjinja-site# nohup Rwebserver 45193 > /dev/null &
访问http://as3.brite.biz:45193/,就可看到网站效果。
http://as3.brite.biz:45193/test1.html,http://as3.brite.biz:45193/test2.html
http://as3.brite.biz:45193/chinese-economy.html,http://as3.brite.biz:45193/fengyuwuzu.html

这个程序跟gabby(http://briteming.blogspot.co.uk/2014/01/linux-vpsnodejs-gabby.html)和webgen
(http://briteming.blogspot.co.uk/2014/01/linux-vpsruby-webgen.html)和staticmatic2
(http://briteming.blogspot.co.uk/2014/01/linux-vpsruby-staticmatic2.html)有着同样的问题:
首页并不自动显示已发表的文章的超链,可这样处理:(编辑源帖所在目录里的index文件)
as3:~/staticjinja-site# cd templates
as3:~/staticjinja-site/templates# ls
chinese-economy.html  fengyuwuzu.html  index.html  test1.html  test2.html
as3:~/staticjinja-site/templates# nano index.html
在<h2>homepage</h2>的下一行加上:
<p><a href=/test1.html>测试1</a></p>
<p><a href=/test2.html>测试2</a></p>
<p><a href=/test3.html>测试3</a></p>
<p><a href=/fengyuwuzu.html>风雨无阻</a></p>
<p><a href=/chinese-economy.html>中国经济</a></p>
保存更改即可。

演示站点:http://as3.brite.biz:45193/,
项目地址:https://github.com/Ceasar/staticjinja
使用指南:http://staticjinja.readthedocs.org/en/latest/