Total Pageviews

Monday 27 January 2014

在linux vps上安装基于python的静态博客程序-swg(这个不错)

git clone https://github.com/evilsocket/SWG swg
cd swg
python setup.py install
(不要用pip install swg的方式安装swg,此方式有问题)

as3:~/swg# swg -h
会显示:
Usage: swg <action>
Options:
  -h, --help      show this help message and exit
  -C, --create    Create a new website basic structure, require a folder name
                  additional parameter.
  -N, --new       Create a new item and open an editor to edit it.
  -G, --generate  Start website generation.
  -S, --serve     Generate website and test it on http://localhost:8080/
as3:~/swg# swg --create swg-site (此命令会在当前目录下生成博客的目录结构:swg-site目录)
as3:~/swg# cd swg-site
as3:~/swg/swg-site# swg --generate
as3:~/swg/swg-site# ls
css  db  images  output-website  robots.txt  swg.cfg  templates
(新出现了output-website目录)
as3:~/swg/swg-site# nano swg.cfg
把siteurl的值改为你的域名地址,我的为http://swg.brite.biz
as3:~/swg/swg-site# cd output-website
as3:~/swg/swg-site/output-website# ls
categories.txt    images             robots.txt
css               index.html         sitemap.xml
feed.xml          instructions.html  tags
hello-world.html  members            worth-a-thousand-words.html
as3:~/swg/swg-site/output-website#
可见~/swg/swg-site/output-website/就是静态网站的根目录。

发贴方法:
as3:~/swg/swg-site/output-website# cd ~/swg/swg-site/db/pages
as3:~/swg/swg-site/db/pages# ls
0.txt  1.txt  2.txt
as3:~/swg/swg-site/db/pages# nano 3.txt
按2.txt的格式,新建帖子3.txt,格式如下:
Date: 2014-01-28 17:34:00
Author: Your Name Here (Author的值不要改)
Categories: Personal, Experience (Categories的值不要改)
Tags: misc1, misc2
Title: 测试1 (标题不能全写中文,可这样做:写完中文后,再接着写英文标题,英文标题写在括弧内,比如中国经济(chinese-economy) 或者先写英文/拼音,再写中文也行,比如fengyuwuzu(风雨无阻) )

这是测试1.
as3:~/swg/swg-site/db/pages# cd ~/swg/swg-site
as3:~/swg/swg-site# swg --generate (这个就是生成/更新静态网站的命令)

演示站点:http://swg.brite.biz/
项目地址:https://github.com/evilsocket/SWG,http://pythonhosted.org/swg/