forked from lackac/app_lego
-
Notifications
You must be signed in to change notification settings - Fork 1
/
misc.rb
110 lines (93 loc) · 2.94 KB
/
misc.rb
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
# app files
file 'app/controllers/application_controller.rb',
%q{class ApplicationController < ActionController::Base
helper :all
protect_from_forgery
filter_parameter_logging "password" unless Rails.env.development?
end
}
file 'app/helpers/application_helper.rb',
%q{module ApplicationHelper
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
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
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
!!!
%html{html_attrs}
%head
%meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}
%link{ :rel => "shortcut icon", :href => "/favicon.ico", :type => "image/x-icon"}
%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}
#header
= render :partial => 'layouts/flashes
.container= 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
<!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 '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 %>">
<div id="header">
<%= render :partial => 'layouts/flashes' -%>
</div>
<div class="container">
<%= yield %>
</div>
</body>
</html>
ERB
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'"