Pages

Sunday, 15 June 2014

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

pip install StrangeCase
git clone https://github.com/colinta/StrangeCase StrangeCase-site
cd StrangeCase-site

as3:~/StrangeCase-site# ls
CHANGELOG.md  MANIFEST.in  requirements.txt  strange_case
LICENSE       README.rst   setup.py
as3:~/StrangeCase-site# cd strange_case/tests/paginated_site
as3:~/StrangeCase-site/strange_case/tests/paginated_site# ls
config.yaml  layouts  site
as3:~/StrangeCase-site/strange_case/tests/paginated_site# scase (这个就是生成/更新静态网站的命令)
as3:~/StrangeCase-site/strange_case/tests/paginated_site# ls
config.yaml  layouts  public  site
(新出现了public目录)
as3:~/StrangeCase-site/strange_case/tests/paginated_site# cd public
as3:~/StrangeCase-site/strange_case/tests/paginated_site/public# ls
blogs  index.html
(可见~/StrangeCase-site/strange_case/tests/paginated_site/public/就是静态网站的根目录.你可绑定域名到此目录。我绑定了sc.brite.biz.st)
as3:~/StrangeCase-site/strange_case/tests/paginated_site/public#
访问http://sc.brite.biz.st即可看到网站效果。

发贴方法:
as3:~/StrangeCase-site/strange_case/tests/paginated_site/public# cd ../site
as3:~/StrangeCase-site/strange_case/tests/paginated_site/site# ls
blogs  index.j2
as3:~/StrangeCase-site/strange_case/tests/paginated_site/site# nano index.j2
在最后一行的上一行加上:
<p>pls visit <a href=/blogs/>my blog</a></p>
as3:~/StrangeCase-site/strange_case/tests/paginated_site/site# cd blogs
as3:~/StrangeCase-site/strange_case/tests/paginated_site/site/blogs# ls
2012_01_01_post1.j2  2012_01_03_post3.j2  2012_01_05_post5.j2 
2012_01_02_post2.j2  2012_01_04_post4.j2  index.j2
as3:~/StrangeCase-site/strange_case/tests/paginated_site/site/blogs# nano 2014_06_15_0810_test1.j2
按2012_01_01_post1.j2的格式,新建帖子2014_06_15_0810_test1.j2,格式为:
{% extends "layouts/base.j2" %}
{% block content %}{% markdown %}
## 测试1

<p>这是测试1.</p>
{% endmarkdown %}{% endblock %}


然后,
as3:~/StrangeCase-site/strange_case/tests/paginated_site/site/blogs# cd ../..
as3:~/StrangeCase-site/strange_case/tests/paginated_site# scase (这个就是生成/更新静
态网站的命令)

演示站点:http://sc.brite.biz.st,
项目地址:https://github.com/colinta/StrangeCase
https://pypi.python.org/pypi/StrangeCase/4.6.5

这个程序很奇怪,所发表的最新帖子不是在网站的首页而是在最后一页