rubybook = Blog.new :title => “Gerald Bauer’s Ruby Notebook”, :about => “Internet Professional in Vancouver, B.C.”

Slide Show - A Free Web Alternative to PowerPoint and KeyNote in Ruby

Posted in Ruby, cssprojection, firefox, fullerscreen, redcloth, textile by Gerald on February 18th, 2008

I’ve uploaded slideshow v0.1 - a Ruby gem that lets you create slide shows and author slides in plain text using a wiki-style markup language that’s easy-to-write and easy-to-read. You can get started in three easy steps:

  • Step 1: Author your slides in plain text using a wiki-style markup language
  • Step 2: Generate your slide show using the slideshow gem
  • Step 3: Open up your slide show in Firefox with the FullerScreen browser addon
  • That’s it. Showtime!

Step 0: Install the slideshow gem

$ gem install slideshow

Step 1: Author your slides in plain text using a wiki-style markup language

Slide Show uses Textile that lets you author your slides using a wiki-style markup language that’s easy-to-write and easy-to-read. Let’s create some slides about best practices for web services using REST (rest.textile):

h1. Web Services REST-Style: Universal Identifiers, Formats & Protocols

Agenda

* What's REST?
* Universal Identifiers, Formats & Protocols - The Holy Trinity
* The Holy REST Trinity - Noun, Verbs, Types
* REST Design Principles - What's REST?
* Architecture Astronaut REST Speak

h1. Representational State Transfer (REST) - Meaningless Acronym? Wordplay?

rest - n. - peace, ease, or refreshment resulting from the insight that the web works

No matter what vendors tell you - no need to "Light Up the Web" - relax - built on
an *open architecture using universal identifiers, formats & protocols and _evolving_
open standards* - no need to reinvent the wheel and sign-up for single-vendor offerings.

h3. Broad Definition

* Best Practices for Designing Web Services for a Unified Human and Programable Web

h3. Narrow Definition

* Alternative to BigCo Web Services (SOAP, WS-STAR) and RPC-Style Web Services (XML-RPC)

Use h1. to start a new slide. That’s it. For more formatting options see the Textile reference.

Step 2: Generate your slide show using the slideshow gem

Run slideshow to generate your slide show. The slideshow gem expects the name of your slide show source document (e.g. rest) without the .textile ending and will generate a web page (e.g. rest.html) that is an all-in-one-page handout and a live slide show all at once thanks to the FullerScreen Firefox browser addon.

$ slideshow rest

=> Preparing slide show 'rest.html'...
=> Done.

Step 3: Open up your slide show in Firefox with the FullerScreen browser addon

Install the FullerScreen Firefox browser addon (if you haven’t yet). Open up your slide show (rest.html) in Firefox and hit F11 to turn your web page into a slide show.

That’s it. Find out more on the Slide Show site on RubyForge.

Questions? Comments? Send them along to the Free Web Slide Show Alternatives (S5, S9 And Friends) Forum/Mailing List. Thanks!

Comments Off

How To: Create a mobile web (iPhone) site using iUI and Ruby on Rails 2.0

Posted in Ruby, iphone, iui, mobileweb, safari, webkit by Gerald on February 12th, 2008

Let’s develop a mobile web application using Ruby on Rails running inside a WebKit browser (such as Safari on iPhone) using the iUI library. We’ll create a mini mobile version of Craigslist that lets you browse classifieds for apartments.

Figure: RoomieNATOR in Action
roomie1.png

Let’s get started. You can get the source from the Vancouver.rb subversion repo on RubyForge. To checkout the sample mobile web application type on the command line:

$ svn checkout http://vanrb.rubyforge.org/svn/roomie

Note, the source requires Rails 2.0.2+ with SQLite.

Change to the Rails application folder and build the sample database and populate it with sample users, neighbourhoods, postings and bookmarks using fixtures. On the command line type:

$ cd roomie
$ rake db:migrate
$ rake db:fixtures:load

Note, the two users setup are bob and alice using the password test.

Start up the web server (script/server) and test drive your installation. To be continued.

Any comments, corrections or additions about the how-to on creating a mobile web (iPhone) site using iUI and Ruby on Rails? Send them along to the Vancouver.rb Mailing List/Forum. Thanks!

Comments Off

Mofo - Getting Started w/ Microformats using Ruby - Web 3.0 In Action

Posted in Microformats, Ruby, giantglobalgraph, hcalendar, hcard, mofo, semanticweb, web30 by Gerald on January 18th, 2008

