diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-11-19 16:57:33 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-11-19 16:57:33 +0000 |
commit | bc6f0d2f30bb9b052d67e79d917bb6b8c6cfb1f8 (patch) | |
tree | 39871b46068029ba384388ce056a295969a56915 /railties | |
parent | 02adc49d72152a00a93423931f767f9cdb0ef15a (diff) | |
download | rails-bc6f0d2f30bb9b052d67e79d917bb6b8c6cfb1f8.tar.gz rails-bc6f0d2f30bb9b052d67e79d917bb6b8c6cfb1f8.tar.bz2 rails-bc6f0d2f30bb9b052d67e79d917bb6b8c6cfb1f8.zip |
Scaffold resource should have both a layout and a stylesheet [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5565 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
6 files changed, 104 insertions, 1 deletions
diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml b/railties/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml index b5ba9a4e99..5c1f304232 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +++ b/railties/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml @@ -1,5 +1,9 @@ -<html> +<!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" lang="en"> <head> + <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <title><%= controller_class_name %>: <%%= controller.action_name %></title> <%%= stylesheet_link_tag 'scaffold' %> </head> diff --git a/railties/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb b/railties/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb index b0d9af7033..112a7cf74f 100644 --- a/railties/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +++ b/railties/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb @@ -46,6 +46,10 @@ class ScaffoldResourceGenerator < Rails::Generator::NamedBase ) end + # Layout and stylesheet. + m.template('layout.rhtml', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.rhtml")) + m.template('style.css', 'public/stylesheets/scaffold.css') + m.template('model.rb', File.join('app/models', class_path, "#{file_name}.rb")) m.template( diff --git a/railties/lib/rails_generator/generators/components/scaffold_resource/templates/layout.rhtml b/railties/lib/rails_generator/generators/components/scaffold_resource/templates/layout.rhtml new file mode 100644 index 0000000000..5c1f304232 --- /dev/null +++ b/railties/lib/rails_generator/generators/components/scaffold_resource/templates/layout.rhtml @@ -0,0 +1,17 @@ +<!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" lang="en"> +<head> + <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> + <title><%= controller_class_name %>: <%%= controller.action_name %></title> + <%%= stylesheet_link_tag 'scaffold' %> +</head> +<body> + +<p style="color: green"><%%= flash[:notice] %></p> + +<%%= yield %> + +</body> +</html> diff --git a/railties/lib/rails_generator/generators/components/scaffold_resource/templates/style.css b/railties/lib/rails_generator/generators/components/scaffold_resource/templates/style.css new file mode 100644 index 0000000000..8f239a3597 --- /dev/null +++ b/railties/lib/rails_generator/generators/components/scaffold_resource/templates/style.css @@ -0,0 +1,74 @@ +body { background-color: #fff; color: #333; } + +body, p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { color: #000; } +a:visited { color: #666; } +a:hover { color: #fff; background-color:#000; } + +.fieldWithErrors { + padding: 2px; + background-color: red; + display: table; +} + +#errorExplanation { + width: 400px; + border: 2px solid red; + padding: 7px; + padding-bottom: 12px; + margin-bottom: 20px; + background-color: #f0f0f0; +} + +#errorExplanation h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + background-color: #c00; + color: #fff; +} + +#errorExplanation p { + color: #333; + margin-bottom: 0; + padding: 5px; +} + +#errorExplanation ul li { + font-size: 12px; + list-style: square; +} + +div.uploadStatus { + margin: 5px; +} + +div.progressBar { + margin: 5px; +} + +div.progressBar div.border { + background-color: #fff; + border: 1px solid grey; + width: 100%; +} + +div.progressBar div.background { + background-color: #333; + height: 18px; + width: 0%; +} + diff --git a/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_edit.rhtml b/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_edit.rhtml index 49b7953b78..bf165e02be 100644 --- a/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_edit.rhtml +++ b/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_edit.rhtml @@ -1,5 +1,7 @@ <h1>Editing <%= singular_name %></h1> +<%%= error_messages_for :<%= singular_name %> %> + <%% form_for(:<%= singular_name %>, :url => <%= singular_name %>_path(@<%= singular_name %>), :html => { :method => :put }) do |f| %> <% for attribute in attributes -%> <p> diff --git a/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_new.rhtml b/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_new.rhtml index 11d762b49a..b3b6f91453 100644 --- a/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_new.rhtml +++ b/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_new.rhtml @@ -1,5 +1,7 @@ <h1>New <%= singular_name %></h1> +<%%= error_messages_for :<%= singular_name %> %> + <%% form_for(:<%= singular_name %>, :url => <%= plural_name %>_path) do |f| %> <% for attribute in attributes -%> <p> |