Total Pageviews

Tuesday 31 December 2013

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

 git clone https://github.com/mytharcher/dwarf.git
cd dwarf
mkdir output
as3:~/dwarf# ls
build.php  example  filters  output  README.md
as3:~/dwarf# cd filters
as3:~/dwarf/filters# git clone https://github.com/mytharcher/php-markdown.git
as3:~/dwarf/filters# cd ..
as3:~/dwarf# php build.php -p example -o output (这个就是生成/更新静态网站的命令)
as3:~/dwarf# cd output
as3:~/dwarf/output# ls
assets  docs  downloads  index.html
(现在output里出现了很多内容,包括index.html,可见~/dwarf/output/就是静态网站的根目录)

发贴方法:在项目的targets目录中创建文本文件即可。
as3:~/dwarf/output# cd ../example/targets/
as3:~/dwarf/example/targets# nano test1.text
格式如下:

这是测试1.

无需写header部分。然后:
as3:~/dwarf/example/targets# cd ~/dwarf/
as3:~/dwarf# php build.php -p example -o output

演示站点:http://as3.brite.biz:23569/,http://dwarf.brite.biz/
不过发布帖子后,帖子的超链并不会自动出现在网站中。比如:
http://dwarf.brite.biz/chinese-economy.html,这个超链是我手工编辑~/dwarf/example/targets/里的index.html,添加到index.html文件的底部而来。
注意 这里的~/dwarf/example/targets/其实是“源目录”,~/dwarf/output/才是“目的地目录”。我们需要编辑“源目录"中的index文件,而非“目的地目录"中的index文件,因为更新网站后,“目的地目录"中的内容会被全部覆盖,包括其中的index文件。  如果修改“目的地目录"中的index文件,就等于是白改了。

像这类不能把所发布的帖子的超链自动展现在网站中的静态博客程序没多大意义。
项目地址:https://github.com/mytharcher/dwarf/