-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfasteragile.rb
610 lines (513 loc) · 17.3 KB
/
fasteragile.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
# This template represents what FasterAgile believes to be the best mix
# of components for ab-initio Rails projects. It includes:
# Mocks with factory_girl instead of fixtures; cucumber and shoulda; friendly_ids
# and canonical links for SEO; HAML and SASS; the Clearance engine; basic sass
# and haml starter files; my favorite plugins and initializers; some utility
# methods that I always use.
#
# Run this template like this:
# rails <myproject> -m fasteragile.rb
#
# Or if you want to live on the bleeding edge you can use the gist-based template:
# rails <myproject> -m http://gist.github.com/gists/182433
#
# Copyright 2009 Faster Agile, LLC
# Author: Peter Jackson
# http://www.fasteragile.com
# License: MIT License
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# Faster Agile's Translation: You may copy, use, and extend this template for any purpose,
# including commercial purposes, but you must leave this comment intact.
puts "Applying Faster Agile template. Copyright 2009 FasterAgile LLC."
git :init
git :add => "."
git :commit => "-a -m 'Initial Commit -- Before template apply'"
plugin 'acts_as_state_machine', :svn => 'http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk'
plugin 'jrails', :svn => 'http://ennerchi.googlecode.com/svn/trunk/plugins/jrails'
plugin 'yaml_mail_config', :svn => 'svn://rubyforge.org/var/svn/slantwise/yaml_mail_config/trunk yaml_mail_config'
run 'cp vendor/plugins/yaml_mail_config/templates/email.example.yml config/email.yml'
plugin 'hoptoad_notifier', :git => 'git://github.com/thoughtbot/hoptoad_notifier.git', :submodule => true
plugin 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git', :submodule => true
plugin 'factory_girl', :git => 'git://github.com/thoughtbot/factory_girl', :submodule => true
plugin 'shoulda', :git => 'git://github.com/thoughtbot/shoulda.git', :submodule => true
plugin 'high_voltage', :git => 'git://github.com/thoughtbot/high_voltage.git', :submodule => true
plugin 'limerick_rake', :git => 'git://github.com/thoughtbot/limerick_rake.git', :submodule => true
plugin 'db_populate', :git => 'git://github.com/ffmike/db-populate.git', :submodule => true
plugin 'paperclippolymorph', :git => 'git://github.com/heavysixer/paperclippolymorph.git', :submodule => true
plugin 'growlr', :git => 'git://github.com/vanntastic/growlr.git', :submodule => true
plugin "peteonrails-seo-kit", :git => "git://github.com/peteonrails/seo-kit.git", :submodule => true
git :submodule => "init"
gem 'will_paginate'
gem 'haml', :version => ">= 2.2.5"
gem "mbleigh-acts-as-taggable-on", :source => "http://gems.github.com", :lib => "acts-as-taggable-on"
gem "thoughtbot-clearance", :lib => 'clearance', :source => 'http://gems.github.com', :version => '0.8.2'
gem 'w3c_validators', :version => '0.9.3'
gem 'friendly_id'
gem 'fastercsv'
gem "peteonrails-simple_tooltips", :lib => "simple_tooltips",:source => 'http://gems.github.com'
gem "peteonrails-vote_fu", :source => "http://gems.github.com", :lib => "vote_fu"
rake("gems:install", :sudo => true)
rake("gems:unpack")
run("haml --rails .")
run 'mkdir app/views/pages'
file 'app/views/pages/home.html.haml',
%q{.mouseover1
This is the home page!
= tooltip_for "mouseover1", "Here's the hint!"
}
file 'app/views/layouts/application.html.haml',
%q{%html
%head
%title= application_title("FasterAgile", controller.controller_name, controller.action_name)
= yield :head
= stylesheet_link_tag "application", "tooltip"
= javascript_include_tag :defaults
%body
#flash= flash_notices
#header
#logo
= render :partial => "shared/logo"
.clearfix
#topnav
= render :partial => 'shared/topnav'
#outer-container
#main-content
= yield
.clearfloat
#footer
#footer-content.ctr
= render :partial => 'shared/footer'
= yield :javascript
= render :partial => 'shared/analytics'
}
file 'app/helpers/application_helper.rb',
%q{# ---
module ApplicationHelper
def application_title(name, controller, action)
"#{name} #{controller} #{action}"
end
def flash_notices
flash_types = [:error, :warning, :notice]
messages = ((flash_types & flash.keys).collect do |key|
"$.jGrowl('#{flash[key]}', { header: '#{I18n.t(key, :default => key.to_s)}', theme: '#{key.to_s}'});"
end.join("\n"))
if messages.size > 0
content_tag(:script, :type => "text/javascript") do
"$(document).ready(function() { #{messages} });"
end
else
""
end
end
end
}
run 'mkdir -p public/stylesheets/sass'
file 'public/stylesheets/sass/util.sass',
%q{.clearfix
:clear both
:width 100%
:height 0
}
file 'public/stylesheets/sass/navigation.sass',
%q{@import colors.sass
#topnav
:margin 0 auto
:width= !content_width
:height 100%
:padding 0px
.lefttab
:width auto
:margin-right= !tabmargin
:padding= !tabpadding
:float left
:font-weight bold
.righttab
:width auto
:margin-left= !tabmargin
:padding= !tabpadding
:float right
:font-weight bold
.selected
:background-color= !white
:color= !black
a
:color= !black
:text-decoration none
.unselected
:background-color= !black
:color= !white
a
:color= !white
:text-decoration none
}
file 'public/stylesheets/sass/application.sass',
%q{@import colors.sass
@import navigation.sass
@import util.sass
html, body
:height 100%
body
:font 100% Arial, Verdana, sans-serif
:font-size 14px
:background-color= !white
:margin 0
:padding 0
:text-align center
:color= !textcolor
#footer
:background url(../images/footer.jpg) repeat-x
:margin 0px
:width 100%
:height= !footer_height
:position relative
#footer-content
:width= !content_width
:margin 0 auto
:padding-top 20px
#header
:background url(../images/header.jpg) repeat-x
:height 99px
#logo
:margin 0px auto
:width= !content_width
:font-size 3.0em
:font-weight bold
:height 65px
#outer-container
:width= !content_width
:margin 0px auto
:background= !white
:text-align left
:min-height 70%
:position relative
#main-content
:padding 10px
#centerpanel
:margin-top 30px
:margin-left auto
:margin-right auto
:width 80%
:border #000 1px solid important
:color= !textcolor
:font-size 1.75em
.headline
:width 80%
.sub-headline
:font-size 0.75em
:font-weight bold
.message
:margin-top 20px
:font-size 0.75em
}
file 'public/robots.txt',
%q{# Ban all spiders from indeing the site until we are ready for SEO launch.
User-Agent: *
Disallow: /
}
file 'config/deploy.rb',
%q{set :stages, %w(staging production)
set :default_stage, 'staging'
require 'capistrano/ext/multistage'
before "deploy:setup", "db:password"
namespace :deploy do
desc "Default deploy - updated to run migrations"
task :default do
set :migrate_target, :latest
update_code
migrate
symlink
restart
end
desc "Run this after every successful deployment"
task :after_default do
cleanup
end
before :deploy do
if real_revision.empty?
raise "The tag, revision, or branch #{revision} does not exist."
end
end
end
namespace :db do
desc "Create database password in shared path"
task :password do
set :db_password, Proc.new { Capistrano::CLI.password_prompt("Remote database password: ") }
run "mkdir -p #{shared_path}/config"
put db_password, "#{shared_path}/config/dbpassword"
end
end
}
run 'mkdir config/deploy'
file 'config/deploy/staging.rb',
%q{# For migrations
set :rails_env, 'staging'
default_run_options[:pty] = true
# Who are we?
set :application, CHANGEME
set :repository, CHANGEME
set :scm, "git"
set :deploy_via, :remote_cache
set :branch, "staging"
set :group_writable, false
# Where to deploy to?
role :web, "staging.CHANGEME.com"
role :app, "staging.CHANGEME.com"
role :db, "staging.CHANGEME.com", :primary => true
# Deploy details
set :user, CHANGEME
set :deploy_to, "/home/#{user}/apps/#{application}"
set :use_sudo, false
set :checkout, 'export'
# We need to know how to use mongrel
set :mongrel_rails, '/usr/local/bin/mongrel_rails'
set :mongrel_cluster_config, "#{deploy_to}/#{current_dir}/config/mongrel_cluster_staging.yml"
namespace :deploy do
after "deploy:restart",
"deploy:railsplayground:fix_permissions",
"deploy:railsplayground:set_production" ,
"deploy:railsplayground:kill_dispatch_fcgi",
"deploy:railsplayground:copy_htaccess"
desc "RailsPlayground version of restart task."
task :restart do
railsplayground::kill_dispatch_fcgi
end
namespace :railsplayground do
desc "Uncomment the RAILS_ENV setting"
task :set_production do
run "sed -i.cap.orig -e 's/^# ENV/ENV/' #{release_path}/config/environment.rb"
end
desc "Kills Ruby instances on RailsPlayground"
task :kill_dispatch_fcgi do
run "pkill -9 -u #{user} -f dispatch.fcgi"
end
desc "Fix g-w issues with RailsPlayground"
task :fix_permissions do
run "cd #{current_path}; chmod -R g-w *"
end
desc "Copy over the RailsPlayground htaccess file"
task :copy_htaccess do
run "cp #{shared_path}/config/htaccess #{release_path}/public/.htaccess"
end
end
end
}
run "mkdir -p app/views/shared"
file "app/views/shared/_logo.html.haml", "#logo"
file "app/views/shared/_topnav.html.haml", "#topnav"
file "app/views/shared/_footer.html.haml", "#footer"
file "app/views/shared/_analytics.html.haml",
%q{%script{ :type => "text/javascript" }
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
%script{ :type => "text/javascript" }
try {
var pageTracker = _gat._getTracker("ENTER TRACKER ID");
pageTracker._trackPageview();
} catch(err) {}</script>
}
file 'config/deploy/production.rb',
%q{# For migrations
set :rails_env, 'production'
# Who are we?
set :application, CHANGEME
set :repository, CHANGEME
set :scm, "git"
set :deploy_via, :remote_cache
set :branch, "production"
# Where to deploy to?
role :web, "www.CHANGEME.com"
role :app, "www.CHANGEME.com"
role :db, "www.CHANGEME.com", :primary => true
# Deploy details
set :user, "#{application}"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :use_sudo, false
set :checkout, 'export'
# We need to know how to use mongrel
set :mongrel_rails, '/usr/local/bin/mongrel_rails'
set :mongrel_cluster_config, "#{deploy_to}/#{current_dir}/config/mongrel_cluster_production.yml"
}
# I still use the dispatchers and fast_cgi in my staging environment. :)
file 'public/.htaccess',
%q{# ---
Options +FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
ErrorDocument 500 /500.html
}
run 'mkdir -p "public/stylesheets/sass"'
file 'public/stylesheets/sass/application.sass', "@import colors.sass"
file 'public/stylesheets/sass/colors.sass',
%q{!white = #f1f1f1
!black = #000
!blue = #cfe0f0
}
file 'config/initializers/hoptoad.rb',
%q{
HoptoadNotifier.configure do |config|
config.api_key = ''
end
}
file 'config/initializers/time_formats.rb',
%q[
{ :short_date => "%x", # 01/03/74
:long_date => "%a, %b %d, %Y", # Mon, Sep 7, 2009
:header_date => "%A, %B %d, %Y", # Tuesday, Sep 07, 2009
:ics => "%Y%m%dT%H%M%S", # 20090907T120000 (formatted for ICS / iCal / vCal)
:w3cdate => '%Y-%m-%d'
}.each do |k, v|
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(k => v)
end
]
file 'config/initializers/array.rb',
%q{# ---
class Array
# If +number+ is greater than the size of the array, the method
# will simply return the array itself sorted randomly
def randomly_pick(number)
sort_by{ rand }.slice(0...number)
end
end
}
file "lib/tasks/css.rake",
%q{# ---
require 'w3c_validators'
def error_messages_for_results(results)
"Error details follow:" +
results.errors.inject("\n") do |memo, err|
memo += " * #{err.message.strip} at line #{err.line.to_s}"
end
end
namespace :css do
include W3CValidators
desc "Validate all CSS as W3C compliant"
task :validate => :environment do
v = CSSValidator.new
v.set_profile!(:css3)
Dir.glob(File.join(RAILS_ROOT, 'public', 'stylesheets', '*.css')) do |file|
results = v.validate_file(file)
puts "CSS File: #{file}: " + ((results.errors.length == 0) ? "Valid!" : error_messages_for_results(results))
end
end
end
}
file 'config/environments/cucumber.rb',
%q{# ---
config.cache_classes = true # This must be true for Cucumber to operate correctly!
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
config.gem 'thoughtbot-factory_girl',
:lib => 'factory_girl',
:source => 'http://gems.github.com',
:version => '>= 1.2.0'
# Cucumber and dependencies
config.gem 'polyglot',
:version => '0.2.6',
:lib => false
config.gem 'treetop',
:version => '1.2.6',
:lib => false
config.gem 'term-ansicolor',
:version => '1.0.3',
:lib => false
config.gem 'diff-lcs',
:version => '1.1.2',
:lib => false
config.gem 'builder',
:version => '2.1.2',
:lib => false
config.gem 'cucumber',
:version => '0.3.11'
# Webrat and dependencies
# NOTE: don't vendor nokogiri - it's a binary Gem
config.gem 'nokogiri',
:version => '1.3.3',
:lib => false
config.gem 'webrat',
:version => '0.4.4'
HOST = 'localhost'
}
file 'config/routes.rb',
%q{ActionController::Routing::Routes.draw do |map|
map.root :controller => "high_voltage/pages", :action => "show", :id => "home"
map.connect '/sitemap.xml', :controller => 'sitemap', :action => "sitemap", :format => "xml"
# Defaults routes have been removed: If you need them, uncomment these two lines
# map.connect ':controller/:action/:id'
# map.connect ':controller/:action/:id.:format'
end
}
run 'mkdir db/populate'
run 'mkdir db/populate/development'
run 'mkdir db/populate/staging'
run 'mkdir db/populate/production'
inside 'public/javascripts' do
run 'wget http://jqueryjs.googlecode.com/svn/trunk/plugins/tooltip/jquery.tooltip.js'
run 'wget http://jqueryjs.googlecode.com/svn/trunk/plugins/tooltip/jquery.formtooltip.js'
run 'wget http://jqueryjs.googlecode.com/svn/trunk/plugins/tooltip/lib/jquery.dimensions.js'
run 'wget http://jqueryjs.googlecode.com/svn/trunk/plugins/checkboxes/jquery.checkboxes.js'
run 'wget http://jqueryjs.googlecode.com/svn/trunk/plugins/autocomplete/jquery.autocomplete.js'
run 'wget http://jqueryjs.googlecode.com/svn/trunk/plugins/tablesorter/jquery.tablesorter.js'
end
inside 'public/stylesheets' do
run 'wget http://jqueryjs.googlecode.com/svn/trunk/plugins/autocomplete/jquery.autocomplete.css'
run 'css2saas jquery.autocomplete.css sass/jquery.autocomplete.sass'
end
run 'rm public/index.html'
run 'rm public/javascripts/prototype.js'
run 'rm public/javascripts/effects.js'
run 'rm public/javascripts/controls.js'
run 'rm public/javascripts/dragdrop.js'
run 'rmdir test/fixtures'
generate("clearance")
generate('tooltip')
generate('vote_fu')
generate('polymorphic_paperclip')
generate('seo_kit')
rake("db:migrate")
rake("growlr:install:all")
run('capify .')
git :add => '.'
git :commit => '-a -m "After template application is complete."'
# Start up TextMate with the files I want to edit
run 'mate .'
run 'mate config/email.yml'
run 'mate app/views/layouts/application.html.haml'
run 'mate public/stylesheets/sass/colors.sass'
run 'mate public/stylesheets/sass/application.sass'
run 'mate config/database.yml'
run 'mate config/initializers/hoptoad.rb'
run 'mate config/routes.rb'