This document discusses using the Sinatra web framework to build a "Time Website" that provides time and beats feeds for Miami. It would include a landing page with HTML, CSS, and JavaScript, as well as feeds that use Sinatra and Ruby gems to dynamically generate the current time and beats. The document provides examples of setting up and using Sinatra, along with suggestions for implementing features like Sass, CoffeeScript, and graceful degradation.
12. Miami Internet Beats
• Based on Miami time (including DST)
• Also compatible with:
• New York City
• Washington DC
• Boston
13. Miami Internet Beats
• Based on Miami time (including DST)
• Also compatible with:
• New York City
• Washington DC
• Boston
• Easy-to-use website
22. Installing
• Mac OS X:
1. gem install sinatra
• Windows:
1. Install ruby from http://rubyinstaller.org
2. gem install sinatra
23. Getting Started
require 'sinatra'
get '/hi' do
  "Hello World!"
end
1. Save as “hello.rb”
2. ruby -rubygems hello.rb
3. Visit http://localhost:4567/hi
30. Beats Feed
get '/beats' do
  now = mt.now
midnight = now.beginning_of_day
tomorrow = now.end_of_day
  seconds = now - midnight
  total_seconds = tomorrow - midnight
  beats = (seconds / total_seconds) * 1000
  beats.to_s
end
43. Time Website
• Time Feeds
• Big showy landing page
• HTML
• CSS
• JavaScript
44. Quick HAML Review
<!DOCTYPE html>
!!! 5 <html>
%html   <head>
  %head     <title>MIAMI</title>
    %title MIAMI   </head>
  <body>
  %body
    <h1>INTERNET</h1>
    %h1 INTERNET     <div class='description'>
    .description       <p>BEATS is the
      :markdown       new time standard.</p>
        BEATS is the     </div>
new time standard. Â Â </body>
</html>
45. HAML in Sinatra
get '/' do
  haml :index
end
views/index.haml
!!! 5
%html
  %head
    %title MIAMI INTERNET BEATS
  %body
    %h1 MIAMI INTERNET BEATS
    .description
      :markdown
        MIAMI INTERNET BEATS is the
new time standard.
48. !!! 5
%html
  %head
    %title MIAMI INTERNET BEATS
  %body
    .rotationPart
      %h1 MIAMI INTERNET BEATS
      .bars
        #beats=current_beats.round
        #beatBar.bar
        #fractionalBeats=(current_beats - current_beats.floor).round(2)
        #fractionBar.bar
        #date
        #dateBar.bar
      #stopButton stop
      .description
        :markdown
          MIAMI INTERNET BEATS is the new time standard…
49. !!! 5
%html
  %head
    %title MIAMI INTERNET BEATS
  %body
    .rotationPart
      %h1 MIAMI INTERNET BEATS
      .bars
        #beats=current_beats.round
        #beatBar.bar
        #fractionalBeats=(current_beats - current_beats.floor).round(2)
        #fractionBar.bar
        #date
        #dateBar.bar
      #stopButton stop
      .description
        :markdown
          MIAMI INTERNET BEATS is the new time standard…
55. Time Website
• Time Feeds
• Big showy landing page
• HTML
• CSS
• JavaScript
56. SASS in Sinatra
get '/miamibeats.css' do
  sass :miamibeats
end
views/miamibeats.sass
a:link, a:visited
  :color #f0f
  :text-decoration none
Napoleon Bonaparte, Emperor of France about two hundred years ago\n\nLOOOOOVED metric\n\nMeters, GRAMS, Seconds is the metric system today\n
He wanted ten hour days, and hours divided into decihours, centihours, and millihours\n
About a hundred eighty five years later, a Swiss company made their own decimal time system, where the Napoleonic millihour was called a &#x201C;Swatch Internet Beat&#x201D;\n
They made watches with internet beats\n\nYou can see it here, below the actual time that normal people used back then and still use today\n
Swatch Internet Beats were universal; even in Miami, you were using the standard time in Switzerland\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
If you&#x2019;re interested in learning more about Ruby on Rails (Sinatra&#x2019;s big brother,) I&#x2019;ll be speaking at Hack Miami this Saturday out in Weston.\n