diff --git a/CHANGELOG.md b/CHANGELOG.md index 99122bad..63b15580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ 3.1.0.rc.2 === +* Custom template classes can now override the file used for creating the project Gemfile. +* Add an "empty" template that produces the minimum necessary structure for a Middleman project. +* Fix ignoring layouts from the sitemap when the source directory has been set to something other than 'source'. #896 * Track test coverage with simplecov * i18n only autodetects languages in the `locales` root * Frontmatter cache fixes solve performance regressions found in 3.1.x @@ -22,7 +25,6 @@ 3.1.0.rc.1 === -* Fix ignoring layouts from the sitemap when the source directory has been set to something other than 'source'. #896 * Move more into core, autoloaded if gems are available. * DataStore may now be accessed like a hash with #[] and #has_key?. #880 * The i18n extension now supports providing localized templates as separate files, like index.es.html.haml. #816, #823 diff --git a/middleman-core/lib/middleman-core/sitemap.rb b/middleman-core/lib/middleman-core/sitemap.rb index 958d6427..88d2bbb9 100644 --- a/middleman-core/lib/middleman-core/sitemap.rb +++ b/middleman-core/lib/middleman-core/sitemap.rb @@ -29,11 +29,11 @@ module Middleman # Files starting with an dot, but not .htaccess :source_dotfiles => proc { |file| - file =~ %r{/\.} && file !~ %r{/\.(htaccess|htpasswd)} + file =~ %r{/\.} && file !~ %r{/\.ht(access|passwd)} }, # Files starting with an underscore, but not a double-underscore - :partials => proc { |file| file =~ %r{/_} && file !~ %r{/__} }, + :partials => proc { |file| file =~ %r{/_[^_]} }, :layout => proc { |file, app| file.start_with?(File.join(app.config[:source], 'layout.')) || file.start_with?(File.join(app.config[:source], 'layouts/')) diff --git a/middleman-core/lib/middleman-core/templates.rb b/middleman-core/lib/middleman-core/templates.rb index 336b81e0..dd9bb6c7 100644 --- a/middleman-core/lib/middleman-core/templates.rb +++ b/middleman-core/lib/middleman-core/templates.rb @@ -34,6 +34,12 @@ module Middleman::Templates source_paths << File.join(File.dirname(__FILE__), 'templates') end + # The gemfile template to use. Individual templates can define this class + # method to override the template path. + def self.gemfile_template + "shared/Gemfile.tt" + end + # Required path for the new project to be generated argument :location, :type => :string @@ -57,7 +63,7 @@ module Middleman::Templates # @return [void] def generate_bundler! return if options[:'skip-gemfile'] - template "shared/Gemfile.tt", File.join(location, "Gemfile") + template self.class.gemfile_template, File.join(location, "Gemfile") return if options[:'skip-bundle'] inside(location) do @@ -90,4 +96,7 @@ require "middleman-core/templates/mobile" require "middleman-more/templates/smacss" # Local templates -require "middleman-core/templates/local" \ No newline at end of file +require "middleman-core/templates/local" + +# Barebones template +require "middleman-core/templates/empty" diff --git a/middleman-core/lib/middleman-core/templates/empty.rb b/middleman-core/lib/middleman-core/templates/empty.rb new file mode 100644 index 00000000..c06ab262 --- /dev/null +++ b/middleman-core/lib/middleman-core/templates/empty.rb @@ -0,0 +1,23 @@ +# A barebones template with nothing much in it +class Middleman::Templates::Empty < Middleman::Templates::Base + + # Template files are relative to this file + # @return [String] + def self.source_root + File.dirname(__FILE__) + end + + def self.gemfile_template + "empty/Gemfile.tt" + end + + # Actually output the files + # @return [void] + def build_scaffold! + create_file File.join(location, "config.rb"), "\n" + empty_directory File.join(location, "source") + end +end + +# Register this template +Middleman::Templates.register(:empty, Middleman::Templates::Empty) diff --git a/middleman-core/lib/middleman-core/templates/empty/Gemfile.tt b/middleman-core/lib/middleman-core/templates/empty/Gemfile.tt new file mode 100644 index 00000000..463687c3 --- /dev/null +++ b/middleman-core/lib/middleman-core/templates/empty/Gemfile.tt @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem "middleman", "~><%= Middleman::VERSION %>"