Pages

Saturday, 26 October 2013

一个只用shell脚本写博的静态博客程序-bashblog(无需安装额外的app)

 git clone https://github.com/cfenollosa/bashblog.git
cd bashblog
as3:~/bashblog# ./bb.sh
显示Please set your $EDITOR environment variable
然后:
EDITOR=/usr/bin/nano; export EDITOR
(不过重启vps后,又要运行一次上述命令。所以建议把export EDITOR=/usr/bin/nano放入/etc/profile文件的末尾,这样重启vps后,无需再次运行
EDITOR=/usr/bin/nano; export EDITOR)
as3:~/bashblog#  ./bb.sh post
(会弹出编辑器,
title on this line改为你的帖子的标题。
在这行写正文(纯文字或源码)。保存更改, 会自动返回shell:
Preview? (Y/n) 输y,回车。出现第二个提示,输p,回车,即可成功发表帖子。


as3:~/bashblog# ./bb.sh post
Preview? (Y/n) y
Open http://example.com/blog/test66.html in your browser
[P]ost this entry, [E]dit again, [D]raft for later? (p/E/d) p
Posted test66.html
Rebuilding the index ......
Creating an index page with all the posts ......
Making RSS ......
as3:~/bashblog# ls
4.html          chinese-economy.html  README.md    wether-sunshine-or-rain.html
all_posts.html  feed.rss              test3.html
bb.sh           index.html            test55.html
blog.css        main.css              test66.html
as3:~/bashblog#
~/bashblog/里有index.html文件,可见 ~/bashblog/就是静态网站的根目录,可绑定一个域名到此目录。

修改 ~/bashblog/bb.sh文件,把global_url=的值由"http://example.com/blog"改为你自己的域名地址"http://urdomain.com"
然后:./bb.sh rebuild (重新生成静态网站)

演示站点:http://as3.brite.biz:6072/
http://as3.brite.biz:6072/chinese-economy.html
 http://as3.brite.biz:6072/test66.html
http://bashblog.brite.biz/


项目地址:
https://github.com/cfenollosa/bashblog