Compare commits
No commits in common. "master" and "v4.1.11" have entirely different histories.
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,18 +1,6 @@
|
||||||
master
|
master
|
||||||
===
|
===
|
||||||
|
|
||||||
# 4.1.13
|
|
||||||
|
|
||||||
* Change how config options are passed to Thor. Removes new Thor warnings from #2017
|
|
||||||
|
|
||||||
# 4.1.12
|
|
||||||
|
|
||||||
* Fix broken `ignore { |p| true }` form.
|
|
||||||
|
|
||||||
# 4.1.11
|
|
||||||
|
|
||||||
* Upgrade to Rack 2.
|
|
||||||
|
|
||||||
# 4.1.10
|
# 4.1.10
|
||||||
|
|
||||||
* Fix unicode issues in URL deeplinks.
|
* Fix unicode issues in URL deeplinks.
|
||||||
|
|
5
Gemfile
5
Gemfile
|
@ -11,11 +11,6 @@ gem 'rspec', '~> 3.0', require: false
|
||||||
gem 'cucumber', '~> 2.0', require: false
|
gem 'cucumber', '~> 2.0', require: false
|
||||||
gem 'addressable', '~> 2.4.0', require: false
|
gem 'addressable', '~> 2.4.0', require: false
|
||||||
|
|
||||||
# Pry tools
|
|
||||||
gem 'pry'
|
|
||||||
gem 'pry-stack_explorer'
|
|
||||||
gem 'pry-rescue'
|
|
||||||
|
|
||||||
# Optional middleman dependencies, included for tests
|
# Optional middleman dependencies, included for tests
|
||||||
gem 'haml', '>= 4.0.5', require: false
|
gem 'haml', '>= 4.0.5', require: false
|
||||||
gem 'sassc', '~> 1.8', require: false
|
gem 'sassc', '~> 1.8', require: false
|
||||||
|
|
|
@ -25,10 +25,12 @@ module Middleman::Cli
|
||||||
if setting.default.is_a?(String) || setting.default.is_a?(NilClass)
|
if setting.default.is_a?(String) || setting.default.is_a?(NilClass)
|
||||||
base.class_option setting.key,
|
base.class_option setting.key,
|
||||||
type: :string,
|
type: :string,
|
||||||
|
default: :undefined,
|
||||||
desc: setting.description
|
desc: setting.description
|
||||||
elsif setting.default.is_a?(TrueClass) || setting.default.is_a?(FalseClass)
|
elsif setting.default.is_a?(TrueClass) || setting.default.is_a?(FalseClass)
|
||||||
base.class_option setting.key,
|
base.class_option setting.key,
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
|
default: :undefined,
|
||||||
desc: setting.description
|
desc: setting.description
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Middleman::Cli
|
||||||
default: false,
|
default: false,
|
||||||
desc: 'Print debug messages'
|
desc: 'Print debug messages'
|
||||||
class_option :instrument,
|
class_option :instrument,
|
||||||
type: :boolean,
|
type: :string,
|
||||||
default: false,
|
default: false,
|
||||||
desc: 'Print instrument messages'
|
desc: 'Print instrument messages'
|
||||||
class_option :profile,
|
class_option :profile,
|
||||||
|
@ -64,7 +64,7 @@ module Middleman::Cli
|
||||||
config[:mode] = :build
|
config[:mode] = :build
|
||||||
config[:show_exceptions] = false
|
config[:show_exceptions] = false
|
||||||
config[:cli_options] = cli_options.each_with_object({}) do |(k, v), sum|
|
config[:cli_options] = cli_options.each_with_object({}) do |(k, v), sum|
|
||||||
sum[k] = v
|
sum[k] = v unless v == :undefined
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Middleman::Cli
|
||||||
default: false,
|
default: false,
|
||||||
desc: 'Print debug messages'
|
desc: 'Print debug messages'
|
||||||
class_option :instrument,
|
class_option :instrument,
|
||||||
type: :boolean,
|
type: :string,
|
||||||
default: false,
|
default: false,
|
||||||
desc: 'Print instrument messages'
|
desc: 'Print instrument messages'
|
||||||
class_option :profile,
|
class_option :profile,
|
||||||
|
|
|
@ -3,60 +3,14 @@ Feature: Page IDs
|
||||||
Scenario: link_to works with blocks (erb)
|
Scenario: link_to works with blocks (erb)
|
||||||
Given the Server is running at "page-id-app"
|
Given the Server is running at "page-id-app"
|
||||||
When I go to "/index.html"
|
When I go to "/index.html"
|
||||||
Then I should see "I am: index"
|
Then I should see "I am: index.html"
|
||||||
And I should see "URL1: /fm.html"
|
And I should see "URL1: /fm.html"
|
||||||
And I should see "URL2: /2.html"
|
And I should see "URL2: /2.html"
|
||||||
And I should see 'URL3: <a href="/3.html">Hi</a>'
|
And I should see 'URL3: <a href="/3.html">Hi</a>'
|
||||||
And I should see 'URL4: <a href="/overwrites/from-default.html">Sym</a>'
|
And I should see 'URL4: <a href="/overwrites/from-default.html">Sym</a>'
|
||||||
And I should see 'URL5: <a href="/implicit.html">Imp</a>'
|
|
||||||
And I should see 'URL6: <a href="/folder/foldern.html">Foldern</a>'
|
|
||||||
And I should see 'URL7: <a href="/feed.xml">Feed</a>'
|
|
||||||
|
|
||||||
When I go to "/fm.html"
|
When I go to "/fm.html"
|
||||||
Then I should see "I am: frontmatter"
|
Then I should see "I am: frontmatter"
|
||||||
When I go to "/implicit.html"
|
|
||||||
Then I should see "I am: implicit"
|
|
||||||
When I go to "/feed.xml"
|
|
||||||
Then I should see "I am: feed.xml"
|
|
||||||
When I go to "/folder/foldern.html"
|
|
||||||
Then I should see "I am: folder/foldern"
|
|
||||||
|
|
||||||
When I go to "/1.html"
|
|
||||||
Then I should see "I am: page1"
|
|
||||||
When I go to "/2.html"
|
|
||||||
Then I should see "I am: page2"
|
|
||||||
When I go to "/3.html"
|
|
||||||
Then I should see "I am: page3"
|
|
||||||
|
|
||||||
When I go to "/overwrites/from-default.html"
|
|
||||||
Then I should see "I am: something-else"
|
|
||||||
|
|
||||||
When I go to "/overwrites/from-frontmatter.html"
|
|
||||||
Then I should see "I am: from_frontmatter"
|
|
||||||
|
|
||||||
Scenario: Override page ID derivation with a proc
|
|
||||||
Given a fixture app "page-id-app"
|
|
||||||
And app "page-id-app" is using config "proc"
|
|
||||||
And the Server is running at "page-id-app"
|
|
||||||
|
|
||||||
When I go to "/index.html"
|
|
||||||
Then I should see "I am: index.html-foo"
|
|
||||||
And I should see "URL1: /fm.html"
|
|
||||||
And I should see "URL2: /2.html"
|
|
||||||
And I should see 'URL3: <a href="/3.html">Hi</a>'
|
|
||||||
And I should see 'URL4: <a href="/overwrites/from-default.html">Sym</a>'
|
|
||||||
And I should see 'URL8: <a href="/implicit.html">Imp</a>'
|
|
||||||
And I should see 'URL9: <a href="/folder/foldern.html">Foldern</a>'
|
|
||||||
And I should see 'URL10: <a href="/feed.xml">Feed</a>'
|
|
||||||
|
|
||||||
When I go to "/fm.html"
|
|
||||||
Then I should see "I am: frontmatter"
|
|
||||||
When I go to "/implicit.html"
|
|
||||||
Then I should see "I am: implicit.html-foo"
|
|
||||||
When I go to "/feed.xml"
|
|
||||||
Then I should see "I am: feed.xml-foo"
|
|
||||||
When I go to "/folder/foldern.html"
|
|
||||||
Then I should see "I am: folder/foldern.html-foo"
|
|
||||||
|
|
||||||
When I go to "/1.html"
|
When I go to "/1.html"
|
||||||
Then I should see "I am: page1"
|
Then I should see "I am: page1"
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
%w(1 2 3).each do |n|
|
|
||||||
proxy "/#{n}.html", "/index.html", id: "page#{n}"
|
|
||||||
end
|
|
||||||
|
|
||||||
page "/overwrites/*", id: :"something-else"
|
|
||||||
|
|
||||||
config[:page_id_generator] = ->(path){ path + "-foo" }
|
|
|
@ -1 +0,0 @@
|
||||||
I am: <%= current_resource.page_id %>
|
|
|
@ -1 +0,0 @@
|
||||||
I am: <%= current_resource.page_id %>
|
|
|
@ -1 +0,0 @@
|
||||||
I am: <%= current_resource.page_id %>
|
|
|
@ -4,11 +4,3 @@ URL1: <%= url_for "frontmatter" %>
|
||||||
URL2: <%= url_for "page2" %>
|
URL2: <%= url_for "page2" %>
|
||||||
URL3: <%= link_to "Hi", "page3" %>
|
URL3: <%= link_to "Hi", "page3" %>
|
||||||
URL4: <%= link_to "Sym", :"something-else" %>
|
URL4: <%= link_to "Sym", :"something-else" %>
|
||||||
URL5: <%= link_to "Imp", :implicit %>
|
|
||||||
URL6: <%= link_to "Foldern", "folder/foldern" %>
|
|
||||||
URL7: <%= link_to "Feed", "feed.xml" %>
|
|
||||||
|
|
||||||
<%# If custom proc %>
|
|
||||||
URL8: <%= link_to "Imp", "implicit.html-foo" %>
|
|
||||||
URL9: <%= link_to "Foldern", "folder/foldern.html-foo" %>
|
|
||||||
URL10: <%= link_to "Feed", "feed.xml-foo" %>
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ module Middleman
|
||||||
|
|
||||||
app = ::Middleman::Application.new do
|
app = ::Middleman::Application.new do
|
||||||
config[:cli_options] = cli_options.each_with_object({}) do |(k, v), sum|
|
config[:cli_options] = cli_options.each_with_object({}) do |(k, v), sum|
|
||||||
sum[k] = v
|
sum[k] = v unless v == :undefined
|
||||||
end
|
end
|
||||||
|
|
||||||
ready do
|
ready do
|
||||||
|
@ -160,9 +160,6 @@ module Middleman
|
||||||
path: root,
|
path: root,
|
||||||
only: match_against
|
only: match_against
|
||||||
|
|
||||||
# Hack around bower_components in root.
|
|
||||||
watcher.listener.ignore(/^bower_components/)
|
|
||||||
|
|
||||||
# Hack around node_modules in root.
|
# Hack around node_modules in root.
|
||||||
watcher.listener.ignore(/^node_modules/)
|
watcher.listener.ignore(/^node_modules/)
|
||||||
|
|
||||||
|
@ -207,7 +204,7 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
def possible_from_cli(key, config)
|
def possible_from_cli(key, config)
|
||||||
if @cli_options[key]
|
if @cli_options[key] && @cli_options[key] != :undefined
|
||||||
@cli_options[key]
|
@cli_options[key]
|
||||||
else
|
else
|
||||||
config[key]
|
config[key]
|
||||||
|
|
|
@ -74,7 +74,7 @@ module Middleman
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class BlockIgnoreDescriptor < IgnoreDescriptor
|
class BlockIgnoreDescriptor
|
||||||
def ignored?(match_path)
|
def ignored?(match_path)
|
||||||
block.call(match_path)
|
block.call(match_path)
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,7 +87,7 @@ module Middleman
|
||||||
|
|
||||||
Contract Or[Symbol, String, Fixnum]
|
Contract Or[Symbol, String, Fixnum]
|
||||||
def page_id
|
def page_id
|
||||||
metadata[:page][:id] || make_implicit_page_id(destination_path)
|
metadata[:page][:id] || destination_path
|
||||||
end
|
end
|
||||||
|
|
||||||
# Merge in new metadata specific to this resource.
|
# Merge in new metadata specific to this resource.
|
||||||
|
@ -208,30 +208,6 @@ module Middleman
|
||||||
"#<#{self.class} path=#{@path}>"
|
"#<#{self.class} path=#{@path}>"
|
||||||
end
|
end
|
||||||
alias inspect to_s # Ruby 2.0 calls inspect for NoMethodError instead of to_s
|
alias inspect to_s # Ruby 2.0 calls inspect for NoMethodError instead of to_s
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
# Makes a page id based on path (when not otherwise given)
|
|
||||||
#
|
|
||||||
# Removes .html extension and potential leading slashes or dots
|
|
||||||
# eg. "foo/bar/baz.foo.html" => "foo/bar/baz.foo"
|
|
||||||
Contract String => String
|
|
||||||
def make_implicit_page_id(path)
|
|
||||||
@id ||= begin
|
|
||||||
if prok = @app.config[:page_id_generator]
|
|
||||||
return prok.call(path)
|
|
||||||
end
|
|
||||||
|
|
||||||
basename = if ext == ".html"
|
|
||||||
File.basename(path, ext)
|
|
||||||
else
|
|
||||||
File.basename(path)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Remove leading dot or slash if present
|
|
||||||
File.join(File.dirname(path), basename).gsub(/^\.?\//, '')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class StringResource < Resource
|
class StringResource < Resource
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Core Pathname library used for traversal
|
# Core Pathname library used for traversal
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'addressable/uri'
|
require 'addressable'
|
||||||
require 'memoist'
|
require 'memoist'
|
||||||
require 'tilt'
|
require 'tilt'
|
||||||
|
|
||||||
|
@ -152,8 +152,7 @@ module Middleman
|
||||||
def url_for(app, path_or_resource, options={})
|
def url_for(app, path_or_resource, options={})
|
||||||
if path_or_resource.is_a?(String) || path_or_resource.is_a?(Symbol)
|
if path_or_resource.is_a?(String) || path_or_resource.is_a?(Symbol)
|
||||||
r = app.sitemap.find_resource_by_page_id(path_or_resource)
|
r = app.sitemap.find_resource_by_page_id(path_or_resource)
|
||||||
|
path_or_resource = r if r
|
||||||
path_or_resource = r ? r : path_or_resource.to_s
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Handle Resources and other things which define their own url method
|
# Handle Resources and other things which define their own url method
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Middleman
|
module Middleman
|
||||||
# Current Version
|
# Current Version
|
||||||
# @return [String]
|
# @return [String]
|
||||||
VERSION = '4.1.14'.freeze unless const_defined?(:VERSION)
|
VERSION = '4.1.11'.freeze unless const_defined?(:VERSION)
|
||||||
end
|
end
|
||||||
|
|
|
@ -220,7 +220,7 @@ describe Middleman::Util do
|
||||||
|
|
||||||
it "does not loop infinitely when file name is a possible templating engine" do
|
it "does not loop infinitely when file name is a possible templating engine" do
|
||||||
expect do
|
expect do
|
||||||
Timeout::timeout(3.0) do
|
Timeout::timeout(0.5) do
|
||||||
result = Middleman::Util.step_through_extensions("markdown.scss")
|
result = Middleman::Util.step_through_extensions("markdown.scss")
|
||||||
expect(result).to eq "markdown"
|
expect(result).to eq "markdown"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue