Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (37 sloc) 1.13 KB
APP_ROOT = File.dirname(__FILE__)
require 'bundler'
Bundler.require
%w{article helpers core_ext/enumerable}.each { |lib| require "#{APP_ROOT}/lib/#{lib}" }
# Set path to our articles
Article.path = "#{APP_ROOT}/articles"
module RohitArondekar
class WebSite < Sinatra::Base
set :public, File.join(APP_ROOT, 'public')
set :haml, :format => :html5, :encoding => 'UTF-8'
enable :static
helpers { include Helpers }
get '/' do
@active = "home"
@articles = Article.all.sort
@few_articles = @articles[0..5]
@title = "Rohit Arondekar &mdash; a web developer based in Goa"
haml :welcome
end
get %r{/articles/([\w-]+)} do |article_slug|
@active = "articles"
@article = Article[article_slug] || raise(Sinatra::NotFound)
@articles = Article.all.sort
@few_articles = @articles[0..5]
@title = @article.title + " by Rohit Arondekar"
haml :article
end
get '/articles.atom' do
@articles = Article.all.sort
content_type 'application/atom+xml'
erb :feed, { :layout => false }
end
not_found do
"Not Found"
end
end
end