Skip to content

Commit

Permalink
added henrik's multiviews feature to jekyll 0.10.0 and before_fold.
Browse files Browse the repository at this point in the history
  • Loading branch information
stammy committed Jan 2, 2011
1 parent 13df722 commit b943d45
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
8 changes: 8 additions & 0 deletions bin/jekyll
Expand Up @@ -72,6 +72,14 @@ opts = OptionParser.new do |opts|
options['permalink'] = style unless style.nil?
end

opts.on("--multiviews", "Don't use .html in links since Apache has 'Options +MultiViews'") do |style|
options['multiviews'] = true
end

opts.on("--sass", "Use Sass from haml gem for CSS generation") do
options['sass'] = true
end

opts.on("--paginate [POSTS_PER_PAGE]", "Paginate a blog's posts") do |per_page|
begin
options['paginate'] = per_page.to_i
Expand Down
8 changes: 8 additions & 0 deletions lib/jekyll/filters.rb
Expand Up @@ -4,6 +4,7 @@ module Jekyll

module Filters
def textilize(input)
#RedCloth.new(input).to_html
TextileConverter.new.convert(input)
end

Expand Down Expand Up @@ -34,6 +35,13 @@ def uri_escape(input)
def number_of_words(input)
input.split.length
end

# Returns all content before the first-encountered WP-style MORE tag.
# Allows authors to mark the fold with an <!--more--> in their drafts.
# e.g. {{ content | before_fold }}
def before_fold(input)
input.split("<!--more-->").first
end

def array_to_sentence_string(array)
connector = "and"
Expand Down
17 changes: 13 additions & 4 deletions lib/jekyll/post.rb
Expand Up @@ -87,7 +87,7 @@ def process(name)
#
# Returns <String>
def dir
File.dirname(url)
File.dirname(generated_path)
end

# The full path and filename of the post.
Expand Down Expand Up @@ -116,10 +116,10 @@ def template
# e.g. /2008/11/05/my-awesome-post.html
#
# Returns <String>
def url
def generated_path
return permalink if permalink

@url ||= {
@generated_path ||= {
"year" => date.strftime("%Y"),
"month" => date.strftime("%m"),
"day" => date.strftime("%d"),
Expand All @@ -132,6 +132,14 @@ def url
result.gsub(/:#{Regexp.escape token.first}/, token.last)
}.gsub(/\/\//, "/")
end

# The generated relative url of this post
# e.g. /2008/11/05/my-awesome-post
#
# Returns <String>
def url
site.config['multiviews'] ? generated_path.sub(/\.html$/, '') : generated_path
end

# The UID for this post (useful in feeds)
# e.g. /2008/11/05/my-awesome-post
Expand Down Expand Up @@ -184,7 +192,7 @@ def render(layouts, site_payload)
# Returns destination file path.
def destination(dest)
# 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.generated_path))
path = File.join(path, "index.html") if template[/\.html$/].nil?
path
end
Expand All @@ -211,6 +219,7 @@ def to_liquid
"date" => self.date,
"id" => self.id,
"categories" => self.categories,
"folded" => (self.content.match("<!--more-->") ? true : false),
"next" => self.next,
"previous" => self.previous,
"tags" => self.tags,
Expand Down
3 changes: 2 additions & 1 deletion lib/jekyll/site.rb
Expand Up @@ -47,7 +47,7 @@ def reset

def setup
require 'classifier' if self.lsi

# If safe mode is off, load in any ruby files under the plugins
# directory.
unless self.safe
Expand Down Expand Up @@ -228,6 +228,7 @@ def read_directories(dir = '')
end
end
end


# Constructs a hash map of Posts indexed by the specified Post attribute
#
Expand Down

0 comments on commit b943d45

Please sign in to comment.