ghart-nifty-generators 0.3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +105 -0
- data/LICENSE +20 -0
- data/README.rdoc +107 -0
- data/Rakefile +15 -0
- data/TODO +7 -0
- data/lib/nifty_generators.rb +3 -0
- data/nifty-generators.gemspec +31 -0
- data/rails_generators/nifty_admin_scaffold/USAGE +51 -0
- data/rails_generators/nifty_admin_scaffold/lib/insert_commands.rb +31 -0
- data/rails_generators/nifty_admin_scaffold/nifty_admin_scaffold_generator.rb +238 -0
- data/rails_generators/nifty_admin_scaffold/templates/actions/create.rb +8 -0
- data/rails_generators/nifty_admin_scaffold/templates/actions/destroy.rb +5 -0
- data/rails_generators/nifty_admin_scaffold/templates/actions/edit.rb +3 -0
- data/rails_generators/nifty_admin_scaffold/templates/actions/index.rb +3 -0
- data/rails_generators/nifty_admin_scaffold/templates/actions/new.rb +3 -0
- data/rails_generators/nifty_admin_scaffold/templates/actions/show.rb +3 -0
- data/rails_generators/nifty_admin_scaffold/templates/actions/update.rb +8 -0
- data/rails_generators/nifty_admin_scaffold/templates/controller.rb +5 -0
- data/rails_generators/nifty_admin_scaffold/templates/fixtures.yml +9 -0
- data/rails_generators/nifty_admin_scaffold/templates/helper.rb +2 -0
- data/rails_generators/nifty_admin_scaffold/templates/migration.rb +16 -0
- data/rails_generators/nifty_admin_scaffold/templates/model.rb +3 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/rspec/actions/create.rb +11 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/rspec/actions/edit.rb +4 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/rspec/actions/index.rb +4 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/rspec/actions/new.rb +4 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/rspec/actions/show.rb +4 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/rspec/actions/update.rb +11 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/rspec/controller.rb +8 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/rspec/model.rb +7 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/shoulda/actions/create.rb +13 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/shoulda/actions/index.rb +6 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/shoulda/actions/new.rb +6 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/shoulda/actions/show.rb +6 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/shoulda/actions/update.rb +13 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/shoulda/controller.rb +5 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/shoulda/model.rb +7 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/testunit/actions/create.rb +11 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/testunit/actions/edit.rb +4 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/testunit/actions/index.rb +4 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/testunit/actions/new.rb +4 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/testunit/actions/show.rb +4 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/testunit/actions/update.rb +11 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/testunit/controller.rb +5 -0
- data/rails_generators/nifty_admin_scaffold/templates/tests/testunit/model.rb +7 -0
- data/rails_generators/nifty_admin_scaffold/templates/views/erb/_form.html.erb +10 -0
- data/rails_generators/nifty_admin_scaffold/templates/views/erb/edit.html.erb +3 -0
- data/rails_generators/nifty_admin_scaffold/templates/views/erb/index.html.erb +29 -0
- data/rails_generators/nifty_admin_scaffold/templates/views/erb/new.html.erb +3 -0
- data/rails_generators/nifty_admin_scaffold/templates/views/erb/show.html.erb +14 -0
- data/rails_generators/nifty_admin_scaffold/templates/views/haml/_form.html.haml +10 -0
- data/rails_generators/nifty_admin_scaffold/templates/views/haml/edit.html.haml +14 -0
- data/rails_generators/nifty_admin_scaffold/templates/views/haml/index.html.haml +26 -0
- data/rails_generators/nifty_admin_scaffold/templates/views/haml/new.html.haml +7 -0
- data/rails_generators/nifty_admin_scaffold/templates/views/haml/show.html.haml +12 -0
- data/rails_generators/nifty_authentication/USAGE +50 -0
- data/rails_generators/nifty_authentication/lib/insert_commands.rb +74 -0
- data/rails_generators/nifty_authentication/nifty_authentication_generator.rb +128 -0
- data/rails_generators/nifty_authentication/templates/authentication.rb +61 -0
- data/rails_generators/nifty_authentication/templates/authlogic_session.rb +2 -0
- data/rails_generators/nifty_authentication/templates/fixtures.yml +24 -0
- data/rails_generators/nifty_authentication/templates/migration.rb +20 -0
- data/rails_generators/nifty_authentication/templates/sessions_controller.rb +45 -0
- data/rails_generators/nifty_authentication/templates/sessions_helper.rb +2 -0
- data/rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb +39 -0
- data/rails_generators/nifty_authentication/templates/tests/rspec/user.rb +83 -0
- data/rails_generators/nifty_authentication/templates/tests/rspec/users_controller.rb +26 -0
- data/rails_generators/nifty_authentication/templates/tests/shoulda/sessions_controller.rb +40 -0
- data/rails_generators/nifty_authentication/templates/tests/shoulda/user.rb +85 -0
- data/rails_generators/nifty_authentication/templates/tests/shoulda/users_controller.rb +27 -0
- data/rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb +36 -0
- data/rails_generators/nifty_authentication/templates/tests/testunit/user.rb +88 -0
- data/rails_generators/nifty_authentication/templates/tests/testunit/users_controller.rb +23 -0
- data/rails_generators/nifty_authentication/templates/user.rb +42 -0
- data/rails_generators/nifty_authentication/templates/users_controller.rb +18 -0
- data/rails_generators/nifty_authentication/templates/users_helper.rb +2 -0
- data/rails_generators/nifty_authentication/templates/views/erb/login.html.erb +30 -0
- data/rails_generators/nifty_authentication/templates/views/erb/signup.html.erb +24 -0
- data/rails_generators/nifty_authentication/templates/views/haml/login.html.haml +30 -0
- data/rails_generators/nifty_authentication/templates/views/haml/signup.html.haml +24 -0
- data/rails_generators/nifty_config/USAGE +23 -0
- data/rails_generators/nifty_config/nifty_config_generator.rb +32 -0
- data/rails_generators/nifty_config/templates/config.yml +8 -0
- data/rails_generators/nifty_config/templates/load_config.rb +2 -0
- data/rails_generators/nifty_layout/USAGE +25 -0
- data/rails_generators/nifty_layout/lib/insert_commands.rb +43 -0
- data/rails_generators/nifty_layout/nifty_layout_generator.rb +55 -0
- data/rails_generators/nifty_layout/templates/helper.rb +22 -0
- data/rails_generators/nifty_layout/templates/layout.html.haml +26 -0
- data/rails_generators/nifty_layout/templates/stylesheet.sass +67 -0
- data/rails_generators/nifty_scaffold/USAGE +51 -0
- data/rails_generators/nifty_scaffold/nifty_scaffold_generator.rb +237 -0
- data/rails_generators/nifty_scaffold/templates/actions/create.rb +9 -0
- data/rails_generators/nifty_scaffold/templates/actions/destroy.rb +6 -0
- data/rails_generators/nifty_scaffold/templates/actions/edit.rb +3 -0
- data/rails_generators/nifty_scaffold/templates/actions/index.rb +3 -0
- data/rails_generators/nifty_scaffold/templates/actions/new.rb +3 -0
- data/rails_generators/nifty_scaffold/templates/actions/show.rb +3 -0
- data/rails_generators/nifty_scaffold/templates/actions/update.rb +9 -0
- data/rails_generators/nifty_scaffold/templates/controller.rb +3 -0
- data/rails_generators/nifty_scaffold/templates/fixtures.yml +9 -0
- data/rails_generators/nifty_scaffold/templates/helper.rb +2 -0
- data/rails_generators/nifty_scaffold/templates/migration.rb +16 -0
- data/rails_generators/nifty_scaffold/templates/model.rb +3 -0
- data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/create.rb +11 -0
- data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
- data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/edit.rb +4 -0
- data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/index.rb +4 -0
- data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/new.rb +4 -0
- data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/show.rb +4 -0
- data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/update.rb +11 -0
- data/rails_generators/nifty_scaffold/templates/tests/rspec/controller.rb +8 -0
- data/rails_generators/nifty_scaffold/templates/tests/rspec/model.rb +7 -0
- data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/create.rb +13 -0
- data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
- data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
- data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/index.rb +6 -0
- data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/new.rb +6 -0
- data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/show.rb +6 -0
- data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/update.rb +13 -0
- data/rails_generators/nifty_scaffold/templates/tests/shoulda/controller.rb +5 -0
- data/rails_generators/nifty_scaffold/templates/tests/shoulda/model.rb +7 -0
- data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/create.rb +11 -0
- data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
- data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/edit.rb +4 -0
- data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/index.rb +4 -0
- data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/new.rb +4 -0
- data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/show.rb +4 -0
- data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/update.rb +11 -0
- data/rails_generators/nifty_scaffold/templates/tests/testunit/controller.rb +5 -0
- data/rails_generators/nifty_scaffold/templates/tests/testunit/model.rb +7 -0
- data/rails_generators/nifty_scaffold/templates/views/erb/_form.html.erb +10 -0
- data/rails_generators/nifty_scaffold/templates/views/erb/edit.html.erb +14 -0
- data/rails_generators/nifty_scaffold/templates/views/erb/index.html.erb +29 -0
- data/rails_generators/nifty_scaffold/templates/views/erb/new.html.erb +7 -0
- data/rails_generators/nifty_scaffold/templates/views/erb/show.html.erb +20 -0
- data/rails_generators/nifty_scaffold/templates/views/haml/_form.html.haml +10 -0
- data/rails_generators/nifty_scaffold/templates/views/haml/edit.html.haml +14 -0
- data/rails_generators/nifty_scaffold/templates/views/haml/index.html.haml +25 -0
- data/rails_generators/nifty_scaffold/templates/views/haml/new.html.haml +7 -0
- data/rails_generators/nifty_scaffold/templates/views/haml/show.html.haml +20 -0
- data/tasks/deployment.rake +2 -0
- data/test/test_helper.rb +117 -0
- data/test/test_nifty_admin_scaffold_generator.rb +538 -0
- data/test/test_nifty_authentication_generator.rb +236 -0
- data/test/test_nifty_config_generator.rb +37 -0
- data/test/test_nifty_layout_generator.rb +47 -0
- data/test/test_nifty_scaffold_generator.rb +538 -0
- metadata +222 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
class <%= user_plural_class_name %>Controller < ApplicationController
|
2
|
+
def new
|
3
|
+
@<%= user_singular_name %> = <%= user_class_name %>.new
|
4
|
+
end
|
5
|
+
|
6
|
+
def create
|
7
|
+
@<%= user_singular_name %> = <%= user_class_name %>.new(params[:<%= user_singular_name %>])
|
8
|
+
if @<%= user_singular_name %>.save
|
9
|
+
<%- unless options[:authlogic] -%>
|
10
|
+
session[:<%= user_singular_name %>_id] = @<%= user_singular_name %>.id
|
11
|
+
<%- end -%>
|
12
|
+
flash[:notice] = "Thank you for signing up! You are now logged in."
|
13
|
+
redirect_to root_url
|
14
|
+
else
|
15
|
+
render :action => 'new'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%% title "Log in" %>
|
2
|
+
|
3
|
+
<p>Don't have an account? <%%= link_to "Sign up!", signup_path %></p>
|
4
|
+
|
5
|
+
<%- if options[:authlogic] -%>
|
6
|
+
<%% form_for @<%= session_singular_name %> do |f| %>
|
7
|
+
<%%= f.error_messages %>
|
8
|
+
<p>
|
9
|
+
<%%= f.label :username %><br />
|
10
|
+
<%%= f.text_field :username %>
|
11
|
+
</p>
|
12
|
+
<p>
|
13
|
+
<%%= f.label :password %><br />
|
14
|
+
<%%= f.password_field :password %>
|
15
|
+
</p>
|
16
|
+
<p><%%= f.submit "Log in" %></p>
|
17
|
+
<%% end %>
|
18
|
+
<%- else -%>
|
19
|
+
<%% form_tag <%= session_plural_name %>_path do %>
|
20
|
+
<p>
|
21
|
+
<%%= label_tag :login, "Username or Email Address" %><br />
|
22
|
+
<%%= text_field_tag :login, params[:login] %>
|
23
|
+
</p>
|
24
|
+
<p>
|
25
|
+
<%%= label_tag :password %><br />
|
26
|
+
<%%= password_field_tag :password %>
|
27
|
+
</p>
|
28
|
+
<p><%%= submit_tag "Log in" %></p>
|
29
|
+
<%% end %>
|
30
|
+
<%- end -%>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%% title "Sign up" %>
|
2
|
+
|
3
|
+
<p>Already have an account? <%%= link_to "Log in", login_path %>.</p>
|
4
|
+
|
5
|
+
<%% form_for @<%= user_singular_name %> do |f| %>
|
6
|
+
<%%= f.error_messages %>
|
7
|
+
<p>
|
8
|
+
<%%= f.label :username %><br />
|
9
|
+
<%%= f.text_field :username %>
|
10
|
+
</p>
|
11
|
+
<p>
|
12
|
+
<%%= f.label :email, "Email Address" %><br />
|
13
|
+
<%%= f.text_field :email %>
|
14
|
+
</p>
|
15
|
+
<p>
|
16
|
+
<%%= f.label :password %><br />
|
17
|
+
<%%= f.password_field :password %>
|
18
|
+
</p>
|
19
|
+
<p>
|
20
|
+
<%%= f.label :password_confirmation, "Confirm Password" %><br />
|
21
|
+
<%%= f.password_field :password_confirmation %>
|
22
|
+
</p>
|
23
|
+
<p><%%= f.submit "Sign up" %></p>
|
24
|
+
<%% end %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
- title "Log in"
|
2
|
+
|
3
|
+
%p== Don't have an account? #{link_to "Sign up!", signup_path}
|
4
|
+
|
5
|
+
<%- if options[:authlogic] -%>
|
6
|
+
- form_for @<%= session_singular_name %> do |f|
|
7
|
+
= f.error_messages
|
8
|
+
%p
|
9
|
+
= f.label :username
|
10
|
+
%br
|
11
|
+
= f.text_field :login
|
12
|
+
%p
|
13
|
+
= f.label :password
|
14
|
+
%br
|
15
|
+
= f.password_field :password
|
16
|
+
%p
|
17
|
+
= f.submit "Log in"
|
18
|
+
<%- else -%>
|
19
|
+
- form_tag <%= session_plural_name %>_path do
|
20
|
+
%p
|
21
|
+
= label_tag :login, "Username or Email Address"
|
22
|
+
%br
|
23
|
+
= text_field_tag :login, params[:login]
|
24
|
+
%p
|
25
|
+
= label_tag :password
|
26
|
+
%br
|
27
|
+
= password_field_tag :password
|
28
|
+
%p
|
29
|
+
= submit_tag "Log in"
|
30
|
+
<%- end -%>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
- title "Sign up"
|
2
|
+
|
3
|
+
%p== Already have an account? #{link_to "Log in", login_path}.
|
4
|
+
|
5
|
+
- form_for @<%= user_singular_name %> do |f|
|
6
|
+
= f.error_messages
|
7
|
+
%p
|
8
|
+
= f.label :username
|
9
|
+
%br
|
10
|
+
= f.text_field :username
|
11
|
+
%p
|
12
|
+
= f.label :email, "Email Address"
|
13
|
+
%br
|
14
|
+
= f.text_field :email
|
15
|
+
%p
|
16
|
+
= f.label :password
|
17
|
+
%br
|
18
|
+
= f.password_field :password
|
19
|
+
%p
|
20
|
+
= f.label :password_confirmation, "Confirm Password"
|
21
|
+
%br
|
22
|
+
= f.password_field :password_confirmation
|
23
|
+
%p
|
24
|
+
= f.submit "Sign up"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Description:
|
2
|
+
The nifty_config generator creates YAML file in your config
|
3
|
+
directory and an initializer to load this config. The config has a
|
4
|
+
separate section for each environment. This is a great place to put
|
5
|
+
any config settings you don't want in your app.
|
6
|
+
|
7
|
+
The config is loaded into a constant called APP_CONFIG by default,
|
8
|
+
this changes depending on the name you choose to pass the generator.
|
9
|
+
Use this constant to access the config settings like this.
|
10
|
+
|
11
|
+
APP_CONFIG[:some_setting]
|
12
|
+
|
13
|
+
|
14
|
+
Examples:
|
15
|
+
script/generate nifty_config
|
16
|
+
|
17
|
+
Config: config/app_config.yml
|
18
|
+
Initializer: config/initializers/load_app_config.rb
|
19
|
+
|
20
|
+
script/generate nifty_config passwords
|
21
|
+
|
22
|
+
Config: config/passwords_config.yml
|
23
|
+
Initializer: config/initializers/load_passwords_config.rb
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class NiftyConfigGenerator < Rails::Generator::Base
|
2
|
+
def initialize(runtime_args, runtime_options = {})
|
3
|
+
super
|
4
|
+
@name = @args.first || 'app'
|
5
|
+
end
|
6
|
+
|
7
|
+
def manifest
|
8
|
+
record do |m|
|
9
|
+
m.directory 'config/initializers'
|
10
|
+
|
11
|
+
m.template "load_config.rb", "config/initializers/load_#{file_name}_config.rb"
|
12
|
+
m.file "config.yml", "config/#{file_name}_config.yml"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def file_name
|
17
|
+
@name.underscore
|
18
|
+
end
|
19
|
+
|
20
|
+
def constant_name
|
21
|
+
@name.underscore.upcase
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
def banner
|
26
|
+
<<-EOS
|
27
|
+
Creates config and loader files.
|
28
|
+
|
29
|
+
USAGE: #{$0} #{spec.name} [config_name]
|
30
|
+
EOS
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Description:
|
2
|
+
The nifty_layout generator creates a basic layout, stylesheet and
|
3
|
+
helper which will give some structure to a starting Rails app.
|
4
|
+
|
5
|
+
The generator takes one argument which will be the name of the
|
6
|
+
layout and stylesheet files. If no argument is passed then it defaults
|
7
|
+
to "application".
|
8
|
+
|
9
|
+
The helper module includes some methods which can be called in any
|
10
|
+
template or partial to set variables to be used in the layout, such as
|
11
|
+
page title and javascript/stylesheet includes.
|
12
|
+
|
13
|
+
Examples:
|
14
|
+
script/generate nifty_layout
|
15
|
+
|
16
|
+
Layout: app/views/layouts/application.html.erb
|
17
|
+
Stylesheet: public/stylesheets/application.css
|
18
|
+
Helper: app/helpers/layout_helper.rb
|
19
|
+
|
20
|
+
|
21
|
+
script/generate nifty_layout admin
|
22
|
+
|
23
|
+
Layout: app/views/layouts/admin.html.erb
|
24
|
+
Stylesheet: public/stylesheets/admin.css
|
25
|
+
Helper: app/helpers/layout_helper.rb
|
@@ -0,0 +1,43 @@
|
|
1
|
+
Rails::Generator::Commands::Create.class_eval do
|
2
|
+
def insert_after(file, sentinel, line)
|
3
|
+
logger.insert "#{line} into #{file}"
|
4
|
+
unless options[:pretend]
|
5
|
+
gsub_file file, /(#{Regexp.escape(sentinel)})/mi do |match|
|
6
|
+
"#{match}\n #{line}"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def replace(file, str1, str2)
|
12
|
+
logger.replace "#{str1} with #{str2}"
|
13
|
+
unless options[:pretend]
|
14
|
+
gsub_file file, "#{str1}", "#{str2}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Rails::Generator::Commands::Destroy.class_eval do
|
20
|
+
def insert_after(file, sentinel, line)
|
21
|
+
logger.remove "#{line} from #{file}"
|
22
|
+
unless options[:pretend]
|
23
|
+
gsub_file file, "\n #{line}", ''
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def replace(file, str1, str2)
|
28
|
+
logger.restore "#{str2} from #{str1}"
|
29
|
+
unless options[:pretend]
|
30
|
+
gsub_file file, "#{str2}", "#{str2}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Rails::Generator::Commands::List.class_eval do
|
36
|
+
def insert_after(file, sentinel, line)
|
37
|
+
logger.insert "#{line} into #{file}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def replace(file, str1, str2)
|
41
|
+
logger.replace "#{str1} with #{str2}"
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
|
2
|
+
class NiftyLayoutGenerator < Rails::Generator::Base
|
3
|
+
def initialize(runtime_args, runtime_options = {})
|
4
|
+
super
|
5
|
+
@name = @args.first || 'application'
|
6
|
+
end
|
7
|
+
|
8
|
+
def manifest
|
9
|
+
record do |m|
|
10
|
+
if options[:compass]
|
11
|
+
m.directory 'app/stylesheets/partials'
|
12
|
+
m.file "stylesheet.sass", "app/stylesheets/partials/_#{file_name}.sass"
|
13
|
+
m.insert_after "app/stylesheets/screen.sass", "@import blueprint/modules/scaffolding.sass", "\n@import partials/#{file_name}.sass"
|
14
|
+
m.replace "app/stylesheets/screen.sass", "// +blueprint", "+blueprint"
|
15
|
+
elsif options[:haml]
|
16
|
+
m.directory 'public/stylesheets/sass'
|
17
|
+
m.file "stylesheet.sass", "public/stylesheets/sass/#{file_name}.sass"
|
18
|
+
else
|
19
|
+
m.directory 'public/stylesheets'
|
20
|
+
m.file "stylesheet.css", "public/stylesheets/#{file_name}.css"
|
21
|
+
end
|
22
|
+
|
23
|
+
m.directory 'app/views/layouts'
|
24
|
+
if options[:haml]
|
25
|
+
m.template "layout.html.haml", "app/views/layouts/#{file_name}.html.haml"
|
26
|
+
else
|
27
|
+
m.template "layout.html.erb", "app/views/layouts/#{file_name}.html.erb"
|
28
|
+
end
|
29
|
+
|
30
|
+
m.directory 'app/helpers'
|
31
|
+
m.file "helper.rb", "app/helpers/layout_helper.rb"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def file_name
|
36
|
+
@name.underscore
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def add_options!(opt)
|
42
|
+
opt.separator ''
|
43
|
+
opt.separator 'Options:'
|
44
|
+
opt.on("--haml", "Generate HAML for view, and SASS for stylesheet.") { |v| options[:haml] = v }
|
45
|
+
opt.on("--compass", "Use Compass for stylesheets.") { |v| options[:compass] = v }
|
46
|
+
end
|
47
|
+
|
48
|
+
def banner
|
49
|
+
<<-EOS
|
50
|
+
Creates generic layout, stylesheet, and helper files.
|
51
|
+
|
52
|
+
USAGE: #{$0} #{spec.name} [layout_name]
|
53
|
+
EOS
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# These helper methods can be called in your template to set variables to be used in the layout
|
2
|
+
# This module should be included in all views globally,
|
3
|
+
# to do so you may need to add this line to your ApplicationController
|
4
|
+
# helper :layout
|
5
|
+
module LayoutHelper
|
6
|
+
def title(page_title, show_title = true)
|
7
|
+
@content_for_title = page_title.to_s
|
8
|
+
@show_title = show_title
|
9
|
+
end
|
10
|
+
|
11
|
+
def show_title?
|
12
|
+
@show_title
|
13
|
+
end
|
14
|
+
|
15
|
+
def stylesheet(*args)
|
16
|
+
content_for(:head) { stylesheet_link_tag(*args) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def javascript(*args)
|
20
|
+
content_for(:head) { javascript_include_tag(*args) }
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
!!! Strict
|
2
|
+
%html{html_attrs}
|
3
|
+
|
4
|
+
%head
|
5
|
+
%title
|
6
|
+
= h(yield(:title) || "Untitled")
|
7
|
+
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
8
|
+
<% if options[:compass] %>
|
9
|
+
= stylesheet_link_tag 'compiled/screen.css', :media => 'screen, projection'
|
10
|
+
= stylesheet_link_tag 'compiled/print.css', :media => 'print'
|
11
|
+
/[if lt IE 8]
|
12
|
+
= stylesheet_link_tag 'compiled/ie.css', :media => 'screen, projection'
|
13
|
+
<% else %>
|
14
|
+
= stylesheet_link_tag '<%= file_name %>'
|
15
|
+
<% end %>
|
16
|
+
= yield(:head)
|
17
|
+
|
18
|
+
%body<% if options[:compass] %>#bp<% end %>
|
19
|
+
#container
|
20
|
+
- flash.each do |name, msg|
|
21
|
+
= content_tag :div, msg, :id => "flash_#{name}"
|
22
|
+
|
23
|
+
- if show_title?
|
24
|
+
%h2=h yield(:title)
|
25
|
+
|
26
|
+
= yield
|
@@ -0,0 +1,67 @@
|
|
1
|
+
!primary_color = #4B7399
|
2
|
+
|
3
|
+
body
|
4
|
+
:background-color = !primary_color
|
5
|
+
:font
|
6
|
+
:family Verdana, Helvetica, Arial
|
7
|
+
:size 14px
|
8
|
+
|
9
|
+
a
|
10
|
+
:color #0000FF
|
11
|
+
img
|
12
|
+
:border none
|
13
|
+
|
14
|
+
.clear
|
15
|
+
:clear both
|
16
|
+
:height 0
|
17
|
+
:overflow hidden
|
18
|
+
|
19
|
+
#container
|
20
|
+
:width 75%
|
21
|
+
:margin 0 auto
|
22
|
+
:background #fff
|
23
|
+
:padding 20px 40px
|
24
|
+
:border solid 1px black
|
25
|
+
:margin-top 20px
|
26
|
+
|
27
|
+
#flash_notice,
|
28
|
+
#flash_error
|
29
|
+
:padding 5px 8px
|
30
|
+
:margin 10px 0
|
31
|
+
|
32
|
+
#flash_notice
|
33
|
+
:background-color #CFC
|
34
|
+
:border solid 1px #6C6
|
35
|
+
|
36
|
+
#flash_error
|
37
|
+
:background-color #FCC
|
38
|
+
:border solid 1px #C66
|
39
|
+
|
40
|
+
.fieldWithErrors
|
41
|
+
:display inline
|
42
|
+
|
43
|
+
#errorExplanation
|
44
|
+
:width 400px
|
45
|
+
:border 2px solid #CF0000
|
46
|
+
:padding 0
|
47
|
+
:padding-bottom 12px
|
48
|
+
:margin-bottom 20px
|
49
|
+
:background-color #f0f0f0
|
50
|
+
h2
|
51
|
+
:text-align left
|
52
|
+
:padding 5px 5px 5px 15px
|
53
|
+
:margin 0
|
54
|
+
:font
|
55
|
+
:weight bold
|
56
|
+
:size 12px
|
57
|
+
:background-color #c00
|
58
|
+
:color #fff
|
59
|
+
p
|
60
|
+
:color #333
|
61
|
+
:margin-bottom 0
|
62
|
+
:padding 8px
|
63
|
+
ul
|
64
|
+
:margin 2px 24px
|
65
|
+
li
|
66
|
+
:font-size 12px
|
67
|
+
:list-style disc
|