jekyll-graph 0.0.3 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56a0cf412d49fe1abbc5280977f3bc732f7ff42836abddb64a948e26d4f5dc89
4
- data.tar.gz: 29914337ea3a859ea54a5585e10944cb3334d48c7d9a021902e2ab8f87130f64
3
+ metadata.gz: 4ed0feb31f2a12640c7ba6611b2768a0d2424fff77a5d6909876e5f1b586abd0
4
+ data.tar.gz: 856133d37f0c83fc570ea8437edea51a4181d5b43f8e832b310ea17a08966a4c
5
5
  SHA512:
6
- metadata.gz: 58d70f942b2024ba62c52c7fcd1a88162f36e342e02268ba198852f6dd09b08f7768edb2a7504abecb0495ae4d8f0d1071dc40320868bd95c06bc94330e82364
7
- data.tar.gz: 66f5daee147641ad9ac8c1c71c8baffe90a6d3400d6e52f42e725cf886444775e38272dbb7907be3df2e892e835e9230ebe4690774a3cc2decdd71f899652152
6
+ metadata.gz: 7cff6886e6391bb8920746f0f248fb13ed8f795841c66c714f0c91b158afa0c16253d82249941fee5b2b4e018a2d715af2fd4527509ab3af7d0626f415c52d68
7
+ data.tar.gz: cbd240e478d07b67f92c8da3d8a31c261e3a3ea58a9052838b7fd4bb30da830dc37092c72453db65e2aab293a9bdf38d022f522cba227008947d3c45bfeb2275
data/CHANGELOG.md CHANGED
@@ -1,4 +1,19 @@
1
- ## [0.0.3] 2021-11-22
1
+ ## [0.0.7] - 2022-01-27
2
+ ### Change
3
+ - Bump jekyll-wikilinks version number (0.0.11).
4
+ ## [0.0.6] - 2022-01-24
5
+ ### Change
6
+ - Move jekyll patch files to patch/ dir.
7
+ - Bump jekyll-wikilinks version number (0.0.10).
8
+ ## [0.0.5] - 2021-11-23
9
+ ### Change
10
+ - 'relatives' -> 'lineage' for tree nodes.
11
+
12
+ ## [0.0.4] - 2021-11-22
13
+ ### Fix
14
+ - Custom path config related fix in scripts.
15
+
16
+ ## [0.0.3] - 2021-11-22
2
17
  ### Change
3
18
  - Fix javascript inheritance.
4
19
  - Decrement missing node log messages from 'warn' to 'debug'.
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
 
8
8
  gem "jekyll", "~> 4.2.0"
9
9
  gem "jekyll-namespaces", "~> 0.0.3"
10
- gem "jekyll-wikilinks", "~> 0.0.8"
10
+ gem "jekyll-wikilinks", "~> 0.0.11"
11
11
 
12
12
  gem "rake", "~> 13.0.3"
13
13
  gem "rspec", "~> 3.10"
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Jekyll-Graph generates data and renders a graph that allows visitors to navigate a jekyll site by clicking nodes in the graph. Nodes are generated from the site's markdown files. Links for the tree graph are generated from [`jekyll-namespaces`](https://github.com/manunamz/jekyll-namespaces) and links for the net-web graph from [`jekyll-wikilinks`](https://github.com/manunamz/jekyll-wikilinks).
8
8
 
