這是我第一次利用 Pelican 架 blog。感謝老天,只花一個早上就把雛型建置起來了。我主要是參考 Blogging with the IPython Notebook 與 Building this blog 這兩篇文章。簡單來說,Building this blog 這篇文章作者把整個 blog 都放到 GitHub 去了,文內說明僅需要先安裝必備的套件(作者建議搭配 virtualenv 使用,但我是用 pyenv),從 GitHub clone 他的 blog 之後,稍作修改即可使用。 跟 GitHub 結合的最大好處是備份與版本控制,我自己最近作的一個專案就是利用 BitBucket 來幫忙作版本控制,這樣就不用帶著隨身碟跑來跑去了。
Pelican 的最大好處是:他可以跟 IPython notebook 作很好的結合,這點對於作資料分析的人而言非常好用。 現在 IPython notebook 越作越強大了,還可以跟 Google doc 結合。 用 IPython Notebook 作分析報告或教案,然後配合 GitHub 作版本控制、教案分享與展示,這樣實在非常完美。
本篇文章是在 IPython notebook 上面完成的,接下來會作些測試,以確認一些常用的功能是否能正常使用。
In [2]:
font='AR PL KaitiM Big5'
mpl.rcParams['font.sans-serif'] = font
mpl.rc('font', family='sans-serif')
mpl.rc('text', usetex='false')
plt.plot(range(100), np.random.randn(100).cumsum())
plt.title(u'中文測試')
Out[2]:
In [3]:
from markdown import markdown
html_url = 'http://weichengliou.github.io/blog/downloads/data/html/kmt_boss.html'
markdown_str=u"[另開新頁]({0})".format(unicode(html_url))
HTML(markdown(markdown_str) +\
u'<iframe height="600px" width="100%" src={0}></iframe>'.format(html_url))
Out[3]:
基本上可以畫圖、可以顯示中文(但是需要設定字體),可以設定超連結。
大致上可以開始寫文章了!
In [4]:
HTML(html)
Out[4]: