rubocop fixes
This commit is contained in:
parent
e18e017242
commit
14d363f87b
21
Gemfile
21
Gemfile
@ -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.
|
# 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
|
# 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:
|
# 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.
|
# This will help ensure the proper Jekyll version is running.
|
||||||
# Happy Jekylling!
|
# 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.
|
# 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
|
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
|
||||||
# uncomment the line below. To upgrade, run `bundle update github-pages`.
|
# uncomment the line below. To upgrade, run `bundle update github-pages`.
|
||||||
# gem "github-pages", group: :jekyll_plugins
|
# gem "github-pages", group: :jekyll_plugins
|
||||||
# If you have any plugins, put them here!
|
# If you have any plugins, put them here!
|
||||||
group :jekyll_plugins do
|
group :jekyll_plugins do
|
||||||
gem "jekyll-feed", git: "https://github.com/hyphacoop/jekyll-feed"
|
gem 'jekyll-feed', git: 'https://github.com/hyphacoop/jekyll-feed'
|
||||||
gem "jekyll-last-modified-at", "~> 1.3"
|
gem 'jekyll-last-modified-at', '~> 1.3'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
|
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
# and associated library.
|
# and associated library.
|
||||||
platforms :mingw, :x64_mingw, :mswin, :jruby do
|
platforms :mingw, :x64_mingw, :mswin, :jruby do
|
||||||
gem "tzinfo", "~> 1.2"
|
gem 'tzinfo', '~> 1.2'
|
||||||
gem "tzinfo-data"
|
gem 'tzinfo-data'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Performance-booster for watching directories on Windows
|
# 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"
|
|
||||||
|
@ -62,6 +62,10 @@ GEM
|
|||||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||||
rb-inotify (~> 0.9, >= 0.9.10)
|
rb-inotify (~> 0.9, >= 0.9.10)
|
||||||
mercenary (0.4.0)
|
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)
|
nokogiri (1.11.1-x86_64-darwin)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.11.1-x86_64-linux)
|
nokogiri (1.11.1-x86_64-linux)
|
||||||
@ -92,6 +96,7 @@ GEM
|
|||||||
yell (2.2.2)
|
yell (2.2.2)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
|
ruby
|
||||||
x86_64-darwin-19
|
x86_64-darwin-19
|
||||||
x86_64-linux
|
x86_64-linux
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Generate bi-directional links from a given collection and the nodes graph.
|
||||||
class BidirectionalLinksGenerator < Jekyll::Generator
|
class BidirectionalLinksGenerator < Jekyll::Generator
|
||||||
def generate(site)
|
def generate(site)
|
||||||
graph_nodes = []
|
graph_nodes = []
|
||||||
@ -9,7 +11,7 @@ class BidirectionalLinksGenerator < Jekyll::Generator
|
|||||||
|
|
||||||
all_docs = all_notes + all_pages
|
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
|
# Convert all Wiki/Roam-style double-bracket link syntax to plain HTML
|
||||||
# anchor tag elements (<a>) with "internal-link" CSS class
|
# anchor tag elements (<a>) with "internal-link" CSS class
|
||||||
@ -74,11 +76,13 @@ class BidirectionalLinksGenerator < Jekyll::Generator
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Nodes: Graph
|
# Nodes: Graph
|
||||||
graph_nodes << {
|
unless current_note.path.include?('_notes/index.html')
|
||||||
id: note_id_from_note(current_note),
|
graph_nodes << {
|
||||||
path: "#{site.baseurl}#{current_note.url}#{link_extension}",
|
id: note_id_from_note(current_note),
|
||||||
label: current_note.data['title'],
|
path: "#{site.baseurl}#{current_note.url}#{link_extension}",
|
||||||
} unless current_note.path.include?('_notes/index.html')
|
label: current_note.data['title']
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# Edges: Jekyll
|
# Edges: Jekyll
|
||||||
current_note.data['backlinks'] = notes_linking_to_current_note
|
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|
|
notes_linking_to_current_note.each do |n|
|
||||||
graph_edges << {
|
graph_edges << {
|
||||||
source: note_id_from_note(n),
|
source: note_id_from_note(n),
|
||||||
target: note_id_from_note(current_note),
|
target: note_id_from_note(current_note)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
File.write('_includes/notes_graph.json', JSON.dump({
|
File.write('_includes/notes_graph.json', JSON.dump({
|
||||||
edges: graph_edges,
|
edges: graph_edges,
|
||||||
nodes: graph_nodes,
|
nodes: graph_nodes
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def note_id_from_note(note)
|
def note_id_from_note(note)
|
||||||
note.data['title']
|
note.data['title']
|
||||||
.dup
|
.dup
|
||||||
.gsub(/\W+/, ' ')
|
.gsub(/\W+/, ' ')
|
||||||
.delete(' ')
|
.delete(' ')
|
||||||
.to_i(36)
|
.to_i(36)
|
||||||
.to_s
|
.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -8,7 +8,7 @@ JEKYLL
|
|||||||
|
|
||||||
# Inject empty front matter in notes that don't have any
|
# Inject empty front matter in notes that don't have any
|
||||||
Jekyll::Hooks.register :site, :after_init do |site|
|
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)
|
raw_note_content = File.read(filename)
|
||||||
unless raw_note_content.start_with?('---')
|
unless raw_note_content.start_with?('---')
|
||||||
raw_note_content.prepend(EMPTY_FRONT_MATTER)
|
raw_note_content.prepend(EMPTY_FRONT_MATTER)
|
||||||
|
Loading…
Reference in New Issue
Block a user