rubocop fixes

This commit is contained in:
Garry Ing 2021-03-31 22:50:13 -04:00
parent e18e017242
commit 14d363f87b
No known key found for this signature in database
GPG Key ID: 62E12D2F8C30C493
4 changed files with 37 additions and 27 deletions

21
Gemfile
View File

@ -1,4 +1,6 @@
source "https://rubygems.org"
# frozen_string_literal: true
source 'https://rubygems.org'
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
@ -7,28 +9,27 @@ source "https://rubygems.org"
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
gem "jekyll", "~> 4.2.0"
gem 'jekyll', '~> 4.2.0'
# This is the default theme for new Jekyll sites. You may change this to anything you like.
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", git: "https://github.com/hyphacoop/jekyll-feed"
gem "jekyll-last-modified-at", "~> 1.3"
gem 'jekyll-feed', git: 'https://github.com/hyphacoop/jekyll-feed'
gem 'jekyll-last-modified-at', '~> 1.3'
end
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
platforms :mingw, :x64_mingw, :mswin, :jruby do
gem "tzinfo", "~> 1.2"
gem "tzinfo-data"
gem 'tzinfo', '~> 1.2'
gem 'tzinfo-data'
end
# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
gem 'wdm', '~> 0.1.1', platforms: %i[mingw x64_mingw mswin]
gem 'html-proofer', '~> 3.18'
gem "html-proofer", "~> 3.18"
gem "rake", "~> 13.0"
gem 'rake', '~> 13.0'

View File

@ -62,6 +62,10 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
mini_portile2 (2.5.0)
nokogiri (1.11.1)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
nokogiri (1.11.1-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.11.1-x86_64-linux)
@ -92,6 +96,7 @@ GEM
yell (2.2.2)
PLATFORMS
ruby
x86_64-darwin-19
x86_64-linux

View File

@ -1,4 +1,6 @@
# frozen_string_literal: true
# Generate bi-directional links from a given collection and the nodes graph.
class BidirectionalLinksGenerator < Jekyll::Generator
def generate(site)
graph_nodes = []
@ -9,7 +11,7 @@ class BidirectionalLinksGenerator < Jekyll::Generator
all_docs = all_notes + all_pages
link_extension = !!site.config["use_html_extension"] ? '.html' : ''
link_extension = site.config['use_html_extension'] ? '.html' : ''
# Convert all Wiki/Roam-style double-bracket link syntax to plain HTML
# anchor tag elements (<a>) with "internal-link" CSS class
@ -74,11 +76,13 @@ class BidirectionalLinksGenerator < Jekyll::Generator
end
# Nodes: Graph
graph_nodes << {
id: note_id_from_note(current_note),
path: "#{site.baseurl}#{current_note.url}#{link_extension}",
label: current_note.data['title'],
} unless current_note.path.include?('_notes/index.html')
unless current_note.path.include?('_notes/index.html')
graph_nodes << {
id: note_id_from_note(current_note),
path: "#{site.baseurl}#{current_note.url}#{link_extension}",
label: current_note.data['title']
}
end
# Edges: Jekyll
current_note.data['backlinks'] = notes_linking_to_current_note
@ -87,23 +91,23 @@ class BidirectionalLinksGenerator < Jekyll::Generator
notes_linking_to_current_note.each do |n|
graph_edges << {
source: note_id_from_note(n),
target: note_id_from_note(current_note),
target: note_id_from_note(current_note)
}
end
end
File.write('_includes/notes_graph.json', JSON.dump({
edges: graph_edges,
nodes: graph_nodes,
}))
edges: graph_edges,
nodes: graph_nodes
}))
end
def note_id_from_note(note)
note.data['title']
.dup
.gsub(/\W+/, ' ')
.delete(' ')
.to_i(36)
.to_s
.dup
.gsub(/\W+/, ' ')
.delete(' ')
.to_i(36)
.to_s
end
end
end

View File

@ -8,7 +8,7 @@ JEKYLL
# Inject empty front matter in notes that don't have any
Jekyll::Hooks.register :site, :after_init do |site|
Dir.glob(site.collections['notes'].relative_directory + '/**/*.md').each do |filename|
Dir.glob("#{site.collections['notes'].relative_directory}/**/*.md").each do |filename|
raw_note_content = File.read(filename)
unless raw_note_content.start_with?('---')
raw_note_content.prepend(EMPTY_FRONT_MATTER)