From 410b6b37d1216881e3a97eb602bd8199948304d9 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sat, 3 Mar 2012 16:40:03 -0800 Subject: [PATCH] make sure html5 template has correct paths setup. Fixes #291 --- middleman-core/features/cli.feature | 1 + middleman-core/lib/middleman-core/cli/init.rb | 6 +++--- middleman-core/lib/middleman-core/templates.rb | 6 +++--- .../lib/middleman-core/templates/default.rb | 10 ++++++++++ .../lib/middleman-core/templates/html5.rb | 15 ++++++++++----- .../lib/middleman-core/templates/shared/config.tt | 12 ++++++------ 6 files changed, 33 insertions(+), 17 deletions(-) diff --git a/middleman-core/features/cli.feature b/middleman-core/features/cli.feature index a5fc1d46..caaa20ea 100644 --- a/middleman-core/features/cli.feature +++ b/middleman-core/features/cli.feature @@ -55,6 +55,7 @@ Feature: Middleman CLI Then the following files should not exist: | config.ru | | Gemfile | + And the file "config.rb" should contain "set :js_dir, 'js'" Then a directory named "source" should exist When I cd to "source" Then the following files should exist: diff --git a/middleman-core/lib/middleman-core/cli/init.rb b/middleman-core/lib/middleman-core/cli/init.rb index 8bf1394a..7fe19a3b 100644 --- a/middleman-core/lib/middleman-core/cli/init.rb +++ b/middleman-core/lib/middleman-core/cli/init.rb @@ -14,13 +14,13 @@ module Middleman::Cli :default => "default", :desc => "Use a project template: #{available_templates}" method_option "css_dir", - :default => "stylesheets", + # :default => "stylesheets", :desc => 'The path to the css files' method_option "js_dir", - :default => "javascripts", + # :default => "javascripts", :desc => 'The path to the javascript files' method_option "images_dir", - :default => "images", + # :default => "images", :desc => 'The path to the image files' method_option "rack", :type => :boolean, diff --git a/middleman-core/lib/middleman-core/templates.rb b/middleman-core/lib/middleman-core/templates.rb index 6d932b5f..9e3bd42d 100644 --- a/middleman-core/lib/middleman-core/templates.rb +++ b/middleman-core/lib/middleman-core/templates.rb @@ -36,13 +36,13 @@ module Middleman::Templates class_option :template, :default => "default" # What to call the directory which CSS will be searched for. - class_option :css_dir, :default => "stylesheets" + class_option :css_dir#, :default => "stylesheets" # What to call the directory which JS will be searched for. - class_option :js_dir, :default => "javascripts" + class_option :js_dir#, :default => "javascripts" # What to call the directory which images will be searched for. - class_option :images_dir, :default => "images" + class_option :images_dir#, :default => "images" # Output a config.ru file for Rack if --rack is passed class_option :rack, :type => :boolean, :default => false diff --git a/middleman-core/lib/middleman-core/templates/default.rb b/middleman-core/lib/middleman-core/templates/default.rb index 233acdde..47a901b5 100644 --- a/middleman-core/lib/middleman-core/templates/default.rb +++ b/middleman-core/lib/middleman-core/templates/default.rb @@ -1,6 +1,16 @@ # Default Middleman template class Middleman::Templates::Default < Middleman::Templates::Base + class_option "css_dir", + :default => "stylesheets", + :desc => 'The path to the css files' + class_option "js_dir", + :default => "javascripts", + :desc => 'The path to the javascript files' + class_option "images_dir", + :default => "images", + :desc => 'The path to the image files' + # Template files are relative to this file # @return [String] def self.source_root diff --git a/middleman-core/lib/middleman-core/templates/html5.rb b/middleman-core/lib/middleman-core/templates/html5.rb index d7872cda..7b2298e1 100644 --- a/middleman-core/lib/middleman-core/templates/html5.rb +++ b/middleman-core/lib/middleman-core/templates/html5.rb @@ -1,11 +1,16 @@ # HTML5 Boilerplate template class Middleman::Templates::Html5 < Middleman::Templates::Base - # Has different default paths - class_option :css_dir, :default => "css" - class_option :js_dir, :default => "js" - class_option :images_dir, :default => "img" - + class_option "css_dir", + :default => "css", + :desc => 'The path to the css files' + class_option "js_dir", + :default => "js", + :desc => 'The path to the javascript files' + class_option "images_dir", + :default => "img", + :desc => 'The path to the image files' + # Templates are relative to this file # @return [String] def self.source_root diff --git a/middleman-core/lib/middleman-core/templates/shared/config.tt b/middleman-core/lib/middleman-core/templates/shared/config.tt index 889e66a5..c7609f3d 100755 --- a/middleman-core/lib/middleman-core/templates/shared/config.tt +++ b/middleman-core/lib/middleman-core/templates/shared/config.tt @@ -47,22 +47,22 @@ # end # end -<% if options[:css_dir] != "stylesheets" -%> -set :css_dir, "<%= options[:css_dir] -%>" +<% if options[:css_dir] -%> +set :css_dir, '<%= options[:css_dir] -%>' <% else -%> # Change the CSS directory # set :css_dir, "alternative_css_directory" <% end -%> -<% if options[:js_dir] != "javascripts" -%> -set :js_dir, "<%= options[:js_dir] -%>" +<% if options[:js_dir] -%> +set :js_dir, '<%= options[:js_dir] -%>' <% else -%> # Change the JS directory # set :js_dir, "alternative_js_directory" <% end -%> -<% if options[:images_dir] != "images" -%> -set :images_dir, "<%= options[:images_dir] -%>" +<% if options[:images_dir] -%> +set :images_dir, '<%= options[:images_dir] -%>' <% else -%> # Change the images directory # set :images_dir, "alternative_image_directory"