commit
2cf685feb2
|
@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
||||||
s.add_runtime_dependency("jekyll-sass-converter", "~> 1.0")
|
s.add_runtime_dependency("jekyll-sass-converter", "~> 1.0")
|
||||||
s.add_runtime_dependency("jekyll-watch", "~> 1.1")
|
s.add_runtime_dependency("jekyll-watch", "~> 1.1")
|
||||||
s.add_runtime_dependency("kramdown", "~> 1.3")
|
s.add_runtime_dependency("kramdown", "~> 1.3")
|
||||||
s.add_runtime_dependency("liquid", "~> 3.0")
|
s.add_runtime_dependency("liquid", "~> 4.0")
|
||||||
s.add_runtime_dependency("mercenary", "~> 0.3.3")
|
s.add_runtime_dependency("mercenary", "~> 0.3.3")
|
||||||
s.add_runtime_dependency("pathutil", "~> 0.9")
|
s.add_runtime_dependency("pathutil", "~> 0.9")
|
||||||
s.add_runtime_dependency("rouge", "~> 1.7")
|
s.add_runtime_dependency("rouge", "~> 1.7")
|
||||||
|
|
|
@ -19,6 +19,10 @@ module Jekyll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def key?(key)
|
||||||
|
(@obj.collections.key?(key) && key != "posts") || super
|
||||||
|
end
|
||||||
|
|
||||||
def posts
|
def posts
|
||||||
@site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a }
|
@site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a }
|
||||||
end
|
end
|
||||||
|
|
|
@ -280,10 +280,11 @@ module Jekyll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pop(array, input = 1)
|
def pop(array, num = 1)
|
||||||
return array unless array.is_a?(Array)
|
return array unless array.is_a?(Array)
|
||||||
|
num = Liquid::Utils.to_integer(num)
|
||||||
new_ary = array.dup
|
new_ary = array.dup
|
||||||
new_ary.pop(input.to_i || 1)
|
new_ary.pop(num)
|
||||||
new_ary
|
new_ary
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -294,10 +295,11 @@ module Jekyll
|
||||||
new_ary
|
new_ary
|
||||||
end
|
end
|
||||||
|
|
||||||
def shift(array, input = 1)
|
def shift(array, num = 1)
|
||||||
return array unless array.is_a?(Array)
|
return array unless array.is_a?(Array)
|
||||||
|
num = Liquid::Utils.to_integer(num)
|
||||||
new_ary = array.dup
|
new_ary = array.dup
|
||||||
new_ary.shift(input.to_i || 1)
|
new_ary.shift(num)
|
||||||
new_ary
|
new_ary
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -310,11 +312,11 @@ module Jekyll
|
||||||
|
|
||||||
def sample(input, num = 1)
|
def sample(input, num = 1)
|
||||||
return input unless input.respond_to?(:sample)
|
return input unless input.respond_to?(:sample)
|
||||||
n = num.to_i rescue 1
|
num = Liquid::Utils.to_integer(num) rescue 1
|
||||||
if n == 1
|
if num == 1
|
||||||
input.sample
|
input.sample
|
||||||
else
|
else
|
||||||
input.sample(n)
|
input.sample(num)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -345,19 +347,12 @@ module Jekyll
|
||||||
|
|
||||||
private
|
private
|
||||||
def time(input)
|
def time(input)
|
||||||
case input
|
date = Liquid::Utils.to_date(input)
|
||||||
when Time
|
unless date.respond_to?(:to_time)
|
||||||
input.clone
|
|
||||||
when Date
|
|
||||||
input.to_time
|
|
||||||
when String
|
|
||||||
Time.parse(input) rescue Time.at(input.to_i)
|
|
||||||
when Numeric
|
|
||||||
Time.at(input)
|
|
||||||
else
|
|
||||||
raise Errors::InvalidDateError,
|
raise Errors::InvalidDateError,
|
||||||
"Invalid Date: '#{input.inspect}' is not a valid datetime."
|
"Invalid Date: '#{input.inspect}' is not a valid datetime."
|
||||||
end.localtime
|
end
|
||||||
|
date.to_time.localtime
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -402,9 +397,11 @@ module Jekyll
|
||||||
operator = parser.consume?(:comparison)
|
operator = parser.consume?(:comparison)
|
||||||
condition =
|
condition =
|
||||||
if operator
|
if operator
|
||||||
Liquid::Condition.new(left_expr, operator, parser.expression)
|
Liquid::Condition.new(Liquid::Expression.parse(left_expr),
|
||||||
|
operator,
|
||||||
|
Liquid::Expression.parse(parser.expression))
|
||||||
else
|
else
|
||||||
Liquid::Condition.new(left_expr)
|
Liquid::Condition.new(Liquid::Expression.parse(left_expr))
|
||||||
end
|
end
|
||||||
parser.consume(:end_of_string)
|
parser.consume(:end_of_string)
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ module Jekyll
|
||||||
|
|
||||||
private
|
private
|
||||||
def parse_expression(str)
|
def parse_expression(str)
|
||||||
Liquid::Variable.new(str, {})
|
Liquid::Variable.new(str, Liquid::ParseContext.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
require "helper"
|
||||||
|
|
||||||
|
class TestSiteDrop < JekyllUnitTest
|
||||||
|
context "a site drop" do
|
||||||
|
setup do
|
||||||
|
@site = fixture_site({
|
||||||
|
"collections" => ["thanksgiving"]
|
||||||
|
})
|
||||||
|
@site.process
|
||||||
|
@drop = @site.to_liquid.site
|
||||||
|
end
|
||||||
|
|
||||||
|
should "respond to `key?`" do
|
||||||
|
assert @drop.respond_to?(:key?)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "find a key if it's in the collection of the drop" do
|
||||||
|
assert @drop.key?("thanksgiving")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -46,8 +46,8 @@ CONTENT
|
||||||
Jekyll::Tags::HighlightBlock.parse(
|
Jekyll::Tags::HighlightBlock.parse(
|
||||||
"highlight",
|
"highlight",
|
||||||
options_string,
|
options_string,
|
||||||
["test", "{% endhighlight %}", "\n"],
|
Liquid::Tokenizer.new("test{% endhighlight %}\n"),
|
||||||
{}
|
Liquid::ParseContext.new
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue