Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

A new application now comes with a layout and a stylesheet.

  • Loading branch information...
commit ea2c5fa8046e2f953b366adc94f0610ccfea0828 1 parent 4eab983
@josevalim josevalim authored
Showing with 28 additions and 67 deletions.
  1. +2 −0  railties/CHANGELOG
  2. +0 −2  railties/lib/rails/generators.rb
  3. +0 −6 railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb
  4. +0 −17 railties/lib/rails/generators/erb/scaffold/templates/layout.html.erb
  5. +1 −1  railties/lib/rails/generators/rails/app/app_generator.rb
  6. +1 −0  railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb
  7. 0  railties/lib/rails/generators/rails/app/templates/app/views/layouts/.empty_directory
  8. +17 −0 railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb
  9. 0  railties/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory
  10. 0  ...nerators/rails/{stylesheets/templates/scaffold.css → app/templates/public/stylesheets/application.css}
  11. +0 −1  railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb
  12. +0 −5 railties/lib/rails/generators/rails/stylesheets/USAGE
  13. +0 −9 railties/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb
  14. +7 −0 railties/test/generators/app_generator_test.rb
  15. +0 −1  railties/test/generators/scaffold_controller_generator_test.rb
  16. +0 −8 railties/test/generators/scaffold_generator_test.rb
  17. +0 −17 railties/test/generators/stylesheets_generator_test.rb
View
2  railties/CHANGELOG
@@ -1,3 +1,5 @@
+* A new application now comes with a layout and a stylesheet. [JV]
+
* Renamed config.cookie_secret to config.secret_token and pass it as env key. [JV]
*Rails 3.0.0 [beta 2] (April 1st, 2010)*
View
2  railties/lib/rails/generators.rb
@@ -26,7 +26,6 @@ module Generators
:orm => '-o',
:resource_controller => '-c',
:scaffold_controller => '-c',
- :stylesheets => '-y',
:template_engine => '-e',
:test_framework => '-t'
},
@@ -56,7 +55,6 @@ module Generators
:resource_controller => :controller,
:scaffold_controller => :scaffold_controller,
:singleton => false,
- :stylesheets => true,
:test_framework => nil,
:template_engine => :erb
},
View
6 railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb
@@ -25,12 +25,6 @@ def copy_view_files
end
end
- def copy_layout_file
- return unless options[:layout]
- template filename_with_extensions(:layout),
- File.join("app/views/layouts", controller_class_path, filename_with_extensions(controller_file_name))
- end
-
protected
def available_views
View
17 railties/lib/rails/generators/erb/scaffold/templates/layout.html.erb
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title><%= controller_class_name %>: <%%= controller.action_name %></title>
- <%%= stylesheet_link_tag 'scaffold' %>
- <%%= javascript_include_tag :defaults %>
- <%%= csrf_meta_tag %>
-</head>
-<body>
-
-<p class="notice"><%%= notice %></p>
-<p class="alert"><%%= alert %></p>
-
-<%%= yield %>
-
-</body>
-</html>
View
2  railties/lib/rails/generators/rails/app/app_generator.rb
@@ -137,7 +137,7 @@ def create_public_image_files
end
def create_public_stylesheets_files
- empty_directory_with_gitkeep "public/stylesheets"
+ directory "public/stylesheets"
end
def create_prototype_files
View
1  railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb
@@ -1,3 +1,4 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+ layout 'application'
end
View
0  railties/lib/rails/generators/rails/app/templates/app/views/layouts/.empty_directory
No changes.
View
17 railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title><%= controller_name.humanize %>: <%= action_name %></title>
+ <%= stylesheet_link_tag 'application' %>
+ <%= javascript_include_tag :defaults %>
+ <%= csrf_meta_tag %>
+</head>
+<body>
+
+<p class="notice"><%= notice %></p>
+<p class="alert"><%= alert %></p>
+
+<%= yield %>
+
+</body>
+</html>
View
0  railties/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory
No changes.
View
0  .../rails/stylesheets/templates/scaffold.css → ...plates/public/stylesheets/application.css
File renamed without changes
View
1  railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb
@@ -7,7 +7,6 @@ class ScaffoldGenerator < ResourceGenerator #metagenerator
remove_class_option :actions
hook_for :scaffold_controller, :required => true
- hook_for :stylesheets
end
end
end
View
5 railties/lib/rails/generators/rails/stylesheets/USAGE
@@ -1,5 +0,0 @@
-Description:
- Copies scaffold stylesheets to public/stylesheets/.
-
-Examples:
- `rails generate stylesheets`
View
9 railties/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb
@@ -1,9 +0,0 @@
-module Rails
- module Generators
- class StylesheetsGenerator < Base
- def copy_stylesheets_file
- template "scaffold.css", "public/stylesheets/scaffold.css" if behavior == :invoke
- end
- end
- end
-end
View
7 railties/test/generators/app_generator_test.rb
@@ -51,6 +51,13 @@ def test_application_skeleton_is_created
).each{ |path| assert_file path }
end
+ def test_application_controller_and_layout_files
+ run_generator
+ assert_file "app/controllers/application_controller.rb", /layout 'application'/
+ assert_file "app/views/layouts/application.html.erb", /stylesheet_link_tag 'application'/
+ assert_file "public/stylesheets/application.css"
+ end
+
def test_name_collision_raises_an_error
content = capture(:stderr){ run_generator [File.join(destination_root, "generate")] }
assert_equal "Invalid application name generate. Please give a name which does not match one of the reserved rails words.\n", content
View
1  railties/test/generators/scaffold_controller_generator_test.rb
@@ -66,7 +66,6 @@ def test_views_are_generated
new
show
).each { |view| assert_file "app/views/users/#{view}.html.erb" }
- assert_file "app/views/layouts/users.html.erb"
end
def test_functional_tests
View
8 railties/test/generators/scaffold_generator_test.rb
@@ -70,14 +70,10 @@ def test_scaffold_on_invoke
show
_form
).each { |view| assert_file "app/views/product_lines/#{view}.html.erb" }
- assert_file "app/views/layouts/product_lines.html.erb"
# Helpers
assert_file "app/helpers/product_lines_helper.rb"
assert_file "test/unit/helpers/product_lines_helper_test.rb"
-
- # Stylesheets
- assert_file "public/stylesheets/scaffold.css"
end
def test_scaffold_on_revoke
@@ -101,13 +97,9 @@ def test_scaffold_on_revoke
# Views
assert_no_file "app/views/product_lines"
- assert_no_file "app/views/layouts/product_lines.html.erb"
# Helpers
assert_no_file "app/helpers/product_lines_helper.rb"
assert_no_file "test/unit/helpers/product_lines_helper_test.rb"
-
- # Stylesheets (should not be removed)
- assert_file "public/stylesheets/scaffold.css"
end
end
View
17 railties/test/generators/stylesheets_generator_test.rb
@@ -1,17 +0,0 @@
-require 'generators/generators_test_helper'
-require 'rails/generators/rails/stylesheets/stylesheets_generator'
-
-class StylesheetsGeneratorTest < Rails::Generators::TestCase
- include GeneratorsTestHelper
-
- def test_copy_stylesheets
- run_generator
- assert_file "public/stylesheets/scaffold.css"
- end
-
- def test_stylesheets_are_not_deleted_on_revoke
- run_generator
- run_generator [], :behavior => :revoke
- assert_file "public/stylesheets/scaffold.css"
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.