Skip to content

Instantly share code, notes, and snippets.

@sidwood
Created December 10, 2010 12:23
Show Gist options
  • Save sidwood/736143 to your computer and use it in GitHub Desktop.
Save sidwood/736143 to your computer and use it in GitHub Desktop.
Micro CMS Concept
%w{rubygems sinatra haml sass dm-core}.each {|lib| require lib}
configure :production, :staging do
require 'dm-postgres-adapter' # for heroku
end
configure :development do
DataMapper.auto_upgrade!
end
configure do
DataMapper.
setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/data.db")
end
class Page
include DataMapper::Resource
property :id, Integer, :key => true
property :title, String, :required => true
property :keywords, String
property :description, String
property :uri, String, :required => true
property :body Text, :required => true
#TODO: Search and indexing
end
get '/' do
params[:uri] = 'home'
haml :page
end
get '/:uri' do
haml :page
end
post '/' do
@results = Page.search(params[:q])
haml :results
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment