Total Pageviews

Saturday 23 November 2013

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

先按此文http://briteming.blogspot.com/2013/11/linux-vpspython333python333-letterpress.html的蓝色字部分,编译python3.5.2环境。

git clone https://github.com/jreese/nib
cd nib
pip3.5 install -r requirements.txt
python3.5 setup.py install
(会显示:Installing nib script to /usr/local/python-3.5.2/bin)
ln -s /usr/local/python-3.5.2/bin/nib /usr/bin/nib

as3:~/nib# ls
bin    LICENSE      nib           README.md         setup.py
build  makefile     Nib.egg-info  requirements.txt
dist   MANIFEST.in  README        sample
as3:~/nib# cd sample
as3:~/nib/sample# ls
documents  resources  templates
as3:~/nib/sample# nib config (该命令将在当前目录下,生成config.nib文件)
as3:~/nib/sample# ls
config.nib documents  resources  templates
as3:~/nib/sample# npm install -g less
as3:~/nib/sample# nib -c config.nib build (这就是生成/更新静态网站的命令)
as3:~/nib/sample# ls
config.nib  documents  resources  site  templates (新出现了site目录)
as3:~/nib/sample# ls site
2012        archive.html  feed.xml    links     posts       tags
about.html  favicon.ico   index.html  main.css  robots.txt
as3:~/nib/sample#
可见~/nib/sample/site/就是静态网站的根目录。

发贴方法:
as3:~/nib/sample# cd documents/posts/
as3:~/nib/sample/documents/posts#
按~/nib/sample/documents/posts/里的first.md的格式,新建帖子test-1.md,格式如下:
title: 测试1
description: xx
date: 2013-11-23
tags: misc
author: brite
---
这是测试1.

然后:
as3:~/nib/sample/documents/posts# cd ~/nib/sample/
as3:~/nib/sample# nib -c config.nib build

修改 ~/nib/sample/里的nib.config文件,修改其中的uri的值为http://nib.brite.biz

演示站点:http://nib.brite.biz/,网站里的链接还需设置一下。
http://nib.bright.biz.st/
 http://nib.brite.biz/posts/test-1.html
 http://nib.brite.biz/posts/test2.html
http://nib.brite.biz/posts/fengyuwuzu.html
项目地址:https://github.com/jreese/nib

帖子的标题,内容都为乱码。需设置浏览器的编码为unicode(utf-8),然后中文帖子才能正常显示。