Total Pageviews

Wednesday 18 June 2014

在linux vps上搭建基于lua和moonscript的静态网站程序-sitegen

luarocks install moonscript
或者运行luarocks build http://moonscript.org/rocks/moonscript-dev-1.rockspec 安装moonscript最新的开发版。
luarocks install luasec

luarocks build https://raw.github.com/leafo/sitegen/master/sitegen-dev-1.rockspec
(这样,就装好了sitegen)

git clone https://github.com/leafo/leafo.net leafo.net-site
cd leafo.net-site

root@as3:~/leafo.net-site# ls
index.html  posts.coffee  README.md  style.scss  www
posts       posts.html    site.moon  templates
root@as3:~/leafo.net-site#
root@as3:~/leafo.net-site# ls www
img  layout.html  style
root@as3:~/leafo.net-site# sitegen (这个就是生成/更新静态网站的命令)
Using:  site.moon
rendered        index.html      ->      www/index.html
rendered        posts.html      ->      www/posts/index.html
rendered        posts/test1.md  ->      www/posts/test1.html
rendered        posts/moonscript_overview.md    ->      www/posts/moonscript_overview.html
rendered        posts/ideas.md  ->      www/posts/ideas.html
rendered        posts/moonscript_v024.md        ->      www/posts/moonscript_v024.html
rendered        posts/lua_on_heroku.md  ->      www/posts/lua_on_heroku.html
rendered        posts/introducing_itchio.md     ->      www/posts/introducing_itchio.html
rendered        posts/moonscript_v020.md        ->      www/posts/moonscript_v020.html
rendered        posts/creating_an_image_server.md       ->      www/posts/creating_an_image_server.html
rendered        posts/moonscript_v023.md        ->      www/posts/moonscript_v023.html
rendered        posts/using_dmenu_to_open_quickly.md    ->      www/posts/using_dmenu_to_open_quickly.html
rendered        posts/getting_started_with_moonscript.md        ->      www/posts/getting_started_with_moonscript.html
rendered        posts/moonscript_v022.md        ->      www/posts/moonscript_v022.html
rendered        README.md       ->      www/README.html
built           coffee (coffee -c -s < posts.coffee > www/posts.js) (0.263s)
sh: pscss: command not found
built           pscss (pscss < style.scss > www/style/style.css) (0.007s)
feeds:          0
blog posts:     8
*       Nginx image processing server with OpenResty and Lua    Fri Sep 20 2013 09:40:00
*       MoonScript v0.2.4       Mon Jul 01 2013 08:38:38
*       Introducing itch.io     Sun Mar 03 2013 20:25:05
*       MoonScript v0.2.3       Thu Jan 24 2013 17:43:27
*       MoonScript v0.2.2       Sun Nov 04 2012 13:11:49
*       Getting started with MoonScript Sun Feb 19 2012 21:06:27
*       Running Lua on Heroku   Sun Feb 05 2012 10:48:29
*       MoonScript v0.2.0       Sun Dec 11 2011 18:22:02
root@as3:~/leafo.net-site# cd www
root@as3:~/leafo.net-site/www# ls
feed.xml  img  index.html  layout.html  posts  posts.js  README.html  style
(可见~/leafo.net-site/www/就是静态网站的根目录)
root@as3:~/leafo.net-site/www# nohup Rwebserver 39847 > /dev/null &
访问http://as3.brite.biz:39847/即可看到网站效果。

发贴方法:
root@as3:~/leafo.net-site/www# cd ..
root@as3:~/leafo.net-site#
root@as3:~/leafo.net-site# ls
index.html  posts.coffee  README.md  style.scss  www
posts       posts.html    site.moon  templates
root@as3:~/leafo.net-site# sitegen page "test2" (这个就是新建源贴的命令)
Using:  site.moon
->      wrote   test2.md (在当前目录下,会生成test2.md)
root@as3:~/leafo.net-site# ls
index.html  posts.coffee  README.md  style.scss  test2.md
posts       posts.html    site.moon  templates    www
root@as3:~/leafo.net-site# mv test2.md posts
root@as3:~/leafo.net-site# nano posts/test2.md
root@as3:~/leafo.net-site# cat posts/test2.md
    date: Thu Jun 19 2014 04:01:34
    title: test2
--

这是测试2.
root@as3:~/leafo.net-site# sitegen (这个就是生成/更新静态网站的命令)
不过所发表的帖子并不自动出现在首页,可这样做:
root@as3:~/leafo.net-site# nano index.html

<a name="Posts"></a>
<h2>Posts</h2>
<div class="inner">
  <ul>
的下一行加上:
    <li>
      <code>06/18/2014</code>
      <a href="$root/posts/test2.html">测试2</a>
    </li>

(注意此index.html是源index.html,并非静态网站的根目录里的index.html )

然后,
root@as3:~/leafo.net-site# sitegen

演示站点:http://as3.brite.biz:39847/,http://sg.brite.biz.st
项目地址:https://github.com/leafo/sitegen
https://github.com/leafo/leafo.net