Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
153 lines (130 sloc) 4.52 KB
load_template File.join(File.dirname(template), "base.rb") unless defined? AppLego::Base
# app files
=begin
file 'app/controllers/application_controller.rb',
%q{class ApplicationController < ActionController::Base
helper :all
protect_from_forgery
filter_parameter_logging "password" unless Rails.env.development?
#{"include HoptoadNotifier::Catcher" if File.exists?('vendor/plugins/hoptoad_notifier')}
end
}
=end
file_insert 'app/helpers/application_helper.rb', {:after => "module ApplicationHelper"}, %q{
def page_title(title=nil)
if title.nil?
@page_title ||= ""
else
@page_title = title
end
end
def body_class
"#{controller.controller_name} #{controller.controller_name}_#{controller.action_name}"
end
}
# layout
# Detect whether stylesheets are placed in compiled directory
stylesheet_path_prefix = File.exists?('public/stylesheets/compiled') ? 'compiled/' : ''
if use_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
!!!
%html{html_attrs}
%head
%meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}
%meta{:name => "description", :content => "A Ruby on Rails application generated by app_lego templates"}
%link{:rel => "shortcut icon", :href => "/favicon.ico", :type => "image/x-icon"}
%title= "\#{page_title + ' - ' unless page_title.blank?}\#{t(:app_name)}"
= stylesheet_link_tag '#{stylesheet_path_prefix}screen.css', :media => 'screen, projection'
= stylesheet_link_tag '#{stylesheet_path_prefix}print.css', :media => 'print'
/[if IE]
= stylesheet_link_tag '#{stylesheet_path_prefix}ie.css', :media => 'screen, projection'
= javascript_include_tag :defaults
%body{:class => body_class}
#container
#header
%h1{:title => t(:app_name)}=h t(:app_name)
/ insert header content
#sidebar
/ insert sidebar content
#content
= render :partial => 'layouts/flashes'
= yield
#footer
/ insert footer content
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<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 '#{stylesheet_path_prefix}screen.css', :media => 'screen, projection' %>
<%= stylesheet_link_tag '#{stylesheet_path_prefix}print.css', :media => 'print' %>
<!--[if IE]>
<%= stylesheet_link_tag '#{stylesheet_path_prefix}ie.css', :media => 'screen, projection' %>
<![endif]-->
<%= javascript_include_tag :defaults %>
</head>
<body class="<%= body_class %>">
<div id="container">
<div id="header">
<h1 title="#{t(:app_name)}"><%=h t(:app_name) %></h1>
<!-- insert header content -->
</div>
<div id="sidebar">
<!-- insert sidebar content -->
</div>
<div class="main">
<%= render :partial => 'layouts/flashes' -%>
<%= yield %>
</div>
<div id="footer">
<!-- insert footer content -->
</div>
</div
</body>
</html>
ERB
end
# convert all app/views/*/*.html.erb to .haml (html2haml) if use_haml?
# TODO test this!!!
if use_haml?
# rename views
Dir['app/views/*/*.html.erb'].each do |erb|
run "html2haml #{erb} #{File.basename(erb) << '.haml'}"
git :rm => erb
end
if use_rspec?
# fix view specs to use *.html.haml instead of *.html.erb
Dir['spec/views/*/*.html.erb_spec.rb'].each do |erb_test_file|
haml_test_file = erb_test_file.gsub(".html.erb_spec.rb", ".html.haml_spec.rb")
git :mv => "#{erb_test_file} #{haml_test_file}"
gsub_file haml_test_file, /(\.html\.erb)/mi, ".html.haml"
end
end
end
# initializers
initializer 'requires.rb',
%q{Dir[Rails.root.join('lib', '*.rb')].each do |f|
require f
end
}
gem 'quietbacktrace', :env => %w[development test]
gem 'capistrano'
rake "gems:install", :sudo=>true
capify!
git :add => "."
git :commit => "-a -m 'Added basic ApplicationController, helpers, layout, flashes, app localizations, initializers, capistrano'"
Jump to Line
Something went wrong with that request. Please try again.