From 70d08a992c81fcda793fe8b110b557963d9810f9 Mon Sep 17 00:00:00 2001 From: Pablo Olmos de Aguilera Date: Sat, 11 Jun 2011 23:44:58 -0400 Subject: [PATCH 1/8] Add a template with the new syntax --- .../layout/templates/stylesheet.css.scss | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 lib/generators/nifty/layout/templates/stylesheet.css.scss diff --git a/lib/generators/nifty/layout/templates/stylesheet.css.scss b/lib/generators/nifty/layout/templates/stylesheet.css.scss new file mode 100644 index 0000000..c020093 --- /dev/null +++ b/lib/generators/nifty/layout/templates/stylesheet.css.scss @@ -0,0 +1,67 @@ +$primary_color: #4b7399; + +body { + background-color: $primary_color; + font: { + family: Verdana, Helvetica, Arial; + size: 14px; }; } + +a { + color: blue; + img { + border: none; } } + +.clear { + clear: both; + height: 0; + overflow: hidden; } + +#container { + width: 75%; + margin: 0 auto; + background: white; + padding: 20px 40px; + border: solid 1px black; + margin-top: 20px; } + +#flash_notice, +#flash_error { + padding: 5px 8px; + margin: 10px 0; } + +#flash_notice { + background-color: #ccffcc; + border: solid 1px #66cc66; } + +#flash_error { + background-color: #ffcccc; + border: solid 1px #cc6666; } + +.fieldWithErrors { + display: inline; } + +#errorExplanation { + width: 400px; + border: 2px solid #cf0000; + padding: 0; + padding-bottom: 12px; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + padding: 5px 5px 5px 15px; + margin: 0; + font: { + weight: bold; + size: 12px; }; + background-color: #cc0000; + color: white; } + p { + color: #333333; + margin-bottom: 0; + padding: 8px; } + ul { + margin: 2px 24px; + li { + font-size: 12px; + list-style: disc; } } } From 7778493cc4b4f1c1ffb3c1482444e76f68b6ffd0 Mon Sep 17 00:00:00 2001 From: Pablo Olmos de Aguilera Date: Sat, 11 Jun 2011 23:54:31 -0400 Subject: [PATCH 2/8] Change the stylesheet directory to be compatible with the new Rails 3.1 structure --- lib/generators/nifty/layout/USAGE | 4 ++-- lib/generators/nifty/layout/layout_generator.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/generators/nifty/layout/USAGE b/lib/generators/nifty/layout/USAGE index f94af0d..09b640d 100644 --- a/lib/generators/nifty/layout/USAGE +++ b/lib/generators/nifty/layout/USAGE @@ -14,12 +14,12 @@ Examples: rails generate nifty:layout Layout: app/views/layouts/application.html.erb - Stylesheet: public/stylesheets/application.css + Stylesheet: app/assets/stylesheets/application.css Helper: app/helpers/layout_helper.rb rails generate nifty:layout admin Layout: app/views/layouts/admin.html.erb - Stylesheet: public/stylesheets/admin.css + Stylesheet: app/assets/stylesheets/admin.css Helper: app/helpers/layout_helper.rb diff --git a/lib/generators/nifty/layout/layout_generator.rb b/lib/generators/nifty/layout/layout_generator.rb index abed99a..f5cf62f 100644 --- a/lib/generators/nifty/layout/layout_generator.rb +++ b/lib/generators/nifty/layout/layout_generator.rb @@ -10,10 +10,10 @@ class LayoutGenerator < Base def create_layout if options.haml? template 'layout.html.haml', "app/views/layouts/#{file_name}.html.haml" - copy_file 'stylesheet.sass', "public/stylesheets/sass/#{file_name}.sass" + copy_file 'stylesheet.sass', "app/assets/stylesheets/#{file_name}.sass" else template 'layout.html.erb', "app/views/layouts/#{file_name}.html.erb" - copy_file 'stylesheet.css', "public/stylesheets/#{file_name}.css" + copy_file 'stylesheet.css', "app/assets/stylesheets/#{file_name}.css" end copy_file 'layout_helper.rb', 'app/helpers/layout_helper.rb' copy_file 'error_messages_helper.rb', 'app/helpers/error_messages_helper.rb' From 1efc2c0b6274dd51a6f094e624fe52c3ff51961c Mon Sep 17 00:00:00 2001 From: Pablo Olmos de Aguilera Date: Sat, 18 Jun 2011 18:24:41 -0400 Subject: [PATCH 3/8] Modify cucumber features to reflect the new estructure --- features/nifty_layout.feature | 18 +++++++++++++----- lib/generators/nifty/layout/USAGE | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/features/nifty_layout.feature b/features/nifty_layout.feature index eea37f8..00a629b 100644 --- a/features/nifty_layout.feature +++ b/features/nifty_layout.feature @@ -10,11 +10,19 @@ Feature: Nifty Layout Generator Then I should see "h(page_title" in file "app/helpers/layout_helper.rb" And I should see file "app/helpers/layout_helper.rb" And I should see file "app/helpers/error_messages_helper.rb" - And I should see file "public/stylesheets/application.css" + And I should see file "app/assets/stylesheets/application.css" - Scenario: Generate named layout with haml and sass + Scenario Outline: Generate named layout with haml Given a new Rails app - When I run "rails g nifty:layout FooBar --haml -f" - Then I should see "stylesheet_link_tag "foo_bar"" in file "app/views/layouts/foo_bar.html.haml" - And I should see file "public/stylesheets/sass/foo_bar.sass" + When I run "rails g nifty:layout FooBar --