What are Microformats? Microformats let you turn your web page into a web service using nothing more than simple coding conventions and patterns that work in today’s browsers. If you markup events, people, reviews, locations and more in your web page using Microformats you contribute to the next version of the web – known as the Semantic Web, Web 3.0 or the Giant Global Graph (GGG).

Let’s skip the theory and dive into code and tap into the Giant Global Graph.

Let’s load up the event listing web page for the Ruby on Rails Workshop on the Yahoo! Upcoming service using mofo – a microformat parser in Ruby .

require 'mofo'
require 'pp'

event = hCalendar.find 'http://upcoming.yahoo.com/event/390146/'

Using hCalendar.find we tell the mofo microformat parser to look for all events marked up in the web page using the hCalendar microformat standard.

That’s all. Now we’re ready to play with the event data:

puts event.summary

Prints the events one-line summary:

=> Intermed. Ruby on Rails Workshop (Incl. Facebook and Mobile Web)

puts event.dtstart

Prints the event start date:

=> Fri Jan 25 00:00:00 -0800 2008

puts event.description

Prints the event description:

=> On Friday Jan 25, 2008, Scott Patten and Gerald Bauer (Rails Advance) are giving a full-day workshop on Intermediate Ruby on Rails at BCIT’s downtown campus. Sign-up and learn how to build a complete RESTful web application and web service using Rails 2.0 and then use ActiveResource to build a facebook and mobile application on top of the web service.

Using the pretty printer (pp) module we can print the hCard microformat inside the hCalendar microformat used to markup the event’s venue name and address:

pp event.location

Pretty prints the hCard microformat data:

#<HCard:0x5225a88
 @adr=
  #<Adr:0x5249d70
   @locality="Vancouver",
   @postal_code="",
   @properties=["locality", "street_address", "region", "postal_code"],
   @region=”British Columbia”,
   @street_address=”555 Seymour Street”>,
 @fn=”BCIT Downtown Campus”,
 @org=”BCIT Downtown Campus”,
 @properties=["fn", "adr", "org"]>

We can, of course, print the items one at a time:

puts event.location.fn

Prints the event’s venue name and fn stands for full name:

=> BCIT Downtown Campus

puts event.location.adr.locality

Prints the event’s venue locality, that is, the city, village, or hamlet:

=> Vancouver

puts event.location.adr.street_address

Prints the event’s venue street address:

=> 555 Seymour Street

And so on and so forth. To see the fully monty pretty print the hCalendar microformat and stand back 1000 meters:

pp event

That’s all to get started using Microformats in Ruby thanks to the mofo parser library.

Interested in learning more? Sign-up today for the world’s 1st Ruby on Rails workshop covering the Semantic Web, Web 3.0, Microformats and the Giant Global Graph.

Any comments, corrections or additions about “Mofo - Getting Started w/ Microformats using Ruby - Web 3.0 In Action”? Send them along to the Vancouver.rb Mailing List/Forum. Thanks!

Comments Off

Let’s Go Camping - Getting Started w/ Ruby’s Model-View-Controller (MVC) Web Microframework

Posted in Camping, Markaby, Microframework, Mongrel, Ruby by Gerald on January 13th, 2008

What’s Camping? Camping is a microframework (in less than 4k of code) that lets you develop a web application using the Model-View-Controller (MVC) architecture with all your code stored in a single Ruby script in less then three minutes.

Let’s go camping and create a web application (hello.rb) showing the current time:

require 'camping'

Camping.goes :Hello

module Hello::Controllers
  class Index < R '/'
    def get
      render :frontpage
    end
  end
end

module Hello::Views
  def frontpage
    h1 "Hola Mundo"
    p  "The time is: #{Time.now}"
  end
end

We have created a controller with an index action mapped to the ‘/’ route and a frontpage view template and that’s it! We’re ready for production.

Let’s use the Mongrel web server to put our Camping web application online. Add the following startup script to hello.rb :

if __FILE__ == $0
  require 'mongrel'
  require 'mongrel/camping'

  server = Mongrel::Camping::start( "0.0.0.0", 3301, "/", Hello )
  puts "**Hello Camping is running on Mongrel at http://localhost:3301/"
  server.run.join
end

Start up the web application and the Mongrel web server and type on the command line:

$ ruby hello.rb
>> Hello Camping is running on Mongrel at http://localhost:3301/

Tune your browser to http://localhost:3301 Voila!

Any comments, corrections or additions about “Let’s Go Camping - Getting Started w/ Ruby’s Model-View-Controller (MVC) Web Microframework”? Send them along to the Vancouver.rb Mailing List/Forum. Thanks!

Comments Off