Compare commits

...

19 Commits

Author SHA1 Message Date
Parker Moore
f8ae6be6c4 Release 💎 3.5.2 2017-08-12 16:28:34 -04:00
Parker Moore
69659d6107 Merge pull request #6303 from jekyll/3.5-stable-backport-6247
Backport #6247 for v3.5.x: kramdown: symbolize keys in-place
2017-08-12 16:17:00 -04:00
Parker Moore
867fc4017e Merge pull request #6304 from jekyll/3.5-stable-backport-6226
Backport #6226 for v3.5.x: Reader#read_directories: guard against an entry not being a directory
2017-08-12 16:16:41 -04:00
Parker Moore
904eeee7a2 Backport read-directories-should-require-directory from #6226 to 3.5-stable 2017-08-12 16:14:02 -04:00
Parker Moore
4500232274 Backport kramdown-configs from #6247 to 3.5-stable 2017-08-12 16:13:38 -04:00
Parker Moore
ae46887375 Merge pull request #6302 from jekyll/3.5-stable-backport-6273
Backport #6273 for v3.5.x: delegate `StaticFile#to_json` to `StaticFile#to_liquid`
2017-08-12 16:12:40 -04:00
Kyle Zhao
27e4f75190 Backport static-file-to-json from #6273 to 3.5-stable 2017-08-12 16:11:50 -04:00
Parker Moore
50453d218d Merge pull request #6301 from jekyll/3.5-stable-backport-6266
Backport #6266 for v3.5.x: Memoize the return value of Document#url
2017-08-12 16:09:03 -04:00
Parker Moore
e19bae814f Backport memoize-document-url from #6266 to 3.5-stable 2017-08-12 16:05:56 -04:00
Parker Moore
1096b4218a Merge pull request #6300 from jekyll/3.5-stable-backport-6266
Backport #6266 for v3.5.x: Memoize the return value of Document#url
2017-08-12 15:59:36 -04:00
Ben Balter
a564b23ca5 Backport memoize-document-url from #6266 to 3.5-stable [merge conflicts] 2017-08-12 15:57:39 -04:00
Ben Balter
7a928f2965 Call to_s on site.url before attempting to concatenate strings (#6253)
Merge pull request 6253 in 3.5-stable branch
2017-08-12 15:52:48 -04:00
Parker Moore
0ef29378f3 Merge pull request #6287 from jekyll/3.5-stable-backport-6280
Backport to 3.5: Guard against type error in absolute url (#6280)
2017-08-10 16:40:54 -04:00
Parker Moore
69e541b4eb Merge pull request #6288 from jekyll/3.5-stable-backport-6281
Backport #6281 for v3.5.x: Fix Drop#key? so it can handle a nil argument
2017-08-10 16:38:38 -04:00
Parker Moore
a7807e65ba Fix Drop#key? so it can handle a nil argument (#6281)
Merge pull request 6281
2017-08-10 11:34:08 -04:00
Parker Moore
c1ac58dbb8 Backport drop-key-types from #6281 to 3.5-stable [merge conflicts] 2017-08-10 11:33:03 -04:00
Ben Balter
6554fb2a22 Backport to 3.5: Guard against type error in absolute url (#6280)
Merge pull request 6280
2017-08-10 11:26:45 -04:00
Parker Moore
ddcb38db71 Merge pull request #6286 from jekyll/3.5-stable-backport-6280
Merge 3.5.1 release into 3.5-stable
2017-08-10 11:24:17 -04:00
Parker Moore
985f031126 Backport guard-against-type-error-in-absolute-url from #6280 to 3.5-stable [merge conflicts] 2017-08-10 11:23:31 -04:00
12 changed files with 88 additions and 17 deletions

View File

@@ -1,3 +1,14 @@
## 3.5.2 / 2017-08-12
### Bug Fixes
* Backport #6281 for v3.5.x: Fix `Drop#key?` so it can handle a nil argument (#6288)
* Backport #6280 for v3.5.x: Guard against type error in `absolute_url` (#6287)
* Backport #6266 for v3.5.x: Memoize the return value of `Document#url` (#6301)
* Backport #6273 for v3.5.x: delegate `StaticFile#to_json` to `StaticFile#to_liquid` (#6302)
* Backport #6226 for v3.5.x: `Reader#read_directories`: guard against an entry not being a directory (#6304)
* Backport #6247 for v3.5.x: kramdown: symbolize keys in-place (#6303)
## 3.5.1 / 2017-07-17
### Minor Enhancements

View File

@@ -43,13 +43,9 @@ module Jekyll
private
def make_accessible(hash = @config)
proc_ = proc { |hash_, key| hash_[key.to_s] if key.is_a?(Symbol) }
hash.default_proc = proc_
hash.each do |_, val|
make_accessible val if val.is_a?(
Hash
)
hash.keys.each do |key|
hash[key.to_sym] = hash[key]
make_accessible(hash[key]) if hash[key].is_a?(Hash)
end
end
@@ -86,7 +82,7 @@ module Jekyll
private
def strip_coderay_prefix(hash)
hash.each_with_object({}) do |(key, val), hsh|
cleaned_key = key.gsub(%r!\Acoderay_!, "")
cleaned_key = key.to_s.gsub(%r!\Acoderay_!, "")
if key != cleaned_key
Jekyll::Deprecator.deprecation_message(

View File

@@ -203,7 +203,7 @@ module Jekyll
#
# Returns the computed URL for the document.
def url
@url = URL.new({
@url ||= URL.new({
:template => url_template,
:placeholders => url_placeholders,
:permalink => permalink,

View File

@@ -71,7 +71,7 @@ module Jekyll
def []=(key, val)
if respond_to?("#{key}=")
public_send("#{key}=", val)
elsif respond_to? key
elsif respond_to?(key.to_s)
if self.class.mutable?
@mutations[key] = val
else
@@ -105,7 +105,7 @@ module Jekyll
if self.class.mutable
@mutations.key?(key)
else
respond_to?(key) || fallback_data.key?(key)
!key.nil? && (respond_to?(key) || fallback_data.key?(key))
end
end

View File

@@ -10,10 +10,12 @@ module Jekyll
# Returns the absolute URL as a String.
def absolute_url(input)
return if input.nil?
return input if Addressable::URI.parse(input).absolute?
return input if Addressable::URI.parse(input.to_s).absolute?
site = @context.registers[:site]
return relative_url(input).to_s if site.config["url"].nil?
Addressable::URI.parse(site.config["url"] + relative_url(input)).normalize.to_s
Addressable::URI.parse(
site.config["url"].to_s + relative_url(input)
).normalize.to_s
end
# Produces a URL relative to the domain root based on site.baseurl.

View File

@@ -39,6 +39,8 @@ module Jekyll
def read_directories(dir = "")
base = site.in_source_dir(dir)
return unless File.directory?(base)
dot = Dir.chdir(base) { filter_entries(Dir.entries("."), base) }
dot_dirs = dot.select { |file| File.directory?(@site.in_source_dir(base, file)) }
dot_files = (dot - dot_dirs)

View File

@@ -1,7 +1,11 @@
module Jekyll
class StaticFile
extend Forwardable
attr_reader :relative_path, :extname, :name, :data
def_delegator :to_liquid, :to_json, :to_json
class << self
# The cache of last modification times [path] -> mtime.
def mtimes

View File

@@ -1,3 +1,3 @@
module Jekyll
VERSION = "3.5.1".freeze
VERSION = "3.5.2".freeze
end

View File

@@ -13,6 +13,10 @@ class TestDrop < JekyllUnitTest
@drop = @document.to_liquid
end
should "reject 'nil' key" do
refute @drop.key?(nil)
end
should "raise KeyError if key is not found and no default provided" do
assert_raises KeyError do
@drop.fetch("not_existing_key")

View File

@@ -13,6 +13,16 @@ class TestFilters < JekyllUnitTest
end
end
class Value
def initialize(value)
@value = value
end
def to_s
@value.respond_to?(:call) ? @value.call : @value.to_s
end
end
def make_filter_mock(opts = {})
JekyllFilter.new(site_configuration(opts)).tap do |f|
tz = f.site.config["timezone"]
@@ -423,6 +433,16 @@ class TestFilters < JekyllUnitTest
page_url = "http://example.com/"
assert_equal "http://example.com/", @filter.absolute_url(page_url)
end
should "transform the input URL to a string" do
page_url = "/my-page.html"
filter = make_filter_mock({ "url" => Value.new(proc { "http://example.org" }) })
assert_equal "http://example.org#{page_url}", filter.absolute_url(page_url)
end
should "not raise a TypeError when passed a hash" do
assert @filter.absolute_url({ "foo" => "bar" })
end
end
context "relative_url filter" do
@@ -500,6 +520,12 @@ class TestFilters < JekyllUnitTest
url << "foo"
assert_equal "/front_matter.erb", page.url
end
should "transform the input baseurl to a string" do
page_url = "/my-page.html"
filter = make_filter_mock({ "baseurl" => Value.new(proc { "/baseurl/" }) })
assert_equal "/baseurl#{page_url}", filter.relative_url(page_url)
end
end
context "strip_index filter" do

View File

@@ -20,11 +20,33 @@ class TestKramdown < JekyllUnitTest
},
},
}
@kramdown_config_keys = @config["kramdown"].keys
@syntax_highlighter_opts_config_keys = \
@config["kramdown"]["syntax_highlighter_opts"].keys
@config = Jekyll.configuration(@config)
@markdown = Converters::Markdown.new(
@config
)
@markdown = Converters::Markdown.new(@config)
@markdown.setup
end
should "fill symbolized keys into config for compatibility with kramdown" do
kramdown_config = @markdown.instance_variable_get(:@parser)
.instance_variable_get(:@config)
@kramdown_config_keys.each do |key|
assert kramdown_config.key?(key.to_sym),
"Expected #{kramdown_config} to include key #{key.to_sym.inspect}"
end
@syntax_highlighter_opts_config_keys.each do |key|
assert kramdown_config["syntax_highlighter_opts"].key?(key.to_sym),
"Expected #{kramdown_config["syntax_highlighter_opts"]} to include " \
"key #{key.to_sym.inspect}"
end
assert_equal kramdown_config["smart_quotes"], kramdown_config[:smart_quotes]
assert_equal kramdown_config["syntax_highlighter_opts"]["css"],
kramdown_config[:syntax_highlighter_opts][:css]
end
should "run Kramdown" do

View File

@@ -174,5 +174,9 @@ class TestStaticFile < JekyllUnitTest
}
assert_equal expected, @static_file.to_liquid.to_h
end
should "jsonify its liquid drop instead of itself" do
assert_equal @static_file.to_liquid.to_json, @static_file.to_json
end
end
end