用Ruby编写博客应用 Powered by Rabbit 0.9.0
用Ruby
编写博客应用
吴江
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Ruby
1/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
作者
2/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
基础
工具 3/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
irb
ri
rdoc 4/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
演示5/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
基本类型
i = 1 # Integer
b = true # Boolean
f = 1.0/3 # Float
n = nil # Null
str = "a stri...
用Ruby编写博客应用 Powered by Rabbit 0.9.0
面向对象
i.class # => Integer
b.class # => Boolean
f.class # => Float
n.class # => NilClas...
用Ruby编写博客应用 Powered by Rabbit 0.9.0
符号
str1 = "a string"
str2 = "a string"
str1 == str2 # true
str1.object_id == str2.obje...
用Ruby编写博客应用 Powered by Rabbit 0.9.0
数组操作
a = [1, 2, 3]
a << 4 # a = [1, 2, 3, 4]
a[0] # => 1
a[1..3] # => [2, 3, 4]
a[1] =...
用Ruby编写博客应用 Powered by Rabbit 0.9.0
哈希表操作
a = { "a" => 1 }
a["a"] # => 1
a["b"] # => nil
a["b"] = 2 # a = { "a" => 1, "b" ...
用Ruby编写博客应用 Powered by Rabbit 0.9.0
写博客
11/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
服务商
12/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
MSN
Space
挂了 13/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Wordpress
14/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
满大街
都是 15/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
没脸和别
人打招呼
16/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
将要实现
的特点
17/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
不用DB
鼓掌!!!
18/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
没有SQL
注入
19/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
不用担心后
台密码被盗
20/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
文件格式
# 文件名: 2010-10-10-a-lucky-day.txt
title: "A Lucky Day"
date: 10/10/2010
# 今天是我的幸运...
用Ruby编写博客应用 Powered by Rabbit 0.9.0
YAML
22/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
JSON
兼容 23/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Markdown
24/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Markdown
不能传值
25/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Haml
模版 26/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Sinatra
DSL
27/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
演示28/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
安装
Ruby29/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
RVM
30/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
安装
Ruby库
31/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Rubygems:
包管理工具
32/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Bundler
33/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
gem
install
bundler34/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Gemfile
source "http://rubygems.org"
gem 'haml' # HAML模版
gem 'rdiscount' # 渲染Markdown
g...
用Ruby编写博客应用 Powered by Rabbit 0.9.0
bundle
install
36/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Hello, world
get '/' do
"Hello, world!"
end
37/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
get '/'
38/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
列出
所有
日志 39/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
外部shell命令
`ls *.txt`
`find -name "*.txt"`
40/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
使用Dir类
Dir["*.txt"]
Dir["**/*.txt"]
41/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
读取
文件
内容 42/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
File.read
43/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
/:year/:month/:day/:title
列出文章内容
44/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
评论45/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Disqus
46/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
部署47/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Heroku
48/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
Q & A
49/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
本项目地址
http://github.com/nouse/text-blog
50/51
用Ruby编写博客应用 Powered by Rabbit 0.9.0
谢谢!
51/51
Upcoming SlideShare
Loading in …5
×

用Ruby编写博客应用

839 views
756 views

Published on

2010年10月23日shlug聚会上现场演示

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
839
On SlideShare
0
From Embeds
0
Number of Embeds
23
Actions
Shares
0
Downloads
12
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

用Ruby编写博客应用

  1. 1. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 用Ruby 编写博客应用 吴江
  2. 2. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Ruby 1/51
  3. 3. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 作者 2/51
  4. 4. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 基础 工具 3/51
  5. 5. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 irb ri rdoc 4/51
  6. 6. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 演示5/51
  7. 7. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 基本类型 i = 1 # Integer b = true # Boolean f = 1.0/3 # Float n = nil # Null str = "a string" # String sym = :"a string" # Symbol 6/51
  8. 8. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 面向对象 i.class # => Integer b.class # => Boolean f.class # => Float n.class # => NilClass str.class # => String sym.class # => Symbol 7/51
  9. 9. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 符号 str1 = "a string" str2 = "a string" str1 == str2 # true str1.object_id == str2.object_id # false sym1 = :"a string" sym2 = :"a string" sym1 == sym2 # true sym1.object_id == sym2.object_id # true 8/51
  10. 10. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 数组操作 a = [1, 2, 3] a << 4 # a = [1, 2, 3, 4] a[0] # => 1 a[1..3] # => [2, 3, 4] a[1] = "a" # a = [1, "a", 3, 4] a[5] = [1,2] # a = [1, "a", 3, 4, nil, [1,2]] 9/51
  11. 11. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 哈希表操作 a = { "a" => 1 } a["a"] # => 1 a["b"] # => nil a["b"] = 2 # a = { "a" => 1, "b" => 2} 10/51
  12. 12. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 写博客 11/51
  13. 13. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 服务商 12/51
  14. 14. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 MSN Space 挂了 13/51
  15. 15. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Wordpress 14/51
  16. 16. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 满大街 都是 15/51
  17. 17. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 没脸和别 人打招呼 16/51
  18. 18. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 将要实现 的特点 17/51
  19. 19. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 不用DB 鼓掌!!! 18/51
  20. 20. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 没有SQL 注入 19/51
  21. 21. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 不用担心后 台密码被盗 20/51
  22. 22. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 文件格式 # 文件名: 2010-10-10-a-lucky-day.txt title: "A Lucky Day" date: 10/10/2010 # 今天是我的幸运日 早上在地铁门将要关上的那一刻,我冲进了车厢,于是约会没有迟到... 中午提前了一点去港丽,居然只排了42分钟... 晚上又赶上了末班车... 到家数了数,钱包里面正好有42块钱... 21/51
  23. 23. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 YAML 22/51
  24. 24. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 JSON 兼容 23/51
  25. 25. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Markdown 24/51
  26. 26. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Markdown 不能传值 25/51
  27. 27. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Haml 模版 26/51
  28. 28. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Sinatra DSL 27/51
  29. 29. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 演示28/51
  30. 30. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 安装 Ruby29/51
  31. 31. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 RVM 30/51
  32. 32. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 安装 Ruby库 31/51
  33. 33. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Rubygems: 包管理工具 32/51
  34. 34. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Bundler 33/51
  35. 35. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 gem install bundler34/51
  36. 36. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Gemfile source "http://rubygems.org" gem 'haml' # HAML模版 gem 'rdiscount' # 渲染Markdown gem 'sinatra' # Sinatra gem 'thin' # 应用服务器 gem 'shotgun' # 负责重启服务器 35/51
  37. 37. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 bundle install 36/51
  38. 38. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Hello, world get '/' do "Hello, world!" end 37/51
  39. 39. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 get '/' 38/51
  40. 40. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 列出 所有 日志 39/51
  41. 41. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 外部shell命令 `ls *.txt` `find -name "*.txt"` 40/51
  42. 42. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 使用Dir类 Dir["*.txt"] Dir["**/*.txt"] 41/51
  43. 43. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 读取 文件 内容 42/51
  44. 44. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 File.read 43/51
  45. 45. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 /:year/:month/:day/:title 列出文章内容 44/51
  46. 46. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 评论45/51
  47. 47. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Disqus 46/51
  48. 48. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 部署47/51
  49. 49. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Heroku 48/51
  50. 50. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 Q & A 49/51
  51. 51. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 本项目地址 http://github.com/nouse/text-blog 50/51
  52. 52. 用Ruby编写博客应用 Powered by Rabbit 0.9.0 谢谢! 51/51

×