Skip to content

Commit 8245835

Browse files
author
Danny Smith
committed
Split into new files, added a bunch of useful stuff.
1 parent 454a235 commit 8245835

File tree

5 files changed

+147
-50
lines changed

5 files changed

+147
-50
lines changed

.DS_Store

6 KB
Binary file not shown.

README.markdown

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
Rails Templates
22
===============
33

4-
This repository contains the rails templates that I'm using to create new rails projects.
4+
This repository contains the rails templates that I'm using to create new rails projects.
5+
6+
== base.rb
7+
Sets up Authentication, git and a bunch of other stuff.
8+
9+
==heroku.rb
10+
Sets up a heroku account along with support for Paperclip on S3 hosting and email support.

base.rb

+66-48
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,84 @@
1-
#Clear out todo and generate a nifty layout
2-
run "echo TODO > README"
3-
generate :nifty_layout
4-
1+
#Ask questions.
2+
3+
description = ask("Please provide a short description of your Project")
4+
5+
if yes?("Use Autlogic?")
6+
using_authlogic = true
7+
user_model_name = ask("What do you want a user to be called?")
8+
else
9+
if yes?("Use nifty-auth without authlogic?")
10+
using_nifty_authentication = true
11+
user_model_name = ask("What do you want a user to be called?")
12+
end
13+
end
14+
15+
#Set up Readme file formatted for GitHub with title and discription.
16+
file 'README.markdown', <<-CODE
17+
#{File.dirname(File.expand_path(__FILE__)).split("/")[-1].titleize}
18+
===
19+
20+
==Description
21+
#{description}
22+
23+
== Other Stuff
24+
Blah...
25+
CODE
26+
527
#Install gems
6-
gem 'RedCloth', :lib => 'redcloth'
7-
gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'
28+
gem "haml"
29+
gem "authlogic" if using_authlogic
30+
31+
#gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'
832
rake "gems:install", :sudo => true
933

