jekyll-graph 0.0.7 → 0.0.9
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 +5 -0
- data/README.md +23 -3
- data/lib/jekyll-graph/jekyll-graph.js +15 -13
- data/lib/jekyll-graph/version.rb +1 -1
- data/lib/jekyll-graph.rb +20 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de4fcabd768803478de94c420777d5c869ef3413cf310fad0a787df5de651291
|
4
|
+
data.tar.gz: dbb8770a7bfd68bde812fc99e45cf048a3f8edef25fc2f02435eaa6aa9047e8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7c26b4ee6344fb97217275054f1d6882eaaa0d137fbcfd6c76045a1819cdc95d351fd77794f0fb560cc5af44571def099d45c3c1a7d3be5fb05a7541c01cb4d
|
7
|
+
data.tar.gz: 8c020f044a5130b91222e1bc990a95f4fe04ceae3e27a29f7f1adce4fa1cc655acf080bbc87a6545e182ad96f92747627bf2a4da389722dd6c19e639780ffcf1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -37,7 +37,7 @@ Follow the instructions for installing a [jekyll plugin](https://jekyllrb.com/do
|
|
37
37
|
```javascript
|
38
38
|
import JekyllGraph from './jekyll-graph.js';
|
39
39
|
|
40
|
-
|
40
|
+
class JekyllGraphSubClass extends JekyllGraph {
|
41
41
|
|
42
42
|
constructor() {
|
43
43
|
super();
|
@@ -49,10 +49,27 @@ export default class JekyllGraphSubClass extends JekyllGraph {
|
|
49
49
|
}
|
50
50
|
```
|
51
51
|
|
52
|
-
|
52
|
+
The import should point to the `jekyll-graph.js` javascript file generated by the plugin. Unless otherwise configured (see `path` vars below), the `jekyll-graph.js` file will be generated into `_site/assets/js/`. The sample javascript snippet above is presumed to be generated into `_site/assets/js/` as well.
|
53
53
|
|
54
|
-
|
54
|
+
4. Create a class instance:
|
55
55
|
|
56
|
+
```javascript
|
57
|
+
var graph = new JekyllGraphSubClass();
|
58
|
+
```
|
59
|
+
|
60
|
+
5. Call `drawNetWeb()` and/or `drawTree()` to actually draw the graph. You could do this simply on initialization or on a button click, etc.
|
61
|
+
|
62
|
+
```javascript
|
63
|
+
// on page load
|
64
|
+
(() => {
|
65
|
+
graph.drawNetWeb();
|
66
|
+
});
|
67
|
+
|
68
|
+
// on button click
|
69
|
+
this.graphBtn.addEventListener('click', () => {
|
70
|
+
graph.drawTree();
|
71
|
+
});
|
72
|
+
```
|
56
73
|
## Configuration
|
57
74
|
|
58
75
|
Default configs look like this:
|
@@ -127,6 +144,8 @@ No configurations are strictly necessary for plugin defaults to work.
|
|
127
144
|
Graph colors are determined by css variables which may be defined like so -- any valid css color works (hex, rgba, etc.):
|
128
145
|
|
129
146
|
```CSS
|
147
|
+
/* make sure color vars are attached to the root of the html document */
|
148
|
+
html {
|
130
149
|
/* nodes */
|
131
150
|
/* glow */
|
132
151
|
--graph-node-current-glow: yellow;
|
@@ -142,6 +161,7 @@ Graph colors are determined by css variables which may be defined like so -- any
|
|
142
161
|
--graph-particles-color: grey;
|
143
162
|
/* label text */
|
144
163
|
--graph-text-color: black;
|
164
|
+
}
|
145
165
|
```
|
146
166
|
|
147
167
|
## Data
|
@@ -14,12 +14,12 @@ export default class JekyllGraph {
|
|
14
14
|
// neighbors: replace ids with full object
|
15
15
|
data.nodes.forEach(node => {
|
16
16
|
let neighborNodes = [];
|
17
|
-
node.neighbors.nodes.forEach(
|
18
|
-
neighborNodes.push(data.nodes.find(node => node.id ===
|
17
|
+
node.neighbors.nodes.forEach(nodeId => {
|
18
|
+
neighborNodes.push(data.nodes.find(node => node.id === nodeId));
|
19
19
|
});
|
20
20
|
let neighborLinks = [];
|
21
|
-
node.neighbors.links.forEach(
|
22
|
-
neighborLinks.push(data.links.find(link => link.source ===
|
21
|
+
node.neighbors.links.forEach(linkIds => {
|
22
|
+
neighborLinks.push(data.links.find(link => link.source === linkIds.source && link.target === linkIds.target));
|
23
23
|
});
|
24
24
|
node.neighbors.nodes = neighborNodes;
|
25
25
|
node.neighbors.links = neighborLinks;
|
@@ -131,15 +131,15 @@ export default class JekyllGraph {
|
|
131
131
|
data.nodes.forEach(node => {
|
132
132
|
// lineage
|
133
133
|
let lineageNodes = [];
|
134
|
-
node.lineage.nodes.forEach(
|
135
|
-
lineageNodes.push(data.nodes.find(node => node.id ===
|
134
|
+
node.lineage.nodes.forEach(nodeId => {
|
135
|
+
lineageNodes.push(data.nodes.find(node => node.id === nodeId));
|
136
136
|
});
|
137
|
-
let
|
138
|
-
node.lineage.links.forEach(
|
139
|
-
|
137
|
+
let lineageLinks = [];
|
138
|
+
node.lineage.links.forEach(linkIds => {
|
139
|
+
lineageLinks.push(data.links.find(link => link.source === linkIds.source && link.target === linkIds.target));
|
140
140
|
});
|
141
141
|
node.lineage.nodes = lineageNodes;
|
142
|
-
node.lineage.links =
|
142
|
+
node.lineage.links = lineageLinks;
|
143
143
|
// siblings
|
144
144
|
this.numSiblingsLeft[node.parent] = node.siblings.length;
|
145
145
|
});
|
@@ -227,7 +227,7 @@ export default class JekyllGraph {
|
|
227
227
|
// draw helpers
|
228
228
|
|
229
229
|
shiftNodeHeight(node) {
|
230
|
-
if (node.namespace !== 'root' && !this.shifted.includes(node)) {
|
230
|
+
if ((node.namespace !== 'root') && (node.namespace !== 'i.bonsai') && !this.shifted.includes(node)) {
|
231
231
|
const padding = 5;
|
232
232
|
let areSiblingsLeftEven = (this.numSiblingsLeft[node.parent] % 2) === 1;
|
233
233
|
let altrntr = areSiblingsLeftEven ? 1 : -1;
|
@@ -338,8 +338,10 @@ export default class JekyllGraph {
|
|
338
338
|
isVisitedPage(node) {
|
339
339
|
if (!this.isMissingPage(node)) {
|
340
340
|
var visited = JSON.parse(localStorage.getItem('visited'));
|
341
|
-
|
342
|
-
|
341
|
+
if (visited !== null) {
|
342
|
+
for (let i = 0; i < visited.length; i++) {
|
343
|
+
if (visited[i]['url'] === node.url) return true;
|
344
|
+
}
|
343
345
|
}
|
344
346
|
}
|
345
347
|
return false;
|
data/lib/jekyll-graph/version.rb
CHANGED
data/lib/jekyll-graph.rb
CHANGED
@@ -37,7 +37,7 @@ module Jekyll
|
|
37
37
|
return
|
38
38
|
end
|
39
39
|
if !$graph_conf.disabled_tree? && !site.respond_to?(:tree)
|
40
|
-
Jekyll.logger.error("Jekyll-Graph: To generate the tree graph, please either add and enable the 'jekyll-namespaces' plugin
|
40
|
+
Jekyll.logger.error("Jekyll-Graph: To generate the tree graph, please either add and enable the 'jekyll-semtree' or 'jekyll-namespaces' plugin, or disable the tree in the jekyll-graph config")
|
41
41
|
return
|
42
42
|
end
|
43
43
|
|
@@ -173,7 +173,7 @@ module Jekyll
|
|
173
173
|
#
|
174
174
|
@site.link_index.index[doc.url].missing.each do |missing_link_name|
|
175
175
|
if net_web_nodes.none? { |node| node[:id] == missing_link_name }
|
176
|
-
Jekyll.logger.warn("Jekyll-Graph: Net-Web node missing: #{missing_link_name}, in: #{doc.
|
176
|
+
Jekyll.logger.warn("Jekyll-Graph: Net-Web node missing: #{missing_link_name}, in: #{File.basename(doc.basename, File.extname(doc.basename))}")
|
177
177
|
net_web_nodes << {
|
178
178
|
id: missing_link_name, # an id is necessary for link targets
|
179
179
|
url: '',
|
@@ -242,18 +242,24 @@ module Jekyll
|
|
242
242
|
return net_web_nodes, net_web_links
|
243
243
|
end
|
244
244
|
|
245
|
+
# used for both plugins:
|
246
|
+
# jekyll-semtree
|
247
|
+
# jekyll-namespace
|
245
248
|
def generate_json_tree(node, json_parent="", tree_nodes=[], tree_links=[], level=0)
|
249
|
+
node = node.is_a?(String) ? @site.tree.nodes.detect { |n| n.text == node } : node
|
246
250
|
#
|
247
251
|
# missing nodes
|
248
252
|
#
|
249
253
|
if node.missing
|
250
|
-
|
254
|
+
missing_text = node.namespace ? node.namespace : node.text
|
255
|
+
Jekyll.logger.warn("Jekyll-Graph: Tree node missing: ", missing_text)
|
251
256
|
|
252
|
-
|
257
|
+
if node.namespace
|
258
|
+
leaf = node.namespace.split('.').pop()
|
259
|
+
end
|
253
260
|
missing_node = {
|
254
|
-
id: node.namespace,
|
255
|
-
label: leaf.gsub('-', ' '),
|
256
|
-
namespace: node.namespace,
|
261
|
+
id: node.namespace ? node.namespace : node.text,
|
262
|
+
label: node.namespace ? leaf.gsub('-', ' ') : node.text,
|
257
263
|
url: "",
|
258
264
|
level: level,
|
259
265
|
lineage: {
|
@@ -262,12 +268,15 @@ module Jekyll
|
|
262
268
|
},
|
263
269
|
siblings: [],
|
264
270
|
}
|
271
|
+
if node.namespace
|
272
|
+
missing_node['namespace'] = node.namespace
|
273
|
+
end
|
265
274
|
# non-root handling
|
266
275
|
if !json_parent.empty?
|
267
276
|
missing_node[:parent] = json_parent[:id]
|
268
277
|
tree_links << {
|
269
278
|
source: json_parent[:id],
|
270
|
-
target: node.namespace,
|
279
|
+
target: node.namespace ? node.namespace : node.text,
|
271
280
|
}
|
272
281
|
end
|
273
282
|
tree_nodes << missing_node
|
@@ -279,7 +288,6 @@ module Jekyll
|
|
279
288
|
existing_node = {
|
280
289
|
id: node.url,
|
281
290
|
label: node.title,
|
282
|
-
namespace: node.namespace,
|
283
291
|
url: relative_url(node.url),
|
284
292
|
level: level,
|
285
293
|
lineage: {
|
@@ -288,6 +296,9 @@ module Jekyll
|
|
288
296
|
},
|
289
297
|
siblings: [],
|
290
298
|
}
|
299
|
+
if node.namespace
|
300
|
+
existing_node['namespace'] = node.namespace
|
301
|
+
end
|
291
302
|
# non-root handling
|
292
303
|
if !json_parent.empty?
|
293
304
|
existing_node[:parent] = json_parent[:id]
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- manunamz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
103
|
+
rubygems_version: 3.4.10
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Add d3 graph generation to jekyll.
|