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...