Created
November 19, 2015 10:58
-
-
Save uraimo/aa1437323a5da43c86cf to your computer and use it in GitHub Desktop.
Diff of some required modifications for my site from jekyll 2.5.x to 3.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Gemfile b/Gemfile | |
index f25308a..4b32b39 100644 | |
--- a/Gemfile | |
+++ b/Gemfile | |
@@ -3,6 +3,7 @@ source "http://rubygems.org" | |
gem 'rake' | |
gem 'jekyll' | |
+gem 'jekyll-paginate' | |
gem 'rdiscount' | |
gem 'liquid' | |
diff --git a/_config.yml b/_config.yml | |
index 6cd5dcb..9f24934 100644 | |
--- a/_config.yml | |
+++ b/_config.yml | |
@@ -1,9 +1,9 @@ | |
lsi: false | |
markdown: rdiscount | |
permalink: /:year/:month/:day/:title | |
paginate: 10 | |
category_dir: category | |
category_title_prefix: | |
exclude: ['Rakefile','Gemfile','Gemfile.lock','README.md'] | |
destination: _site | |
+ gems: [jekyll-paginate] | |
diff --git a/_plugins/archive.rb b/_plugins/archive.rb | |
index 48cb309..49b2b80 100644 | |
--- a/_plugins/archive.rb | |
+++ b/_plugins/archive.rb | |
@@ -21,7 +21,7 @@ module Jekyll | |
def collate(site) | |
collated_posts = {} | |
- site.posts.reverse.each do |post| | |
+ site.posts.docs.reverse.each do |post| | |
y, m, d = post.date.year, post.date.month, post.date.day | |
collated_posts[ y ] = {} unless collated_posts.key? y | |
@@ -62,7 +62,7 @@ module Jekyll | |
end | |
def collate(site) | |
- site.posts.reverse.each do |post| | |
+ site.posts.docs.reverse.each do |post| | |
y, m, d = post.date.year, post.date.month, post.date.day | |
self.collated_posts[ y ] = {} unless self.collated_posts.key? y | |
@@ -72,4 +72,4 @@ module Jekyll | |
end | |
end | |
end | |
-end | |
\ No newline at end of file | |
+end | |
diff --git a/_plugins/sitemap_generator.rb b/_plugins/sitemap_generator.rb | |
index 03907e1..f8109f9 100644 | |
--- a/_plugins/sitemap_generator.rb | |
+++ b/_plugins/sitemap_generator.rb | |
@@ -34,6 +34,7 @@ | |
# Distributed Under A Creative Commons License | |
# - http://creativecommons.org/licenses/by/3.0/ | |
+require 'jekyll/document' | |
require 'rexml/document' | |
module Jekyll | |
@@ -58,13 +59,9 @@ module Jekyll | |
CHANGE_FREQUENCY_CUSTOM_VARIABLE_NAME = "change_frequency" | |
PRIORITY_CUSTOM_VARIABLE_NAME = "priority" | |
- class Post | |
+ class Jekyll::Document | |
attr_accessor :name | |
- def full_path_to_source | |
- File.join(@base, @name) | |
- end | |
- | |
def location_on_server | |
"#{MY_URL}#{url}" | |
end | |
@@ -73,22 +70,13 @@ module Jekyll | |
class Page | |
attr_accessor :name | |
- def full_path_to_source | |
- File.join(@base, @dir, @name) | |
- end | |
- | |
def location_on_server | |
- location = "#{MY_URL}#{url}" #location = "#{MY_URL}#{@dir}#{url}" | |
+ location = "#{MY_URL}#{url}" #location = "#{MY_URL}#{@dir}#{url}" | |
+ print location | |
location.gsub(/index.html$/, "") | |
end | |
end | |
- class Layout | |
- def full_path_to_source | |
- File.join(@base, @name) | |
- end | |
- end | |
- | |
# Recover from strange exception when starting server without --auto | |
class SitemapFile < StaticFile | |
def write(dest) | |
@@ -138,14 +126,12 @@ module Jekyll | |
# Returns last_modified_date of latest post | |
def fill_posts(site, urlset) | |
last_modified_date = nil | |
- site.posts.each do |post| | |
+ site.collections["posts"].docs.each do |post| | |
if !excluded?(post.name) | |
url = fill_url(site, post) | |
urlset.add_element(url) | |
end | |
- | |
- path = post.full_path_to_source | |
- date = File.mtime(path) | |
+ date = File.mtime(post.path) | |
last_modified_date = date if last_modified_date == nil or date > last_modified_date | |
end | |
@@ -158,9 +144,9 @@ module Jekyll | |
# Returns last_modified_date of index page | |
def fill_pages(site, urlset) | |
site.pages.each do |page| | |
+ | |
if !excluded?(page.name) | |
- path = page.full_path_to_source | |
- if File.exists?(path) | |
+ if File.exists?(page.path) | |
url = fill_url(site, page) | |
urlset.add_element(url) | |
end | |
@@ -222,10 +208,8 @@ module Jekyll | |
# | |
# Returns lastmod REXML::Element or nil | |
def fill_last_modified(site, page_or_post) | |
- path = page_or_post.full_path_to_source | |
- | |
lastmod = REXML::Element.new "lastmod" | |
- date = File.mtime(path) | |
+ date = File.mtime(page_or_post.path) | |
latest_date = find_latest_date(date, site, page_or_post) | |
if @last_modified_post_date == nil | |
@@ -252,8 +236,7 @@ module Jekyll | |
layouts = site.layouts | |
layout = layouts[page_or_post.data["layout"]] | |
while layout | |
- path = layout.full_path_to_source | |
- date = File.mtime(path) | |
+ date = File.mtime(layout.path) | |
latest_date = date if (date > latest_date) | |
diff --git a/_plugins/tag.rb b/_plugins/tag.rb | |
index 98f2dc7..59f9e08 100644 | |
--- a/_plugins/tag.rb | |
+++ b/_plugins/tag.rb | |
@@ -12,7 +12,7 @@ module Jekyll | |
self.data['related'] = [] | |
site.tags[tag].each do |post| | |
- post.tags.each do |rel| | |
+ post.data['tags'].each do |rel| | |
self.data['related'].push(rel) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment