-
Notifications
You must be signed in to change notification settings - Fork 0
/
project-template.rb
168 lines (130 loc) · 5.51 KB
/
project-template.rb
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
################################################################################
# agilitic SRCL base Rails template
# http://en.agilitic.com
################################################################################
BASE_GH_URL = 'http://github.com/agilitic/rails-template/raw/master/files'
def copy_remote_file(path)
file(path, open("#{BASE_GH_URL}/#{path}").read)
end
def copy_remote_files(array)
array.each { |i| copy_remote_file(i) }
end
# Options ======================================================================
options = {}
options[:use_hoptoad] = yes?('Use hoptoad_notifier plugin?')
options[:use_geokit] = yes?('Use GeoKit gem?')
options[:use_responds_to_parent] = yes?('Use responds_to_parent plugin?')
options[:use_globalization] = yes?('Use globalization?') # install globalize/translates_routes
options[:use_wysiwyg] = yes?('Use wysiwyg?')
options[:bootstrap_smtp] = yes?('Bootstrap smtp?')
options[:bootstrap_contact_form] = yes?('Bootstrap contact form?')
options[:bootstrap_google_map] = yes?('Bootstrap google maps?')
options[:use_capistrano] = yes?('Use Capistrano?')
# Rails plugins & gems =========================================================
plugin 'acts_as_list', :git => 'git://github.com/rails/acts_as_list.git'
plugin 'responds_to_parent', :git => 'git://github.com/markcatley/responds_to_parent.git' if options[:use_responds_to_parent]
plugin 'hoptoad_notifier', :git => 'git://github.com/thoughtbot/hoptoad_notifier.git' if options[:use_hoptoad]
plugin 'misc_validators', :git => 'git://github.com/aurels/misc_validators.git'
gem 'authlogic'
gem 'will_paginate'
gem 'paperclip'
if options[:use_globalization]
gem 'globalize2'
plugin 'translate_routes', :git => 'git://github.com/raul/translate_routes.git'
copy_remote_file 'lib/tasks/translator.rake'
copy_remote_file 'lib/active_record/globalize_extensions.rb'
end
if options[:use_geokit]
gem 'geokit'
plugin 'geokit-rails', :git => 'git://github.com/andre/geokit-rails.git'
copy_remote_file 'config/initializers/geokit.rb'
end
rake "gems:install"
# Config =======================================================================
copy_remote_files(["config/config.yml", "config/initializers/load_config.rb"])
# Rake tasks ===================================================================
copy_remote_files(["lib/tasks/bootstrap.rake", "lib/tasks/seed.rake", "lib/tasks/cron.rake", "lib/tasks/uml.rake"])
# Authentication system & admin layout =========================================
generate :session_migration
generate :model, 'user', 'username:string', 'email:string', 'crypted_password:string', 'password_salt:string', 'persistence_token:string', 'admin:boolean'
generate :session, 'user_session'
copy_remote_files([
'app/views/layouts/admin.html.erb',
'app/views/admin/shared/_tabs.html.erb',
'public/stylesheets/admin.css',
'public/images/admin/alert-overlay.png',
'public/images/admin/check.gif',
'public/images/admin/x.gif',
'public/images/admin/x2.gif'
])
copy_remote_files([
'app/views/layouts/application.html.erb',
'app/models/user.rb',
'app/controllers/application_controller.rb',
'app/controllers/base_controller.rb',
'app/controllers/users_controller.rb',
'app/controllers/user_sessions_controller.rb',
'app/controllers/admin/base_controller.rb',
'app/controllers/admin/users_controller.rb',
'app/views/users/_form.html.erb',
'app/views/users/new.html.erb',
'app/views/users/index.html.erb',
'app/views/users/edit.html.erb',
'app/views/admin/users/index.html.erb',
'app/views/admin/users/_form.html.erb',
'app/views/admin/users/new.html.erb',
'app/views/admin/users/edit.html.erb',
'app/views/admin/users/show.html.erb',
'app/views/admin/users/_user.html.erb',
'app/helpers/layout_helper.rb',
'app/helpers/error_messages_helper.rb',
'app/views/user_sessions/new.html.erb'
])
# Routes =======================================================================
copy_remote_file 'config/routes.rb'
# Javascripts ==================================================================
copy_remote_files([
'public/javascripts/jquery-1.3.2.min.js',
'public/javascripts/jquery-ui-1.7.2.custom.min.js',
'public/javascripts/jquery.tablednd.js'
])
copy_remote_files([
'public/facebox/b.png',
'public/facebox/bl.png',
'public/facebox/br.png',
'public/facebox/closelabel.gif',
'public/facebox/facebox.css',
'public/facebox/facebox.js',
'public/facebox/loading.gif',
'public/facebox/README.txt',
'public/facebox/tl.png',
'public/facebox/tr.png'
])
# Misc =========================================================================
copy_remote_file 'config/database.yml'
copy_remote_file '.gems'
run "rm public/index.html"
run "rm public/javascripts/prototype.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/controls.js"
rake "db:migrate"
rake "app:bootstrap"
# Initializers =================================================================
copy_remote_file 'config/initializers/action_view_hacks.rb'
copy_remote_file 'public/images/exclamation.png'
# Capistrano ===================================================================
if options[:use_capistrano]
capify!
copy_remote_files([
'config/deploy.rb',
'config/deploy/production.rb',
'config/deploy/staging.rb'
])
end
run "cp config/environments/production.rb config/environments/staging.rb"
# Git setup ====================================================================
copy_remote_file '.gitignore'
git :init
git :add => "."
git :commit => "-a -m 'Initial commit'"