Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mazyar committed Apr 9, 2009
1 parent 128ea59 commit 75447a9
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 85 deletions.
8 changes: 8 additions & 0 deletions app_lego.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,10 @@
NAME=File.basename(root)

# environment options # environment options
@lego_options = ENV['LEGOS'] ? ENV['LEGOS'].downcase.split(/[,\s]+/) : false @lego_options = ENV['LEGOS'] ? ENV['LEGOS'].downcase.split(/[,\s]+/) : false
@used_legos = [] @used_legos = []



def use_lego?(lego, question) def use_lego?(lego, question)
use = if @lego_options use = if @lego_options
@lego_options.include?(lego) @lego_options.include?(lego)
Expand Down Expand Up @@ -33,12 +36,17 @@ def plugin(name, options)


modules = [ modules = [
["basic", "Do basic setup? (only exclude this if you already have a Rails app skeleton with Rails 2.3+ frozen, or as a gem)"], ["basic", "Do basic setup? (only exclude this if you already have a Rails app skeleton with Rails 2.3+ frozen, or as a gem)"],
["frozen_edge", "Freeze edge Rails?"],
["rspec", "Use RSpec instead of test/unit?"], ["rspec", "Use RSpec instead of test/unit?"],
["haml", "Use haml for views and sass for css?"], ["haml", "Use haml for views and sass for css?"],
["hoptoad", "Use Hoptoad error notifier?"],
["compass", "Use compass for CSS?"],
["jquery", "Use jQuery instead of Prototype + Script.aculo.us?"], ["jquery", "Use jQuery instead of Prototype + Script.aculo.us?"],
["jrails", "install jquery for rails plugin?"],
["auth", "Add authentication module?"], ["auth", "Add authentication module?"],
["couchdb", "Use CouchDB?"], ["couchdb", "Use CouchDB?"],
["locale", "Add specific localizations?"], ["locale", "Add specific localizations?"],
["layout", "Add basic layout?"],
["misc", "Add miscellaneous stuff (helpers, basic layout, flashes, initializers)?"], ["misc", "Add miscellaneous stuff (helpers, basic layout, flashes, initializers)?"],
] ]


Expand Down
10 changes: 0 additions & 10 deletions basic.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,14 +36,4 @@
git :add => "." git :add => "."
git :commit => "-a -m 'Setting up a new rails app. Copy config/database.yml.sample to config/database.yml and customize.'" git :commit => "-a -m 'Setting up a new rails app. Copy config/database.yml.sample to config/database.yml and customize.'"


# freeze edge rails
if respond_to?(:braid)
braid "git://github.com/rails/rails.git", "vendor/rails"
else
# Guess full Rails path
rails_path = Pathname.new($LOAD_PATH.find {|p| p =~ /railties/}.gsub(%r{/railties/.*}, '')).realpath
run "cp -r '#{rails_path}' vendor/rails"
run "rm -rf vendor/rails/.git"
end

log "initialized", "application structure" log "initialized", "application structure"
6 changes: 6 additions & 0 deletions compass.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,6 @@
gem 'chriseppstein-compass', :lib => 'compass', :version => '>= 0.3.4'

run "echo -e 'y\nn\n' | compass --rails -f blueprint"

git :add => "."
git :commit => "-a -m 'Added compass for css'"
15 changes: 15 additions & 0 deletions frozen_edge.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,15 @@
# freeze edge rails
if respond_to?(:braid)
braid "git://github.com/rails/rails.git", "vendor/rails"
else
# Guess full Rails path
rails_path = Pathname.new($LOAD_PATH.find {|p| p =~ /railties/}.gsub(%r{/railties/.*}, '')).realpath
run "cp -r '#{rails_path}' vendor/rails"
run "rm -rf vendor/rails/.git"
end

# commit changes
git :add => "."
git :commit => "-a -m 'frozen edge rails'"

log "rails", "edge frozen"
4 changes: 1 addition & 3 deletions haml.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,6 @@
gem 'haml', :version => '>= 2.1' gem 'haml', :version => '>= 2.1'
gem 'chriseppstein-compass', :lib => 'compass', :version => '>= 0.3.4'


run "haml --rails ." run "haml --rails ."
run "echo -e 'y\nn\n' | compass --rails -f blueprint"


git :add => "." git :add => "."
git :commit => "-a -m 'Added haml for views and compass for css'" git :commit => "-a -m 'Added haml for views'"
8 changes: 8 additions & 0 deletions hoptoad.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,8 @@
plugin 'hoptoad_notifier', :git => "git://github.com/thoughtbot/hoptoad_notifier"

hoptoad_key = ask("\nPlease enter your Hoptoad API key: ")
initializer "hoptoad.rb", <<-HOPTOAD
HoptoadNotifier.configure do |config|
config.api_key = '#{hoptoad_key}'
end
HOPTOAD
3 changes: 3 additions & 0 deletions jrails.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,3 @@
plugin "jrails", :git => "git://github.com/aaronchi/jrails"
plugin "jrails_in_place_editing", :git => "git://github.com/rakuto/jrails_in_place_editing"

58 changes: 58 additions & 0 deletions layout.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,58 @@
if File.exists?('vendor/plugins/haml')

file 'app/views/layouts/_flashes.html.haml', <<-HAML
#flash
- flash.each do |key, value|
%div{:id => "flash_\#{key}"}= value
HAML

