Skip to content

Instantly share code, notes, and snippets.

@jrom
Created November 30, 2009 17:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrom/245567 to your computer and use it in GitHub Desktop.
Save jrom/245567 to your computer and use it in GitHub Desktop.
Typus template
##
# $ rails example.com -m http://tr.im/typus_example
##
# Install Typus and friends.
plugin 'typus', :git => 'git://github.com/fesplugas/typus.git'
plugin 'acts_as_list', :git => 'git://github.com/rails/acts_as_list.git'
plugin 'acts_as_tree', :git => 'git://github.com/rails/acts_as_tree.git'
plugin 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
# Gems
gem "formtastic", :source => "http://gemcutter.org/"
# Run generators.
generate("scaffold",
"Asset asset_file_name:string asset_content_type:string asset_file_size:integer asset_updated_at:datetime",
"--skip-timestamps")
generate("scaffold",
"Category name:string slug:string",
"--skip-timestamps")
generate("scaffold",
"Page title:string body:text published:boolean position:integer",
"--skip-timestamps")
generate("scaffold",
"Project title:string slug:string body:text published:boolean category_id:integer",
"--skip-timestamps")
# Define models.
file 'app/models/asset.rb', <<-CODE
class Asset < ActiveRecord::Base
has_attached_file :asset, :styles => { :typus_preview => "692x461>", :typus_thumbnail => "100x100>" }
validates_attachment_presence :asset
end
CODE
file 'app/models/category.rb', <<-CODE
class Category < ActiveRecord::Base
validates_presence_of :name
has_many :projects
end
CODE
file 'app/models/page.rb', <<-CODE
class Page < ActiveRecord::Base
acts_as_list
validates_presence_of :title
end
CODE
file 'app/models/project.rb', <<-CODE
class Project < ActiveRecord::Base
validates_presence_of :title
belongs_to :category
def typus_name
title
end
end
CODE
# Run the migrations and set the routes.
rake 'db:migrate'
run "rm public/index.html"
route "map.root :controller => 'pages'"
# Run the Typus generator and migrate.
generate 'typus'
rake 'db:migrate'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment