Merge pull request #1124 from imathis/jekyll-1.0

Integrate Jekyll 1.0
This commit is contained in:
Parker Moore 2013-03-26 05:12:56 -07:00
commit 759b19908e
8 changed files with 73 additions and 76 deletions

View File

@ -3,7 +3,7 @@ source "http://rubygems.org"
group :development do
gem 'rake', '~> 10.0.3'
gem 'rack', '~> 1.5.0'
gem 'jekyll', '~> 0.12.0'
gem 'jekyll', '~> 1.0.0.beta2'
gem 'redcarpet', '~> 2.2.2'
gem 'pygments.rb', '~> 0.3.4'
gem 'RedCloth', '~> 4.2.9'

View File

@ -10,14 +10,16 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.4.0)
commander (4.1.3)
highline (~> 1.6.11)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
directory_watcher (1.4.1)
directory_watcher (1.5.1)
execjs (1.4.0)
multi_json (~> 1.0)
fast-stemmer (1.0.1)
fast-stemmer (1.0.2)
ffi (1.2.0)
fssm (0.2.9)
guard (1.6.2)
@ -35,14 +37,17 @@ GEM
guard-shell (0.5.1)
guard (>= 1.1.0)
haml (3.1.7)
jekyll (0.12.0)
highline (1.6.16)
jekyll (1.0.0.beta2)
classifier (~> 1.3)
commander (~> 4.1.3)
directory_watcher (~> 1.1)
kramdown (~> 0.13.4)
kramdown (~> 0.14)
liquid (~> 2.3)
maruku (~> 0.5)
pygments.rb (~> 0.3.2)
kramdown (0.13.8)
safe_yaml (~> 0.7.0)
kramdown (0.14.2)
liquid (2.3.0)
listen (0.7.3)
lumberjack (1.0.2)
@ -70,6 +75,7 @@ GEM
ffi (>= 0.5.0)
redcarpet (2.2.2)
rubypants (0.2.0)
safe_yaml (0.7.1)
sass (3.2.4)
sass-globbing (1.0.0)
sass (>= 3.1)
@ -101,7 +107,7 @@ DEPENDENCIES
guard-compass
guard-shell
haml (~> 3.1.7)
jekyll (~> 0.12.0)
jekyll (~> 1.0.0.beta2)
liquid (~> 2.3.0)
minitest (~> 4.6)
pygments.rb (~> 0.3.4)

View File

@ -114,7 +114,7 @@ task :generate do
js_assets = Octopress::JSAssetsManager.new
js_assets.compile
system "compass compile --css-dir #{configuration[:source]}/stylesheets"
system "jekyll --no-server --no-auto #{'--no-future' if Octopress.env == 'production'}"
system "jekyll build #{"--drafts --trace" unless Octopress.env == 'production'}"
unpublished = get_unpublished(Dir.glob("#{configuration[:source]}/#{configuration[:posts_dir]}/*.*"), {env: Octopress.env, message: "\nThese posts were not generated:"})
puts unpublished unless unpublished.empty?
configurator.remove_configs_for_generation

View File

@ -8,7 +8,7 @@ require 'octopress'
module Guard
class Jekyll < Guard
VERSION = '0.0.1'
VERSION = '0.0.2'
# Calls #run_all if the :all_on_start option is present.
def start
@ -20,7 +20,7 @@ module Guard
if Watcher.match_files(self, Dir.glob('{,**/}*{,.*}').uniq).size > 0
configurator = Octopress::Configuration.new
configurator.write_configs_for_generation
system "jekyll#{' --no-future' if Octopress.env == 'production'}"
system "jekyll build #{"--drafts" unless Octopress.env == 'production'}"
configurator.remove_configs_for_generation
end
end
@ -28,7 +28,7 @@ module Guard
def run_on_changes(_)
configurator = Octopress::Configuration.new
configurator.write_configs_for_generation
system "jekyll#{' --no-future' if Octopress.env == 'production'}"
system "jekyll build #{"--drafts" unless Octopress.env == 'production'}"
configurator.remove_configs_for_generation
end
end

View File

@ -14,7 +14,7 @@ module Jekyll
end
def render_include(file, context)
tag = IncludeTag.new('', file, [])
tag = Tags::IncludeTag.new('', file, [])
tag.render(context)
end
end

View File

