Skip to content

Instantly share code, notes, and snippets.

@aaroncampos
Created June 26, 2009 18:23
Show Gist options
  • Save aaroncampos/136649 to your computer and use it in GitHub Desktop.
Save aaroncampos/136649 to your computer and use it in GitHub Desktop.
My Rails template using Haml, Compass, make_resourceful, shoulda and, optionally, heroku
# This template assumes you have the HAML and Compass gems installed.
run "haml --rails ."
run "compass --rails -f blueprint --sass-dir public/stylesheets/sass --css-dir public/stylesheets ."
run "rm public/index.html"
plugin 'jrails', :git => 'git://github.com/aaronchi/jrails.git'
plugin 'make_resourceful', :git => 'git://github.com/hcatlin/make_resourceful.git'
plugin 'shoulda', :git => 'git://github.com/thoughtbot/shoulda.git'
gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com'
file '.gitignore', <<-CODE
log
tmp
public/system
public/system/*
db/*.sqlite3
db/data.yml
.DS_Store
.eprj
*~
lib/tasks/cucumber.rake
#*#
.#*
TAGS
CODE
file 'app/helpers/application_helper.rb', <<-HELPER
module ApplicationHelper
def yield_authenticity_token
if protect_against_forgery?
<<-JAVASCRIPT
<script type='text/javascript'>
//<![CDATA[
window._auth_token_name = "\#{request_forgery_protection_token}";
window._auth_token = "\#{form_authenticity_token}";
//]]>
</script>
JAVASCRIPT
end
end
end
HELPER
file 'public/javascripts/application.js', <<-JS
// Behaviours
$(document).ready(function() {
// All non-GET requests will add the authenticity token
// if not already present in the data packet
$("body").bind("ajaxSend", function(elm, xhr, s) {
if (s.type == "GET") return;
if (s.data && s.data.match(new RegExp("\\b" + window._auth_token_name + "="))) return;
if (s.data) {
s.data = s.data + "&";
} else {
s.data = "";
// if there was no data, jQuery didn't set the content-type
xhr.setRequestHeader("Content-Type", s.contentType);
}
s.data = s.data + encodeURIComponent(window._auth_token_name)
+ "=" + encodeURIComponent(window._auth_token);
});
});
// All ajax requests will trigger the wants.js block
// of +respond_to do |wants|+ declarations
jQuery.ajaxSetup({
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")},
});
JS
generate(:cucumber)
# Git stuff
git :init
git :add => "."
git :commit => "-a -m 'Initial commit'"
run "heroku create" if yes?("Create Heroku app?")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment