Pages

Tuesday, 5 November 2013

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

apt-get install -y libffi-dev python-dev python-pip python-setuptools
pip install socrates
socrates -i socrates-site (在当前目录下,会生成socrates-site目录)
cd socrates-site
socrates -g
(在当前目录下,会生成deploy目录,deploy目录就是静态网站的根目录。所以socrates -g就是生成/更新静态网站的命令)

发贴方法:
as3:~/socrates-site# ls

config.yaml  deploy  layout  pages  posts
as3:~/socrates-site# cd posts
as3:~/socrates-site/posts# ls
2011-02-11-why-nokia-chose-windows-over-android.md


按~/socrates-site/posts/里面的帖子2011-02-11-why-nokia-chose-windows-over-android.md的格式,新建帖子2013-11-05-test1.md,格式如下:
--------------------------------------------------------------------------------
title: test1
(标题不支持中文) 
date: 2013-11-05 16:44:00
categories:
   - misc
--------------------------------------------------------------------------------

this is test1.(可惜内容竟然不支持中文.上述2行小横杆须为整个默认的putty窗口的宽度)


然后:
as3:~/socrates-site/posts# cd ..
as3:~/socrates-site# socrates -g

Themes
Socrates supports Django templates and Jinja2 templates. You can specify which templating engine .

you wish to use in the config.yaml file. There are two basic themes in the themes directory to get you started.you can choose between Django templates and Jinja2 templates. The default theme uses Django.

demo site: http://sr.brite.biz/。
注意:在绑定域名时,如果你的webserver为apache,则需在virtualhost段里插入:
<Directory /root/socrates-site/deploy>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
        </Directory>

我的情形:
<VirtualHost vps-ip:80>
ServerName sr.brite.biz
DocumentRoot /root/socrates-site/deploy
<Directory /root/socrates-site/deploy>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
        </Directory>
</VirtualHost>


项目地址:http://github.com/honza/socrates,http://honza.ca/socrates/