Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixes problem in issue 64 fix where pages like about.md would be outp…

…ut as about.md/index.html. provides the output extension as a method rather than replacing the ext attribute as part of transform
  • Loading branch information...
commit f73dac1582350edef8036bf683a2e9f6b9d0bf6d 1 parent 4fd2b54
@krisb krisb authored
Showing with 31 additions and 8 deletions.
  1. +1 −0  cucumber.yml
  2. +16 −3 lib/jekyll/convertible.rb
  3. +14 −5 lib/jekyll/page.rb
View
1  cucumber.yml
@@ -0,0 +1 @@
+default: --format progress
View
19 lib/jekyll/convertible.rb
@@ -3,6 +3,7 @@
#
# Requires
# self.site -> Jekyll::Site
+# self.content
# self.content=
# self.data=
# self.ext=
@@ -31,20 +32,32 @@ def read_yaml(base, name)
self.data ||= {}
end
- # Transform the contents based on the file extension.
+ # Transform the contents based on the content type.
#
# Returns nothing
def transform
case self.content_type
when 'textile'
- self.ext = ".html"
self.content = self.site.textile(self.content)
when 'markdown'
- self.ext = ".html"
self.content = self.site.markdown(self.content)
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
# extension
#
View
19 lib/jekyll/page.rb
@@ -43,10 +43,10 @@ def permalink
end
def template
- if self.site.permalink_style == :pretty && !index?
- "/:name/"
+ if self.site.permalink_style == :pretty && !index? && html?
+ "/:basename/"
else
- "/:name.html"
+ "/:basename:output_ext"
end
end
@@ -57,7 +57,12 @@ def template
def url
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
# Extract information from the page filename
@@ -91,7 +96,7 @@ def write(dest_prefix, dest_suffix = nil)
# The url needs to be unescaped in order to preserve the correct filename
path = File.join(dest, CGI.unescape(self.url))
- if self.ext == '.html' && self.url[/\.html$/].nil?
+ if self.url =~ /\/$/
FileUtils.mkdir_p(path)
path = File.join(path, "index.html")
end
@@ -107,6 +112,10 @@ def inspect
private
+ def html?
+ output_ext == '.html'
+ end
+
def index?
basename == 'index'
end
Please sign in to comment.
Something went wrong with that request. Please try again.