Total Pageviews

Friday 18 October 2013

在linux vps上安装基于python的静态博客程序-nikola

wget https://github.com/getnikola/nikola/archive/v6.1.1.zip
mv v6.1.1.zip nikola-6.1.1.zip
unzip  nikola-6.1.1.zip
cd nikola-6.1.1
pip install -r requirements-full.txt
python setup.py install
curl http://python-distribute.org/distribute_setup.py | python
或者cd ~
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
这样easy_install程序就装好了

easy_install docutils)

as3:~/nikola-6.1.1# nikola init nikola-site (此命令会在当前目录下,生成nikola-site目录)
as3:~/nikola-6.1.1# cd nikola-site
as3:~/nikola-6.1.1/nikola-site# ls
conf.py  files  galleries  listings  posts  stories
as3:~/nikola-6.1.1/nikola-site# nano conf.py (编辑一下conf.py文件,把
# INDEX_DISPLAY_POST_COUNT = 10 改为INDEX_DISPLAY_POST_COUNT = 3)
as3:~/nikola-6.1.1/nikola-site# nikola new_post -p (这个是创建新页面的命令。 -p 参数表示是在创建页面而不是帖子)
显示:
Creating New Post
-----------------

Enter title: test1
Scanning posts....done!
[2013-10-18T13:39:23Z] NOTICE: new_post: Your post's text is at: stories/test1.rst
as3:~/nikola-6.1.1/nikola-site# nano stories/test1.rst
as3:~/nikola-6.1.1/nikola-site# nikola build  (这个就是生成/更新静态网站的命令)
as3:~/nikola-6.1.1/nikola-site# ls
cache  conf.py  conf.pyc  files  galleries  listings  output  posts  stories
(新出现了output目录)
as3:~/nikola-6.1.1/nikola-site# ls output
archive.html  categories  index.html  rss.xml      stories
assets        galleries   listings    sitemap.xml
(运行了nikola build命令后,在~/nikola/nikola-site/里会生成output目录,这个
~/nikola/nikola-site/output/就是静态网站的根目录。你可绑定一个域名到该目录.)
as3:~/nikola-6.1.1/nikola-site# nikola new_post(这个是创建新帖子的命令。)
显示:
Creating New Post
-----------------

Enter title: take a look
Scanning posts....done!
[2013-10-18T13:54:08Z] NOTICE: new_post: Your post's text is at: posts/take-a-look.rst
as3:~/nikola-6.1.1/nikola-site# nano posts/take-a-look.rst
as3:~/nikola-6.1.1/nikola-site# nikola build

在编辑帖子时,输入的内容是所见即所得模式,而非html代码模式。因为源贴是rst格式,所以我们在输入html代码时,需这样做:

.. raw:: html
(这里还要空一行)
   <embed ... 

</embed> 
上面的<embed 要往右空3格才写!
比如此帖:http://as3.brite.biz:8866/posts/feng-yu-wu-zu.html

演示站点:http://as3.brite.biz:8866,http://as3.brite.biz:8866/stories/test1.html
http://nkl.brite.biz/
项目地址: https://github.com/getnikola/nikola
https://github.com/getnikola/nikola/tree/v6.1.1  (建议使用v6.1.1版,我用最新的v7.0.1,遇错了)
http://getnikola.com/creating-a-site-not-a-blog-with-nikola.html
http://getnikola.com/handbook.html
http://getnikola.com/handbook.html#restructuredtext-extensions http://getnikola.com/documentation.html
http://getnikola.com/quickstart.html

不过生成的站点的右下角会出现 "+ share" 按钮,它掩盖了Older posts按钮。解决办法:
修改~/nikola-6.1.1/nikola-site/conf.py文件的social buttons部分为:
# Social buttons. This is sample code for AddThis (which was the default for a
# long time). Insert anything you want here, or even make it empty.
SOCIAL_BUTTONS_CODE = """
"""
 
然后运行 :
as3:~/nikola-6.1.1/nikola-site# nikola build 


这样 "+ share" 按钮就被除掉了。

在使用本程序时,如果你遇到 “ImportError: No module named _sqlite3”问题,解决办法请参考http://briteming.blogspot.co.uk/2013/11/importerror-no-module-named-sqlite3.html