From 945b1640c2119c1fdbe2cc75956b8c23df292b07 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 2 Jul 2014 14:28:59 +0200 Subject: [PATCH] downgrade jekyll for now to solve build error with category pagination --- Gemfile | 2 +- Gemfile.lock | 55 ++++++--------- _config.yml | 1 + _src/_plugins/cat_pagination.rb | 116 ++++++++++++++++---------------- 4 files changed, 80 insertions(+), 94 deletions(-) diff --git a/Gemfile b/Gemfile index 8a656727..82e4126c 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" # gem "rails" -gem 'jekyll', '>=2.0.0' +gem 'jekyll', '1.5.1' gem 'mini_magick', '>=3.6.0' gem 'fileutils', '>=0.7' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 469ef3cc..296143f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,67 +2,50 @@ GEM remote: https://rubygems.org/ specs: blankslate (2.1.2.4) - celluloid (0.15.2) - timers (~> 1.1.0) classifier (1.3.4) fast-stemmer (>= 1.0.0) - coffee-script (2.2.0) - coffee-script-source - execjs - coffee-script-source (1.7.0) colorator (0.1) - execjs (2.2.1) + commander (4.1.6) + highline (~> 1.6.11) fast-stemmer (1.0.2) ffi (1.9.3) fileutils (0.7) rmagick (>= 2.13.1) - jekyll (2.1.0) + highline (1.6.21) + jekyll (1.5.1) classifier (~> 1.3) colorator (~> 0.1) - jekyll-coffeescript (~> 1.0) - jekyll-gist (~> 1.0) - jekyll-paginate (~> 1.0) - jekyll-sass-converter (~> 1.0) - jekyll-watch (~> 1.0) - kramdown (~> 1.3) - liquid (~> 2.6.1) - mercenary (~> 0.3.3) - pygments.rb (~> 0.6.0) - redcarpet (~> 3.1) + commander (~> 4.1.3) + liquid (~> 2.5.5) + listen (~> 1.3) + maruku (= 0.7.0) + pygments.rb (~> 0.5.0) + redcarpet (~> 2.3.0) safe_yaml (~> 1.0) toml (~> 0.1.0) - jekyll-coffeescript (1.0.0) - coffee-script (~> 2.2) - jekyll-gist (1.1.0) - jekyll-paginate (1.0.0) - jekyll-sass-converter (1.0.0) - sass (~> 3.2) - jekyll-watch (1.0.0) - listen (~> 2.7) - kramdown (1.4.0) - liquid (2.6.1) - listen (2.7.9) - celluloid (>= 0.15.2) + liquid (2.5.5) + listen (1.3.1) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) - mercenary (0.3.3) + rb-kqueue (>= 0.2) + maruku (0.7.0) mini_magick (3.7.0) subexec (~> 0.2.1) parslet (1.5.0) blankslate (~> 2.0) posix-spawn (0.3.8) - pygments.rb (0.6.0) + pygments.rb (0.5.4) posix-spawn (~> 0.3.6) yajl-ruby (~> 1.1.0) rb-fsevent (0.9.4) rb-inotify (0.9.5) ffi (>= 0.5.0) - redcarpet (3.1.2) + rb-kqueue (0.2.3) + ffi (>= 0.5.0) + redcarpet (2.3.0) rmagick (2.13.2) safe_yaml (1.0.3) - sass (3.3.9) subexec (0.2.3) - timers (1.1.0) toml (0.1.1) parslet (~> 1.5.0) yajl-ruby (1.1.0) @@ -72,5 +55,5 @@ PLATFORMS DEPENDENCIES fileutils (>= 0.7) - jekyll (>= 2.0.0) + jekyll (= 1.5.1) mini_magick (>= 3.6.0) diff --git a/_config.yml b/_config.yml index cfc4c9b2..ea40a2f8 100644 --- a/_config.yml +++ b/_config.yml @@ -33,6 +33,7 @@ category_title_prefix: "" future: false markdown: redcarpet +pygments: true redcarpet: extensions: ['autolink', 'smart'] diff --git a/_src/_plugins/cat_pagination.rb b/_src/_plugins/cat_pagination.rb index 5679e955..af788f0f 100644 --- a/_src/_plugins/cat_pagination.rb +++ b/_src/_plugins/cat_pagination.rb @@ -5,74 +5,76 @@ # module Jekyll + module Paginate - class Pagination < Generator - def generate(site) - end - end - - class CategoryPages < Generator - - safe true - - def generate(site) - - site.pages.dup.each do |page| - paginate(site, page) if CategoryPager.pagination_enabled?(site.config, page) + class Pagination < Generator + def generate(site) end - end - def paginate(site, page) - - # sort categories by descending date of publish - category_posts = site.categories[page.data['category']].sort_by { |p| -p.date.to_f } + class CategoryPages < Generator - # calculate total number of pages - pages = CategoryPager.calculate_pages(category_posts, site.config['paginate'].to_i) + safe true - # iterate over the total number of pages and create a physical page for each - (1..pages).each do |num_page| - - # the CategoryPager handles the paging and category data - pager = CategoryPager.new(site, num_page, category_posts, page.data['category'], pages) + def generate(site) - if num_page > 1 - newpage = Page.new(site, site.source, page.dir, page.name) - newpage.pager = pager - newpage.dir = File.join(page.dir, "/page/#{num_page}") - site.pages << newpage - else - page.pager = pager + site.pages.dup.each do |page| + paginate(site, page) if CategoryPager.pagination_enabled?(site.config, page) end end + + def paginate(site, page) + + # sort categories by descending date of publish + category_posts = site.categories[page.data['category']].sort_by { |p| -p.date.to_f } + + # calculate total number of pages + pages = CategoryPager.calculate_pages(category_posts, site.config['paginate'].to_i) + + # iterate over the total number of pages and create a physical page for each + (1..pages).each do |num_page| + + # the CategoryPager handles the paging and category data + pager = CategoryPager.new(site, num_page, category_posts, page.data['category'], pages) + + if num_page > 1 + newpage = Page.new(site, site.source, page.dir, page.name) + newpage.pager = pager + newpage.dir = File.join(page.dir, "/page/#{num_page}") + site.pages << newpage + else + page.pager = pager + end + + end + end + + end + + class CategoryPager < Pager + + attr_reader :category + + def self.pagination_enabled?(config, page) + page.name == 'index.html' && page.data.key?('category') && !config['paginate'].nil? + end + + # same as the base class, but includes the category value + def initialize(site, page, all_posts, category, num_pages = nil) + @category = category + super site, page, all_posts, num_pages + end + + # use the original to_liquid method, but add in category info + alias_method :original_to_liquid, :to_liquid + def to_liquid + x = original_to_liquid + x['category'] = @category + x + end + end end - - class CategoryPager < Pager - - attr_reader :category - - def self.pagination_enabled?(config, page) - page.name == 'index.html' && page.data.key?('category') && !config['paginate'].nil? - end - - # same as the base class, but includes the category value - def initialize(site, page, all_posts, category, num_pages = nil) - @category = category - super site, page, all_posts, num_pages - end - - # use the original to_liquid method, but add in category info - alias_method :original_to_liquid, :to_liquid - def to_liquid - x = original_to_liquid - x['category'] = @category - x - end - - end - end \ No newline at end of file