Total Pageviews

Friday, 20 December 2013

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


按https://soho.readthedocs.org/en/latest/tutorial-1-intro.html,
https://soho.readthedocs.org/en/latest/tutorial-2-assets.html#tutorial-2-assets
https://soho.readthedocs.org/en/latest/tutorial-3-metadata.html#tutorial-3-metadata
即可成功搭建。

easy_install Soho[all]
 
as3:~/soho-site# ls
assets  sohoconf.py  src  templates  www
as3:~/soho-site# cd www
as3:~/soho-site/www# ls
3.html  4.html  5.html  css  index.html  second.html  sitemap.xml
as3:~/soho-site/www#
可见~/soho-site/www/就是静态网站的根目录。
发贴方法:
 as3:~/soho-site/www# cd ../src
as3:~/soho-site/src# ls
3.html          4.html.meta.py  index.rst
3.html.meta.py  5.html          second.html
4.html          5.html.meta.py  second.html.meta.py
as3:~/soho-site/src# 

~/soho-site/src/里面新建帖子6.html,格式如下:
<p><a href="index.html">home page</a>
<p><a href="second.html">第二页</a>
<p><a href="3.html">第三页</a>
<p><a href="4.html">第四页</a>
<p><a href="5.html">第五页</a>

<p>这里写正文。
 
然后还要新建一个相应的 6.html.meta.py,内容为:
title = 'The 5th page(括号里可写中文标题)'

然后:
as3:~/soho-site/src# cd ..
as3:~/soho-site# soho-build --force (这是更新静态网站的命令)
as3:~/soho-site/src# cat index.rst
.. meta::
   :title: The home page

This is the **home** page. Look, here is a `link`_ to the second page.

.. _link: second.html

.. raw:: html

   <p><a href="index.html">home page</a>
   <p><a href="second.html">第二页</a>
   <p><a href="3.html">第三页</a>
   <p><a href="4.html">第四页</a>
   <p><a href="5.html">第五页</a>
as3:~/soho-site/src# 
因为首页文件是index.rst,而rst文件的语法有些独特,若想插入html code,比如每页的超链,请
参阅http://briteming.blogspot.co.uk/2013/11/linux-vpspythonhandcrank.html
  
demo site: http://as3.brite.biz:34520/,http://sh.brite.biz
项目地址:https://github.com/dbaty/soho
使用指南:https://soho.readthedocs.org/en/latest/,(看人家鬼佬的使用指南写得多么详细。哪像一些国人写的文档语焉不详。差距就体现在这里!)