Total Pageviews

Monday, 20 January 2014

在linux vps上搭建基于python3.3的静态博客程序-longblog(国人的作品,还不错)

git clone https://gitcafe.com/long_python/longblog
cd longblog
cp settings.py settings.py.bak
nano settings.py
cat settings.py
...
#站点文章目录首页url
'site_url':'http://lb.brite.biz/index_1.html',
#站点次根目录(如果本程序中的build目录是您网站的根目录,请将'myself/'改为'',如果不是,请将'myself/'改为您的子目录,注意保留'/')
'site_suburl':'',
...

mkdir backup

as3:~/longblog# ls
backup  buildpages.py  __pycache__  resources  settings.py
contents readme.txt   server.py  settings.py.bak
as3:~/longblog# python3.3 buildpages.py(这个就是生成/更新静态网站的命令。需先安装python3.3,参见
http://briteming.blogspot.co.uk/2013/11/linux-vpspython333python333-letterpress.html)           
as3:~/longblog# ls
backup  buildpages.py  __pycache__  resources  settings.py
build   contents       readme.txt   server.py  settings.py.bak
(新出现了build目录)
as3:~/longblog# cd build
as3:~/longblog/build# ls
archives  index_1.html  pages     tags
css       log       start.py
(在build目录里,并无index.html,我们可新建一个index.html,内容为:
<meta HTTP-EQUIV=REFRESH CONTENT="0;URL=http://lb.brite.biz/index_1.html"> )
as3:~/longblog/build# ls
archives  index_1.html  index.html  pages     tags
css       log         start.py
as3:~/longblog/build#
可见~/longblog/build/就是静态网站的根目录。

发贴方法:
as3:~/longblog/build# cd ~/longblog/contents/
as3:~/longblog/contents# nano test2.md
格式为:
title:测试2
date:2014-01-20-14-17-00
tags:misc1#misc2#misc3
summary:点击标题看全文
content:
StartFlag==>|
这是测试2.
as3:~/longblog/contents# cd ..
as3:~/longblog# python3.3 buildpages.py  (这个就是更新静态网站的命令)
这个程序有个特点:在运行python3.3 buildpages.py后,在~/longblog/contents/里面新建的帖子会全部自动移动到~/longblog/backup/里。
as3:~/longblog/contents# ls
as3:~/longblog/contents# ls ../backup
chinese-economy.md  hi.md     test2.md
fengyuwuzu.md       test1.md  欢迎使用longblog静态博客发布系统.md
as3:~/longblog/contents#

演示站点:http://lb.brite.biz
项目地址:https://gitcafe.com/long_python/longblog/