@ -1,52 +1,55 @@
module Jekyll
module Generators
class Pagination < Generator
# This generator is safe from arbitrary code execution.
safe true
class Pagination < Generator
# This generator is safe from arbitrary code execution.
safe true
# Generate paginated pages if necessary.
#
# site - The Site.
#
# Returns nothing.
def generate(site)
site.pages.dup.each do |page|
paginate(site, page) if Pager.pagination_enabled?(site.config, page)
end
end
# Paginates the blog's posts. Renders the index.html file into paginated
# directories, e.g.: page2/index.html, page3/index.html, etc and adds more
# site-wide data.
#
# site - The Site.
# page - The index.html Page that requires pagination.
#
# {"paginator" => { "page" => <Number>,
# "per_page" => <Number>,
# "posts" => [<Post>],
# "total_posts" => <Number>,
# "total_pages" => <Number>,
# "previous_page" => <Number>,
# "next_page" => <Number> }}
def paginate(site, page)
all_posts = site.site_payload['site']['posts']
pages = Pager.calculate_pages(all_posts, site.config['paginate'].to_i)
page_dir = page.destination('').sub(/\/[^\/]+$/, '')
page_dir_config = site.config['pagination_dir']
dir = ((page_dir_config || page_dir) + '/').sub(/^\/+/, '')
(1..pages).each do |num_page|
pager = Pager.new(site.config, num_page, all_posts, page_dir+'/', '/'+dir, pages)
if num_page > 1
newpage = Page.new(site, site.source, page_dir, page.name)
newpage.pager = pager
newpage.dir = File.join(page.dir, "#{dir}page/#{num_page}")
site.pages << newpage
else
page.pager = pager
# Generate paginated pages if necessary.
#
# site - The Site.
#
# Returns nothing.
def generate(site)
site.pages.dup.each do |page|
paginate(site, page) if Pager.pagination_enabled?(site.config, page.name)
end
end
# Paginates the blog's posts. Renders the index.html file into paginated
# directories, e.g.: page2/index.html, page3/index.html, etc and adds more
# site-wide data.
#
# site - The Site.
# page - The index.html Page that requires pagination.
#
# {"paginator" => { "page" => <Number>,
# "per_page" => <Number>,
# "posts" => [<Post>],
# "total_posts" => <Number>,
# "total_pages" => <Number>,
# "previous_page" => <Number>,
# "next_page" => <Number> }}
def paginate(site, page)
all_posts = site.site_payload['site']['posts']
pages = Pager.calculate_pages(all_posts, site.config['paginate'].to_i)
(1..pages).each do |num_page|
pager = Pager.new(site.config, num_page, all_posts, pages)
if num_page > 1
newpage = Page.new(site, site.source, page.dir, page.name)
newpage.pager = pager
newpage.dir = File.join(page.dir, paginate_path(site, num_page))
site.pages << newpage
else
page.pager = pager
end
end
end
private
def paginate_path(site, num_page)
format = site.config['paginate_path']
format.sub(':num', num_page.to_s)
end
end
end
@ -70,7 +73,7 @@ module Jekyll
#
# Returns true if pagination is enabled, false otherwise.
def self.pagination_enabled?(config, file)
file.name == 'index.html' && !config['paginate'].nil? && file.content =~ /paginator\./
file == 'index.html' && !config['paginate'].nil?
end
# Initialize a new Pager.
@ -80,12 +83,10 @@ module Jekyll
# all_posts - The Array of all the site's Posts.
# num_pages - The Integer number of pages or nil if you'd like the number
# of pages calculated.
def initialize(config, page, all_posts, index_dir, pagination_dir, num_pages = nil)
def initialize(config, page, all_posts, num_pages = nil)
@page = page
@per_page = config['paginate'].to_i
@page_dir = pagination_dir + 'page/'
@total_pages = num_pages || Pager.calculate_pages(all_posts, @per_page)
@previous_page = nil
if @page > @total_pages
raise RuntimeError, "page number can't be greater than total pages: #{@page} > #{@total_pages}"
@ -96,9 +97,8 @@ module Jekyll
@total_posts = all_posts.size
@posts = all_posts[init..offset]
@previous_page = @page != 1 ? @page_dir + (@page - 1).to_s + '/' : nil
@previous_page = index_dir if @page - 1 == 1
@next_page = @page != @total_pages ? @page_dir + (@page + 1).to_s + '/' : nil
@previous_page = @page != 1 ? @page - 1 : nil
@next_page = @page != @total_pages ? @page + 1 : nil
end
# Convert this Pager's data to a Hash suitable for use by Liquid.
@ -116,5 +116,4 @@ module Jekyll
}
end
end
end

View File

@ -37,11 +37,7 @@ module Jekyll
# Instantiates all of the post_filter plugins. This is basically
# a duplication of the other loaders in Site#setup.
def load_post_filters
self.post_filters = Jekyll::PostFilter.subclasses.select do |c|
!self.safe || c.safe
end.map do |c|
c.new(self.config)
end
self.post_filters = instantiate_subclasses(Jekyll::PostFilter)
end
end

View File

@ -4,7 +4,7 @@
# How To Use:
# 1) Copy source file into your _plugins folder within your Jekyll project.
# 2) Change modify the url variable in _config.yml to reflect your domain name.
# 3) Run Jekyll: jekyll --server to re-generate your site.
# 3) Run Jekyll: jekyll build to re-generate your site.
#
# Variables:
# * Change SITEMAP_FILE_NAME if you want your sitemap to be called something
@ -270,11 +270,7 @@ module Jekyll
#
# Returns latest of two dates
def greater_date(date1, date2)
if (date1 >= date2)
date1
else
date2
end
[date1, date2].max
end
# Is the page or post listed as something we want to exclude?