Merge branch 'master' of github.com:mojombo/jekyll
* 'master' of github.com:mojombo/jekyll: Moving comparison for PostUrl tag to the PostComparer class Fail if destination directory for jekyll new exists and is not empty. Fixes #981. Remove code duplication: #write in Page and Post is the same.
This commit is contained in:
commit
8ed092ed94
|
@ -8,6 +8,10 @@ module Jekyll
|
||||||
|
|
||||||
new_blog_path = File.expand_path(args.join(" "), Dir.pwd)
|
new_blog_path = File.expand_path(args.join(" "), Dir.pwd)
|
||||||
FileUtils.mkdir_p new_blog_path
|
FileUtils.mkdir_p new_blog_path
|
||||||
|
unless Dir["#{new_blog_path}/**/*"].empty?
|
||||||
|
Jekyll::Logger.error "Conflict:", "#{new_blog_path} exists and is not empty."
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
create_sample_files new_blog_path
|
create_sample_files new_blog_path
|
||||||
|
|
||||||
|
|
|
@ -118,5 +118,18 @@ module Jekyll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Write the generated page file to the destination directory.
|
||||||
|
#
|
||||||
|
# dest - The String path to the destination dir.
|
||||||
|
#
|
||||||
|
# Returns nothing.
|
||||||
|
def write(dest)
|
||||||
|
path = destination(dest)
|
||||||
|
FileUtils.mkdir_p(File.dirname(path))
|
||||||
|
File.open(path, 'w') do |f|
|
||||||
|
f.write(self.output)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -129,19 +129,6 @@ module Jekyll
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
# Write the generated page file to the destination directory.
|
|
||||||
#
|
|
||||||
# dest - The String path to the destination dir.
|
|
||||||
#
|
|
||||||
# Returns nothing.
|
|
||||||
def write(dest)
|
|
||||||
path = destination(dest)
|
|
||||||
FileUtils.mkdir_p(File.dirname(path))
|
|
||||||
File.open(path, 'w') do |f|
|
|
||||||
f.write(self.output)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns the object as a debug String.
|
# Returns the object as a debug String.
|
||||||
def inspect
|
def inspect
|
||||||
"#<Jekyll:Page @name=#{self.name.inspect}>"
|
"#<Jekyll:Page @name=#{self.name.inspect}>"
|
||||||
|
|
|
@ -258,19 +258,6 @@ module Jekyll
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
# Write the generated post file to the destination directory.
|
|
||||||
#
|
|
||||||
# dest - The String path to the destination dir.
|
|
||||||
#
|
|
||||||
# Returns nothing.
|
|
||||||
def write(dest)
|
|
||||||
path = destination(dest)
|
|
||||||
FileUtils.mkdir_p(File.dirname(path))
|
|
||||||
File.open(path, 'w') do |f|
|
|
||||||
f.write(self.output)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Convert this post into a Hash for use in Liquid templates.
|
# Convert this post into a Hash for use in Liquid templates.
|
||||||
#
|
#
|
||||||
# Returns the representative Hash.
|
# Returns the representative Hash.
|
||||||
|
|
|
@ -10,6 +10,13 @@ module Jekyll
|
||||||
@slug = slug
|
@slug = slug
|
||||||
@date = Time.parse(date)
|
@date = Time.parse(date)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ==(other)
|
||||||
|
slug == other.slug &&
|
||||||
|
date.year == other.date.year &&
|
||||||
|
date.month == other.date.month &&
|
||||||
|
date.day == other.date.day
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class PostUrl < Liquid::Tag
|
class PostUrl < Liquid::Tag
|
||||||
|
@ -23,11 +30,7 @@ module Jekyll
|
||||||
site = context.registers[:site]
|
site = context.registers[:site]
|
||||||
|
|
||||||
site.posts.each do |p|
|
site.posts.each do |p|
|
||||||
if p.slug == @post.slug \
|
if @post == p
|
||||||
and p.date.year == @post.date.year \
|
|
||||||
and p.date.month == @post.date.month \
|
|
||||||
and p.date.day == @post.date.day
|
|
||||||
|
|
||||||
return p.url
|
return p.url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue