Total Pageviews

Wednesday, 29 January 2014

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

git clone https://github.com/pdonis/simpleblog
cd simpleblog
pip install plib.stdlib
python setup.py install
(安装完毕后,执行文件为simpleblog-run)

as3:~/simpleblog# cd examples
as3:~/simpleblog/examples# ls
bare  reallybare  timezone
(~/simpleblog/examples/下有3个示例用的博客目录结构,我们一个一个进去探究)
as3:~/simpleblog/examples# cd reallybare
as3:~/simpleblog/examples/reallybare# ls
blog.json  config.json  entries  static  templates
as3:~/simpleblog/examples/reallybare# nano blog.json
as3:~/simpleblog/examples/reallybare# cat blog.json
{
    "title": "A Blog",
    "description": "An example blog using simpleblog",
    "author": "ym",
    "email": "me@example.com",
    "charset": "utf8"
}
as3:~/simpleblog/examples/reallybare# simpleblog-run -c config.json -b blog.json render-static
(这个就是生成/更新静态网站的命令)
as3:~/simpleblog/examples/reallybare#
as3:~/simpleblog/examples/reallybare# cd static
as3:~/simpleblog/examples/reallybare/static# ls
example-post.html     index.html      
as3:~/simpleblog/examples/reallybare/static#
可见~/simpleblog/examples/reallybare/static/就是静态网站的根目录。
as3:~/simpleblog/examples/reallybare/static# nohup Rwebserver 45310 > /dev/null &

发贴方法:
as3:~/simpleblog/examples/reallybare/static# cd ../entries
as3:~/simpleblog/examples/reallybare/entries# nano xinli-jiankang.html
格式为:
<h2>心理健康的标准</h2>
这里写正文或html code.
as3:~/simpleblog/examples/reallybare/entries# cd ..
as3:~/simpleblog/examples/reallybare# simpleblog-run -c config.json -b blog.json render-static
(这个就是更新静态网站的命令)

演示站点:http://as3.brite.biz:45310/


as3:~/simpleblog/examples/reallybare# cd ..
as3:~/simpleblog/examples# ls
bare  reallybare  timezone
as3:~/simpleblog/examples# cd bare
as3:~/simpleblog/examples/bare# ls
blog.yaml  config.yaml  entries  static  templates
as3:~/simpleblog/examples/bare# nano blog.yaml

as3:~/simpleblog/examples/bare# cat blog.yaml
# Blog metadata for example blog
# Used by simpleblog

title: "A Blog"
description: "An example blog using simpleblog"
author: "YM"
email: "me@example.com"

charset: "utf8"
as3:~/simpleblog/examples/bare# simpleblog-run -c config.yaml -b blog.yaml render-static
会显示:
Rendering /root/simpleblog/examples/bare/static/index.html
Rendering /root/simpleblog/examples/bare/static/example-post.html
as3:~/simpleblog/examples/bare#
可见/root/simpleblog/examples/bare/static/就是静态网站的根目录。
as3:~/simpleblog/examples/bare# cd static
as3:~/simpleblog/examples/bare/static# nohup Rwebserver 45311 > /dev/null &

发贴方法:
as3:~/simpleblog/examples/bare# cd entries
as3:~/simpleblog/examples/bare/entries# ls
example-post.txt  titles
as3:~/simpleblog/examples/bare/entries# cat example-post.txt
An Example Post
This is an example of a blog post.
as3:~/simpleblog/examples/bare/entries# nano test1.txt
格式为:
测试1
这是测试1.
as3:~/simpleblog/examples/bare/entries# cd ..
as3:~/simpleblog/examples/bare# simpleblog-run -c config.yaml -b blog.yaml render-static
(这个就是生成/更新静态网站的命令)

演示站点:http://as3.brite.biz:45311/,http://sb.brite.biz.st

项目地址:https://github.com/pdonis/simpleblog
https://github.com/pdonis/simpleblog#extensions (看这里,研究如何分页)