Pages

Thursday, 27 March 2014

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


git clone https://github.com/littledu/dublog
cd dublog

as3:~/dublog# ls
bin  lib  package.json  README.md  source
as3:~/dublog# npm install
as3:~/dublog# ls bin
dublog-build.js dublog-init.js dublog-server.js
as3:~/dublog# chmod 755 bin/*
as3:~/dublog# cd source
as3:~/dublog/source# ls
articles  config.json  images  pages  skin
as3:~/dublog/source# ~/dublog/bin/dublog-build.js all ~/dublog/source/
(这个就是生成/更新静态网站的命令)
as3:~/dublog/source# ls
articles  config.json  dist  images  pages  skin
(新出现了dist目录)
as3:~/dublog/source# ls dist
articles  css  images  index.html  js  pages
as3:~/dublog/source# cd dist
as3:~/dublog/source/dist# ls
articles  css  images  index.html  js  pages
(可见~/dublog/source/dist/就是静态网站的根目录)
as3:~/dublog/source/dist# nohup Rwebserver 43642 > /dev/null &
访问http://as3.brite.biz:43642/就可看到网站效果。

发贴方法:
as3:~/dublog/source/dist# cd ../articles/
as3:~/dublog/source/articles# nano test1.md
格式为:
<{
"title": "测试1",
"id": "test1",
"postedOn": "2014-03-27 23:48:16",
"excerpt": "点击标题看全文"
}>

这是测试1.

然后,
as3:~/dublog/source/articles# cd ..
as3:~/dublog/source# ~/dublog/bin/dublog-build.js all ~/dublog/source/

演示站点:http://as3.brite.biz:43642/,http://db.brite.biz.st
HTTP://db2.brite.biz.st(这是新版的dublog;旧版的dublog里面发贴时, 帖子并非按时间顺序排列,而新版修复了此问题。)
http://db3.brite.biz.st/ (这是用第3版搭建的,此版可以自行设置帖子的id,即所谓的post slug,还提供了分页功能)
项目地址:https://github.com/littledu/dublog
(修改自https://github.com/ericzhang-cn/papery)