-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
911ffae
commit a9ae483
Showing
12 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.1.3 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
|
||
# these gems aren't published so we need to tell ruby where they're located | ||
gem "absolute-urls", path: "_plugins/absolute-urls" | ||
gem "post-aliases", path: "_plugins/post-aliases" | ||
gem "unwrap-img", path: "_plugins/unwrap-img" | ||
|
||
gemspec |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
gemspec |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "absolute-urls" | ||
spec.version = "0.1.0" | ||
spec.authors = ["Quincy Morgan"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = "Force absolute URLs in Jekyll Kramdown `href` and `src` properties." | ||
spec.homepage = "https://github.com/osmus/dogwood" | ||
spec.license = "MIT" | ||
|
||
spec.files = Dir["lib/**/*"] | ||
|
||
spec.add_runtime_dependency "jekyll", "~> 4.3" | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This plugin ensures all `src` and `href` properties created by markdown parsing | ||
# are absolute links. This solves issues that occur when the baseurl is a subdirectory. | ||
|
||
require 'kramdown/utils/html' | ||
|
||
SITE_BASEURL = (Jekyll.sites()[0].config['url'] || '') + (Jekyll.sites()[0].config['baseurl'] || ''); | ||
|
||
module AbsoluteUrls | ||
def html_attributes(attr) | ||
|
||
return super unless attr['src'] || attr['href'] | ||
|
||
if attr['src'] && attr['src'].start_with?("/") | ||
attr['src'] = SITE_BASEURL + attr['src'] | ||
end | ||
|
||
if attr['href'] && attr['href'].start_with?("/") | ||
attr['href'] = SITE_BASEURL + attr['href'] | ||
end | ||
|
||
super(attr) | ||
end | ||
end | ||
|
||
Kramdown::Utils::Html.prepend AbsoluteUrls |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
gemspec |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This plugin generates redirect pages for all posts, pointing from the /:year/:month/:title | ||
# format to the actual URL, whatever it may be. This makes the site backwards-compatible | ||
# for links to pre-2023-redesign blog posts. It could have other uses as well, like URL-shortening. | ||
# | ||
# Example: | ||
# /2023/02/tasking-manager-redesign | ||
# --> automatically redirects to --> | ||
# /news/2023/02/tasking-manager-redesign | ||
|
||
module RedirectPosts | ||
class RedirectPostsGenerator < Jekyll::Generator | ||
safe true | ||
|
||
def generate(site) | ||
site.posts.docs.each do |post| | ||
site.pages << PostRedirectPage.new(site, post) | ||
end | ||
end | ||
end | ||
end | ||
|
||
class PostRedirectPage < Jekyll::Page | ||
def initialize(site, post) | ||
@site = site # the current site instance. | ||
@base = site.source # path to the source directory. | ||
|
||
@basename = post.basename # filename without the extension. | ||
@ext = post.data["ext"] # the extension. | ||
@name = post.basename + post.data["ext"] # basically @basename + @ext. | ||
|
||
@data = {} | ||
|
||
data["layout"] = "redirect" | ||
data["redirect"] = post.url | ||
data["permalink"] = post.date.strftime('/%Y/%m/') + post.data["slug"] + "/" | ||
|
||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "post-aliases" | ||
spec.version = "0.1.0" | ||
spec.authors = ["Quincy Morgan"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = "Create redirect pages for /:year/:month/:title to canonical posts." | ||
spec.homepage = "https://github.com/osmus/dogwood" | ||
spec.license = "MIT" | ||
|
||
spec.files = Dir["lib/**/*"] | ||
|
||
spec.add_runtime_dependency "jekyll", "~> 4.3" | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
gemspec |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This plugin unwrap <img> elements wrapped in <p> elements, and adds an 'img-container' | ||
# class to <a> elements that wrap <img> elements. This allows us to properly style images | ||
# separately from <p>, e.g. to give them different widths. | ||
|
||
require 'kramdown/converter/html' | ||
|
||
BLANK_RE = /\A[[:space:]]*\z/ | ||
|
||
module StandaloneImages | ||
def isImageElement(ele) | ||
return ele.type == :img || (ele.type == :html_element && ele.value == "img") | ||
end | ||
def convert_p(el, indent) | ||
return super unless el.children.any? {|child| isImageElement(child) } || el.children.all? { |child| child.type == :a } | ||
# remove empty text elements that might be sandwiched between images | ||
els = el.children.select { |child| child.type != :text || !BLANK_RE.match?(child.value) } | ||
els = els.map { |child| | ||
if child.children.size == 1 && isImageElement(child.children.first) | ||
if child.attr['class'].nil? | ||
child.attr['class'] = 'img-container' | ||
else | ||
child.attr['class'] = child.attr['class'] + ' img-container' | ||
end | ||
end | ||
convert(child, indent) | ||
} | ||
return els.join('') | ||
end | ||
end | ||
|
||
Kramdown::Converter::Html.prepend StandaloneImages |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "unwrap-img" | ||
spec.version = "0.1.0" | ||
spec.authors = ["Quincy Morgan"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = "Unwrap Kramdown <img> elements from <p> elements." | ||
spec.homepage = "https://github.com/osmus/dogwood" | ||
spec.license = "MIT" | ||
|
||
spec.files = Dir["lib/**/*"] | ||
|
||
spec.add_runtime_dependency "jekyll", "~> 4.3" | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "osmus-dogwood" | ||
spec.version = "0.1.0" | ||
spec.authors = ["Quincy Morgan"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = "The Jekyll theme powering openstreetmap.us" | ||
spec.homepage = "https://github.com/osmus/dogwood" | ||
spec.license = "MIT" | ||
|
||
spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r!^(assets|_data|_plugins|_layouts|_includes|_sass|LICENSE|README|_config\.yml)!i) } | ||
|
||
spec.add_runtime_dependency "jekyll", "~> 4.3" | ||
|
||
spec.add_runtime_dependency "jekyll-archives", "~> 2.2.1" | ||
spec.add_runtime_dependency 'jekyll-include-cache', "~> 0.2.1" | ||
|
||
spec.add_runtime_dependency "absolute-urls" | ||
spec.add_runtime_dependency "post-aliases" | ||
spec.add_runtime_dependency "unwrap-img" | ||
end |