Update: 後來我又寫了一個功能比較強大的helper script, 有興趣者可參考這裡
一直都很想用Vim來寫Blog, 正巧最近octopress一直被人提到, 評估了一下便換了,
RSS Feed 改到 FeedBurner, 請大家重新訂閱, sorry.
一開始參考 Github Custom Domain With Octopress in Ubuntu Oneiric 11.10 把環境架起來, 不過depoly到github N
次卻發現自己的master branch 都是空的, 後來仔細檢查了一下,發現原來在rake generate pages的步驟就失敗了, 原因是找不到OpenSSL.
最後查了一下google, 根據這篇裝了openssl package, 還有rvm 就正常了
裝ruby openssl之前要先裝header file, Ubuntu User 可以打下列指令安裝
1
| apt-get install libssl-dev
|
1
2
| rvm pkg install openssl
rvm install 1.9.2 -C --with-openssl-dir=$HOME/.rvm/usr,--with-iconv-dir=$HOME/.rvm/usr
|
搬舊文
WordPress轉到octopress可以參考Xdite的文章如何從 Wordpress Migrate 到 Octopress, 但我是手動一個一個搬,
一來是想順便熟悉一下MarkDown的語法, 二來是反正文章不多, 就手動搬, 順便重讀一下以前寫的東西。(有時效性、沒啥內容的的文章就沒搬了)
helper script
octopress要打太多指令了.. 所以還是寫個script集中起來…
用法如下:
blog post {文章title}
其他動作請直接參考原始碼
(blog.sh) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| #!/bin/bash
# Author: Hsin-Yi Chen <ossug.hychen AT gmail.com>
ERRMSG_WRONGDIR='You are not under octopress directory'
[ ! -f _config.yml ] && echo ${ERRMSG_WRONGDIR} && exit
BLOGDIR=${PWD}
deploy(){
git checkout source
git push origin source
rake generate
rake deploy
}
update_octopress(){
echo 'upgrading octopress source'
git pull octopress master # Get the latest Octopress
bundle install # Keep gems updated
rake update_source # update the template's source
rake update_style # update the template's style
}
preview(){
rake preview &
sleep 1
sensible-browser 127.0.0.1:4000
}
upgrade(){
update_octopress
deploy
}
# start to write new post
# @param: post title
post(){
local title=${1?"requires title"}
_new_item post ${title}
}
# start to write new page
# @param: page title
page(){
_new_item page $1
}
_new_item(){
local tmpfile=`mktemp`
local item_name=${1?"requires item name"}
local title=${2?"requires title"}
rake new_${item_name}["\"${title}\""] | tee ${tmpfile}
local file=`cat ${tmpfile} | awk -F: '{print $2}' | sed -e 's/ //'`
sensible-editor ${BLOGDIR}/$file
rm ${tmpfile}
# return file name
RET=${file}
}
# Main
# ----
actions="post upgrade preview deploy"
action=${1?"requirs action!, avaliabl actions are ${actions}"}
# run action
shift
${action} $@
|
小結
優點:
- 可以用Vim直接寫文章
- 用git deploy
- 可以把blog免費host在github
- MarkDown很好用
缺點:
- 目錄不支援中文
- blog title不可以有標點符號
- blogging環境變成client side, 所以你要自己維護
- 好宅啊!