Total Pageviews

Saturday, 3 May 2014

在linux vps上搭建基于ruby的静态网站程序-machined

gem install machined
gem install sprockets tilt hike multi_json sprockets-sass rack-protection activesupport i18n
machined new machined-site (此命令会在当前目录下,生成machined-site目录)
cd machined-site

as3:~/machined-site# ls
assets     Gemfile       machined.rb  public
config.ru  Gemfile.lock  pages        views
as3:~/machined-site# cd public
as3:~/machined-site/public# ls
assets  first-post.html  index.html
(可见~/machined-site/public/就是静态网站的根目录)
as3:~/machined-site/public# nohup Rwebserver 25384 >  /dev/null &
访问http://as3.brite.biz:25384/即可看到网站效果。

发帖方法:
as3:~/machined-site/public# cd ..
as3:~/machined-site# ls
assets     Gemfile       machined.rb  public
config.ru  Gemfile.lock  pages        views
as3:~/machined-site# cd pages
as3:~/machined-site/pages#
as3:~/machined-site/pages# ls
index.html.erb  index.html.erb.bak
as3:~/machined-site/pages# 编辑index.html.erb如下:
---
title: My Blog
---
<h1><%= title %></h1>
<ul>
  <li><%= link_to "First Post", "/first-post.html" %></li>
</ul> 
as3:~/machined-site/pages# 新建first-post.html.erb如下:
---
title: 第一个帖子
---
<h1><%= title %></h1>
<p>这是第一个帖子</p>
as3:~/machined-site/pages# 新建smiling-face.html.erb如下:
---
title: 笑脸
---
<h1><%= title %></h1>
<p>html code</p>
as3:~/machined-site/pages# 每次新建帖子后,都需编辑index.html.erb如下:
(在此行<li><%= link_to "First Post", "/first-post.html" %></li>的上一行加上:
<li><%= link_to "First Post", "/first-post.html" %></li> )

---
title: My Blog
---
<h1><%= title %></h1>
<ul>
 <li><%= link_to "笑脸", "/smiling-face.html" %></li>
  <li><%= link_to "First Post", "/first-post.html" %></li>
</ul>
as3:~/machined-site/pages# cd ..
as3:~/machined-site# machined compile (这个就是更新静态网站的命令)

demo site: http://as3.brite.biz:25384/,http://mc.surmount.biz.wf
项目地址:https://github.com/petebrowne/machined,
https://github.com/petebrowne/machined/wiki