Total Pageviews

Wednesday, 15 January 2014

在linux vps上搭建基于nodejs的静态博客程序-toosolo(国人的作品,非常不错)

npm install -g toosolo
mkdir -p toosolo-site
cd toosolo-site
mkdir blogs pages global
cd ..
nano config.json
文件内容为:
{
    "blogName" : "SOLO",
    "blogSubTitle" : "Life is Solo...",
    "blogKeywords" : "SOLO,Blog,Node,博客",
    "blogDescription" : "TooBug - 专注前端开发",

    "domain" : "toosolo.brite.biz",

    "sourcePath" : ".",
    "distPath" : "./dist",
    "skinPath" : "./skin"
}


as3:~/toosolo-site# ls
config.json blogs pages global
as3:~/toosolo-site# git clone https://github.com/TooBug/TooSolo
as3:~/toosolo-site# ls
config.json blogs  global  pages TooSolo
as3:~/toosolo-site# cp -r TooSolo/skin/ .
as3:~/toosolo-site# ls
config.json blogs  global  pages skin TooSolo

发贴方法:
as3:~/toosolo-site# cd blogs
as3:~/toosolo-site/blogs# nano test3.md
格式为:
Title: 测试3
Date: 2014-01-15 13:36:00
Tags: misc1 misc2

这是测试3.


然后,
as3:~/toosolo-site/blogs# cd ..
as3:~/toosolo-site# toosolo (这个就是生成/更新静态网站的命令)
会显示:
==================== Solo 2.0 ====================

    解析博客……
        chinese-economy.md
        fengyuwuzu.md
        test1.md
        test2.md
        test3.md
        test4.md

    解析Pages……

    测试解析插件……

    博客文章页面构建……
        chinese-economy.html
        fengyuwuzu.html
        test1.html
        test2.html
        test3.html
        test4.html

    构建分类页……

    首页构建……
        index.html
        index_page2.html

    Pages页面构建……

    RSS构建……
        rss.xml

    复制全局文件……

    复制皮肤文件……

    复制皮肤文件……
{ [Error: ENOENT, no such file or directory '/usr/local/lib/node_modules/toosolo/lib/skin']
  errno: 34,
  code: 'ENOENT',
  path: '/usr/local/lib/node_modules/toosolo/lib/skin',
  syscall: 'stat' }
(上面花括号内的提示不用理睬)

as3:~/toosolo-site# ls
blogs  config.json  dist  global  pages  TooSolo 
(新出现了dist目录)
as3:~/toosolo-site# cd dist
as3:~/toosolo-site/dist# ls
article  categories  css  fonts  index.html  js  page  rss  source
as3:~/toosolo-site/dist#
可见~/toosolo-site/dist/就是静态网站的根目录。
as3:~/toosolo-site/dist# nohup Rwebserver 45293 > /dev/null &
访问http://as3.brite.biz:45293,就可看到网站效果。

注意:上面运行了toosolo命令后, ~/toosolo-site/里面的skin目录消失了。因此在再次新建帖子后,需要把~/toosolo-site/TooSolo/skin/目录复制到~/toosolo-site/,然后才再次运行更新命令:toosolo.
as3:~/toosolo-site# cp -r TooSolo/skin/ .
as3:~/toosolo-site# ls
config.json blogs  global  pages skin TooSolo
as3:~/toosolo-site# toosolo

演示站点:http://as3.brite.biz:45293/index.html,http://toosolo.brite.biz/
项目地址:https://github.com/TooBug/TooSolo
----------------------------
还可以clone程序作者的博客 :
git clone https://github.com/TooBug/toobug.github.io
cd toobug.github.io

as3:~/toobug.github.io# ls
config.json  dist  source
as3:~/toobug.github.io# cd source
as3:~/toobug.github.io/source# ls
blogs  global  pages  skin


发贴方法:
as3:~/toobug.github.io/source# cd blogs
as3:~/toobug.github.io/source/blogs#  nano test1.md
格式如下:
Title: 测试1
Date: 2014-01-15 13:35:00
Tags: misc1 misc2

这是测试1.


然后,
as3:~/toobug.github.io/source/blogs# cd ~/toobug.github.io
as3:~/toobug.github.io# ls
config.json  dist  source
as3:~/toobug.github.io# toosolo
会显示:
==================== Solo 2.0 ====================

    解析博客……
        chinese-economy.md
        fengyuwuzu.md
        test1.md
        test2.md
        xinli-jiankang.md

    解析Pages……
        about.md

    测试解析插件……

    博客文章页面构建……
        chinese-economy.html
        fengyuwuzu.html
        test1.html
        test2.html
        xinli-jiankang.html

    构建分类页……

    首页构建……
        index.html
        index_page2.html
        index_page3.html
        index_page4.html
        index_page5.html
        index_page6.html
        index_page7.html
        index_page8.html

    Pages页面构建……
        about.html

    RSS构建……
        rss.xml

    复制全局文件……

    复制皮肤文件……

=================== 博客构建完成 ===================
as3:~/toobug.github.io#
as3:~/toobug.github.io# ls
config.json  dist  source
as3:~/toobug.github.io# cd dist
as3:~/toobug.github.io/dist# ls
article      css          index.html        index_page5.html  js
attachments  favicon.ico  index_page2.html  index_page6.html  page
categories   fonts        index_page3.html  index_page7.html  rss
CNAME        images       index_page4.html  index_page8.html
as3:~/toobug.github.io/dist#
可见~/toobug.github.io/dist/就是静态网站的根目录。
as3:~/toobug.github.io/dist# nohup Rwebserver 43284 > /dev/null &
访问http://as3.brite.biz:43284/index.html,就可看到网站效果。

设置文章摘要的方法:
用<!-- $$solo_more$$ -->进行分隔,上下各加一个空行,这个标记前的内容就是摘要了。

演示站点:http://as3.brite.biz:43284/index.html,http://toosolo2.brite.biz/
项目地址:https://github.com/TooBug/TooSolo,
https://github.com/TooBug/toobug.github.io

跟上面的做法略有不同。