Pages

Thursday, 19 January 2017

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

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

cd /usr/local
git clone https://github.com/jaspervdj/jaspervdj  jaspervdj-site
cd jaspervdj-site

root@AR:/usr/local/jaspervdj-site# ls
404.html    dist        index.html         src
LICENSE  drafts        jaspervdj.cabal 
README.markdown  contact.markdown      favicon.ico  photos         templates
Setup.hs     css               files        photos.markdown  tmp
cv.markdown           images        posts
root@AR:/usr/local/jaspervdj-site#  cabal sandbox init
root@AR:/usr/local/jaspervdj-site#  cabal install
root@AR:/usr/local/jaspervdj-site#
root@AR:/usr/local/jaspervdj-site# ls .cabal-sandbox/bin/
aeson-pretty  jaspervdj  pandoc          warp
hakyll-init   json2yaml  pandoc-citeproc  yaml2json
root@AR:/usr/local/jaspervdj-site# .cabal-sandbox/bin/jaspervdj build (这个就是生成/更新静态网站的根目录的命令。这步可能遇错:
[ERROR] dot: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory),解决办法:apt-get install graphviz -y)
root@AR:/usr/local/jaspervdj-site# ls
404.html     _site               dist        index.html         src
LICENSE         cabal.sandbox.config  drafts        jaspervdj.cabal  stack.yaml
README.markdown  contact.markdown      favicon.ico  photos         templates
Setup.hs     css               files        photos.markdown  tmp
_cache         cv.markdown           images        posts
root@AR:/usr/local/jaspervdj-site# cd _site
root@AR:/usr/local/jaspervdj-site/_site# ls
404.html      cv.html       images      photos.html  rss.xml    tmp
contact.html  favicon.ico  index.html  posts        style.css
css          files       photos      posts.html   tags
root@AR:/usr/local/jaspervdj-site/_site#
(可见/usr/local/jaspervdj-site/_site就是静态网站的根目录)

 新建源帖:
root@AR:/usr/local/jaspervdj-site/_site# cd ../posts
root@AR:/usr/local/jaspervdj-site/posts# nano 2017-01-19-test-1.markdown
root@AR:/usr/local/jaspervdj-site/posts# cat 2017-01-19-test-1.markdown
---
title: 测试1
description: 这是测试。。。
tags: misc1, misc2, misc3
---

这是测试1.

看看如何?

root@AR:/usr/local/jaspervdj-site/posts# cd ..
root@AR:/usr/local/jaspervdj-site# .cabal-sandbox/bin/jaspervdj build
root@AR:/usr/local/jaspervdj-site# cp -rf css _site/ (如果不把css目录复制到_site目录里面,则最终建成的网站会变形或者“一片惨白”)

演示网站:http://jvdj.bright.biz.st/, https://jaspervdj.be/(程序作者搭建的网站。这个程序作者就是大名鼎鼎的hakyll- https://jaspervdj.be/hakyll/的作者)
项目地址:https://github.com/jaspervdj/jaspervdj
https://github.com/jaspervdj/jaspervdj/issues/15

注:上面生成程序的可执行文件是用cabal install法实现的。因为存在.cabal文件,我们也可运行stack init ,生成stack.yaml文件,从而运行stack build来生成程序的可执行文件
root@AR:/usr/local/jaspervdj-site# stack init
root@AR:/usr/local/jaspervdj-site# stack build
会显示:
...
Linking .stack-work/dist/i386-linux/Cabal-1.24.0.0/build/jaspervdj/jaspervdj ...
jaspervdj-0.1.0.0: copy/register
Installing executable(s) in
/usr/local/jaspervdj-site/.stack-work/install/i386-linux/nightly-2017-01-17/8.0.1/bin
Completed 137 action(s).
root@AR:/usr/local/jaspervdj-site# .stack-work/dist/i386-linux/Cabal-1.24.0.0/build/jaspervdj/jaspervdj build (这个也是生成/更新静态网站的根目录的命令)

No comments:

Post a Comment