aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikachu.com>2011-04-14 21:32:18 +0800
committerDavid Heinemeier Hansson <david@loudthinking.com>2011-04-15 00:32:27 +0800
commit89884c194af77f5324509db1d14e20f45fc106e0 (patch)
tree5192904d77af864918fdec40fe7ab5ea611590fc /railties/lib
parent93641ed6c8c684f6b4db02b6c8a22fa9bc7f0eaf (diff)
downloadrails-89884c194af77f5324509db1d14e20f45fc106e0.tar.gz
rails-89884c194af77f5324509db1d14e20f45fc106e0.tar.bz2
rails-89884c194af77f5324509db1d14e20f45fc106e0.zip
Update scaffold controller to generate scss file if Sass is available
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb16
-rw-r--r--railties/lib/rails/generators/rails/stylesheets/templates/scaffold.css.scss58
2 files changed, 73 insertions, 1 deletions
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