diff --git a/CHANGELOG.md b/CHANGELOG.md index 724499e6..9d026e8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,22 @@ master * Remove old module-style extension support * Placed all `config.rb` evaluation inside the `ConfigContext` class +3.3.5 +=== + +* Update Padrino to ~> 0.12.3 (removed breadcrumb helper) +* Update compass-import-once to 1.0.5 +* Fix issue with Slim partials. #1327 + +3.3.4 +=== + +* Fix `automatic_alt_tags` error. #1341 +* `partial` now looks for i18n suffixed filenames. #1333 +* Allow excluding paths from `gzip`. #1268 +* Let LiveReload work on 404 pages. +* Update `listen` dependency. + 3.3.3 === diff --git a/Gemfile b/Gemfile index 7d0c73df..1668ca87 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ gem 'liquid', '>= 2.6', require: false gem 'stylus', '>= 1.0', require: false gem 'sinatra', '>= 1.4', require: false gem 'redcarpet', '>= 3.1', require: false unless RUBY_ENGINE == 'jruby' -gem 'asciidoctor', '>= 0.1', require: false +gem 'asciidoctor', '~> 0.1', require: false # For less, note there is no compatible JS runtime for windows gem 'therubyrhino', '>= 2.0', platforms: :jruby diff --git a/middleman-core/features/automatic_alt_tags.feature b/middleman-core/features/automatic_alt_tags.feature new file mode 100644 index 00000000..12e84459 --- /dev/null +++ b/middleman-core/features/automatic_alt_tags.feature @@ -0,0 +1,8 @@ +Feature: Automatically detect and insert image dimensions into tags + In order to speed up development and appease YSlow + + Scenario: Rendering an image with the feature enabled + Given "automatic_alt_tags" feature is "enabled" + And the Server is running at "automatic-alt-tags-app" + When I go to "/auto-image-sizes.html" + Then I should see 'alt="Blank"' \ No newline at end of file diff --git a/middleman-core/features/i18n_partials.feature b/middleman-core/features/i18n_partials.feature new file mode 100644 index 00000000..f4f947c0 --- /dev/null +++ b/middleman-core/features/i18n_partials.feature @@ -0,0 +1,23 @@ +Feature: i18n Partials + + Scenario: Running localize with the default config + Given a fixture app "i18n-test-app" + And a file named "config.rb" with: + """ + activate :i18n + """ + Given the Server is running at "i18n-test-app" + When I go to "/partials/index.html" + Then I should see "Country: USA" + Then I should see "State: District of Columbia" + Then I should see "Greeting: Hello" + Then I should see "Site: Locale Site" + Then I should see "Flag: stars" + Then I should see "President: obama" + When I go to "/es/partials/index.html" + Then I should see "Country: Mexico" + Then I should see "State: Distrito Federal" + Then I should see "Greeting: Hola" + Then I should see "Site: Locale Site" + Then I should see "Flag: bars" + Then I should see "President: nieto" \ No newline at end of file diff --git a/middleman-core/features/partials.feature b/middleman-core/features/partials.feature index 76a7e75a..965215a9 100644 --- a/middleman-core/features/partials.feature +++ b/middleman-core/features/partials.feature @@ -49,3 +49,9 @@ Feature: Provide Sane Defaults for Partial Behavior Given the Server is running at "partials-app" When I go to "/svg.html" Then I should see "
" + When I go to "/code_snippet.html" + Then I should see "File Not Found" + When I go to "/_code_snippet.html" + Then I should see "File Not Found" diff --git a/middleman-core/features/slim.feature b/middleman-core/features/slim.feature index 62471060..32c4a344 100644 --- a/middleman-core/features/slim.feature +++ b/middleman-core/features/slim.feature @@ -19,3 +19,63 @@ Feature: Support slim templating language And the Server is running at "empty_app" When I go to "/slim.html" Then I should see "Hello World
\ No newline at end of file diff --git a/middleman-core/fixtures/partials-app/source/static_underscore.html.erb b/middleman-core/fixtures/partials-app/source/static_underscore.html.erb new file mode 100644 index 00000000..911d816d --- /dev/null +++ b/middleman-core/fixtures/partials-app/source/static_underscore.html.erb @@ -0,0 +1 @@ +<%= partial "code_snippet.html" %> \ No newline at end of file diff --git a/middleman-core/fixtures/slim-content-for-app/config.rb b/middleman-core/fixtures/slim-content-for-app/config.rb new file mode 100755 index 00000000..e69de29b diff --git a/middleman-core/fixtures/slim-content-for-app/source/index.html.slim b/middleman-core/fixtures/slim-content-for-app/source/index.html.slim new file mode 100755 index 00000000..8a61ffff --- /dev/null +++ b/middleman-core/fixtures/slim-content-for-app/source/index.html.slim @@ -0,0 +1,7 @@ +- content_for :a do + | Content A + +| Content Main + +- content_for :b do + | Content B diff --git a/middleman-core/fixtures/slim-content-for-app/source/layouts/layout.slim b/middleman-core/fixtures/slim-content-for-app/source/layouts/layout.slim new file mode 100755 index 00000000..160a7646 --- /dev/null +++ b/middleman-core/fixtures/slim-content-for-app/source/layouts/layout.slim @@ -0,0 +1,15 @@ +doctype html +html + body + .test + | Content for A: + == yield_content :a + br + + | Content for main: + == yield + br + + | Content for B: + == yield_content :b + br diff --git a/middleman-core/lib/middleman-core/builder.rb b/middleman-core/lib/middleman-core/builder.rb index 0af4f471..0e745ea7 100644 --- a/middleman-core/lib/middleman-core/builder.rb +++ b/middleman-core/lib/middleman-core/builder.rb @@ -16,7 +16,7 @@ module Middleman def_delegator :@app, :logger # Sort order, images, fonts, js/css and finally everything else. - SORT_ORDER = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .ico .woff .otf .ttf .eot .js .css) + SORT_ORDER = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .webp .ico .woff .otf .ttf .eot .js .css) # Create a new Builder instance. # @param [Middleman::Application] app The app to build. diff --git a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb index 8c6b0ca2..39019beb 100644 --- a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb @@ -29,7 +29,6 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::RenderHelpers ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::NumberHelpers # ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::TranslationHelpers - ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::Breadcrumbs app.config.define_setting :relative_links, false, 'Whether to generate relative links instead of absolute ones' end diff --git a/middleman-core/lib/middleman-core/core_extensions/i18n.rb b/middleman-core/lib/middleman-core/core_extensions/i18n.rb index 3b24552b..896ccf3f 100644 --- a/middleman-core/lib/middleman-core/core_extensions/i18n.rb +++ b/middleman-core/lib/middleman-core/core_extensions/i18n.rb @@ -40,6 +40,33 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension def t(*args) ::I18n.t(*args) end + + def locate_partial(partial_name) + locals_dir = extensions[:i18n].options[:templates_dir] + + # Try /localizable + partials_path = File.join(locals_dir, partial_name) + + lang_suffix = current_resource.metadata[:locals] && current_resource.metadata[:locals][:lang] + + extname = File.extname(partial_name) + maybe_static = extname.length > 0 + suffixed_partial_name = if maybe_static + partial_name.sub(extname, ".#{lang_suffix}#{extname}") + else + "#{partial_name}.#{lang_suffix}" + end + + if lang_suffix + super(suffixed_partial_name) || + super(File.join(locals_dir, suffixed_partial_name)) || + super(partials_path) || + super + else + super(partials_path) || + super + end + end end Contract None => ArrayOf[Symbol] diff --git a/middleman-core/lib/middleman-core/extensions/asset_hash.rb b/middleman-core/lib/middleman-core/extensions/asset_hash.rb index ae4801c2..48ca8f92 100644 --- a/middleman-core/lib/middleman-core/extensions/asset_hash.rb +++ b/middleman-core/lib/middleman-core/extensions/asset_hash.rb @@ -1,7 +1,7 @@ require 'middleman-core/util' class Middleman::Extensions::AssetHash < ::Middleman::Extension - option :exts, %w(.jpg .jpeg .png .gif .js .css .otf .woff .eot .ttf .svg), 'List of extensions that get asset hashes appended to them.' + option :exts, %w(.jpg .jpeg .png .gif .webp .js .css .otf .woff .eot .ttf .svg), 'List of extensions that get asset hashes appended to them.' option :ignore, [], 'Regexes of filenames to skip adding asset hashes to' def initialize(app, options_hash={}, &block) diff --git a/middleman-core/lib/middleman-core/extensions/asset_host.rb b/middleman-core/lib/middleman-core/extensions/asset_host.rb index 07aac381..be161501 100644 --- a/middleman-core/lib/middleman-core/extensions/asset_host.rb +++ b/middleman-core/lib/middleman-core/extensions/asset_host.rb @@ -2,7 +2,7 @@ require 'middleman-core/middleware/inline_url_rewriter' class Middleman::Extensions::AssetHost < ::Middleman::Extension option :host, nil, 'The asset host to use or a Proc to determine asset host', required: true - option :exts, %w(.css .png .jpg .jpeg .svg .svgz .js .gif), 'List of extensions that get cache busters strings appended to them.' + option :exts, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif), 'List of extensions that get cache busters strings appended to them.' option :sources, %w(.htm .html .php .css .js), 'List of extensions that are searched for bustable assets.' option :ignore, [], 'Regexes of filenames to skip adding query strings to' diff --git a/middleman-core/lib/middleman-core/extensions/automatic_alt_tags.rb b/middleman-core/lib/middleman-core/extensions/automatic_alt_tags.rb index 84d23b13..dcbcb04c 100644 --- a/middleman-core/lib/middleman-core/extensions/automatic_alt_tags.rb +++ b/middleman-core/lib/middleman-core/extensions/automatic_alt_tags.rb @@ -1,19 +1,15 @@ # Automatic Image alt tags from image names extension class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension - def initialize(app, options_hash={}, &block) - super - end - helpers do # Override default image_tag helper to automatically insert alt tag # containing image name. - def image_tag(path) + def image_tag(path, params={}) unless path.include?('://') params[:alt] ||= '' real_path = path.dup - real_path = File.join(images_dir, real_path) unless real_path.start_with?('/') + real_path = File.join(config[:images_dir], real_path) unless real_path.start_with?('/') file = app.files.find(:source, real_path) @@ -26,7 +22,7 @@ class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension end end - super(path) + super(path, params) end end end diff --git a/middleman-core/lib/middleman-core/extensions/cache_buster.rb b/middleman-core/lib/middleman-core/extensions/cache_buster.rb index 24536f95..7cc41a36 100644 --- a/middleman-core/lib/middleman-core/extensions/cache_buster.rb +++ b/middleman-core/lib/middleman-core/extensions/cache_buster.rb @@ -1,6 +1,6 @@ # The Cache Buster extension class Middleman::Extensions::CacheBuster < ::Middleman::Extension - option :exts, %w(.css .png .jpg .jpeg .svg .svgz .js .gif), 'List of extensions that get cache busters strings appended to them.' + option :exts, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif), 'List of extensions that get cache busters strings appended to them.' option :sources, %w(.htm .html .php .css .js), 'List of extensions that are searched for bustable assets.' option :ignore, [], 'Regexes of filenames to skip adding query strings to' diff --git a/middleman-core/lib/middleman-core/extensions/relative_assets.rb b/middleman-core/lib/middleman-core/extensions/relative_assets.rb index f5e8a499..817119ca 100644 --- a/middleman-core/lib/middleman-core/extensions/relative_assets.rb +++ b/middleman-core/lib/middleman-core/extensions/relative_assets.rb @@ -1,6 +1,6 @@ # Relative Assets extension class Middleman::Extensions::RelativeAssets < ::Middleman::Extension - option :exts, %w(.css .png .jpg .jpeg .svg .svgz .js .gif .ttf .otf .woff), 'List of extensions that get cache busters strings appended to them.' + option :exts, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif .ttf .otf .woff), 'List of extensions that get cache busters strings appended to them.' option :sources, %w(.htm .html .css), 'List of extensions that are searched for relative assets.' option :ignore, [], 'Regexes of filenames to skip adding query strings to' diff --git a/middleman-core/lib/middleman-core/step_definitions/server_steps.rb b/middleman-core/lib/middleman-core/step_definitions/server_steps.rb index eccf3331..a2c0da39 100644 --- a/middleman-core/lib/middleman-core/step_definitions/server_steps.rb +++ b/middleman-core/lib/middleman-core/step_definitions/server_steps.rb @@ -101,6 +101,14 @@ Then /^I should not see content matching %r{(.*)}$/ do |expected| expect(@last_response.body).to_not match(expected) end +Then /^I should not see:$/ do |expected| + expect(@browser.last_response.body).to_not include(expected.chomp) +end + +Then /^the status code should be "([^\"]*)"$/ do |expected| + expect(@browser.last_response.status).to eq expected.to_i +end + Then /^I should see "([^\"]*)" lines$/ do |lines| expect(@last_response.body.chomp.split($/).length).to eq(lines.to_i) end diff --git a/middleman-core/lib/middleman-core/template_context.rb b/middleman-core/lib/middleman-core/template_context.rb index 38732719..921ebc3e 100644 --- a/middleman-core/lib/middleman-core/template_context.rb +++ b/middleman-core/lib/middleman-core/template_context.rb @@ -104,10 +104,11 @@ module Middleman raise ::Middleman::TemplateRenderer::TemplateNotFound, "Could not locate partial: #{name}" unless partial_file - r = sitemap.find_resource_by_path(sitemap.file_to_path(partial_file)) + source_path = sitemap.file_to_path(partial_file) + r = sitemap.find_resource_by_path(source_path) - if r && !r.template? - File.read(r.source_file[:full_path]) + if (r && !r.template?) || (Tilt[partial_file[:full_path]].nil? && partial_file[:full_path].exist?) + File.read(partial_file[:full_path]) else opts = options.dup locs = opts.delete(:locals) @@ -116,8 +117,6 @@ module Middleman end end - protected - # Locate a partial relative to the current path or the source dir, given a partial's path. # # @api private @@ -140,6 +139,7 @@ module Middleman [ [relative_dir.to_s, { preferred_engine: resource.source_file[:relative_path].extname[1..-1].to_sym }], [non_root], + [non_root, { try_static: true }], [relative_dir_no_underscore.to_s, { try_static: true }], [non_root_no_underscore, { try_static: true }] ].each do |args| @@ -147,9 +147,11 @@ module Middleman break if partial_file end - partial_file + partial_file || nil end + protected + # Render a path with locs, opts and contents block. # # @api private diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 2bced4f9..f8735917 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |s| # Helpers s.add_dependency('activesupport', ['~> 4.1.0']) - s.add_dependency("padrino-helpers", ['~> 0.12.1']) + s.add_dependency('padrino-helpers', ['~> 0.12.3']) # Watcher s.add_dependency('listen', ['>= 2.7.9', '< 3.0'])