updated from stable

remove_hooks
Thomas Reynolds 2014-08-14 10:14:26 -07:00
commit 0f785a448a
37 changed files with 208 additions and 21 deletions

View File

@ -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
===

View File

@ -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

View File

@ -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"'

View File

@ -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"

View File

@ -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 "<svg"
When I go to "/static_underscore.html"
Then I should see "<p>Hello World</p>"
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"

View File

@ -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 "<h1>Welcome to Slim</h1>"
Scenario: Slim Content For
Given the Server is running at "slim-content-for-app"
When I go to "/index.html"
Then I should not see "Content AContent B"
Then I should see "Content for A:Content A"
Then I should see "Content for main:Content Main"
Then I should see "Content for B:Content B"
Scenario: Rendering Scss in a Slim filter
Given an empty app
And a file named "config.rb" with:
"""
"""
And a file named "source/scss.html.slim" with:
"""
doctype 5
html lang='en'
head
meta charset="utf-8"
scss:
@mixin global-reset {
html, body, div {
padding: 0;
}
}
@include global-reset;
body
h1 Welcome to Slim
"""
And a file named "source/sass.html.slim" with:
"""
doctype 5
html lang='en'
head
meta charset="utf-8"
sass:
html, body, div
padding: 0
body
h1 Welcome to Slim
"""
And a file named "source/error.html.slim" with:
"""
doctype 5
html lang='en'
head
meta charset="utf-8"
scss:
+global-reset2
body
h1 Welcome to Slim
"""
And the Server is running at "empty_app"
When I go to "/scss.html"
Then I should see "html,body,div"
When I go to "/sass.html"
Then I should see "html,body,div"
When I go to "/error.html"
Then I should see "Syntax error"

View File

@ -0,0 +1 @@
<%= image_tag "blank.gif" %>

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

View File

@ -0,0 +1 @@
USA

View File

@ -0,0 +1 @@
Mexico

View File

@ -0,0 +1 @@
Locale Site

View File

@ -0,0 +1 @@
obama

View File

@ -0,0 +1 @@
nieto

View File

@ -0,0 +1 @@
District of Columbia

View File

@ -0,0 +1 @@
Distrito Federal

View File

@ -0,0 +1,6 @@
Site: <%= partial :site %>
Country: <%= partial :country %>
Greeting: <%= partial :greeting %>
State: <%= partial :state %>
Flag: <%= partial "images/flag.svg" %>
President: <%= partial "images/president.svg" %>

View File

@ -0,0 +1 @@
<p>Hello World</p>

View File

@ -0,0 +1 @@
<%= partial "code_snippet.html" %>

View File

@ -0,0 +1,7 @@
- content_for :a do
| Content A
| Content Main
- content_for :b do
| Content B

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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]

View File

@ -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)

View File

@ -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'

View File

@ -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

View File

@ -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'

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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'])