SlideShare une entreprise Scribd logo
1  sur  52
Télécharger pour lire hors ligne
用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 string" # String
sym = :"a string" # Symbol
6/51
用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
用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
用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
用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
用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
# 今天是我的幸运日
早上在地铁门将要关上的那一刻,我冲进了车厢,于是约会没有迟到...
中午提前了一点去港丽,居然只排了42分钟...
晚上又赶上了末班车...
到家数了数,钱包里面正好有42块钱...
21/51
用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
gem 'sinatra' # Sinatra
gem 'thin' # 应用服务器
gem 'shotgun' # 负责重启服务器
35/51
用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

Contenu connexe

Similaire à 用Ruby编写博客应用

IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the RubyistWill Green
 
Make your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On RailsMake your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On RailsNataly Tkachuk
 
IronRuby for the .NET Developer
IronRuby for the .NET DeveloperIronRuby for the .NET Developer
IronRuby for the .NET DeveloperCory Foy
 
Top 15 Ruby on Rails (RoR) Gems by Code Garage Tech
Top 15 Ruby on Rails (RoR) Gems by Code Garage TechTop 15 Ruby on Rails (RoR) Gems by Code Garage Tech
Top 15 Ruby on Rails (RoR) Gems by Code Garage TechCode Garage Tech
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overviewThomas Asikis
 
Merb presentation at ORUG
Merb presentation at ORUGMerb presentation at ORUG
Merb presentation at ORUGMatt Aimonetti
 
Ruby'izing iOS development
Ruby'izing iOS developmentRuby'izing iOS development
Ruby'izing iOS developmenttoamitkumar
 
IronRuby: Ruby on the .NET Platform
IronRuby: Ruby on the .NET PlatformIronRuby: Ruby on the .NET Platform
IronRuby: Ruby on the .NET PlatformAndre John Cruz
 
Crate - ruby based standalone executables
Crate - ruby based standalone executablesCrate - ruby based standalone executables
Crate - ruby based standalone executablesJeremy Hinegardner
 
Run Fast, Try Not to Break S**t
Run Fast, Try Not to Break S**tRun Fast, Try Not to Break S**t
Run Fast, Try Not to Break S**tMichael Schmidt
 
Approaching unknown unknowns: CMF for the masses
Approaching unknown unknowns: CMF for the massesApproaching unknown unknowns: CMF for the masses
Approaching unknown unknowns: CMF for the massesAlessandro Nadalin
 
RubyMotion Introduction
RubyMotion IntroductionRubyMotion Introduction
RubyMotion IntroductionLori Olson
 
Introducing Elixir the easy way
Introducing Elixir the easy wayIntroducing Elixir the easy way
Introducing Elixir the easy wayTobias Pfeiffer
 
Loading... Ruby on Rails 3
Loading... Ruby on Rails 3Loading... Ruby on Rails 3
Loading... Ruby on Rails 3Rafael García
 
RubyMotion: Hack Your iOS App Like Never Before
RubyMotion: Hack Your iOS App Like Never BeforeRubyMotion: Hack Your iOS App Like Never Before
RubyMotion: Hack Your iOS App Like Never BeforeJoseph Ku
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overviewjonkinney
 

Similaire à 用Ruby编写博客应用 (20)

IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the Rubyist
 
Make your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On RailsMake your app idea a reality with Ruby On Rails
Make your app idea a reality with Ruby On Rails
 
ruby pentest
ruby pentestruby pentest
ruby pentest
 
Web application intro
Web application introWeb application intro
Web application intro
 
Hanami
HanamiHanami
Hanami
 
IronRuby for the .NET Developer
IronRuby for the .NET DeveloperIronRuby for the .NET Developer
IronRuby for the .NET Developer
 
Top 15 Ruby on Rails (RoR) Gems by Code Garage Tech
Top 15 Ruby on Rails (RoR) Gems by Code Garage TechTop 15 Ruby on Rails (RoR) Gems by Code Garage Tech
Top 15 Ruby on Rails (RoR) Gems by Code Garage Tech
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
 
Merb presentation at ORUG
Merb presentation at ORUGMerb presentation at ORUG
Merb presentation at ORUG
 
Ruby'izing iOS development
Ruby'izing iOS developmentRuby'izing iOS development
Ruby'izing iOS development
 
IronRuby: Ruby on the .NET Platform
IronRuby: Ruby on the .NET PlatformIronRuby: Ruby on the .NET Platform
IronRuby: Ruby on the .NET Platform
 
Crate - ruby based standalone executables
Crate - ruby based standalone executablesCrate - ruby based standalone executables
Crate - ruby based standalone executables
 
Run Fast, Try Not to Break S**t
Run Fast, Try Not to Break S**tRun Fast, Try Not to Break S**t
Run Fast, Try Not to Break S**t
 
Approaching unknown unknowns: CMF for the masses
Approaching unknown unknowns: CMF for the massesApproaching unknown unknowns: CMF for the masses
Approaching unknown unknowns: CMF for the masses
 
RubyMotion Introduction
RubyMotion IntroductionRubyMotion Introduction
RubyMotion Introduction
 
Introducing Elixir the easy way
Introducing Elixir the easy wayIntroducing Elixir the easy way
Introducing Elixir the easy way
 
Loading... Ruby on Rails 3
Loading... Ruby on Rails 3Loading... Ruby on Rails 3
Loading... Ruby on Rails 3
 
RubyMotion: Hack Your iOS App Like Never Before
RubyMotion: Hack Your iOS App Like Never BeforeRubyMotion: Hack Your iOS App Like Never Before
RubyMotion: Hack Your iOS App Like Never Before
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overview
 
Ruby - The Hard Bits
Ruby - The Hard BitsRuby - The Hard Bits
Ruby - The Hard Bits
 

Plus de Jiang Wu

Python speed up with numba
Python speed up with numbaPython speed up with numba
Python speed up with numbaJiang Wu
 
Implement Web API with Swagger
Implement Web API with SwaggerImplement Web API with Swagger
Implement Web API with SwaggerJiang Wu
 
API documentation with Swagger UI(LT)
API documentation with Swagger UI(LT)API documentation with Swagger UI(LT)
API documentation with Swagger UI(LT)Jiang Wu
 
Sinatra and friends
Sinatra and friendsSinatra and friends
Sinatra and friendsJiang Wu
 
Rubyconf China
Rubyconf ChinaRubyconf China
Rubyconf ChinaJiang Wu
 
Ruby off Rails---rack, sinatra and sequel
Ruby off Rails---rack, sinatra and sequelRuby off Rails---rack, sinatra and sequel
Ruby off Rails---rack, sinatra and sequelJiang Wu
 

Plus de Jiang Wu (7)

Python speed up with numba
Python speed up with numbaPython speed up with numba
Python speed up with numba
 
Implement Web API with Swagger
Implement Web API with SwaggerImplement Web API with Swagger
Implement Web API with Swagger
 
API documentation with Swagger UI(LT)
API documentation with Swagger UI(LT)API documentation with Swagger UI(LT)
API documentation with Swagger UI(LT)
 
Sinatra and friends
Sinatra and friendsSinatra and friends
Sinatra and friends
 
Rubyconf China
Rubyconf ChinaRubyconf China
Rubyconf China
 
JS2
JS2JS2
JS2
 
Ruby off Rails---rack, sinatra and sequel
Ruby off Rails---rack, sinatra and sequelRuby off Rails---rack, sinatra and sequel
Ruby off Rails---rack, sinatra and sequel
 

Dernier

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Dernier (20)

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

用Ruby编写博客应用