Total Pageviews

Saturday 19 November 2016

搭建基于haskell的静态博客程序heckle

先按此文http://briteming.blogspot.com/2016/07/haskellghc.html安装cabal.

cd /usr/local
git clone https://github.com/2016rshah/heckle heckle-blog-by-2016rshah
cd heckle-blog-by-2016rshah (因为当前目录下有cabal文件,于是运行cabal sandbox init)
cabal sandbox init
cabal install

等待安装完成后,进入.cabal-sandbox/bin/目录,.cabal-sandbox/bin/目录里有heckle文件,这个heckle文件就是本程序的可执行文件,其完整路径为/usr/local/heckle-blog-by-2016rshah/.cabal-sandbox/bin/heckle ,
另外一个可执行文件为/usr/local/heckle-blog-by-2016rshah/dist/dist-sandbox-9ebc2966/build/heckle/heckle,这2个可执行文件是等效的。

root@AR:/usr/local/heckle-blog-by-2016rshah# ls
example       heckle.cabal  Setup.hs
cabal.sandbox.config  heckle       meta         src
README.md     stack.yaml
root@AR:/usr/local/heckle-blog-by-2016rshah# mkdir heckle-blog
root@AR:/usr/local/heckle-blog-by-2016rshah# cd heckle-blog
root@AR:/usr/local/heckle-blog-by-2016rshah/heckle-blog#  /usr/local/heckle/.cabal-sandbox/bin/heckle init
(此命令会在当前目录下,生成博客目录结构)
root@AR:/usr/local/heckle-blog-by-2016rshah/heckle-blog# ls
index.html  index.html.hkl  posts  template.html.hkl
root@AR:/usr/local/heckle-blog-by-2016rshah/heckle-blog# cd posts
root@AR:/usr/local/heckle-blog-by-2016rshah/heckle-blog/posts# ls
example-markdown.html  example-markdown.md
root@AR:/usr/local/heckle-blog-by-2016rshah/heckle-blog/posts# nano test-1.md
root@AR:/usr/local/heckle-blog-by-2016rshah/heckle-blog/posts# cat test-1.md
% 测试1
% brite fisherman
% 19 November 2016

这是测试1.

看看如何?

root@AR:/usr/local/heckle-blog-by-2016rshah/heckle-blog/posts# cd ..
root@AR:/usr/local/heckle-blog-by-2016rshah/heckle-blog#  /usr/local/heckle-blog-by-2016rshah/.cabal-sandbox/bin/heckle build
(此即生成静态网站的根目录的命令)
root@AR:/usr/local/heckle-blog-by-2016rshah/heckle-blog# ls
index.html  index.html.hkl  posts  template.html.hkl
root@AR:/usr/local/heckle-blog-by-2016rshah/heckle-blog#
(可见此处,/usr/local/heckle/heckle-blog就是静态网站的根目录,不过这个/usr/local/heckle/heckle-blog/所对应的网站很简陋)
root@AR:/usr/local/heckle-blog-by-2016rshah/heckle-blog# cd ..

我们来克隆程序作者的网站:
root@AR:/usr/local/heckle-blog-by-2016rshah# git clone https://github.com/2016rshah/blog 2016rshah-blog
root@AR:/usr/local/heckle-blog-by-2016rshah# cd 2016rshah-blog
root@AR:/usr/local/heckle-blog-by-2016rshah/2016rshah-blog# ls
discarded_posts  index_files  index.html.hkl  README.md  template.html.hkl
fonts         index.html   posts          resources
root@AR:/usr/local/heckle-blog-by-2016rshah/2016rshah-blog# cd posts
root@AR:/usr/local/heckle-blog-by-2016rshah/2016rshah-blog/posts# nano test-1.md
root@AR:/usr/local/heckle-blog-by-2016rshah/2016rshah-blog/posts# cat test-1.md
% 测试1
% brite fisherman
% 19 November 2016

# 测试1

这是测试1.

看看如何?

root@AR:/usr/local/heckle-blog-by-2016rshah/2016rshah-blog/posts# cd ..
root@AR:/usr/local/heckle-blog-by-2016rshah/2016rshah-blog# /usr/local/heckle-blog-by-2016rshah/.cabal-sandbox/bin/heckle build

注:如果你安装了latex,这个博客程序还可生成pdf文件。只要你新建的源帖为tex文件,就可把tex文件转化为pdf文件。
root@AR:/usr/local/heckle-blog-by-2016rshah/2016rshah-blog# cd posts
root@AR:/usr/local/heckle-blog-by-2016rshah/2016rshah-blog/posts# ls
abstraction-progression-blatex.pdf  green-sky.tex
abstraction-progression-blatex.tex  haskell-emacs-workflow.pdf
bcoz-i-love-u.html            haskell-emacs-workflow.tex
bcoz-i-love-u.md            k-nearest-neighbors.pdf
birth-of-heckle.html            k-nearest-neighbors.tex
birth-of-heckle.md            pollen.bib
chinese-economy.html            pollen.pdf
chinese-economy.md            pollen.tex
clearing-up-week-05-of-cis194.pdf   sinatra.pdf
clearing-up-week-05-of-cis194.tex   sinatra.tex
distributive-applicative.pdf        test-1.html
distributive-applicative.tex        test-1.md
dynamic-versus-static-typing.pdf    test-2.html
dynamic-versus-static-typing.tex    test-2.md
elixir_of_life.pdf            tic-hack-toe.pdf
elixir_of_life.tex            tic-hack-toe.tex
feature-extraction.pdf            week-06-of-cis194.pdf
feature-extraction.tex            week-06-of-cis194.tex
generic-java.pdf            what-is-the-web.pdf
generic-java.tex            what-is-the-web.tex
green-sky.pdf
root@AR:/usr/local/heckle-blog-by-2016rshah/2016rshah-blog/posts#

演示网站:http://rsb.bright.biz.st (可惜同一天发表的帖子并非按发表的时间顺序排列)
项目地址: https://github.com/2016rshah/heckle,
(https://hackage.haskell.org/package/heckle)
https://github.com/2016rshah/blog