file 'app/views/layouts/application.html.haml', <<-HAML
!!! XML
!!! Strict
%html{'xmlns' => 'http://www.w3.org/1999/xhtml', 'xml:lang' => 'en', 'lang' => 'en'}
%head
%meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}
%title= "\#{page_title + ' - ' unless page_title.blank?}\#{t(:app_name)}"
= stylesheet_link_tag 'screen.css', :media => 'screen, projection'
= stylesheet_link_tag 'print.css', :media => 'print'
/[if IE]
= stylesheet_link_tag 'ie.css', :media => 'screen, projection'
%body{:class => body_class}
= render :partial => 'layouts/flashes'
= yield
HAML

else

file 'app/views/layouts/_flashes.html.erb', <<-ERB
<div id="flash">
<% flash.each do |key, value| -%>
<div id="flash_<%= key %>"><%=h value %></div>
<% end -%>
</div>
ERB

file 'app/views/layouts/application.html.erb', <<-ERB
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title><%= page_title + ' - ' unless page_title.blank? %><%=t :app_name %></title>
<%= stylesheet_link_tag 'screen.css', :media => 'screen, projection' %>
<%= stylesheet_link_tag 'print.css', :media => 'print' %>
<!--[if IE]>
<%= stylesheet_link_tag 'ie.css', :media => 'screen, projection' %>
<![endif]-->
</head>
<body class="<%= body_class %>">
<%= render :partial => 'layouts/flashes' -%>
<%= yield %>
</body>
</html>
ERB

end


9 changes: 9 additions & 0 deletions locale.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,5 +31,14 @@ def uri_exists?(uri)
/(#\s*)?config.i18n.default_locale.*$/, /(#\s*)?config.i18n.default_locale.*$/,
"config.i18n.default_locale = '#{locales.first.gsub(/\.(yml|rb)$/, '')}'" "config.i18n.default_locale = '#{locales.first.gsub(/\.(yml|rb)$/, '')}'"


Dir['config/locales/*.*'].map {|f| File.basename(f).split(".").first}.uniq.each do |locale|
file "config/locales/#{locale}.app.yml", <<-YAML
#{locale}:
app_name: "#{NAME}"
YAML
end

git :rm => 'config/locales/en.yml'

git :add => "." git :add => "."
git :commit => "-a -m 'Added #{locales.join(",")} localizations'" git :commit => "-a -m 'Added #{locales.join(",")} localizations'"
77 changes: 5 additions & 72 deletions misc.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,15 +1,16 @@
# app files # app files
file 'app/controllers/application_controller.rb', file 'app/controllers/application_controller.rb', <<-APP
%q{class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
helper :all helper :all
protect_from_forgery protect_from_forgery
filter_parameter_logging "password" unless Rails.env.development? filter_parameter_logging "password" unless Rails.env.development?
#{"include HoptoadNotifier::Catcher" if File.exists?('vendor/plugins/hoptoad_notifier')}
end end
} APP


file 'app/helpers/application_helper.rb', file 'app/helpers/application_helper.rb',
%q{module ApplicationHelper %q{module ApplicationHelper
Expand All @@ -27,74 +28,6 @@ def body_class
end end
} }



Dir['config/locales/*.*'].map {|f| File.basename(f).split(".").first}.uniq.each do |locale|
file "config/locales/#{locale}.app.yml", <<-YAML
#{locale}:
app_name: "APP_NAME"
YAML
end

git :rm => 'config/locales/en.yml'

if File.exists?('vendor/plugins/haml')

file 'app/views/layouts/_flashes.html.haml', <<-HAML
#flash
- flash.each do |key, value|
%div{:id => "flash_\#{key}"}= value
HAML

file 'app/views/layouts/application.html.haml', <<-HAML
!!! XML
!!! Strict
%html{'xmlns' => 'http://www.w3.org/1999/xhtml', 'xml:lang' => 'en', 'lang' => 'en'}
%head
%meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}
%title= "\#{page_title + ' - ' unless page_title.blank?}\#{t(:app_name)}"
= stylesheet_link_tag 'screen.css', :media => 'screen, projection'
= stylesheet_link_tag 'print.css', :media => 'print'
/[if IE]
= stylesheet_link_tag 'ie.css', :media => 'screen, projection'
%body{:class => body_class}
= render :partial => 'layouts/flashes'
= yield
HAML

else

file 'app/views/layouts/_flashes.html.erb', <<-ERB
<div id="flash">
<% flash.each do |key, value| -%>
<div id="flash_<%= key %>"><%=h value %></div>
<% end -%>
</div>
ERB

file 'app/views/layouts/application.html.erb', <<-ERB
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title><%= page_title + ' - ' unless page_title.blank? %><%=t :app_name %></title>
<%= stylesheet_link_tag 'screen.css', :media => 'screen, projection' %>
<%= stylesheet_link_tag 'print.css', :media => 'print' %>
<!--[if IE]>
<%= stylesheet_link_tag 'ie.css', :media => 'screen, projection' %>
<![endif]-->
</head>
<body class="<%= body_class %>">
<%= render :partial => 'layouts/flashes' -%>
<%= yield %>
</body>
</html>
ERB

end


# initializers # initializers


initializer 'requires.rb', initializer 'requires.rb',
Expand All @@ -104,4 +37,4 @@ def body_class
} }


git :add => "." git :add => "."
git :commit => "-a -m 'Added basic ApplicationController, helpers, layout, flashes, app localizations, initializers'" git :commit => "-a -m 'Added basic ApplicationController, helpers, initializers'"
7 changes: 7 additions & 0 deletions rspec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@
# remove test dir # remove test dir
git :rm => '-r test' git :rm => '-r test'


file "spec/spec.opts", <<-OPTS
--colour
--format specdoc
--loadby mtime
--reverse
OPTS

git :add => "." git :add => "."
git :commit => "-a -m 'Added RSpec for testing'" git :commit => "-a -m 'Added RSpec for testing'"

0 comments on commit 75447a9

Please sign in to comment.