Total Pageviews

Monday 28 October 2013

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

gem install pith
mkdir pith-site
cd pith-site
# mkdir _pith images
# nano index.html.haml (输入一段源码,比如<center>THIS IS THE DEFAULT HOMEPAGE.</center>)
# pith build (在当前目录下,会生成_out目录,这个_out目录就是静态网站的根目录。)

as3:~# mkdir pith-site
as3:~# cd pith-site
as3:~/pith-site# mkdir _pith images
as3:~/pith-site# ls
images  _pith
as3:~/pith-site# nano index.html.haml
as3:~/pith-site# ls
images  index.html.haml  _pith
as3:~/pith-site# pith build
Generating to "_out"
+ index.html.haml
--> index.html
as3:~/pith-site# ls
images  index.html.haml  _out  _pith
as3:~/pith-site# cd _out
as3:~/pith-site/_out# ls
index.html
as3:~/pith-site/_out# nohup Rwebserver 2349 > /dev/null &
[1] 2834
as3:~/pith-site/_out# nohup: ignoring input and redirecting stderr to stdout
as3:~/pith-site/_out#

as3:~/pith-site/_out# cd ..
as3:~/pith-site# pith serve
Generating to "_out"
>>> Now taking the Pith at "http://localhost:4321"  (这个是预览服务器)
按ctrl+c退出。
as3:~/pith-site# nohup pith serve > /dev/null &
[2] 3525
as3:~/pith-site# nohup: ignoring input and redirecting stderr to stdout
as3:~/pith-site#

发表帖子的方法:
as3:~/pith-site# nano  test1.html.haml
格式为:
<h2>测试1</h2>
这是测试1.
然后,
as3:~/pith-site# pith build (这个就是更新静态网站的命令)

 不过首页并不自动显示已发表的文章的超链,可以这样处理:(编辑~/pith-site/目录里的index文件-index.html.haml)
在<center>THIS IS THE DEFAULT HOMEPAGE.</center>这行的下一行加上:
<center><p><a href=/test1.html>测试1</a></p></center>
<center><p><a href=/test2.html>测试2</a></p></center>
<center><p><a href=/fengyuwuzu.html>风雨无阻</a></p></center>
<center><p><a href=/chinese-economy.html>中国经济</a></p></center>
然后,
as3:~/pith-site# pith build
demo site: http://as3.brite.biz:2349/,http://as3.brite.biz:4321/
项目地址: https://github.com/mdub/pith(这个也只是个初步框架,需自行设计模板)