简洁的想法

仁爱、喜乐、和平、忍耐、恩慈、良善、信实、温柔、节制

First Blog Using Octopress

| Comments

Octopress 真是太棒了, 可以用vi来写blog, 用git来管理, 相当省心.

  • 首先下载一分代码
1
git clone git://github.com/imathis/octopress.git blog
  • 我为octopress生成一个gems包, 进入目录的同时, 运行rvm use命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
vi neten/.rvmrc
# rvm use 1.9.2
rvm use ruby-1.9.2-p290@octopress

$ cd blog
====================================================================================
= NOTICE                                                                           =
====================================================================================
= RVM has encountered a new or modified .rvmrc file in the current directory       =
= This is a shell script and therefore may contain any shell commands.             =
=                                                                                  =
= Examine the contents of this file carefully to be sure the contents are          =
= safe before trusting it! ( Choose v[iew] below to view the contents )            =
====================================================================================
Do you wish to trust this .rvmrc file? (/home/peng/Projects/RubySites/blog/.rvmrc)
y[es], n[o], v[iew], c[ancel]> y

$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
  • 安装缺少的包
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
$ gem install bundler
Successfully installed bundler-1.1.3
1 gem installed
Installing ri documentation for bundler-1.1.3...
Installing RDoc documentation for bundler-1.1.3...

$ bundle install
Using rake (0.9.2)
Using RedCloth (4.2.8)
Using posix-spawn (0.3.6)
Using albino (1.3.3)
Using blankslate (2.1.2.4)
Using chunky_png (1.2.1)
Using fast-stemmer (1.0.0)
Using classifier (1.3.3)
Using fssm (0.2.7)
Using sass (3.1.5)
Using compass (0.11.5)
Using directory_watcher (1.4.0)
Using ffi (1.0.9)
Using haml (3.1.2)
Using kramdown (0.13.3)
Using liquid (2.2.2)
Using syntax (1.0.0)
Using maruku (0.6.0)
Using jekyll (0.11.0)
Using rubypython (0.5.1)
Using pygments.rb (0.1.3)
Using rack (1.3.2)
Using rb-fsevent (0.4.3.1)
Using rdiscount (1.6.8)
Using rubypants (0.2.0)
Using tilt (1.3.2)
Using sinatra (1.2.6)
Using stringex (1.3.0)
Using bundler (1.1.3)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
  • Install the default Octopress theme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ rake install
** Copying classic theme into ./source and ./sass

$ rake preview
Starting to watch source with Jekyll and Compass. Starting Rack on port 4000
directory source/stylesheets/
   create source/stylesheets/screen.css
Configuration from /home/neten/Projects/RubySites/blog/_config.yml
[2012-05-14 22:10:42] INFO  WEBrick 1.3.1
[2012-05-14 22:10:42] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
[2012-05-14 22:10:42] INFO  WEBrick::HTTPServer#start: pid=4578 port=4000
>>> Change detected to: screen.scss
Auto-regenerating enabled: source -> public
[2012-05-14 22:10:43] regeneration: 94 files changed
127.0.0.1 - - [14/May/2012 22:10:43] "GET / HTTP/1.1" 200 3040 0.0165
127.0.0.1 - - [14/May/2012 22:10:43] "GET /stylesheets/screen.css HTTP/1.1" 200 44900 0.0030
127.0.0.1 - - [14/May/2012 22:10:43] "GET /javascripts/octopress.js HTTP/1.1" 200 8829 0.0018
127.0.0.1 - - [14/May/2012 22:10:43] "GET /javascripts/ender.js HTTP/1.1" 200 30652 0.0091
127.0.0.1 - - [14/May/2012 22:10:43] "GET /javascripts/modernizr-2.0.js HTTP/1.1" 200 9946 0.0131
identical public/stylesheets/screen.css
FSSM -> An optimized backend is available for this platform!
FSSM ->     gem install rb-inotify
>>> Compass is polling for changes. Press Ctrl-C to Stop.

好了, blog能访问了: http://localhost:4000

  • 下一步, 就是配置blog了
