hardbap (owner)

Fork Of

Revisions

gist: 82960 Download_button fork
public
Description:
a simple hack to use gists in your Rails 2.3 templates
Public Clone URL: git://gist.github.com/82960.git
Embed All Files: show embed
Ruby #
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
# SUPER DARING APP TEMPLATE 1.0
# Originally By Peter Cooper
# Modified by Jason Seifer
# Modified by Mike Breen
 
# I'm a big fan of the application templates in Rails 2.3 and I'm a big fan of Gist
# so I decided to do what Officer Reeses would do is this situation.
# (http://www.youtube.com/watch?v=ATHY05pbb8k)
#
# Instead of:
# file 'config/environment.rb', <<-END
# RAILS_GEM_VERSION = '2.3.0' unless defined? RAILS_GEM_VERSION
 
# # Bootstrap the Rails environment, frameworks, and default configuration
# require File.join(File.dirname(__FILE__), 'boot')
 
# Rails::Initializer.run do |config|
# config.load_paths += %W( \#\{RAILS_ROOT\}/app/presenters )
# # Only load the plugins named here, in the order given (default is alphabetical).
# # :all can be used as a placeholder for all plugins not explicitly named
# # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# # Activate observers that should always be running
# # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# config.action_controller.session = {
# :session_key => '_#{(1..6).map { |x| (65 + rand(26)).chr }.join}_session',
# :secret => '#{(1..40).map { |x| (65 + rand(26)).chr }.join}'
# }
# config.time_zone = 'UTC'
#
# end
#END
 
# I can do this:
# gist 82962, 'config/environment.rb'
 
# Just add this method to your template.
 
# === start
# Download a gist and create a new file in the Rails project. Specify the
# relative path from the RAILS_ROOT.
# (a shout out to defunkt's gist gem for showing me the way ;)
# ==== Example
#
# gist 6099, '.gitignore'
#
def gist(gist_id, filename, log_action=true)
  log 'gist', "#{gist_id} => #{filename}" if log_action
  file(filename, open('http://gist.github.com/%s.txt' % gist_id).read, false)
end
# === end
 
# Now on to the rest of our template...
 
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
run "rm -f public/javascripts/*"
 
# Download JQuery
inside('public/javascripts') do
  run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.3.min.js > jquery.js"
  run "curl -d 'version=1.6rc5&compression=jsmin&files%5B%5D=ui.core.js&files%5B%5D=ui.draggable.js&files%5B%5D=ui.droppable.js&files%5B%5D=ui.resizable.js&files%5B%5D=ui.selectable.js&files%5B%5D=ui.sortable.js&files%5B%5D=ui.accordion.js&files%5B%5D=ui.dialog.js&files%5B%5D=ui.slider.js&files%5B%5D=ui.tabs.js&files%5B%5D=ui.datepicker.js&files%5B%5D=ui.progressbar.js&files%5B%5D=effects.core.js&files%5B%5D=effects.blind.js&files%5B%5D=effects.bounce.js&files%5B%5D=effects.clip.js&files%5B%5D=effects.drop.js&files%5B%5D=effects.explode.js&files%5B%5D=effects.fold.js&files%5B%5D=effects.highlight.js&files%5B%5D=effects.pulsate.js&files%5B%5D=effects.scale.js&files%5B%5D=effects.shake.js&files%5B%5D=effects.slide.js&files%5B%5D=effects.transfer.js' http://ui.jquery.com/actions/download_builder.php -L > jqueryui.zip"
  run "curl -L http://ui.jquery.com/applications/themeroller/download.php?href=/applications/themeroller/css/parseTheme.css.php?ctl=themeroller > theme.zip"
  run "unzip theme.zip -d jquery-ui-theme"
  run "rm theme.zip"
  run "unzip jqueryui.zip"
  run "rm jqueryui.zip"
  run "rm -rf ui"
  run "find . -name \"jquery-ui*.js\" | xargs -I xxx mv xxx jquery-ui.js"
end
 
# Set up git repository
git :init
git :add => '.'
 
# Copy database.yml for distribution use
run "cp config/database.yml config/database.yml.example"
 
# Set up .gitignore files
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore}
 
# my .gitignore from http://gist.github.com/60999
gist 60999, '.gitignore'
 
inside('app') { run "mkdir presenters" }
 
run "rm config/environment.rb"
run "touch config/environment.rb"
 
# my config/environment.rb from http://gist.github.com/82962
gist 82962, 'config/environment.rb'
 
# Install submoduled plugins
plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git', :submodule => true
plugin 'role_requirement', :git => 'git://github.com/timcharper/role_requirement.git', :submodule => true
plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => false
plugin 'forgot_password', :git => 'git://github.com/greenisus/forgot_password', :submodule => false
 
# Install all gems
gem 'rack' # remove when edge rails fixes..
gem 'active_presenter'
# gem 'RedCloth', :lib => 'redcloth'
gem 'hpricot', :source => 'http://code.whytheluckystiff.net'
gem 'webrat'
gem 'mislav-will_paginate', :version => '~> 2.2.3', :lib => 'will_paginate', :source => 'http://gems.github.com'
gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com'
gem 'thoughtbot-shoulda', :lib => 'shoulda', :source => 'http://gems.github.com'
gem 'jeremymcanally-context', :lib => 'context', :source => 'http://gems.github.com'
rake('gems:install', :sudo => true)
rake('gems:unpack')
 
# Set up sessions, RSpec, user model, OpenID, etc, and run migrations
generate("authenticated", "user session")
generate("roles", "Role User")
generate('forgot_password', 'password user')
rake('db:migrate')
 
run "touch test/factories.rb"
 
# Initialize submodules
git :submodule => "init"
 
# Commit all work so far to the repository
git :add => '.'
git :commit => "-a -m 'Initial commit'"
 
# Success!
puts "SUCCESS!"