From 2500f1a62636465dcc38e02913100e3b6aa99c7f Mon Sep 17 00:00:00 2001 From: James Walker Date: Thu, 15 Dec 2022 14:39:17 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20relative=5Fpath=20filter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 404.html | 2 +- Gemfile.lock | 47 ++++++++++++++++++++++++++++++++++++- _includes/article_list.html | 2 +- _includes/post.html | 4 ++-- _layouts/default.html | 4 ++-- _layouts/post.html | 6 ++--- _plugins/relative_path.rb | 10 ++++++++ _plugins/tag_index.rb | 37 +++++++++++++++-------------- index.html | 4 ++-- 9 files changed, 87 insertions(+), 29 deletions(-) create mode 100644 _plugins/relative_path.rb diff --git a/404.html b/404.html index 37f2a35..483d743 100644 --- a/404.html +++ b/404.html @@ -2,4 +2,4 @@ layout: page title: Uh oh. --- -Looks like I lost that one, sorry. Maybe check the archive? +Looks like I lost that one, sorry. Maybe check the archive? diff --git a/Gemfile.lock b/Gemfile.lock index 325851b..41428e7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,15 +3,20 @@ GEM specs: addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) + ast (2.4.2) + backport (1.2.0) + benchmark (0.2.1) colorator (1.1.0) concurrent-ruby (1.1.10) + diff-lcs (1.5.0) + e2mmap (0.1.0) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) ethon (0.16.0) ffi (>= 1.15.0) eventmachine (1.2.7) - faraday (2.7.1) + faraday (2.7.2) faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) faraday-net_http (3.0.2) @@ -29,6 +34,7 @@ GEM http_parser.rb (0.8.0) i18n (1.12.0) concurrent-ruby (~> 1.0) + jaro_winkler (1.5.4) jekyll (4.3.1) addressable (~> 2.4) colorator (~> 1.0) @@ -56,6 +62,7 @@ GEM sassc (> 2.0.1, < 3.0) jekyll-watch (2.2.1) listen (~> 3.0) + json (2.6.3) kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) @@ -73,6 +80,8 @@ GEM faraday (>= 1, < 3) sawyer (~> 0.9) parallel (1.22.1) + parser (3.1.3.0) + ast (~> 2.4.1) pathutil (0.16.2) forwardable-extended (~> 2.6) public_suffix (5.0.1) @@ -81,8 +90,24 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) + regexp_parser (2.6.1) + reverse_markdown (2.1.1) + nokogiri rexml (3.2.5) rouge (4.0.0) + rubocop (1.40.0) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.1.2.1) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.23.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.24.0) + parser (>= 3.1.1.0) + ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) safe_yaml (1.0.5) sassc (2.4.0) @@ -90,12 +115,31 @@ GEM sawyer (0.9.2) addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) + solargraph (0.47.2) + backport (~> 1.2) + benchmark + bundler (>= 1.17.2) + diff-lcs (~> 1.4) + e2mmap + jaro_winkler (~> 1.5) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.1) + parser (~> 3.0) + reverse_markdown (>= 1.0.5, < 3) + rubocop (>= 0.52) + thor (~> 1.0) + tilt (~> 2.0) + yard (~> 0.9, >= 0.9.24) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) + thor (1.2.1) + tilt (2.0.11) typhoeus (1.4.0) ethon (>= 0.9.0) unicode-display_width (2.3.0) webrick (1.7.0) + yard (0.9.28) + webrick (~> 1.7.0) yell (2.2.2) zeitwerk (2.6.6) @@ -109,6 +153,7 @@ DEPENDENCIES jekyll-feed jekyll-gist jekyll-postcss + solargraph BUNDLED WITH 2.2.20 diff --git a/_includes/article_list.html b/_includes/article_list.html index ad439fa..0e99b5d 100644 --- a/_includes/article_list.html +++ b/_includes/article_list.html @@ -1,4 +1,4 @@
- {{post.title}} + {{post.title}}
diff --git a/_includes/post.html b/_includes/post.html index a1e6460..d712563 100644 --- a/_includes/post.html +++ b/_includes/post.html @@ -1,11 +1,11 @@

{{ post.title }}