1
2
3
4
5
6
7
8
9
10
11
$ vi _config.yml
...
url: http://neten.heroku.com
title: 简洁的想法
subtitle: 仁爱、喜乐、和平、忍耐、恩慈、良善、信实、温柔、节制 。
author: Peter
...
permalink: /posts/:year/:month-:day/:title/
...
category_dir: posts/categories
...
  • 写篇文章看看
1
2
3
4
$ rake new_post["first blog using octopress"]
Creating new post: source/_posts/2012-05-14-first-blog-using-octopress.markdown

$ vi source/_posts/2012-05-14-first-blog-using-octopress.markdown

写完之后:

1
2
3
4
5
6
$ rake generate
** Generating Site with Jekyll
unchanged sass/screen.scss
Configuration from /home/neten/Projects/RubySites/blog/_config.yml
Building site: source -> public
Successfully generated site: source -> public
  • Using Octopress With Heroku
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
$ gem install heroku
Fetching: netrc-0.7.1.gem (100%)
Fetching: mime-types-1.18.gem (100%)
Fetching: rest-client-1.6.7.gem (100%)
Fetching: addressable-2.2.8.gem (100%)
Fetching: launchy-2.1.0.gem (100%)
Fetching: rubyzip-0.9.8.gem (100%)
Fetching: heroku-2.25.0.gem (100%)
Successfully installed netrc-0.7.1
Successfully installed mime-types-1.18
Successfully installed rest-client-1.6.7
Successfully installed addressable-2.2.8
Successfully installed launchy-2.1.0
Successfully installed rubyzip-0.9.8
Successfully installed heroku-2.25.0
7 gems installed
Installing ri documentation for netrc-0.7.1...
Installing ri documentation for mime-types-1.18...
Installing ri documentation for rest-client-1.6.7...
Installing ri documentation for addressable-2.2.8...
Installing ri documentation for launchy-2.1.0...
Installing ri documentation for rubyzip-0.9.8...
Installing ri documentation for heroku-2.25.0...
Installing RDoc documentation for netrc-0.7.1...
Installing RDoc documentation for mime-types-1.18...
Installing RDoc documentation for rest-client-1.6.7...
Installing RDoc documentation for addressable-2.2.8...
Installing RDoc documentation for launchy-2.1.0...
Installing RDoc documentation for rubyzip-0.9.8...
Installing RDoc documentation for heroku-2.25.0...

这一步会把 ~/.ssh/id_rsa.pub 上传到heroku服务器, 因为我原来已经上传了, 所以没有输出相关信息.

1
2
3
4
$ heroku create neten
Creating neten... done, stack is bamboo-mri-1.9.2
http://neten.heroku.com/ | git@heroku.com:neten.git
Git remote heroku added

在运行git之前, 不要忘记这一步:

1
$ vi .gitignore

然后把public给删除了, 因为heroku不会让运行代码你生成html文件

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
$ git config branch.master.remote neten
$ git add .
$ git commit -m "first blog"
[master 7bfcebf] first blog
 184 files changed, 7354 insertions(+), 10 deletions(-)
...

$ git push heroku master
Counting objects: 3977, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1385/1385), done.
Writing objects: 100% (3977/3977), 921.28 KiB | 2 KiB/s, done.
Total 3977 (delta 2277), reused 3935 (delta 2268)

-----> Heroku receiving push
-----> Ruby/Sinatra app detected
-----> Gemfile detected, running Bundler version 1.0.7
       Unresolved dependencies detected; Installing...
       Using --without development:test
       Fetching source index for http://rubygems.org/
       Installing rack (1.3.2)
       Installing tilt (1.3.2)
       Installing sinatra (1.2.6)
       Using bundler (1.0.7)
       Your bundle is complete! It was installed into ./.bundle/gems/
-----> Compiled slug size is 624K
-----> Launching... done, v3
       http://neten.heroku.com deployed to Heroku

To git@heroku.com:neten.git
 * [new branch]      master -> master

Comments