Pages

Friday, 16 December 2016

搭建基于haskell的静态博客程序ian-ross-blog(这个不错,可分页)

首先按此文http://briteming.blogspot.jp/2016/07/hakyll.html安装stack,ghc.

cd /usr/local
git clone https://github.com/ian-ross/old-blog ian-ross-blog
cd ian-ross-blog

root@AR:/usr/local/ian-ross-blog# ls
build css js     README.markdown templates
images posts  scripts static

root@AR:/usr/local/ian-ross-blog# cd build
root@AR:/usr/local/ian-ross-blog/build# ls
blog.cabal  blog.hs  LICENSE  Setup.hs stack.yaml  TikZ.hs
root@AR:/usr/local/ian-ross-blog/build# stack build
(如果你系统里的git的版本太低,比如在1.8.2以下,就会遇错:
Downloaded nightly-2016-12-10 build plan.
Shallow package index repo detected, transitioning to a full clone... Updating package index Hackage (mirrored at https://github.com/commercialhaskell/all-cabal-hashes.git) ...Running /usr/bin/git fetch --unshallow in directory /root/.stack/indices/Hackage/git-update/all-cabal-hashes/ exited with ExitFailure 129
error: unknown option `unshallow'
解决的办法:
apt-get remove git -y,然后按此文http://briteming.blogspot.jp/2016/12/git.html编译安装最新版的Git,然后再次运行stack build,就不会遇错了
会显示:
Linking .stack-work/dist/i386-linux/Cabal-1.24.0.0/build/blog/blog ...
blog-0.1.0.0: copy/register
Installing executable(s) in
/usr/local/ian-ross-blog/build/.stack-work/install/i386-linux/nightly-2016-12-10/8.0.1/bin
Completed 141 action(s).
root@AR:/usr/local/ian-ross-blog/build#
(可知,/usr/local/ian-ross-blog/build/.stack-work/dist/i386-linux/Cabal-1.24.0.0/build/blog/blog就是可执行文件)
root@AR:/usr/local/ian-ross-blog/build# cd ..
root@AR:/usr/local/ian-ross-blog# build/.stack-work/dist/i386-linux/Cabal-1.24.0.0/build/blog/blog rebuild (此即生成/更新静态网站的根目录的命令)
root@AR:/usr/local/ian-ross-blog# ls
build css js     README.markdown _site templates
_cache images posts  scripts static
(生成了_site目录)
root@AR:/usr/local/ian-ross-blog# cd _site
root@AR:/usr/local/ian-ross-blog/_site# ls
blog       haskell-rss.xml
css       images
data-visualisation.html       index.html
dv       js
favicon.ico       misc-images
favicon.png       programming-bio.html
files       rss.xml
gui-programming.html       thesis
haskell-data-analysis-ao1-index.html  web-apps.html
haskell-fft-index.html
root@AR:/usr/local/ian-ross-blog/_site#
(可见/usr/local/ian-ross-blog/_site就是静态网站的根目录)

新建源帖:
root@AR:/usr/local/ian-ross-blog/_site# cd ../posts
root@AR:/usr/local/ian-ross-blog/posts# ls
2011  2012  2013  2014 2015  
root@AR:/usr/local/ian-ross-blog/posts# mkdir -p 2016/12/16
root@AR:/usr/local/ian-ross-blog/posts# cd 2016/12/16
root@AR:/usr/local/ian-ross-blog/posts/2016/12/16# nano test-1.markdown
root@AR:/usr/local/ian-ross-blog/posts/2016/12/16# cat test-1.markdown
---
author: brite fisherman
title: 测试1
tags: misc1, misc2, misc3
published: 2016-12-16 18:58:00
---

这是测试1.

<!--MORE-->

看看如何呢?
root@AR:/usr/local/ian-ross-blog/posts/2016/12/16# cd /usr/local/ian-ross-blog
root@AR:/usr/local/ian-ross-blog# build/.stack-work/dist/i386-linux/Cabal-1.24.0.0/build/blog/blog rebuild

演示网站:http://irb.bright.biz.st,http://irb.bright.biz.st/blog
项目地址:https://github.com/ian-ross/old-blog/,
https://github.com/ian-ross/old-blog/issues/2
https://github.com/luckypoem/ian-ross-old-blog