Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cloning Internet Applications with Ruby

You're reading from   Cloning Internet Applications with Ruby Make clones of some of the best applications on the Web using the dynamic and object-oriented features of Ruby

Arrow left icon
Product type Paperback
Published in Aug 2010
Publisher Packt
ISBN-13 9781849511063
Length 336 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Chang Sau Sheong Chang Sau Sheong
Author Profile Icon Chang Sau Sheong
Chang Sau Sheong
Arrow right icon
View More author details
Toc

Building the application flow


While much of the application logic resides in the data model, the flow of the application determines how the user uses Colony. Let's begin with the overall structure of the application and then we'll inspect each feature for its flow.

Structure of the application and flow

Unlike the previous clones where we stored the entire flow in a single file, Colony is too big to fit into a single file, so we split the application along the lines of its features and use one file per feature. The main file is called colony.rb. It contains the main processing necessary to log in as well as the landing page.

require 'rubygems'
gem 'rest-client', '=1.0.3'
%w(config haml sinatra digest/md5 rack-flash json restclient models).each  { |lib| require lib}
set :sessions, true
set :show_exceptions, false
use Rack::Flash

get "/" do
  if session[:userid].nil? then
    @token = "http://#{env["HTTP_HOST"]}/after_login"
    haml :login
  else
    @all = @user.feed
    haml :landing
  end...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image