jekyll-graph 0.0.2 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/Gemfile +2 -2
- data/README.md +36 -29
- data/bin/console +1 -1
- data/jekyll-graph.gemspec +5 -4
- data/lib/jekyll-graph/config.rb +32 -8
- data/lib/jekyll-graph/jekyll-graph.js +60 -26
- data/lib/jekyll-graph/{context.rb → patch/context.rb} +0 -0
- data/lib/jekyll-graph/{page.rb → patch/page.rb} +0 -0
- data/lib/jekyll-graph/version.rb +1 -1
- data/lib/jekyll-graph.rb +67 -52
- metadata +25 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1573d14b40e41fa648645091c1b204877affa7f83bb89fc5c201f2cfa424eaec
|
4
|
+
data.tar.gz: 670c6b66d66a56c3c63030637450336fa2d9e357b0499615d8799552b047329a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b0ceda8dcd2b4955fa291bc2b2f17846952eabf03beb301c333627ae9347695972324f9e19b0c32fd4485dcaf4e70a56c4b8103957b1825dc3c9e95d4fd97e4
|
7
|
+
data.tar.gz: fc17d253fed0a6bcb738d21ca2469c7025bdccd0abe476a223649ec0fb3c672a2417f38cbc4381ab92b60a6c69f2480f4daf73bad4c2536e9c8f477924ffec2a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## [0.0.6] - 2022-01-24
|
2
|
+
### Change
|
3
|
+
- Move jekyll patch files to patch/ dir.
|
4
|
+
- Bump jekyll-wikilinks version number (0.0.10).
|
5
|
+
## [0.0.5] - 2021-11-23
|
6
|
+
### Change
|
7
|
+
- 'relatives' -> 'lineage' for tree nodes.
|
8
|
+
|
9
|
+
## [0.0.4] - 2021-11-22
|
10
|
+
### Fix
|
11
|
+
- Custom path config related fix in scripts.
|
12
|
+
|
13
|
+
## [0.0.3] - 2021-11-22
|
14
|
+
### Change
|
15
|
+
- Fix javascript inheritance.
|
16
|
+
- Decrement missing node log messages from 'warn' to 'debug'.
|
17
|
+
- Update license.
|
18
|
+
### Fix
|
19
|
+
- Display log messages related to dependencies (see [#2](https://github.com/manunamz/jekyll-graph/issues/2)).
|
20
|
+
- Custom path configs.
|
21
|
+
|
1
22
|
## [0.0.2] - 2021-09-17
|
2
23
|
### Change
|
3
24
|
- Liquid tag `force-graph` -> `jekyll_graph`.
|
data/Gemfile
CHANGED
@@ -6,8 +6,8 @@ source "https://rubygems.org"
|
|
6
6
|
gemspec
|
7
7
|
|
8
8
|
gem "jekyll", "~> 4.2.0"
|
9
|
-
gem "jekyll-namespaces", "~> 0.0.
|
10
|
-
gem "jekyll-wikilinks", "~> 0.0.
|
9
|
+
gem "jekyll-namespaces", "~> 0.0.3"
|
10
|
+
gem "jekyll-wikilinks", "~> 0.0.10"
|
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://
|
9
|
+
This gem is part of the [jekyll-bonsai](https://jekyll-bonsai.netlify.app/) project. 🎋
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -37,41 +37,45 @@ 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
|
-
export default class JekyllGraphSubClass {
|
41
|
-
...
|
42
|
-
}
|
43
|
-
|
44
|
-
// subclass
|
45
|
-
// Hook up the instance properties
|
46
|
-
Object.setPrototypeOf(JekyllGraphSubClass.prototype, JekyllGraph.prototype);
|
47
|
-
|
48
|
-
// Hook up the static properties
|
49
|
-
Object.setPrototypeOf(JekyllGraphSubClass, JekyllGraph);
|
40
|
+
export default class JekyllGraphSubClass extends JekyllGraph {
|
50
41
|
|
42
|
+
constructor() {
|
43
|
+
super();
|
44
|
+
// access graph with 'this.graph'
|
45
|
+
// access graph div with 'this.graphDiv'
|
46
|
+
}
|
47
|
+
|
48
|
+
// ...
|
49
|
+
}
|
51
50
|
```
|
51
|
+
|
52
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.
|
53
53
|
|
54
|
-
Unless otherwise
|
54
|
+
Unless otherwise configured (see `path` vars below), the `jekyll-graph.js` file will be generated into `_site/assets/js/`.
|
55
55
|
|
56
56
|
## Configuration
|
57
57
|
|
58
58
|
Default configs look like this:
|
59
59
|
|
60
|
-
```
|
60
|
+
```yaml
|
61
61
|
graph:
|
62
62
|
enabled: true
|
63
63
|
exclude: []
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
path:
|
65
|
+
assets: "/assets"
|
66
|
+
scripts: "/assets/js"
|
67
|
+
net_web:
|
67
68
|
enabled: true
|
69
|
+
exclude:
|
70
|
+
attrs: false
|
71
|
+
links: false
|
68
72
|
force:
|
69
73
|
charge:
|
70
74
|
strength_x:
|
71
75
|
x_val:
|
72
76
|
strength_y:
|
73
77
|
y_val:
|
74
|
-
|
78
|
+
tree:
|
75
79
|
enabled: true
|
76
80
|
force:
|
77
81
|
charge:
|
@@ -85,11 +89,13 @@ graph:
|
|
85
89
|
|
86
90
|
`exclude`: Exclude specific jekyll document types (`posts`, `pages`, `collection_items`).
|
87
91
|
|
88
|
-
`
|
92
|
+
`path.assets`: An optional custom assets location for graph assets to generate into. Location is relative to the root of the generated `_site/` directory.
|
93
|
+
|
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/`).
|
89
95
|
|
90
|
-
`
|
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.
|
91
97
|
|
92
|
-
`tree.enabled` and `net_web.enabled`: Toggles on/off the `tree` and `net_web` graphs, respectively.
|
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.
|
93
99
|
|
94
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).
|
95
101
|
|
@@ -98,7 +104,6 @@ Force values will likely need to be played with depending on the div size and nu
|
|
98
104
|
```yaml
|
99
105
|
graph:
|
100
106
|
tree:
|
101
|
-
# enabled: true
|
102
107
|
dag_lvl_dist: 100
|
103
108
|
force:
|
104
109
|
charge: -100
|
@@ -107,7 +112,6 @@ graph:
|
|
107
112
|
strength_y: 0.1
|
108
113
|
y_val: 0.9
|
109
114
|
net_web:
|
110
|
-
# enabled: true
|
111
115
|
force:
|
112
116
|
charge: -300
|
113
117
|
strength_x: 0.3
|
@@ -138,13 +142,13 @@ Graph colors are determined by css variables which may be defined like so -- any
|
|
138
142
|
--graph-particles-color: grey;
|
139
143
|
/* label text */
|
140
144
|
--graph-text-color: black;
|
141
|
-
/* */
|
142
145
|
```
|
143
146
|
|
144
147
|
## Data
|
145
148
|
Graph data is generated in the following format:
|
146
149
|
|
147
150
|
For the net-web graph, `graph-net-web.json`,`links` are built from `backlinks` and `attributed` metadata generated in `jekyll-wikilinks`:
|
151
|
+
|
148
152
|
```json
|
149
153
|
// graph-net-web.json
|
150
154
|
{
|
@@ -154,8 +158,8 @@ For the net-web graph, `graph-net-web.json`,`links` are built from `backlinks` a
|
|
154
158
|
"url": "<relative-url>", // site.baseurl is handled for you here
|
155
159
|
"label": "<note's-title>",
|
156
160
|
"neighbors": {
|
157
|
-
"nodes": [<neighbor-node>, ...],
|
158
|
-
"links": [<neighbor-link>, ...],
|
161
|
+
"nodes": [<neighbor-node-id>, ...],
|
162
|
+
"links": [<neighbor-link-id>, ...],
|
159
163
|
}
|
160
164
|
},
|
161
165
|
...
|
@@ -169,18 +173,20 @@ For the net-web graph, `graph-net-web.json`,`links` are built from `backlinks` a
|
|
169
173
|
]
|
170
174
|
}
|
171
175
|
```
|
176
|
+
|
172
177
|
For the tree graph, `graph-tree.json`, `links` are built from a tree data structure constructed in `jekyll-namespaces`:
|
178
|
+
|
173
179
|
```json
|
174
180
|
// graph-tree.json
|
175
181
|
{
|
176
182
|
"nodes": [
|
177
183
|
{
|
178
184
|
"id": "<some-id>",
|
179
|
-
"url": "<
|
185
|
+
"url": "<lineage-url>", // site.baseurl wil be handled for you here
|
180
186
|
"label": "<note's-title>",
|
181
|
-
"
|
182
|
-
"nodes": [<
|
183
|
-
"links": [<
|
187
|
+
"lineage": {
|
188
|
+
"nodes": [<lineage-node-id>, ...],
|
189
|
+
"links": [<lineage-link-id>, ...],
|
184
190
|
}
|
185
191
|
},
|
186
192
|
...
|
@@ -194,4 +200,5 @@ For the tree graph, `graph-tree.json`, `links` are built from a tree data struct
|
|
194
200
|
]
|
195
201
|
}
|
196
202
|
```
|
203
|
+
|
197
204
|
Unless otherwise defined, both json files are generated into `_site/assets/`.
|
data/bin/console
CHANGED
data/jekyll-graph.gemspec
CHANGED
@@ -12,7 +12,8 @@ Gem::Specification.new do |spec|
|
|
12
12
|
# spec.description = "TODO: Write a longer description or delete this line."
|
13
13
|
spec.homepage = "https://github.com/manunamz/jekyll-graph"
|
14
14
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
15
|
-
|
15
|
+
spec.licenses = ["GPL3"]
|
16
|
+
|
16
17
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
17
18
|
|
18
19
|
spec.metadata["homepage_uri"] = spec.homepage
|
@@ -29,11 +30,11 @@ Gem::Specification.new do |spec|
|
|
29
30
|
spec.require_paths = ["lib"]
|
30
31
|
|
31
32
|
# Uncomment to register a new dependency of your gem
|
32
|
-
|
33
|
+
spec.add_dependency "jekyll", "~> 4.2.0"
|
33
34
|
|
34
35
|
# For more information and examples about making a new gem, checkout our
|
35
36
|
# guide at: https://bundler.io/guides/creating_gem.html
|
36
37
|
|
37
|
-
spec.add_runtime_dependency "jekyll-namespaces", "~> 0.0.
|
38
|
-
spec.add_runtime_dependency "jekyll-wikilinks", "~> 0.0.
|
38
|
+
spec.add_runtime_dependency "jekyll-namespaces", "~> 0.0.3"
|
39
|
+
spec.add_runtime_dependency "jekyll-wikilinks", "~> 0.0.10"
|
39
40
|
end
|
data/lib/jekyll-graph/config.rb
CHANGED
@@ -5,12 +5,16 @@ module Jekyll
|
|
5
5
|
module Graph
|
6
6
|
|
7
7
|
class PluginConfig
|
8
|
+
|
9
|
+
ASSETS_KEY = "assets"
|
10
|
+
ATTRS_KEY = "attrs"
|
8
11
|
CONFIG_KEY = "graph"
|
9
12
|
ENABLED_KEY = "enabled"
|
10
13
|
EXCLUDE_KEY = "exclude"
|
14
|
+
LINKS_KEY = "links"
|
11
15
|
NET_WEB_KEY = "net_web"
|
12
|
-
|
13
|
-
|
16
|
+
PATH_KEY = "path"
|
17
|
+
SCRIPTS_KEY = "scripts"
|
14
18
|
TREE_KEY = "tree"
|
15
19
|
TYPE_KEY = "type"
|
16
20
|
|
@@ -20,7 +24,7 @@ module Jekyll
|
|
20
24
|
Jekyll.logger.debug("Excluded jekyll types in graph: ", option(EXCLUDE_KEY)) unless disabled?
|
21
25
|
end
|
22
26
|
|
23
|
-
#
|
27
|
+
# descriptors
|
24
28
|
|
25
29
|
def disabled?
|
26
30
|
return option(ENABLED_KEY) == false
|
@@ -39,22 +43,42 @@ module Jekyll
|
|
39
43
|
return option(EXCLUDE_KEY).include?(type.to_s)
|
40
44
|
end
|
41
45
|
|
42
|
-
def
|
43
|
-
return
|
46
|
+
def has_custom_assets_path?
|
47
|
+
return option_path(ASSETS_KEY)
|
44
48
|
end
|
45
49
|
|
46
50
|
def has_custom_scripts_path?
|
47
|
-
return
|
51
|
+
return option_path(SCRIPTS_KEY)
|
52
|
+
end
|
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)
|
48
62
|
end
|
49
63
|
|
64
|
+
# options
|
65
|
+
|
50
66
|
def option(key)
|
51
67
|
@config[CONFIG_KEY] && @config[CONFIG_KEY][key]
|
52
68
|
end
|
53
69
|
|
70
|
+
def option_path(key)
|
71
|
+
@config[CONFIG_KEY] && @config[CONFIG_KEY][PATH_KEY] && @config[CONFIG_KEY][PATH_KEY][key]
|
72
|
+
end
|
73
|
+
|
54
74
|
def option_net_web(key)
|
55
75
|
@config[CONFIG_KEY] && @config[CONFIG_KEY][NET_WEB_KEY] && @config[CONFIG_KEY][NET_WEB_KEY][key]
|
56
76
|
end
|
57
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
|
+
|
58
82
|
def option_tree(key)
|
59
83
|
@config[CONFIG_KEY] && @config[CONFIG_KEY][TREE_KEY] && @config[CONFIG_KEY][TREE_KEY][key]
|
60
84
|
end
|
@@ -66,11 +90,11 @@ module Jekyll
|
|
66
90
|
end
|
67
91
|
|
68
92
|
def path_assets
|
69
|
-
return
|
93
|
+
return has_custom_assets_path? ? option_path(ASSETS_KEY) : "/assets"
|
70
94
|
end
|
71
95
|
|
72
96
|
def path_scripts
|
73
|
-
return has_custom_scripts_path? ?
|
97
|
+
return has_custom_scripts_path? ? File.join(path_assets, option_path(SCRIPTS_KEY)) : File.join(path_assets, "js")
|
74
98
|
end
|
75
99
|
|
76
100
|
def testing
|
@@ -1,4 +1,5 @@
|
|
1
1
|
// don't need frontmatter because liquid is handled internally...somehow...
|
2
|
+
|
2
3
|
export default class JekyllGraph {
|
3
4
|
|
4
5
|
constructor() {
|
@@ -7,7 +8,7 @@ export default class JekyllGraph {
|
|
7
8
|
|
8
9
|
// d3
|
9
10
|
drawNetWeb () {
|
10
|
-
let assetsPath = '{{ site.graph.
|
11
|
+
let assetsPath = '{{ site.graph.path.assets }}' !== '' ? '{{ site.graph.path.assets }}' : '/assets';
|
11
12
|
fetch(`{{ site.baseurl }}${assetsPath}/graph-net-web.json`).then(res => res.json()).then(data => {
|
12
13
|
|
13
14
|
// neighbors: replace ids with full object
|
@@ -29,9 +30,11 @@ export default class JekyllGraph {
|
|
29
30
|
let hoverNode = null;
|
30
31
|
let hoverLink = null;
|
31
32
|
|
32
|
-
|
33
|
+
if (this.graph) {
|
34
|
+
this.graph._destructor();
|
35
|
+
}
|
33
36
|
|
34
|
-
(this.graphDiv)
|
37
|
+
const Graph = ForceGraph()(this.graphDiv)
|
35
38
|
// container
|
36
39
|
.height(this.graphDiv.parentElement.clientHeight)
|
37
40
|
.width(this.graphDiv.parentElement.clientWidth)
|
@@ -101,35 +104,47 @@ export default class JekyllGraph {
|
|
101
104
|
Graph.height(el.offsetHeight);
|
102
105
|
}
|
103
106
|
);
|
107
|
+
|
108
|
+
this.graph = Graph;
|
104
109
|
});
|
105
110
|
}
|
106
111
|
|
107
112
|
drawTree () {
|
108
|
-
let assetsPath = '{{ site.graph.
|
113
|
+
let assetsPath = '{{ site.graph.path.assets }}' !== '' ? '{{ site.graph.path.assets }}' : '/assets';
|
109
114
|
fetch(`{{ site.baseurl }}${assetsPath}/graph-tree.json`).then(res => res.json()).then(data => {
|
115
|
+
|
116
|
+
if (this.graph) {
|
117
|
+
this.graph._destructor();
|
118
|
+
}
|
110
119
|
|
111
|
-
//
|
112
|
-
|
113
|
-
|
114
|
-
node.relatives.nodes.forEach(nNodeId => {
|
115
|
-
relativeNodes.push(data.nodes.find(node => node.id === nNodeId));
|
116
|
-
});
|
117
|
-
let relativeLinks = [];
|
118
|
-
node.relatives.links.forEach(nLink => {
|
119
|
-
relativeLinks.push(data.links.find(link => link.source === nLink.source && link.target === nLink.target));
|
120
|
-
});
|
121
|
-
node.relatives.nodes = relativeNodes;
|
122
|
-
node.relatives.links = relativeLinks;
|
123
|
-
});
|
120
|
+
// node height vars
|
121
|
+
this.shifted = [];
|
122
|
+
this.numSiblingsLeft = [];
|
124
123
|
|
124
|
+
// hover vars
|
125
125
|
const highlightNodes = new Set();
|
126
126
|
const highlightLinks = new Set();
|
127
127
|
let hoverNode = null;
|
128
128
|
let hoverLink = null;
|
129
129
|
|
130
|
-
|
130
|
+
// lineage: replace ids with full objects
|
131
|
+
data.nodes.forEach(node => {
|
132
|
+
// lineage
|
133
|
+
let lineageNodes = [];
|
134
|
+
node.lineage.nodes.forEach(nNodeId => {
|
135
|
+
lineageNodes.push(data.nodes.find(node => node.id === nNodeId));
|
136
|
+
});
|
137
|
+
let relativeLinks = [];
|
138
|
+
node.lineage.links.forEach(nLink => {
|
139
|
+
relativeLinks.push(data.links.find(link => link.source === nLink.source && link.target === nLink.target));
|
140
|
+
});
|
141
|
+
node.lineage.nodes = lineageNodes;
|
142
|
+
node.lineage.links = relativeLinks;
|
143
|
+
// siblings
|
144
|
+
this.numSiblingsLeft[node.parent] = node.siblings.length;
|
145
|
+
});
|
131
146
|
|
132
|
-
(this.graphDiv)
|
147
|
+
const Graph = ForceGraph()(this.graphDiv)
|
133
148
|
// dag-mode (tree)
|
134
149
|
.dagMode('td')
|
135
150
|
.dagLevelDistance(Number('{{ site.graph.tree.dag_lvl_dist }}'))
|
@@ -141,6 +156,8 @@ export default class JekyllGraph {
|
|
141
156
|
// .nodePointerAreaPaint((node, color, ctx, scale) => nodePaint(node, nodeTypeInNetWeb(node), ctx))
|
142
157
|
.nodeId('id')
|
143
158
|
.nodeLabel('label')
|
159
|
+
// todo-shift: this shiftNodeHeight() always renders, but animatation is choppy
|
160
|
+
// .nodeVal(node => this.shiftNodeHeight(node))
|
144
161
|
.onNodeClick((node, event) => this.goToPage(node, event))
|
145
162
|
// link
|
146
163
|
.linkSource('source')
|
@@ -171,8 +188,8 @@ export default class JekyllGraph {
|
|
171
188
|
highlightLinks.clear();
|
172
189
|
if (node) {
|
173
190
|
highlightNodes.add(node);
|
174
|
-
node.
|
175
|
-
node.
|
191
|
+
node.lineage.nodes.forEach(node => highlightNodes.add(node));
|
192
|
+
node.lineage.links.forEach(link => highlightLinks.add(link));
|
176
193
|
}
|
177
194
|
hoverNode = node || null;
|
178
195
|
})
|
@@ -202,12 +219,29 @@ export default class JekyllGraph {
|
|
202
219
|
Graph.height(el.offsetHeight);
|
203
220
|
}
|
204
221
|
);
|
222
|
+
|
223
|
+
this.graph = Graph;
|
205
224
|
});
|
206
225
|
}
|
207
226
|
|
208
227
|
// draw helpers
|
209
228
|
|
229
|
+
shiftNodeHeight(node) {
|
230
|
+
if (node.namespace !== 'root' && !this.shifted.includes(node)) {
|
231
|
+
const padding = 5;
|
232
|
+
let areSiblingsLeftEven = (this.numSiblingsLeft[node.parent] % 2) === 1;
|
233
|
+
let altrntr = areSiblingsLeftEven ? 1 : -1;
|
234
|
+
node.fy = node.fy + (altrntr * (this.numSiblingsLeft[node.parent] * padding));
|
235
|
+
this.numSiblingsLeft[node.parent] -= 1;
|
236
|
+
this.shifted.push(node);
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
210
240
|
nodePaint(node, ctx, hoverNode, hoverLink, gType) {
|
241
|
+
// todo-shift: this shiftNodeHeight() animates more smoothly, but suffers from a race condition
|
242
|
+
// if (gType === "tree") {
|
243
|
+
// this.shiftNodeHeight(node);
|
244
|
+
// }
|
211
245
|
let fillText = true;
|
212
246
|
let radius = 6;
|
213
247
|
//
|
@@ -216,7 +250,7 @@ export default class JekyllGraph {
|
|
216
250
|
if (this.isVisitedPage(node)) {
|
217
251
|
ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--graph-node-visited-color');
|
218
252
|
} else if (this.isMissingPage(node)) {
|
219
|
-
ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--graph-node-missing-color')
|
253
|
+
ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--graph-node-missing-color');
|
220
254
|
} else if (!this.isVisitedPage(node) && !this.isMissingPage(node)) {
|
221
255
|
ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--graph-node-unvisited-color');
|
222
256
|
} else {
|
@@ -235,9 +269,9 @@ export default class JekyllGraph {
|
|
235
269
|
} else if (hoverNode !== null && gType === "net-web" && !hoverNode.neighbors.nodes.includes(node)) {
|
236
270
|
// non-neighbor to hoverNode
|
237
271
|
fillText = false;
|
238
|
-
} else if (hoverNode !== null && gType === "tree" && hoverNode.
|
272
|
+
} else if (hoverNode !== null && gType === "tree" && hoverNode.lineage.nodes.includes(node)) {
|
239
273
|
// neighbor to hoverNode
|
240
|
-
} else if (hoverNode !== null && gType === "tree" && !hoverNode.
|
274
|
+
} else if (hoverNode !== null && gType === "tree" && !hoverNode.lineage.nodes.includes(node)) {
|
241
275
|
// non-neighbor to hoverNode
|
242
276
|
fillText = false;
|
243
277
|
} else if ((hoverNode === null && hoverLink !== null) && (hoverLink.source === node || hoverLink.target === node)) {
|
@@ -255,11 +289,11 @@ export default class JekyllGraph {
|
|
255
289
|
//
|
256
290
|
if (this.isCurrentPage(node)) {
|
257
291
|
// turn glow on
|
258
|
-
ctx.shadowBlur =
|
292
|
+
ctx.shadowBlur = 40;
|
259
293
|
ctx.shadowColor = getComputedStyle(document.documentElement).getPropertyValue('--graph-node-current-glow');
|
260
294
|
} else if (this.isTag(node)) {
|
261
295
|
// turn glow on
|
262
|
-
ctx.shadowBlur =
|
296
|
+
ctx.shadowBlur = 40;
|
263
297
|
ctx.shadowColor = getComputedStyle(document.documentElement).getPropertyValue('--graph-node-tagged-glow');
|
264
298
|
} else if (this.isVisitedPage(node)) {
|
265
299
|
// turn glow on
|
File without changes
|
File without changes
|
data/lib/jekyll-graph/version.rb
CHANGED
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
|
@@ -30,13 +30,14 @@ module Jekyll
|
|
30
30
|
CONVERTER_CLASS = Jekyll::Converters::Markdown
|
31
31
|
|
32
32
|
def generate(site)
|
33
|
+
# check what's enabled
|
33
34
|
return if $graph_conf.disabled?
|
34
|
-
if !$graph_conf.disabled_net_web? && site.link_index
|
35
|
-
Jekyll.logger.error("To generate the net-web graph, please add and enable the 'jekyll-wikilinks' plugin")
|
35
|
+
if !$graph_conf.disabled_net_web? && !site.respond_to?(:link_index)
|
36
|
+
Jekyll.logger.error("Jekyll-Graph: To generate the net-web graph, please either add and enable the 'jekyll-wikilinks' plugin or disable the net-web in the jekyll-graph config")
|
36
37
|
return
|
37
38
|
end
|
38
|
-
if !$graph_conf.disabled_tree? && site.tree
|
39
|
-
Jekyll.logger.error("To generate the tree graph, please add and enable the 'jekyll-namespaces' plugin")
|
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 or disable the tree in the jekyll-graph config")
|
40
41
|
return
|
41
42
|
end
|
42
43
|
|
@@ -50,7 +51,7 @@ module Jekyll
|
|
50
51
|
docs += @site.docs_to_write.filter { |d| !$graph_conf.excluded?(d.type) }
|
51
52
|
@md_docs = docs.filter { |doc| markdown_extension?(doc.extname) }
|
52
53
|
if @md_docs.empty?
|
53
|
-
Jekyll.logger.
|
54
|
+
Jekyll.logger.warn("Jekyll-Graph: No documents to process.")
|
54
55
|
end
|
55
56
|
|
56
57
|
# write graph
|
@@ -64,25 +65,23 @@ module Jekyll
|
|
64
65
|
)
|
65
66
|
# create json file
|
66
67
|
json_net_web_graph_file = self.new_page($graph_conf.path_assets, "graph-net-web.json", net_web_graph_content)
|
67
|
-
self.register_static_file(json_net_web_graph_file)
|
68
68
|
end
|
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,
|
76
76
|
)
|
77
77
|
# create json file
|
78
78
|
json_tree_graph_file = self.new_page($graph_conf.path_assets, "graph-tree.json", tree_graph_content)
|
79
|
-
self.register_static_file(json_tree_graph_file)
|
80
79
|
end
|
81
80
|
# add graph drawing scripts
|
82
81
|
script_filename = "jekyll-graph.js"
|
83
82
|
graph_script_content = File.read(source_path(script_filename))
|
83
|
+
# create js file
|
84
84
|
static_file = self.new_page($graph_conf.path_scripts, script_filename, graph_script_content)
|
85
|
-
self.register_static_file(static_file)
|
86
85
|
end
|
87
86
|
|
88
87
|
# helpers
|
@@ -116,13 +115,12 @@ module Jekyll
|
|
116
115
|
return new_file
|
117
116
|
end
|
118
117
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
end
|
118
|
+
# keeping this around in case it's needed again
|
119
|
+
# # tests fail without manually adding the static file, but actual site builds seem to do ok
|
120
|
+
# # ...although there does seem to be a race condition which causes a rebuild to be necessary in order to detect the graph data file
|
121
|
+
# def register_static_file(static_file)
|
122
|
+
# @site.static_files << static_file if !@site.static_files.include?(static_file)
|
123
|
+
# end
|
126
124
|
|
127
125
|
# json population helpers
|
128
126
|
# set ids here, full javascript objects are populated in client-side javascript.
|
@@ -140,18 +138,24 @@ module Jekyll
|
|
140
138
|
end
|
141
139
|
end
|
142
140
|
|
143
|
-
def
|
141
|
+
def set_lineage(json_nodes, json_links)
|
144
142
|
# TODO: json nodes have relative_url, but node.id's/urls are doc urls.
|
145
143
|
json_nodes.each do |json_node|
|
146
|
-
|
147
|
-
|
148
|
-
json_node[:
|
144
|
+
# set lineage
|
145
|
+
|
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
|
+
|
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
|
+
|
156
|
+
# set siblings
|
152
157
|
|
153
|
-
|
154
|
-
json_node[:relatives][:links] = json_relative_links if !json_relative_links.nil?
|
158
|
+
json_node[:siblings] = @site.tree.get_sibling_ids(json_node[:id])
|
155
159
|
end
|
156
160
|
end
|
157
161
|
|
@@ -163,14 +167,13 @@ module Jekyll
|
|
163
167
|
@md_docs.each do |doc|
|
164
168
|
if !$graph_conf.excluded?(doc.type)
|
165
169
|
|
166
|
-
Jekyll.logger.debug
|
170
|
+
Jekyll.logger.debug("Jekyll-Graph: Processing graph nodes for doc: ", doc.data['title'])
|
167
171
|
#
|
168
172
|
# missing nodes
|
169
173
|
#
|
170
174
|
@site.link_index.index[doc.url].missing.each do |missing_link_name|
|
171
175
|
if net_web_nodes.none? { |node| node[:id] == missing_link_name }
|
172
|
-
Jekyll.logger.warn
|
173
|
-
Jekyll.logger.warn " in: ", doc.data['title']
|
176
|
+
Jekyll.logger.warn("Jekyll-Graph: Net-Web node missing: #{missing_link_name}, in: #{doc.data['title']}")
|
174
177
|
net_web_nodes << {
|
175
178
|
id: missing_link_name, # an id is necessary for link targets
|
176
179
|
url: '',
|
@@ -200,10 +203,27 @@ module Jekyll
|
|
200
203
|
},
|
201
204
|
}
|
202
205
|
# TODO: this link calculation ends up with duplicates -- re-visit this later.
|
203
|
-
|
204
|
-
#
|
205
|
-
|
206
|
-
|
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]
|
207
227
|
link_no_baseurl = @site.baseurl.nil? ? link_no_anchor : link_no_anchor.gsub(@site.baseurl, "")
|
208
228
|
linked_doc = @md_docs.select{ |d| d.url == link_no_baseurl }
|
209
229
|
if !linked_doc.nil? && linked_doc.size == 1 && !$graph_conf.excluded?(linked_doc.first.type)
|
@@ -215,19 +235,6 @@ module Jekyll
|
|
215
235
|
end
|
216
236
|
end
|
217
237
|
end
|
218
|
-
@site.link_index.index[doc.url].forelinks.each do |link| # link = { 'type' => str, 'url' => str }
|
219
|
-
# TODO: Header + Block-level wikilinks
|
220
|
-
link_no_anchor = link['url'].match(/([^#]+)/i)[0]
|
221
|
-
link_no_baseurl = @site.baseurl.nil? ? link_no_anchor : link_no_anchor.gsub(@site.baseurl, "")
|
222
|
-
linked_doc = @md_docs.select{ |d| d.url == link_no_baseurl }
|
223
|
-
if !linked_doc.nil? && linked_doc.size == 1 && !$graph_conf.excluded?(linked_doc.first.type)
|
224
|
-
# TODO: add link['type'] to d3 graph
|
225
|
-
net_web_links << {
|
226
|
-
source: doc.url,
|
227
|
-
target: linked_doc.first.url,
|
228
|
-
}
|
229
|
-
end
|
230
|
-
end
|
231
238
|
|
232
239
|
end
|
233
240
|
end
|
@@ -235,12 +242,12 @@ module Jekyll
|
|
235
242
|
return net_web_nodes, net_web_links
|
236
243
|
end
|
237
244
|
|
238
|
-
def generate_json_tree(node, json_parent="", tree_nodes=[], tree_links=[])
|
245
|
+
def generate_json_tree(node, json_parent="", tree_nodes=[], tree_links=[], level=0)
|
239
246
|
#
|
240
247
|
# missing nodes
|
241
248
|
#
|
242
249
|
if node.missing
|
243
|
-
Jekyll.logger.warn("Document for tree node missing: ", node.namespace)
|
250
|
+
Jekyll.logger.warn("Jekyll-Graph: Document for tree node missing: ", node.namespace)
|
244
251
|
|
245
252
|
leaf = node.namespace.split('.').pop()
|
246
253
|
missing_node = {
|
@@ -248,18 +255,22 @@ module Jekyll
|
|
248
255
|
label: leaf.gsub('-', ' '),
|
249
256
|
namespace: node.namespace,
|
250
257
|
url: "",
|
251
|
-
|
258
|
+
level: level,
|
259
|
+
lineage: {
|
252
260
|
nodes: [],
|
253
261
|
links: [],
|
254
262
|
},
|
263
|
+
siblings: [],
|
255
264
|
}
|
256
|
-
|
265
|
+
# non-root handling
|
257
266
|
if !json_parent.empty?
|
267
|
+
missing_node[:parent] = json_parent[:id]
|
258
268
|
tree_links << {
|
259
269
|
source: json_parent[:id],
|
260
270
|
target: node.namespace,
|
261
271
|
}
|
262
272
|
end
|
273
|
+
tree_nodes << missing_node
|
263
274
|
json_parent = missing_node
|
264
275
|
#
|
265
276
|
# existing nodes
|
@@ -270,22 +281,26 @@ module Jekyll
|
|
270
281
|
label: node.title,
|
271
282
|
namespace: node.namespace,
|
272
283
|
url: relative_url(node.url),
|
273
|
-
|
284
|
+
level: level,
|
285
|
+
lineage: {
|
274
286
|
nodes: [],
|
275
287
|
links: [],
|
276
288
|
},
|
289
|
+
siblings: [],
|
277
290
|
}
|
278
|
-
|
291
|
+
# non-root handling
|
279
292
|
if !json_parent.empty?
|
293
|
+
existing_node[:parent] = json_parent[:id]
|
280
294
|
tree_links << {
|
281
295
|
source: json_parent[:id],
|
282
296
|
target: node.url,
|
283
297
|
}
|
284
298
|
end
|
299
|
+
tree_nodes << existing_node
|
285
300
|
json_parent = existing_node
|
286
301
|
end
|
287
302
|
node.children.each do |child|
|
288
|
-
self.generate_json_tree(child, json_parent, tree_nodes, tree_links)
|
303
|
+
self.generate_json_tree(child, json_parent, tree_nodes, tree_links, (level + 1))
|
289
304
|
end
|
290
305
|
return tree_nodes, tree_links
|
291
306
|
end
|
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
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.6
|
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: 2022-01-24 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
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.
|
33
|
+
version: 0.0.3
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0.
|
40
|
+
version: 0.0.3
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: jekyll-wikilinks
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.
|
47
|
+
version: 0.0.10
|
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.
|
54
|
+
version: 0.0.10
|
41
55
|
description:
|
42
56
|
email:
|
43
57
|
- manunamz@pm.me
|
@@ -59,13 +73,14 @@ 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/
|
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
|
68
|
-
licenses:
|
82
|
+
licenses:
|
83
|
+
- GPL3
|
69
84
|
metadata:
|
70
85
|
homepage_uri: https://github.com/manunamz/jekyll-graph
|
71
86
|
source_code_uri: https://github.com/manunamz/jekyll-graph
|
@@ -85,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
100
|
- !ruby/object:Gem::Version
|
86
101
|
version: '0'
|
87
102
|
requirements: []
|
88
|
-
rubygems_version: 3.2.
|
103
|
+
rubygems_version: 3.2.27
|
89
104
|
signing_key:
|
90
105
|
specification_version: 4
|
91
106
|
summary: Add d3 graph generation to jekyll.
|