Total Pageviews

Wednesday 23 October 2013

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

npm install -g gabby
gabby init gabby-site

as3:~# gabby init gabby-site
  started - Generating new project in /root/gabby-site
  created - /root/gabby-site
  created - /root/gabby-site/generated
  created - /root/gabby-site/content
  created - /root/gabby-site/content/index.md
  created - /root/gabby-site/public
  created - /root/gabby-site/public/images
  created - /root/gabby-site/public/images/favicon.png
  created - /root/gabby-site/public/images/gabby.png
  created - /root/gabby-site/public/images/background.png
    error - ENOENT, open '/usr/local/lib/node_modules/gabby/lib/../src/public/images/background@2x.png'
as3:~# cd gabby-site
as3:~/gabby-site# ls
content  generated  public

~/gabby-site/里的内容跟https://github.com/alexmingoia/gabby 中所说的“That will create the following directory structure”有些差别,少了scripts,styles,templates.我们需进入~/gabby-site/里自行创建这些内容:

as3:~/gabby-site# mkdir  scripts
as3:~/gabby-site# ls
content  generated  public  scripts
as3:~/gabby-site# mkdir styles
as3:~/gabby-site# cd styles
as3:~/gabby-site/styles# ls
as3:~/gabby-site/styles# nano screen.styl (按https://github.com/alexmingoia/gabby/blob/master/src/styles/screen.styl,添加内容)
as3:~/gabby-site/styles# ls
screen.styl
as3:~/gabby-site/styles# cd ..
as3:~/gabby-site# ls
content  generated  public  scripts  styles
as3:~/gabby-site# mkdir  templates
as3:~/gabby-site# cd  templates
as3:~/gabby-site/templates# ls
as3:~/gabby-site/templates# nano layout.html (按https://github.com/alexmingoia/gabby/blob/master/src/templates/layout.html,添加内容)
as3:~/gabby-site/templates# nano index.html (按https://github.com/alexmingoia/gabby/blob/master/src/templates/index.html,添加内容)
as3:~/gabby-site/templates# ls
layout.html index.html
as3:~/gabby-site/templates# cd ..
as3:~/gabby-site# ls
content  generated  public  scripts  styles  templates
as3:~/gabby-site# gabby listen ~/gabby-site (这是启动预览服务器的命令,然后即可访问http://as3.brite.biz:3001/)
as3:~/gabby-site# gabby build (这个是生成/更新静态网站的命令)
  started - Building static files
 finished - Your site is ready :)
as3:~/gabby-site# ls
content  generated  public  scripts  styles  templates
as3:~/gabby-site# ls generated
images  index.html  screen.css (可见~/gabby-site/generated/就是静态网站的根目录。)
as3:~/gabby-site# cd generated
as3:~/gabby-site/generated# Rwebserver 5839 > /dev/null &

demo site: http://as3.brite.biz:5839
(这也只是个初步框架,还需自己设计模板)
项目地址:https://github.com/alexmingoia/gabby