Total Pageviews

Tuesday, 7 January 2014

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

git clone https://github.com/mindeavor/staticmatic2
cd staticmatic2
~/staticmatic2/bin/staticmatic init staticmatic2-site (此命令会在当前目录下,生成staticmatic2-site目录)
cd staticmatic2-site

as3:~/staticmatic2/staticmatic2-site# ls
config  README.md  src
as3:~/staticmatic2/staticmatic2-site# cd ..
as3:~/staticmatic2# cp Gemfile Gemfile.bak
as3:~/staticmatic2# gem install sass compass
as3:~/staticmatic2# nano Gemfile
把里面的gem "sass", "~> 3.1"改为gem "sass", "3.2.13"
把里面的gem "compass", "~> 0.12.1"改为gem "compass", "0.12.2"
(一定要做上面的操作,否则以后会遇到“cannot load such file -- sass/script/node (LoadError)”错误)

as3:~/staticmatic2# cd staticmatic2-site
as3:~/staticmatic2/staticmatic2-site# ~/staticmatic2/bin/staticmatic build (这个就是生成静态网站的命令)
会显示:
Building website...
Site root is: .
  Rendered ./src/index.haml => ./build/index.html
as3:~/staticmatic2/staticmatic2-site# ls
build  config  README.md  src
(新出现了build目录)
as3:~/staticmatic2/staticmatic2-site# cd build
as3:~/staticmatic2/staticmatic2-site/build# ls
index.html
as3:~/staticmatic2/staticmatic2-site/build# nohup Rwebserver 23542 > /dev/null &
可见~/staticmatic2/staticmatic2-site/build/就是静态网站的根目录。
访问http://as3.brite.biz:23542/

as3:~/staticmatic2# ~/staticmatic2/bin/staticmatic add js-app git://github.com/mindeavor/staticmatic-js-app-starter.git
as3:~/staticmatic2# ~/staticmatic2/bin/staticmatic init my-new-project --skeleton=js-app
as3:~/staticmatic2# cd my-new-project
as3:~/staticmatic2/my-new-project# ls
config  README.md  src
as3:~/staticmatic2/my-new-project# ~/staticmatic2/bin/staticmatic build
Building website...
Site root is: .
  Rendered ./src/css/app.scss => ./build/css/app.css
  Rendered ./src/index.haml => ./build/index.html
as3:~/staticmatic2/my-new-project# ls
build  config  README.md  src
as3:~/staticmatic2/my-new-project# cd build
as3:~/staticmatic2/my-new-project/build# ls
css  index.html  js
as3:~/staticmatic2/my-new-project/build# nohup Rwebserver 23658 > /dev/null &
访问http://as3.brite.biz:23658/

发贴方法:
as3:~/staticmatic2/my-new-project/build# cd ../src
as3:~/staticmatic2/my-new-project/build/src# mv _partials _partials-bak
as3:~/staticmatic2/my-new-project/build/src# nano index.haml
把其内容改为<h2>homepage</h2>
as3:~/staticmatic2/my-new-project/build/src# nano test1.haml
其格式为:
<h2>test1</h2>
这是测试1.


然后,
as3:~/staticmatic2/my-new-project/build/src# cd ~/staticmatic2/my-new-project/
as3:~/staticmatic2/my-new-project# ~/staticmatic2/bin/staticmatic build
不过首页并不自动显示已发表的文章的超链,可以这样处理:(编辑源目录里的index文件

as3:~/staticmatic2/my-new-project# cd src
as3:~/staticmatic2/my-new-project/src# ls
chinese-economy.haml  fengyuwuzu.haml  js        _partials-bak  test2.haml
css                   index.haml       _layouts  test1.haml
as3:~/staticmatic2/my-new-project/src# nano index.haml
在<h2>homepage</h2>的下一行加上:
<p><a href=/test1.html>测试1</a></p>
<p><a href=/test2.html>测试2</a></p>
<p><a href=/fengyuwuzu.html>风雨无阻</a></p>
<p><a href=/chinese-economy.html>中国经济</a></p>
然后,
as3:~/staticmatic2/my-new-project/src# cd ..
as3:~/staticmatic2/my-new-project# ~/staticmatic2/bin/staticmatic build

demo site: http://as3.brite.biz:23658/
http://as3.brite.biz:23658/test1.html
http://as3.brite.biz:23658/test2.html
http://as3.brite.biz:23658/fengyuwuzu.html
http://as3.brite.biz:23658/chinese-economy.html
项目地址:https://github.com/mindeavor/staticmatic2