Total Pageviews

Monday, 28 July 2014

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

首先安装nimrod和babel:
wget http://nimrod-lang.org/download/nimrod_0.9.4_linux_i386.tar.gz
tar zxvf nimrod_0.9.4_linux_i386.tar.gz
cd nimrod_0.9.4_linux_i386

root@as3:~/nimrod_0.9.4_linux_i386# ls
bin     contributors.txt  doc       install.txt  lib
config  copying.txt       examples  koch         readme.txt
root@as3:~/nimrod_0.9.4_linux_i386# cd bin
root@as3:~/nimrod_0.9.4_linux_i386/bin# ls
babel  c2nim  nimgrep  nimrod
root@as3:~/nimrod_0.9.4_linux_i386/bin# ln -s ~/nimrod_0.9.4_linux_i386/bin/babel
/usr/local/bin/babel
root@as3:~/nimrod_0.9.4_linux_i386/bin# ln -s ~/nimrod_0.9.4_linux_i386/bin/nimrod
/usr/local/bin/nimrod
(这样,nimrod和babel就装好了)

root@as3:~/nimrod_0.9.4_linux_i386/bin# cd ~
root@as3:~# git clone https://github.com/dom96/ipsumgenera ipsumgenera-site
root@as3:~# cd ipsumgenera-site
root@as3:~/ipsumgenera-site# babel install
显示:
/root/ipsumgenera-site/ipsum -> /root/.babel/pkgs/ipsumgenera-0.1.0/ipsum
/root/ipsumgenera-site/LICENSE.md -> /root/.babel/pkgs/ipsumgenera-0.1.0/LICENSE.md
/root/ipsumgenera-site/ipsum.babel -> /root/.babel/pkgs/ipsumgenera-0.1.0/ipsum.babel
/root/ipsumgenera-site/ipsum.nim -> /root/.babel/pkgs/ipsumgenera-0.1.0/ipsum.nim
/root/ipsumgenera-site/ipsum.nimrod.cfg -> /root/.babel/pkgs/ipsumgenera-
0.1.0/ipsum.nimrod.cfg
/root/ipsumgenera-site/src/config.nim -> /root/.babel/pkgs/ipsumgenera-
0.1.0/src/config.nim
/root/ipsumgenera-site/src/rstrender.nim -> /root/.babel/pkgs/ipsumgenera-
0.1.0/src/rstrender.nim
/root/ipsumgenera-site/src/metadata.nim -> /root/.babel/pkgs/ipsumgenera-
0.1.0/src/metadata.nim
/root/ipsumgenera-site/ipsum.babel -> /root/.babel/pkgs/ipsumgenera-0.1.0/ipsum.babel
/root/ipsumgenera-site/readme.md -> /root/.babel/pkgs/ipsumgenera-0.1.0/readme.md
/root/ipsumgenera-site/layouts/articles.html -> /root/.babel/pkgs/ipsumgenera-
0.1.0/layouts/articles.html
/root/ipsumgenera-site/layouts/atom.xml -> /root/.babel/pkgs/ipsumgenera-
0.1.0/layouts/atom.xml
/root/ipsumgenera-site/ipsum.babel -> /root/.babel/pkgs/ipsumgenera-0.1.0/ipsum.babel
/root/ipsumgenera-site/ipsum.babel -> /root/.babel/pkgs/ipsumgenera-0.1.0/ipsum.babel
Creating symlink: /root/.babel/pkgs/ipsumgenera-0.1.0/ipsum -> /root/.babel/bin/ipsum
ipsumgenera installed successfully.
(这里的/root/.babel/pkgs/ipsumgenera-0.1.0/ipsum就是ipsum这个程序的执行文件
root@as3:~/ipsumgenera-site# ln -s /root/.babel/pkgs/ipsumgenera-0.1.0/ipsum
/usr/local/bin/ipsum
root@as3:~/ipsumgenera-site# cd ~
root@as3:~# git clone https://github.com/gradha/gradha.github.io
root@as3:~# cd gradha.github.io
root@as3:~/gradha.github.io# cd src
root@as3:~/gradha.github.io/src# ls
articles  ipsum.ini  layouts  manual  static  update_static_files.sh
root@as3:~/gradha.github.io/src# ipsum (这个就是生成/更新静态网站的命令)
显示:
Copying /root/gradha.github.io/src/output/users-prefer-static-linking.html
Processing /root/gradha.github.io/src/output/cookie-policy.html
Processing /root/gradha.github.io/src/output/about.html
Copying /root/gradha.github.io/src/output/i/python_trap.jpg
Copying /root/gradha.github.io/src/output/i/bomi_calm_down.jpg
Copying /root/gradha.github.io/src/output/i/so_metal.jpg
Copying /root/gradha.github.io/src/output/i/nimrod_doge.jpg
Copying /root/gradha.github.io/src/output/i/christina_punch.jpg
Copying /root/gradha.github.io/src/output/i/do_not_want.jpg
Copying /root/gradha.github.io/src/output/i/nuke_orbit.jpg
Copying /root/gradha.github.io/src/output/i/wikipedia_slutdrop.jpg
Copying /root/gradha.github.io/src/output/i/Feed-icon.svg
Copying /root/gradha.github.io/src/output/articles/2014/01/how_to_release_software_periodically.pdf
Processing /root/gradha.github.io/src/articles/01-first-post.rst
Processing /root/gradha.github.io/src/articles/02-users-prefer-static-linking.rst
Processing /root/gradha.github.io/src/articles/03-you-have-to-realise-that-someday-
you-will-die.rst
Processing /root/gradha.github.io/src/articles/04-40-years-later-we-still-cant-be-
friends.rst
Processing /root/gradha.github.io/src/articles/05-worse-than-global-variables.rst
Processing /root/gradha.github.io/src/articles/06-small-big-mistakes.rst
Processing /root/gradha.github.io/src/articles/07-tyranny-of-git-flow-defaults.rst
Processing /root/gradha.github.io/src/articles/08-master-cant-die.rst
Processing /root/gradha.github.io/src/articles/09-invoking-dash-from-vim.rst
Processing /root/gradha.github.io/src/articles/10-nimrod-for-cross-platform-
software.rst
Processing /root/gradha.github.io/src/articles/11-sweet-python-trap.rst
Processing /root/gradha.github.io/src/articles/12-could-dropbox-switch-to-nimrod.rst
Processing /root/gradha.github.io/src/articles/13-unit-testing-installation-instructions.rst
Processing /root/gradha.github.io/src/articles/14-songs-for-the-nsa.rst
Processing /root/gradha.github.io/src/articles/15-dirrty-objects-in-dirrty-nimrod.rst
Processing /root/gradha.github.io/src/articles/16-why-i-will-never-use-an-iwatch.rst
Processing /root/gradha.github.io/src/articles/17-mountain-song.rst
root@as3:~/gradha.github.io/src# ls
articles  ipsum.ini  layouts  manual  output  static  update_static_files.sh
(新出现了output目录)
root@as3:~/gradha.github.io/src# cd output
root@as3:~/gradha.github.io/src/output# ls
about.html  cookie-policy.html  i           tags
articles    feed.xml            index.html  users-prefer-static-linking.html
(可见~/gradha.github.io/src/output/就是静态网站的根目录)
root@as3:~/gradha.github.io/src/output# nohup Rwebserver 32195 > /dev/null &
访问http://as3.brite.biz:32195/即可看到网站效果。

发贴方法:
root@as3:~/gradha.github.io/src/output# cd ..
root@as3:~/gradha.github.io/src# cd articles
root@as3:~/gradha.github.io/src/articles#
root@as3:~/gradha.github.io/src/articles# ls
01-first-post.rst
02-users-prefer-static-linking.rst
03-you-have-to-realise-that-someday-you-will-die.rst
04-40-years-later-we-still-cant-be-friends.rst
05-worse-than-global-variables.rst
06-small-big-mistakes.rst
07-tyranny-of-git-flow-defaults.rst
08-master-cant-die.rst
09-invoking-dash-from-vim.rst
10-nimrod-for-cross-platform-software.rst
11-sweet-python-trap.rst
12-could-dropbox-switch-to-nimrod.rst
13-unit-testing-installation-instructions.rst
14-songs-for-the-nsa.rst
15-dirrty-objects-in-dirrty-nimrod.rst
16-why-i-will-never-use-an-iwatch.rst
root@as3:~/gradha.github.io/src/articles# nano 17-mountain-song.rst
按01-first-post.rst的格式,新建帖子17-mountain-song.rst,格式为:
---
title: 山歌好比春江水
pubdate: 2014-07-28 18:37
moddate: 2014-07-28 18:37
tags: misc
---

.. raw:: html

   <embed 。。。></embed>


然后,
root@as3:~/gradha.github.io/src/articles# cd ..
root@as3:~/gradha.github.io/src# ipsum

演示站点:http://as3.brite.biz:32195/,http://is.briteming.yi.org
http://gradha.github.io/
项目地址:https://github.com/dom96/ipsumgenera
demo site source: https://github.com/gradha/gradha.github.io

如果想分页,At the moment the index page is generated in https://github.com/dom96/ipsumgenera/blob/master/ipsum.nim#L199 looping over the articles and calling renderArticle which writes just the title and some metadata. You need to do something like processArticle, but instead of generating individual files for each article, lumping the HTML three at a time for the default page and adding pagination on overflow.
参见 https://github.com/gradha/gradha.github.io/issues/3