diff --git a/cucumber.yml b/cucumber.yml new file mode 100644 index 00000000..9692830c --- /dev/null +++ b/cucumber.yml @@ -0,0 +1 @@ +default: --format progress \ No newline at end of file diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index f3da5579..644dd053 100644 --- a/lib/jekyll/convertible.rb +++ b/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 @@ module Jekyll 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 # diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 62a757dc..188288f7 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -43,10 +43,10 @@ module Jekyll 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 @@ module Jekyll 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 @@ module Jekyll # 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 @@ module Jekyll private + def html? + output_ext == '.html' + end + def index? basename == 'index' end