- +
{% if post.image %}
- {{ post.title }} + {{ post.title }} {% if post.image_source %}
{{ post.image_source }} diff --git a/_layouts/default.html b/_layouts/default.html index 63e121d..7dad595 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -3,8 +3,8 @@ {% if page.title %}{{ page.title }} | {% endif %}{{ site.title }} {% include meta.html %} - - + + diff --git a/_layouts/post.html b/_layouts/post.html index 317e1da..03ae267 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -8,7 +8,7 @@ layout: default {% if page.image %}
- {{ page.title }} + {{ page.title }} {% if page.image_source %}
{{ page.image_source }} @@ -21,8 +21,8 @@ layout: default diff --git a/_plugins/relative_path.rb b/_plugins/relative_path.rb new file mode 100644 index 0000000..faafc56 --- /dev/null +++ b/_plugins/relative_path.rb @@ -0,0 +1,10 @@ +module Jekyll + module RelativePath + def relative_path(url) + page_url = @context.registers[:page]['url'] + Pathname(url).relative_path_from(Pathname(page_url)).to_s + end + end +end + +Liquid::Template.register_filter(Jekyll::RelativePath) diff --git a/_plugins/tag_index.rb b/_plugins/tag_index.rb index f0ca9a5..8e22a8c 100644 --- a/_plugins/tag_index.rb +++ b/_plugins/tag_index.rb @@ -5,12 +5,12 @@ module Jekyll @base = base @dir = dir @name = 'index.html' - self.process(@name) - self.read_yaml(File.join(base, '_layouts'), 'tag_index.html') - self.data['tag'] = tag + process(@name) + read_yaml(File.join(base, '_layouts'), 'tag_index.html') + data['tag'] = tag tag_title_prefix = site.config['tag_title_prefix'] || 'Posts Tagged “' tag_title_suffix = site.config['tag_title_suffix'] || '”' - self.data['title'] = "#{tag_title_prefix}#{tag}#{tag_title_suffix}" + data['title'] = "#{tag_title_prefix}#{tag}#{tag_title_suffix}" end end @@ -20,31 +20,31 @@ module Jekyll @base = base @dir = tag_dir @name = 'atom.xml' - self.process(@name) + process(@name) # Read the YAML data from the layout page. - self.read_yaml(File.join(base, '_layouts'), 'tag_feed.xml') - self.data['tag'] = tag + read_yaml(File.join(base, '_layouts'), 'tag_feed.xml') + data['tag'] = tag # Set the title for this page. tag_title_prefix = site.config['tag_title_prefix'] || 'Posts Tagged “' tag_title_suffix = site.config['tag_title_suffix'] || '”' - self.data['title'] = "#{tag_title_prefix}#{tag}#{tag_title_suffix}" + data['title'] = "#{tag_title_prefix}#{tag}#{tag_title_suffix}" # Set the meta-description for this page. # Set the correct feed URL. - self.data['feed_url'] = "#{tag_dir}/#{name}" + data['feed_url'] = "#{tag_dir}/#{name}" end end class TagGenerator < Generator safe true def generate(site) - if site.layouts.key? 'tag_index' - dir = site.config['tag_dir'] || 'tag' - site.tags.keys.each do |tag| - dest_dir = File.join(dir, tag.tr(' ', '-')) - write_tag_index(site, dest_dir, tag) - write_tag_feed(site, dest_dir, tag) - end + return unless site.layouts.key? 'tag_index' + + dir = site.config['tag_dir'] || 'tag' + site.tags.keys.each do |tag| + dest_dir = File.join(dir, tag.tr(' ', '-')) + write_tag_index(site, dest_dir, tag) + write_tag_feed(site, dest_dir, tag) end end @@ -74,8 +74,11 @@ module Jekyll # def tag_links(tags) tags = tags.sort!.map do |item| + page_url = @context.registers[:page]['url'] + item.tr!(' ', '-') - "#{item}" + tag_path = "/tag/#{item}" + "#{item}" end tags.join(', ') end diff --git a/index.html b/index.html index 083193f..eb2a709 100644 --- a/index.html +++ b/index.html @@ -4,11 +4,11 @@ title: James Walker ---
- James Walker + James Walker

👋 I'm James Walker aka walkah.

I am a free software developer in Toronto, Canada. I'm currently the VP of Engineering at Fission where we're building tools for a decentralized, open web.

You can follow my work on github and twitter, but I prefer the fediverse and matrix.

-
\ No newline at end of file +