Total Pageviews

Thursday 31 October 2013

在linux vps上搭建基于java和groovy的静态博客程序rizzo

as3:~# wget http://dist.groovy.codehaus.org/distributions/groovy-binary-2.1.9.zip
as3:~# unzip groovy-binary-2.1.9.zip
as3:~# git clone https://github.com/fifthposition/rizzo.git
as3:~# cd rizzo
as3:~/rizzo# ~/groovy-2.1.9/bin/groovy rizzo.groovy -s . -d published
[copy] Copying 1 file to /root/rizzo/published/css
[copy] Copying 1 file to /root/rizzo/published/images
[copy] Copying 1 file to /root/rizzo/published/files
(以上的~/groovy-2.1.9/bin/groovy rizzo.groovy -s . -d published就是生成/更新静态网站的命令。它会在当前目录下,生成published目录)
as3:~/rizzo# ls
css images pages published rizzo.groovy templates
files meta.groovy posts README.md site-config.groovy
as3:~/rizzo# ls pages
about.html markdownness.md
as3:~/rizzo# ls posts
a-markdown-test.md lorem-ipsum.html
lorem-ipsum-again.html our-first-post.html
as3:~/rizzo# ls published
about.html archives.html feed.xml images markdownness.html tags.html
archives css files index.html tags
as3:~/rizzo# cd published
as3:~/rizzo/published#

so ~/rizzo/published/ is the root dir of the static site.可见~/rizzo/published/就是静态网站的根目录。

demo site: http://rz.brite.biz/

发贴方法:
as3:~/rizzo# cd posts
as3:~/rizzo/posts# nano test1.html
格式如下:

测试1 (这是标题)
11-01-2013 11:18 AM (这是时间,mm-dd-yyyy hh:mm am or pm)
11-01-2013 11:18 AM  (需再写一次)
misc (这是标签)


这是测试1

保存更改,然后:
as3:~/rizzo/posts# cd ..
as3:~/rizzo# ~/groovy-2.1.9/bin/groovy rizzo.groovy -s . -d published

as3:~/rizzo# nano site-config.groovy
(编辑配置文件,把各个=号后的值改为自己的值)
as3:~/rizzo# cat site-config.groovy
site {
        domain = "rz.brite.biz"
        base = "" // use if the site should be relative to a top level domain - example: /mypath
        name = "YM'S RIZZO Site"
}

author {
        name = "YM"
        email = "your@email.com"
}
as3:~/rizzo# ~/groovy-2.1.9/bin/groovy rizzo.groovy -s . -d published
as3:~/rizzo#


注意:不要用apt-get install groovy来安装groovy,否则会出错:
as3:~/rizzo# groovy rizzo.groovy -s . -d published
Caught: java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException
at rizzo.class$(rizzo.groovy)
at rizzo.$get$$class$groovy$util$AntBuilder(rizzo.groovy)
at rizzo.run(rizzo.groovy:163)

可见有时apt-get install xxx(yum install xxx)所安装的程序不一定可靠,那就自己下载源码编译。如果官方网站已提供可执行文件,就更好办,直接下载,就可使用了。

项目地址: https://github.com/fifthposition/rizzo
https://github.com/fifthposition/rizzo/wiki
https://github.com/fifthposition/elliotquotes