9
- This gem is part of the [jekyll-bonsai](https://manunamz.github.io/jekyll-bonsai/) project. 🎋
9
+ This gem is part of the [jekyll-bonsai](https://jekyll-bonsai.netlify.app/) project. 🎋
10
10
 
11
11
  ## Installation
12
12
 
@@ -41,15 +41,17 @@ export default class JekyllGraphSubClass extends JekyllGraph {
41
41
 
42
42
  constructor() {
43
43
  super();
44
+ // access graph with 'this.graph'
44
45
  // access graph div with 'this.graphDiv'
45
46
  }
46
47
 
47
48
  // ...
48
49
  }
49
50
  ```
51
+
50
52
  Call `this.drawNetWeb()` and `this.drawTree()` to actually draw the graph. You could do this simply on initialization or on a button click, etc.
51
53
 
52
- Unless otherwise defined, the `jekyll-graph.js` file will be generated into `_site/assets/js/`.
54
+ Unless otherwise configured (see `path` vars below), the `jekyll-graph.js` file will be generated into `_site/assets/js/`.
53
55
 
54
56
  ## Configuration
55
57
 
@@ -64,6 +66,9 @@ graph:
64
66
  scripts: "/assets/js"
65
67
  net_web:
66
68
  enabled: true
69
+ exclude:
70
+ attrs: false
71
+ links: false
67
72
  force:
68
73
  charge:
69
74
  strength_x:
@@ -88,6 +93,8 @@ graph:
88
93
 
89
94
  `path.scripts`: An optional custom scripts location for the graph scripts to generate into. Location is relative to the assets location in the `_site/` directory (If `assets_path` is set, but `scripts_path` is not, the location will default to `_site/<assets_path>/js/`).
90
95
 
96
+ `net_web.exclude.attrs` and `net_web.exclude.links`: Determines whether wikilink attributes and/or links are added to the net-web graph from the link index.
97
+
91
98
  `tree.enabled` and `net_web.enabled`: Toggles on/off the `tree` and `net_web` graphs, respectively. Be sure to disable graphs that are not in use.
92
99
 
93
100
  `tree.force` and `net_web.force`: These are force variables from d3's simulation forces. You can check out the [docs for details](https://github.com/d3/d3-force#simulation_force).
@@ -175,11 +182,11 @@ For the tree graph, `graph-tree.json`, `links` are built from a tree data struct
175
182
  "nodes": [
176
183
  {
177
184
  "id": "<some-id>",
178
- "url": "<relative-url>", // site.baseurl wil be handled for you here
185
+ "url": "<lineage-url>", // site.baseurl wil be handled for you here
179
186
  "label": "<note's-title>",
180
- "relatives": {
181
- "nodes": [<relative-node-id>, ...],
182
- "links": [<relative-link-id>, ...],
187
+ "lineage": {
188
+ "nodes": [<lineage-node-id>, ...],
189
+ "links": [<lineage-link-id>, ...],
183
190
  }
184
191
  },
185
192
  ...
data/jekyll-graph.gemspec CHANGED
@@ -30,11 +30,11 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  # Uncomment to register a new dependency of your gem
33
- # spec.add_dependency "example-gem", "~> 1.0"
33
+ spec.add_dependency "jekyll", "~> 4.2.0"
34
34
 
35
35
  # For more information and examples about making a new gem, checkout our
36
36
  # guide at: https://bundler.io/guides/creating_gem.html
37
37
 
38
38
  spec.add_runtime_dependency "jekyll-namespaces", "~> 0.0.3"
39
- spec.add_runtime_dependency "jekyll-wikilinks", "~> 0.0.8"
39
+ spec.add_runtime_dependency "jekyll-wikilinks", "~> 0.0.11"
40
40
  end
@@ -7,9 +7,11 @@ module Jekyll
7
7
  class PluginConfig
8
8
 
9
9
  ASSETS_KEY = "assets"
10
+ ATTRS_KEY = "attrs"
10
11
  CONFIG_KEY = "graph"
11
12
  ENABLED_KEY = "enabled"
12
13
  EXCLUDE_KEY = "exclude"
14
+ LINKS_KEY = "links"
13
15
  NET_WEB_KEY = "net_web"
14
16
  PATH_KEY = "path"
15
17
  SCRIPTS_KEY = "scripts"
@@ -22,7 +24,7 @@ module Jekyll
22
24
  Jekyll.logger.debug("Excluded jekyll types in graph: ", option(EXCLUDE_KEY)) unless disabled?
23
25
  end
24
26
 
25
- # options
27
+ # descriptors
26
28
 
27
29
  def disabled?
28
30
  return option(ENABLED_KEY) == false
@@ -49,6 +51,18 @@ module Jekyll
49
51
  return option_path(SCRIPTS_KEY)
50
52
  end
51
53
 
54
+ def use_attrs?
55
+ return true if option_net_web_exclude(ATTRS_KEY).nil?
56
+ return !option_net_web_exclude(ATTRS_KEY)
57
+ end
58
+
59
+ def use_links?
60
+ return true if option_net_web_exclude(LINKS_KEY).nil?
61
+ return !option_net_web_exclude(LINKS_KEY)
62
+ end
63
+
64
+ # options
65
+
52
66
  def option(key)
53
67
  @config[CONFIG_KEY] && @config[CONFIG_KEY][key]
54
68
  end
@@ -61,6 +75,10 @@ module Jekyll
61
75
  @config[CONFIG_KEY] && @config[CONFIG_KEY][NET_WEB_KEY] && @config[CONFIG_KEY][NET_WEB_KEY][key]
62
76
  end
63
77
 
78
+ def option_net_web_exclude(key)
79
+ @config[CONFIG_KEY] && @config[CONFIG_KEY][NET_WEB_KEY] && @config[CONFIG_KEY][NET_WEB_KEY][EXCLUDE_KEY] && @config[CONFIG_KEY][NET_WEB_KEY][EXCLUDE_KEY][key]
80
+ end
81
+
64
82
  def option_tree(key)
65
83
  @config[CONFIG_KEY] && @config[CONFIG_KEY][TREE_KEY] && @config[CONFIG_KEY][TREE_KEY][key]
66
84
  end
@@ -8,7 +8,7 @@ export default class JekyllGraph {
8
8
 
9
9
  // d3
10
10
  drawNetWeb () {
11
- let assetsPath = '{{ site.graph.assets_path }}' !== '' ? '{{ site.graph.assets_path }}' : '/assets';
11
+ let assetsPath = '{{ site.graph.path.assets }}' !== '' ? '{{ site.graph.path.assets }}' : '/assets';
12
12
  fetch(`{{ site.baseurl }}${assetsPath}/graph-net-web.json`).then(res => res.json()).then(data => {
13
13
 
14
14
  // neighbors: replace ids with full object
@@ -110,7 +110,7 @@ export default class JekyllGraph {
110
110
  }
111
111
 
112
112
  drawTree () {
113
- let assetsPath = '{{ site.graph.assets_path }}' !== '' ? '{{ site.graph.assets_path }}' : '/assets';
113
+ let assetsPath = '{{ site.graph.path.assets }}' !== '' ? '{{ site.graph.path.assets }}' : '/assets';
114
114
  fetch(`{{ site.baseurl }}${assetsPath}/graph-tree.json`).then(res => res.json()).then(data => {
115
115
 
116
116
  if (this.graph) {
@@ -127,19 +127,19 @@ export default class JekyllGraph {
127
127
  let hoverNode = null;
128
128
  let hoverLink = null;
129
129
 
130
- // relatives: replace ids with full objects
130
+ // lineage: replace ids with full objects
131
131
  data.nodes.forEach(node => {
132
- // relatives
133
- let relativeNodes = [];
134
- node.relatives.nodes.forEach(nNodeId => {
135
- relativeNodes.push(data.nodes.find(node => node.id === nNodeId));
132
+ // lineage
133
+ let lineageNodes = [];
134
+ node.lineage.nodes.forEach(nNodeId => {
135
+ lineageNodes.push(data.nodes.find(node => node.id === nNodeId));
136
136
  });
137
137
  let relativeLinks = [];
138
- node.relatives.links.forEach(nLink => {
138
+ node.lineage.links.forEach(nLink => {
139
139
  relativeLinks.push(data.links.find(link => link.source === nLink.source && link.target === nLink.target));
140
140
  });
141
- node.relatives.nodes = relativeNodes;
142
- node.relatives.links = relativeLinks;
141
+ node.lineage.nodes = lineageNodes;
142
+ node.lineage.links = relativeLinks;
143
143
  // siblings
144
144
  this.numSiblingsLeft[node.parent] = node.siblings.length;
145
145
  });
@@ -188,8 +188,8 @@ export default class JekyllGraph {
188
188
  highlightLinks.clear();
189
189
  if (node) {
190
190
  highlightNodes.add(node);
191
- node.relatives.nodes.forEach(node => highlightNodes.add(node));
192
- node.relatives.links.forEach(link => highlightLinks.add(link));
191
+ node.lineage.nodes.forEach(node => highlightNodes.add(node));
192
+ node.lineage.links.forEach(link => highlightLinks.add(link));
193
193
  }
194
194
  hoverNode = node || null;
195
195
  })
@@ -269,9 +269,9 @@ export default class JekyllGraph {
269
269
  } else if (hoverNode !== null && gType === "net-web" && !hoverNode.neighbors.nodes.includes(node)) {
270
270
  // non-neighbor to hoverNode
271
271
  fillText = false;
272
- } else if (hoverNode !== null && gType === "tree" && hoverNode.relatives.nodes.includes(node)) {
272
+ } else if (hoverNode !== null && gType === "tree" && hoverNode.lineage.nodes.includes(node)) {
273
273
  // neighbor to hoverNode
274
- } else if (hoverNode !== null && gType === "tree" && !hoverNode.relatives.nodes.includes(node)) {
274
+ } else if (hoverNode !== null && gType === "tree" && !hoverNode.lineage.nodes.includes(node)) {
275
275
  // non-neighbor to hoverNode
276
276
  fillText = false;
277
277
  } else if ((hoverNode === null && hoverLink !== null) && (hoverLink.source === node || hoverLink.target === node)) {
File without changes
File without changes
@@ -3,7 +3,7 @@
3
3
  module Jekyll
4
4
  module Graph
5
5
 
6
- VERSION = "0.0.3"
6
+ VERSION = "0.0.7"
7
7
 
8
8
  end
9
9
  end
data/lib/jekyll-graph.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  require "jekyll"
3
3
 
4
- require_relative "jekyll-graph/context"
5
- require_relative "jekyll-graph/page"
4
+ require_relative "jekyll-graph/patch/context"
5
+ require_relative "jekyll-graph/patch/page"
6
6
  require_relative "jekyll-graph/version"
7
7
 
8
8
  # setup config
@@ -69,7 +69,7 @@ module Jekyll
69
69
  if !$graph_conf.disabled_tree?
70
70
  # generate json data
71
71
  json_tree_nodes, json_tree_links = self.generate_json_tree(@site.tree.root)
72
- self.set_relatives(json_tree_nodes, json_tree_links)
72
+ self.set_lineage(json_tree_nodes, json_tree_links)
73
73
  tree_graph_content = JSON.dump(
74
74
  nodes: json_tree_nodes,
75
75
  links: json_tree_links,
@@ -138,20 +138,20 @@ module Jekyll
138
138
  end
139
139
  end
140
140
 
141
- def set_relatives(json_nodes, json_links)
141
+ def set_lineage(json_nodes, json_links)
142
142
  # TODO: json nodes have relative_url, but node.id's/urls are doc urls.
143
143
  json_nodes.each do |json_node|
144
- # set relatives
144
+ # set lineage
145
145
 
146
- ancestor_node_ids, descendent_node_ids = @site.tree.get_all_relative_ids(json_node[:id])
147
- relative_node_ids = ancestor_node_ids.concat(descendent_node_ids)
148
- json_node[:relatives][:nodes] = relative_node_ids if !relative_node_ids.nil?
146
+ ancestor_node_ids, descendent_node_ids = @site.tree.get_all_lineage_ids(json_node[:id])
147
+ lineage_node_ids = ancestor_node_ids.concat(descendent_node_ids)
148
+ json_node[:lineage][:nodes] = lineage_node_ids if !lineage_node_ids.nil?
149
149
 
150
150
  # include current node when filtering for links along entire relative lineage
151
- lineage_ids = relative_node_ids.concat([json_node[:id]])
151
+ lineage_ids = lineage_node_ids.concat([json_node[:id]])
152
152
 
153
- json_relative_links = json_links.select { |l| lineage_ids.include?(l[:source]) && lineage_ids.include?(l[:target]) }
154
- json_node[:relatives][:links] = json_relative_links if !json_relative_links.nil?
153
+ json_lineage_links = json_links.select { |l| lineage_ids.include?(l[:source]) && lineage_ids.include?(l[:target]) }
154
+ json_node[:lineage][:links] = json_lineage_links if !json_lineage_links.nil?
155
155
 
156
156
  # set siblings
157
157
 
@@ -203,10 +203,27 @@ module Jekyll
203
203
  },
204
204
  }
205
205
  # TODO: this link calculation ends up with duplicates -- re-visit this later.
206
- @site.link_index.index[doc.url].attributes.each do |link| # link = { 'type' => str, 'urls' => [str, str, ...] }
207
- # TODO: Header + Block-level wikilinks
208
- link['urls'].each do |lu|
209
- link_no_anchor = lu.match(/([^#]+)/i)[0]
206
+ if $graph_conf.use_attrs?
207
+ @site.link_index.index[doc.url].attributes.each do |link| # link = { 'type' => str, 'urls' => [str, str, ...] }
208
+ # TODO: Header + Block-level wikilinks
209
+ link['urls'].each do |lu|
210
+ link_no_anchor = lu.match(/([^#]+)/i)[0]
211
+ link_no_baseurl = @site.baseurl.nil? ? link_no_anchor : link_no_anchor.gsub(@site.baseurl, "")
212
+ linked_doc = @md_docs.select{ |d| d.url == link_no_baseurl }
213
+ if !linked_doc.nil? && linked_doc.size == 1 && !$graph_conf.excluded?(linked_doc.first.type)
214
+ # TODO: add link['type'] to d3 graph
215
+ net_web_links << {
216
+ source: doc.url,
217
+ target: linked_doc.first.url,
218
+ }
219
+ end
220
+ end
221
+ end
222
+ end
223
+ if $graph_conf.use_links?
224
+ @site.link_index.index[doc.url].forelinks.each do |link| # link = { 'type' => str, 'url' => str }
225
+ # TODO: Header + Block-level wikilinks
226
+ link_no_anchor = link['url'].match(/([^#]+)/i)[0]
210
227
  link_no_baseurl = @site.baseurl.nil? ? link_no_anchor : link_no_anchor.gsub(@site.baseurl, "")
211
228
  linked_doc = @md_docs.select{ |d| d.url == link_no_baseurl }
212
229
  if !linked_doc.nil? && linked_doc.size == 1 && !$graph_conf.excluded?(linked_doc.first.type)
@@ -218,19 +235,6 @@ module Jekyll
218
235
  end
219
236
  end
220
237
  end
221
- @site.link_index.index[doc.url].forelinks.each do |link| # link = { 'type' => str, 'url' => str }
222
- # TODO: Header + Block-level wikilinks
223
- link_no_anchor = link['url'].match(/([^#]+)/i)[0]
224
- link_no_baseurl = @site.baseurl.nil? ? link_no_anchor : link_no_anchor.gsub(@site.baseurl, "")
225
- linked_doc = @md_docs.select{ |d| d.url == link_no_baseurl }
226
- if !linked_doc.nil? && linked_doc.size == 1 && !$graph_conf.excluded?(linked_doc.first.type)
227
- # TODO: add link['type'] to d3 graph
228
- net_web_links << {
229
- source: doc.url,
230
- target: linked_doc.first.url,
231
- }
232
- end
233
- end
234
238
 
235
239
  end
236
240
  end
@@ -252,7 +256,7 @@ module Jekyll
252
256
  namespace: node.namespace,
253
257
  url: "",
254
258
  level: level,
255
- relatives: {
259
+ lineage: {
256
260
  nodes: [],
257
261
  links: [],
258
262
  },
@@ -278,7 +282,7 @@ module Jekyll
278
282
  namespace: node.namespace,
279
283
  url: relative_url(node.url),
280
284
  level: level,
281
- relatives: {
285
+ lineage: {
282
286
  nodes: [],
283
287
  links: [],
284
288
  },
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - manunamz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-22 00:00:00.000000000 Z
11
+ date: 2022-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: jekyll-namespaces
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -30,14 +44,14 @@ dependencies:
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: 0.0.8
47
+ version: 0.0.11
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: 0.0.8
54
+ version: 0.0.11
41
55
  description:
42
56
  email:
43
57
  - manunamz@pm.me
@@ -59,9 +73,9 @@ files:
59
73
  - jekyll-graph.gemspec
60
74
  - lib/jekyll-graph.rb
61
75
  - lib/jekyll-graph/config.rb
62
- - lib/jekyll-graph/context.rb
63
76
  - lib/jekyll-graph/jekyll-graph.js
64
- - lib/jekyll-graph/page.rb
77
+ - lib/jekyll-graph/patch/context.rb
78
+ - lib/jekyll-graph/patch/page.rb
65
79
  - lib/jekyll-graph/tags.rb
66
80
  - lib/jekyll-graph/version.rb
67
81
  homepage: https://github.com/manunamz/jekyll-graph