From 89884c194af77f5324509db1d14e20f45fc106e0 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Thu, 14 Apr 2011 21:32:18 +0800 Subject: Update scaffold controller to generate scss file if Sass is available --- .../rails/stylesheets/stylesheets_generator.rb | 16 +++++- .../rails/stylesheets/templates/scaffold.css.scss | 58 ++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 railties/lib/rails/generators/rails/stylesheets/templates/scaffold.css.scss (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb b/railties/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb index 12bd3920f8..d06db25292 100644 --- a/railties/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb +++ b/railties/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb @@ -2,7 +2,21 @@ module Rails module Generators class StylesheetsGenerator < Base def copy_stylesheets_file - template "scaffold.css", "app/assets/stylesheets/scaffold.css" if behavior == :invoke + if behavior == :invoke + template "scaffold.#{stylesheet_extension}", "app/assets/stylesheets/scaffold.#{stylesheet_extension}" + end + end + + private + def stylesheet_extension + using_sass? ? "css.scss" : "css" + end + + def using_sass? + require 'sass' + defined?(Sass) + rescue LoadError + false end end end diff --git a/railties/lib/rails/generators/rails/stylesheets/templates/scaffold.css.scss b/railties/lib/rails/generators/rails/stylesheets/templates/scaffold.css.scss new file mode 100644 index 0000000000..45116b53f6 --- /dev/null +++ b/railties/lib/rails/generators/rails/stylesheets/templates/scaffold.css.scss @@ -0,0 +1,58 @@ +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; + &:visited { color: #666; } + &:hover { color: #fff; background-color:#000; } +} + +div.field, div.actions { + margin-bottom: 10px; +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; + } + + ul li { + font-size: 12px; + list-style: square; + } +} \ No newline at end of file -- cgit v1.2.3