SINATRA + HAML + TWITTER
        Elber Ribeiro @dynaum
           BBTI TechTalk #2
              17/09/2010
SINATRA
Micro 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 :index
end
EXEMPLO
require 'rubygems'
require 'sinatra'
require 'haml'

get '/hi' do
  haml :index
end
URL PADRONIZADA
require 'rubygems'
require 'sinatra'
require 'haml'

post '/posts' do
  post = Post.create! params
  redir...
MAIS
•   Template ( erb, haml, builder )

•   Testes ( rspec, test::unit )

•   Before filters

•   Helpers

•   Error hand...
NICEDOG
NICEDOG

require 'NiceDog.php';

R('/posts')->controller('post')->action('index')->on('GET');

class Post extends C{
    p...
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"><%= c...
HAML

#profile
  .left.column
    #date= print_date
    #address= current_user.address
  .right.column
    #email= current...
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;...
SASS
table.hl
  margin: 2em 0
  td.ln
    text-align: right

li
     font:
       family: serif
       weight: bold
      ...
EM BREVE
É ISSO!

Elber Ribeiro
  dynaum.com
   @dynaum
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
Upcoming SlideShare
Loading in …5
×

SINATRA + HAML + TWITTER

2,601 views

Published on

Segunda apresentação no bbti techtalk.

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

  • Be the first to like this

No Downloads
Views
Total views
2,601
On SlideShare
0
From Embeds
0
Number of Embeds
35
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

SINATRA + HAML + TWITTER

  1. 1. SINATRA + HAML + TWITTER Elber Ribeiro @dynaum BBTI TechTalk #2 17/09/2010
  2. 2. SINATRA Micro Web Framework
  3. 3. SINATRA •RACK •REST •URL
  4. 4. EXEMPLO require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end
  5. 5. EXEMPLO $ gem install sinatra $ ruby hello.rb >> Listen on 0.0.0.0:4567
  6. 6. EXEMPLO require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end
  7. 7. EXEMPLO require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end
  8. 8. EXEMPLO require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end
  9. 9. EXEMPLO require 'rubygems' require 'sinatra' get '/hi' do erb :index end
  10. 10. EXEMPLO require 'rubygems' require 'sinatra' require 'haml' get '/hi' do haml :index end
  11. 11. URL PADRONIZADA 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 :post end
  12. 12. MAIS • Template ( erb, haml, builder ) • Testes ( rspec, test::unit ) • Before filters • Helpers • Error handlers • Inline templates • HTTP Caching ( etag, last-modified ) • Rack
  13. 13. NICEDOG
  14. 14. NICEDOG require 'NiceDog.php'; R('/posts')->controller('post')->action('index')->on('GET'); class Post extends C{ public function index(){ echo 'Hello'; } } run();
  15. 15. NICEDOG + LASA = LASA_API • Conexão entra apps ruby com o sap (RFC) • Login AD (apenas teste ainda)
  16. 16. 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>
  17. 17. HAML #profile .left.column #date= print_date #address= current_user.address .right.column #email= current_user.email #bio= current_user.bio
  18. 18. TUTORIAL ERB <strong><%= item.title %></strong> Haml %strong= item.title
  19. 19. TUTORIAL HTML <strong class="code" id="msg">Hello!</strong> Haml %strong{:class => "code", :id => "msg"} Hello!
  20. 20. TUTORIAL Haml .content Hello, World! HTML <div class='content'>Hello, World!</div>
  21. 21. CSS table.hl { margin: 2em 0; } table.hl td.ln { text-align: right; } li { font-family: serif; font-weight: bold; font-size: 1.2em; }
  22. 22. SASS table.hl margin: 2em 0 td.ln text-align: right li font: family: serif weight: bold size: 1.2em
  23. 23. EM BREVE
  24. 24. É ISSO! Elber Ribeiro dynaum.com @dynaum

×