jekyll-graph 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +9 -4
- data/lib/jekyll-graph/config.rb +19 -1
- data/lib/jekyll-graph/jekyll-graph.js +10 -10
- data/lib/jekyll-graph/version.rb +1 -1
- data/lib/jekyll-graph.rb +32 -28
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16fc54d9f258c71e879a2b65b3d642e2c6ba0a30efaec85fb036941bffdf5c49
|
|
4
|
+
data.tar.gz: 052f0d8c7c64150116e7205f66f8d0052433713f0f012eac3ce229f9f48001fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a4e8ea1b69e907907d5d384f7352dc4bc7f9cc1511c0e3a731cea9f43138074aa24f17691bc740a09979c34605add2838334b1ddf6ce8d96066597386c4ea70
|
|
7
|
+
data.tar.gz: 7ca4c585d6f999fb4a4dbf24801b7165fee27b67f01334e9d3dc66eb06f638889fc0276feeef71a5d632424c51a23c62445f667be74abbb255902936c63f7b2c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -64,6 +64,9 @@ graph:
|
|
|
64
64
|
scripts: "/assets/js"
|
|
65
65
|
net_web:
|
|
66
66
|
enabled: true
|
|
67
|
+
exclude:
|
|
68
|
+
attrs: false
|
|
69
|
+
links: false
|
|
67
70
|
force:
|
|
68
71
|
charge:
|
|
69
72
|
strength_x:
|
|
@@ -88,6 +91,8 @@ graph:
|
|
|
88
91
|
|
|
89
92
|
`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
93
|
|
|
94
|
+
`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.
|
|
95
|
+
|
|
91
96
|
`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
97
|
|
|
93
98
|
`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 +180,11 @@ For the tree graph, `graph-tree.json`, `links` are built from a tree data struct
|
|
|
175
180
|
"nodes": [
|
|
176
181
|
{
|
|
177
182
|
"id": "<some-id>",
|
|
178
|
-
"url": "<
|
|
183
|
+
"url": "<lineage-url>", // site.baseurl wil be handled for you here
|
|
179
184
|
"label": "<note's-title>",
|
|
180
|
-
"
|
|
181
|
-
"nodes": [<
|
|
182
|
-
"links": [<
|
|
185
|
+
"lineage": {
|
|
186
|
+
"nodes": [<lineage-node-id>, ...],
|
|
187
|
+
"links": [<lineage-link-id>, ...],
|
|
183
188
|
}
|
|
184
189
|
},
|
|
185
190
|
...
|
data/lib/jekyll-graph/config.rb
CHANGED
|
@@ -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
|
-
#
|
|
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
|
|
@@ -127,19 +127,19 @@ export default class JekyllGraph {
|
|
|
127
127
|
let hoverNode = null;
|
|
128
128
|
let hoverLink = null;
|
|
129
129
|
|
|
130
|
-
//
|
|
130
|
+
// lineage: replace ids with full objects
|
|
131
131
|
data.nodes.forEach(node => {
|
|
132
|
-
//
|
|
132
|
+
// lineage
|
|
133
133
|
let relativeNodes = [];
|
|
134
|
-
node.
|
|
134
|
+
node.lineage.nodes.forEach(nNodeId => {
|
|
135
135
|
relativeNodes.push(data.nodes.find(node => node.id === nNodeId));
|
|
136
136
|
});
|
|
137
137
|
let relativeLinks = [];
|
|
138
|
-
node.
|
|
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.
|
|
142
|
-
node.
|
|
141
|
+
node.lineage.nodes = relativeNodes;
|
|
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.
|
|
192
|
-
node.
|
|
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.
|
|
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.
|
|
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)) {
|
data/lib/jekyll-graph/version.rb
CHANGED
data/lib/jekyll-graph.rb
CHANGED
|
@@ -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.
|
|
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
|
|
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
|
|
144
|
+
# set lineage
|
|
145
145
|
|
|
146
|
-
ancestor_node_ids, descendent_node_ids = @site.tree.
|
|
147
|
-
|
|
148
|
-
json_node[:
|
|
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 =
|
|
151
|
+
lineage_ids = lineage_node_ids.concat([json_node[:id]])
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
json_node[:
|
|
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
|
-
|
|
207
|
-
#
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
|
|
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
|
-
|
|
285
|
+
lineage: {
|
|
282
286
|
nodes: [],
|
|
283
287
|
links: [],
|
|
284
288
|
},
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll-graph
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
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-
|
|
11
|
+
date: 2021-11-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jekyll-namespaces
|