github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

didip / rails-templates forked from jm/rails-templates

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 3
    • 98
  • Source
  • Commits
  • Network (98)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A library of neat Rails application templates. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Fixed illegal indentation on application.haml 
didip (author)
Mon Aug 31 22:51:55 -0700 2009
commit  6290039e667ddc389711334e17dd861febe37ff3
tree    4eee44eadd7f9d751225c44e5d95c9c0707efad1
parent  4b0c3814e42664410106627761a9ba88c5dac5e6
rails-templates / mozomo.rb mozomo.rb
100644 146 lines (119 sloc) 3.37 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# mozomo.rb
# from Didip Kerabat and Quin Hoxie
 
# run 'gem install hassox-rails_warden'
 
gem 'rack'
gem 'haml'
gem 'less'
gem 'mocha'
gem 'json_pure', :lib => 'json'
gem 'bcrypt-ruby', :lib => 'bcrypt'
gem 'warden'
gem 'rails_warden'
 
# Github gems
def github_gem(lib_name)
  gem lib_name, :lib => lib_name.match(/[^-]+-(.*)/)[1], :source => 'http://gems.github.com'
end
 
[
  'mislav-will_paginate',
  'thoughtbot-factory_girl',
  'thoughtbot-shoulda',
  'thoughtbot-quietbacktrace'
].each do |library|
  github_gem(library)
end
 
# get all datamapper related gems (assume sqlite3 to be database)
gem "addressable", :lib => "addressable/uri"
gem "do_sqlite3"
gem 'dm-validations'
gem 'dm-types'
gem 'dm-timestamps'
 
# Rails plugins
plugin "less-for-rails", :git => "git://github.com/augustl/less-for-rails.git"
plugin "flash-message-conductor", :git => "git://github.com/planetargon/flash-message-conductor.git"
 
rake "gems:install"
rake "gems:unpack"
rake "gems:build"
 
# install datamapper rake tasks
generate("dm_install")
 
# fix config files to work with datamapper instead of active_record
run "sed -i config/environment.rb -e 's/#.*config.frameworks.*/config.frameworks -= [ :active_record ]/'"
run "sed -i spec/spec_helper.rb -e 's/^\\s*config[.]/#\\0/'"
run "sed -i test/test_helper.rb -e 's/^[^#]*fixtures/#\\0/'"
 
# fix a problem with missing class constants for models woth relations
initializer 'preload_models.rb', <<-CODE
require 'datamapper4rails/preload_models'
CODE
 
# basic layout
file('app/views/layouts/application.html.haml') do
  <<-EOF
!!!
 
%html
%head
%title My Mozomo App
= stylesheet_link_tag 'screen', :media => 'screen, projection'
= stylesheet_link_tag 'print', :media => 'print'
%body
#container
= render_flash_messages
= yield
= javascript_include_tag 'jquery'
EOF
end
 
# basic model objects
file('app/models/user.rb') do
  <<-EOF
class User
attr_accessor :password, :password_confirmation
include DataMapper::Resource
 
property :id, Serial
property :email, String
property :encrypted_password, BCryptHash, :nullable => false
property :created_at, DateTime
 
validates_is_confirmed :password
 
def password=(pass)
@password = pass
self.encrypted_password = pass
end
end
EOF
end
 
initializer('warden.rb') do
  <<-EOF
Rails.configuration.middleware.use RailsWarden::Manager do |manager|
manager.default_strategies :bcrypt
manager.failure_app = UserController
end
 
Warden::Manager.serialize_into_session{ |user| [user.class, user.id] }
Warden::Manager.serialize_from_session{ |klass, id| klass.get(id) }
 
Warden::Strategies.add(:bcrypt) do
def valid?
params[:email] || params[:password]
end
 
def authenticate!
return fail! unless user = User.first(:email => params[:email])
 
if user.encrypted_password == params[:password]
success!(user)
else
errors.add(:login, "Email or Password incorrect")
fail!
end
end
end
EOF
end
 
# integrate HAML to rails
run "haml --rails ."
 
# Download jquery
run 'rm public/javascripts/*'
run 'curl http://jqueryjs.googlecode.com/files/jquery-1.3.2.js > public/javascripts/jquery.js'
 
# Delete unnecessary files
def rm_file(file)
  run "rm #{file}"
end
 
[
  'README',
  'doc/README_FOR_APP',
  'public/index.html',
  'public/favicon.ico',
  'public/robots.txt'
].each { |f| rm_file(f) }
 
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server