Pages

Tuesday, 20 December 2016

搭建基于python的静态网站程序igor

cd /usr/local
git clone https://github.com/aconbere/igor igor-site
cd igor-site
python setup.py install
会显示:
...
copying build/scripts-2.7/igor-post-update -> /usr/local/bin
copying build/scripts-2.7/igor -> /usr/local/bin

然后,
pip install pyparsing
pip install jinja2
pip install markdown
pip install py
pip install textile

root@localhost:/usr/local/igor-site# igor init igor-blog (该命令会在当前目录下,生成igor-blog目录)
Initializing new igor project: /usr/local/igor-site/igor-blog
root@localhost:/usr/local/igor-site# cd igor-blog
root@localhost:/usr/local/igor-site/igor-blog# ls
_config.yaml  media  _posts  _templates
root@localhost:/usr/local/igor-site/igor-blog# igor publish . output (该命令会在当前目录下,生成output目录)
root@localhost:/usr/local/igor-site/igor-blog# ls
_config.yaml  media  output  _posts  _templates
root@localhost:/usr/local/igor-site/igor-blog# cd output
root@localhost:/usr/local/igor-site/igor-blog/output# ls
2016  archive  feed.atom  index.html  media  output
root@localhost:/usr/local/igor-site/igor-blog/output# 
(/usr/local/igor-site/igor-blog/output目录里有index.html文件,可见/usr/local/igor-site/igor-blog/output就是静态网站的根目录.不过这个index.html没有实质内容,其内容为:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
        <title></title>
</head>

<body>
    <div id="content">
       
    </div>
</body>

</html>

这样的index.html文件所对应的页面是个空白页面。)

新建源帖:
root@localhost:/usr/local/igor-site/igor-blog/output#  cd ../_posts
root@localhost:/usr/local/igor-site/igor-blog/_posts# ls
welcome.txt
root@localhost:/usr/local/igor-site/igor-blog/_posts# nano test-1.txt
root@localhost:/usr/local/igor-site/igor-blog/_posts# cat test-1.txt
test 1

this is test 1.

(不支持中文标题/内容)
root@localhost:/usr/local/igor-site/igor-blog/_posts# cd ..
root@localhost:/usr/local/igor-site/igor-blog# igor publish . output
root@localhost:/usr/local/igor-site/igor-blog# cd output
root@localhost:/usr/local/igor-site/igor-blog/output# rm index.html
root@localhost:/usr/local/igor-site/igor-blog/output# nano index.html
root@localhost:/usr/local/igor-site/igor-blog/output# cat index.html
<meta http-equiv="refresh" content="3;url=/archive">
root@localhost:/usr/local/igor-site/igor-blog/output#
(意思是删除旧的index.html,建立一个新的index.html)

演示网站:
http://ig.bright.biz.st/
http://ig.bright.biz.st/archive/
项目地址:https://github.com/aconbere/igor

这个网站太简陋了。