fixes problem in issue 64 fix where pages like about.md would be output as about.md/index.html. provides the output extension as a method rather than replacing the ext attribute as part of transform
This commit is contained in:
parent
4fd2b54a7d
commit
f73dac1582
|
@ -0,0 +1 @@
|
||||||
|
default: --format progress
|
|
@ -3,6 +3,7 @@
|
||||||
#
|
#
|
||||||
# Requires
|
# Requires
|
||||||
# self.site -> Jekyll::Site
|
# self.site -> Jekyll::Site
|
||||||
|
# self.content
|
||||||
# self.content=
|
# self.content=
|
||||||
# self.data=
|
# self.data=
|
||||||
# self.ext=
|
# self.ext=
|
||||||
|
@ -31,20 +32,32 @@ module Jekyll
|
||||||
self.data ||= {}
|
self.data ||= {}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Transform the contents based on the file extension.
|
# Transform the contents based on the content type.
|
||||||
#
|
#
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def transform
|
def transform
|
||||||
case self.content_type
|
case self.content_type
|
||||||
when 'textile'
|
when 'textile'
|
||||||
self.ext = ".html"
|
|
||||||
self.content = self.site.textile(self.content)
|
self.content = self.site.textile(self.content)
|
||||||
when 'markdown'
|
when 'markdown'
|
||||||
self.ext = ".html"
|
|
||||||
self.content = self.site.markdown(self.content)
|
self.content = self.site.markdown(self.content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Determine the extension depending on content_type
|
||||||
|
#
|
||||||
|
# Returns the extensions for the output file
|
||||||
|
def output_ext
|
||||||
|
case self.content_type
|
||||||
|
when 'textile'
|
||||||
|
".html"
|
||||||
|
when 'markdown'
|
||||||
|
".html"
|
||||||
|
else
|
||||||
|
self.ext
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Determine which formatting engine to use based on this convertible's
|
# Determine which formatting engine to use based on this convertible's
|
||||||
# extension
|
# extension
|
||||||
#
|
#
|
||||||
|
|
|
@ -43,10 +43,10 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def template
|
def template
|
||||||
if self.site.permalink_style == :pretty && !index?
|
if self.site.permalink_style == :pretty && !index? && html?
|
||||||
"/:name/"
|
"/:basename/"
|
||||||
else
|
else
|
||||||
"/:name.html"
|
"/:basename:output_ext"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,7 +57,12 @@ module Jekyll
|
||||||
def url
|
def url
|
||||||
return permalink if permalink
|
return permalink if permalink
|
||||||
|
|
||||||
@url ||= (ext == '.html') ? template.gsub(':name', basename) : "/#{name}"
|
@url ||= {
|
||||||
|
"basename" => self.basename,
|
||||||
|
"output_ext" => self.output_ext,
|
||||||
|
}.inject(template) { |result, token|
|
||||||
|
result.gsub(/:#{token.first}/, token.last)
|
||||||
|
}.gsub(/\/\//, "/")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Extract information from the page filename
|
# Extract information from the page filename
|
||||||
|
@ -91,7 +96,7 @@ module Jekyll
|
||||||
|
|
||||||
# The url needs to be unescaped in order to preserve the correct filename
|
# The url needs to be unescaped in order to preserve the correct filename
|
||||||
path = File.join(dest, CGI.unescape(self.url))
|
path = File.join(dest, CGI.unescape(self.url))
|
||||||
if self.ext == '.html' && self.url[/\.html$/].nil?
|
if self.url =~ /\/$/
|
||||||
FileUtils.mkdir_p(path)
|
FileUtils.mkdir_p(path)
|
||||||
path = File.join(path, "index.html")
|
path = File.join(path, "index.html")
|
||||||
end
|
end
|
||||||
|
@ -107,6 +112,10 @@ module Jekyll
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def html?
|
||||||
|
output_ext == '.html'
|
||||||
|
end
|
||||||
|
|
||||||
def index?
|
def index?
|
||||||
basename == 'index'
|
basename == 'index'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue