Total Pageviews

Thursday, 31 October 2013

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

npm install roots -g
roots new roots-site
cd roots-site

as3:~# npm install roots -g
as3:~# roots new roots-site (该命令会在当前目录下,生成roots-site目录)
new project created at /roots-site
as3:~# cd roots-site
as3:~/roots-site# ls
app.coffee  assets  readme.md  views
as3:~/roots-site# roots compile (这个是生成/更新静态网站的命令)
compiling...
minifying & compressing...
WARN: Dropping unused function argument $ [null:13,31]
done!
as3:~/roots-site# ls
app.coffee  assets  public  readme.md  views (多出了public目录)
as3:~/roots-site# ls public
css  favicon.ico  img  index.html  js
as3:~/roots-site# cd public
as3:~/roots-site/public# 
(可见~/roots-site/public/就是静态网站的根目录,可绑定一个域名到该目录)
 以上的roots new roots-site命令生成的只是很简陋的静态页面。

如果使用命令:roots new roots-blogstyle --blog, 生成的则是博客风格的静态网站。(参见http://roots.cx/docs/man.html)
 as3:~# roots new roots-blogstyle --blog
new project created at /roots-blogstyle
as3:~# cd roots-blogstyle
as3:~/roots-blogstyle# ls
app.coffee  assets  posts readme.md  views
as3:~/roots-blogstyle# roots compile (这个是生成/更新静态网站的命令)
as3:~/roots-blogstyle# ls
app.coffee  assets  posts public  readme.md  views (多出了public目录)
as3:~/roots-blogstyle# ls public
css  favicon.ico  img  index.html  js posts
as3:~/roots-blogstyle# cd public
as3:~/roots-blogstyle/public# 
(可见~/roots-blogstyle/public/就是静态网站的根目录,可绑定一个域名到该目录)

发贴方法:
as3:~# cd /root/roots-blogstyle/posts
as3:~/roots-blogstyle/posts# ls
hello_world.jade                           some-chinese-words.jade
it-doesnt-support-180kb-long-article.jade  test1.jade
programmer-wife.jade                       test2.jade
second_post.jade                           wether-sunshine-or-rain.jade
as3:~/roots-blogstyle/posts# nano test3.jade
按~/roots-blogstyle/posts/里面的帖子hello_world.jade的格式,新建帖子test3.jade,格式如下:
---
title: 测试3
date: 11/04/2013
layout: /root/roots-blogstyle/views/_single_post.jade
---

这是测试3.(这里写正文-纯文字或html code.)

然后:
as3:~/roots-blogstyle/posts# cd ..
as3:~/roots-blogstyle# roots compile (这个是生成/更新静态网站的命令)

demo site: http://as3.brite.biz:7531/,http://roots.brite.biz/
-------------------------------------------
as3:~/roots-site# roots watch
compiling... done!
server started on port 1111
(roots watch是启动预览服务器的命令,访问http://ur-vps-ip:1111即可预览网站,比如http://as3.brite.biz:1111/)
按ctrl+c退出。
as3:~/roots-site# nohup roots watch > /dev/null &
[2] 20245
as3:~/roots-site# nohup: ignoring input and redirecting stderr to stdout
as3:~/roots-site#
演示站点:
http://as3.brite.biz:1111/

项目地址:https://github.com/jenius/roots, https://github.com/jescalan/roots
官网: http://roots.cx
http://roots.cx/docs/
http://roots.cx/docs/man.html