34+
#Install Plugins
35+
# Attachments with no extra database tables, only one library to install for image processing
36+
plugin 'paperclip', :git => "git://github.com/thoughtbot/paperclip.git"
37+
1038
#Initiate git repo & add gitignore rules
1139
git :init
12-
13-
file ".gitignore", <<-END
40+
41+
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
42+
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore}
43+
file '.gitignore', <<-END
1444
.DS_Store
1545
log/*.log
1646
tmp/**/*
1747
config/database.yml
1848
db/*.sqlite3
1949
END
20-
21-
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
50+
run "rm README"
51+
run "rm public/index.html"
52+
run "rm public/favicon.ico"
53+
run "rm public/robots.txt"
54+
2255
run "cp config/database.yml config/example_database.yml"
2356

24-
#Add initial stuff to git repo
25-
git :add => ".", :commit => "-m 'initial commit'"
26-
27-
#Add nifty authentication if needed
28-
if yes?("Do you want authentication?")
29-
name = ask("What do you want a user to be called?")
30-
generate :nifty_authentication, name
31-
rake "db:migrate"
32-
33-
git :add => ".", :commit => "-m 'adding authentication'"
34-
end
35-
36-
#Remove prototype files
37-
git :rm => "public/javascripts/controls.js"
38-
git :rm => "public/javascripts/dragdrop.js"
39-
git :rm => "public/javascripts/effects.js"
40-
git :rm => "public/javascripts/prototype.js"
41-
42-
inside('public/javascripts') do
43-
#and add jquery
44-
run "cp ~/current_libs/jquery/* ."
45-
git :add => ".", :commit => "-m 'switching prototype for jquery'"
46-
end
47-
48-
#Vendor rails
49-
if yes?("Vendor rails?")
50-
inside('vendor') do
51-
run "git clone git://github.com/rails/rails.git"
52-
end
53-
end
54-
5557
#Generate welcome controller for front page
5658
generate :controller, "welcome index"
5759
route "map.root :controller => 'welcome'"
58-
git :rm => "public/index.html"
59-
git :add => ".", :commit => "-m 'adding welcome controller'"
60+
run "rm public/index.html"
6061

61-
if yes?("Deploy to Heroku?") do
62-
heroku create --remote
63-
git push heroku master
64-
puts "\n\nTo push to heroku, use:\n\n\tgit push heroku master\n\nfollowed by\n\nheroku rake db:migrate"
62+
#Remove prototype files
63+
run "rm public/javascripts/controls.js"
64+
run "rm public/javascripts/dragdrop.js"
65+
run "rm public/javascripts/effects.js"
66+
run "rm public/javascripts/prototype.js"
67+
68+
#Add nifty authentication or authlogic if needed
69+
if using_authlogic
70+
generate :nifty_authentication, "--authlogic", user_model_name
71+
rake "db:migrate"
72+
git :add => ".", :commit => "-m 'adding authlogic authentication'"
73+
end
74+
75+
if using_nifty_authentication
76+
generate :nifty_authentication, user_model_name
77+
rake "db:migrate"
78+
git :add => ".", :commit => "-m 'adding nifty_layouts authentication'"
6579
end
66-
puts "\n\nTo push to github, use:\n\tgit push\n\n"
80+
81+
#Add initial stuff to git repo
82+
git :add => ".", :commit => "-m 'initial commit'"
83+
84+
puts "\nDon't forget to set up a github repository and set github as a remote by running\n\tgit remote add origin [email protected]:dannysmith/WHATEVER_THE_REPO_IS_CALLED.git\n\nAfter that, push to github using:\n\tgit push\n\n"

heroku.rb

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
load_template '/Users/danny/code/libs_and_repos/rails-templates/base.rb'
2+
3+
#Add Extra Stuff ------------
4+
#Add Plugins
5+
plugin 'sass_on_heroku', :git => 'git://github.com/heroku/sass_on_heroku.git'
6+
7+
#Add Gems File & Gems
8+
file '.gems', <<-CODE
9+
right_http_connection --version 1.2.4
10+
right_aws --version 1.10.0
11+
authlogic
12+
CODE
13+
14+
gem 'right_http_connection'
15+
gem 'right_aws'
16+
17+
#Adds Config File for Amazon S3.
18+
file 'config/s3.yml', <<-CODE
19+
access_key_id:
20+
secret_access_key:
21+
CODE
22+
23+
#Adds Fix for Paperclip
24+
initializer 'paperclip.rb', <<-CODE
25+
# config/initializers/paperclip.rb
26+
# Added by hand to fix imagemagick problem.
27+
28+
# initializer solution for paperclip + passenger combo
29+
# Paperclip::Attachment#post_process => "/tmp/stream.3916.0 is not recognized by the 'identify'
30+
# command" error.
31+
if RAILS_ENV == "development"
32+
Paperclip.options[:image_magick_path] = "/opt/local/bin"
33+
end
34+
CODE
35+
36+
#Adds Email Settings to config
37+
initializer 'email.rb', <<-CODE
38+
# Load mail configuration if not in test environment
39+
if RAILS_ENV == 'production'
40+
email_settings = YAML::load(File.open("\#{RAILS_ROOT}/config/email.yml"))
41+
ActionMailer::Base.smtp_settings = email_settings[RAILS_ENV] unless email_settings[RAILS_ENV].nil?
42+
end
43+
CODE
44+
45+
file 'config/email.yml', <<-CODE
46+
development:
47+
:address:
48+
:port: 25
49+
:authentication: login
50+
:user_name:
51+
:password:
52+
production:
53+
:address:
54+
:port: 25
55+
:authentication: login
56+
:user_name:
57+
:password:
58+
CODE
59+
60+
#Writes a few lines for email settings to the differenct enviroments config files.
61+
File.open('config/environments/test.rb', "a") {|f| f.write "\nconfig.action_mailer.delivery_method = :test" }
62+
File.open('config/environments/development.rb', "a") {|f| f.write "\nconfig.action_mailer.delivery_method = :test #:smtp" }
63+
File.open('config/environments/production.rb', "a") {|f| f.write "\nconfig.action_mailer.delivery_method = :smtp" }
64+
65+
git :add => "."
66+
git :commit => "-m 'setting up for heroku'"
67+
68+
#Create Heroku App --------------------------------
69+
run 'heroku create --remote'
70+
run 'git push heroku master'
71+
72+
73+
puts "\nTo push to heroku, use:\n\n\tgit push heroku master\n\nfollowed by\n\n\theroku rake db:migrate"
74+

tester.rb

-1
This file was deleted.

0 commit comments

Comments
 (0)