SINATRA + HAML + TWITTER
-
Upload
elber-ribeiro -
Category
Technology
-
view
2.056 -
download
3
description
Transcript of SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTERElber Ribeiro @dynaum
BBTI TechTalk #217/09/2010
SINATRAMicro Web Framework
SINATRA
•RACK
•REST
•URL
EXEMPLO
require 'rubygems'require 'sinatra'
get '/hi' do "Hello World!"end
EXEMPLO
$ gem install sinatra$ ruby hello.rb
>> Listen on 0.0.0.0:4567
EXEMPLO
require 'rubygems'require 'sinatra'
get '/hi' do "Hello World!"end
EXEMPLO
require 'rubygems'require 'sinatra'
get '/hi' do "Hello World!"end
EXEMPLO
require 'rubygems'require 'sinatra'
get '/hi' do "Hello World!"end
EXEMPLO
require 'rubygems'require 'sinatra'
get '/hi' do erb :indexend
EXEMPLO
require 'rubygems'require 'sinatra'require 'haml'
get '/hi' do haml :indexend
require 'rubygems'require 'sinatra'require 'haml'
post '/posts' do post = Post.create! params redirect “/posts/#{post.id}”end
get '/posts/:id' do @post = Post.find(params[:id]) haml :postend
URL PADRONIZADA
MAIS• Template ( erb, haml, builder )
• Testes ( rspec, test::unit )
• Before filters
• Helpers
• Error handlers
• Inline templates
• HTTP Caching ( etag, last-modified )
• Rack
NICEDOG
NICEDOG
require 'NiceDog.php';
R('/posts')->controller('post')->action('index')->on('GET');
class Post extends C{ public function index(){ echo 'Hello'; }}
run();
NICEDOG + LASA = LASA_API
• Conexão entra apps ruby com o sap (RFC)
• Login AD (apenas teste ainda)
ERB
<div id="profile"> <div class="left column"> <div id="date"><%= print_date %></div> <div id="address"><%= current_user.address %></div> </div> <div class="right column"> <div id="email"><%= current_user.email %></div> <div id="bio"><%= current_user.bio %></div> </div></div>
HAML
#profile .left.column #date= print_date #address= current_user.address .right.column #email= current_user.email #bio= current_user.bio
TUTORIAL
ERB<strong><%= item.title %></strong>
Haml%strong= item.title
TUTORIAL
HTML<strong class="code" id="msg">Hello!</strong>
Haml%strong{:class => "code", :id => "msg"} Hello!
TUTORIAL
Haml.content Hello, World!
HTML<div class='content'>Hello, World!</div>
CSS
table.hl { margin: 2em 0;}table.hl td.ln { text-align: right;}
li { font-family: serif; font-weight: bold; font-size: 1.2em;}
SASS
table.hl margin: 2em 0 td.ln text-align: right
li font: family: serif weight: bold size: 1.2em
EM BREVE
É ISSO!
Elber Ribeirodynaum.com@dynaum