jekyll-graph 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '038de01bbe85bc24af50ccb57201b05a10652580dd8143bfe5a0e465b8a7a291'
4
- data.tar.gz: 2af7e4481d0bab8691a34675fb48b51bab6f5a4a422f4c0f460581f3e1cc70a9
3
+ metadata.gz: 56a0cf412d49fe1abbc5280977f3bc732f7ff42836abddb64a948e26d4f5dc89
4
+ data.tar.gz: 29914337ea3a859ea54a5585e10944cb3334d48c7d9a021902e2ab8f87130f64
5
5
  SHA512:
6
- metadata.gz: 5b25396bcf649bcb017f9d713c4393be1e86ea3728e970146115ee1524c9f6e38c68a78ff996329eac93c12716ddb213ca9583c1962e2ba396301ae785c7f3ef
7
- data.tar.gz: d4f7cccfb7204a986e7d5f8aa49a049d773680b6a69e5a6c6bd10476fcee8fb7a08bbd4f7e3ba134722fba5af11bcad548a8ea4e5b8ea85f3371b5817eddc7bd
6
+ metadata.gz: 58d70f942b2024ba62c52c7fcd1a88162f36e342e02268ba198852f6dd09b08f7768edb2a7504abecb0495ae4d8f0d1071dc40320868bd95c06bc94330e82364
7
+ data.tar.gz: 66f5daee147641ad9ac8c1c71c8baffe90a6d3400d6e52f42e725cf886444775e38272dbb7907be3df2e892e835e9230ebe4690774a3cc2decdd71f899652152
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [0.0.3] 2021-11-22
2
+ ### Change
3
+ - Fix javascript inheritance.
4
+ - Decrement missing node log messages from 'warn' to 'debug'.
5
+ - Update license.
6
+ ### Fix
7
+ - Display log messages related to dependencies (see [#2](https://github.com/manunamz/jekyll-graph/issues/2)).
8
+ - Custom path configs.
9
+
1
10
  ## [0.0.2] - 2021-09-17
2
11
  ### Change
3
12
  - 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.2"
10
- gem "jekyll-wikilinks", "~> 0.0.6"
9
+ gem "jekyll-namespaces", "~> 0.0.3"
10
+ gem "jekyll-wikilinks", "~> 0.0.8"
11
11
 
12
12
  gem "rake", "~> 13.0.3"
13
13
  gem "rspec", "~> 3.10"
data/README.md CHANGED
@@ -37,33 +37,32 @@ 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
- ...
40
+ export default class JekyllGraphSubClass extends JekyllGraph {
41
+
42
+ constructor() {
43
+ super();
44
+ // access graph div with 'this.graphDiv'
45
+ }
46
+
47
+ // ...
42
48
  }
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);
50
-
51
49
  ```
52
50
  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
51
 
54
- Unless otherwise defined, the `jekyll-graph.js` file will be generated into `_site/assets/scripts/`.
52
+ Unless otherwise defined, the `jekyll-graph.js` file will be generated into `_site/assets/js/`.
55
53
 
56
54
  ## Configuration
57
55
 
58
56
  Default configs look like this:
59
57
 
60
- ```yml
58
+ ```yaml
61
59
  graph:
62
60
  enabled: true
63
61
  exclude: []
64
- assets_path: "/assets"
65
- scripts_path: "/assets/js"
66
- tree:
62
+ path:
63
+ assets: "/assets"
64
+ scripts: "/assets/js"
65
+ net_web:
67
66
  enabled: true
68
67
  force:
69
68
  charge:
@@ -71,7 +70,7 @@ graph:
71
70
  x_val:
72
71
  strength_y:
73
72
  y_val:
74
- net_web:
73
+ tree:
75
74
  enabled: true
76
75
  force:
77
76
  charge:
@@ -85,11 +84,11 @@ graph:
85
84
 
86
85
  `exclude`: Exclude specific jekyll document types (`posts`, `pages`, `collection_items`).
87
86
 
88
- `assets_path`: Custom graph file location from the root of the generated `_site/` directory.
87
+ `path.assets`: An optional custom assets location for graph assets to generate into. Location is relative to the root of the generated `_site/` directory.
89
88
 
90
- `scripts_path`: Custom graph scripts location from the assets location of the generated `_site/` directory (If `assets_path` is set, but `scripts_path` is not, the location will default to `_site/<assets_path>/js/`).
89
+ `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/`).
91
90
 
92
- `tree.enabled` and `net_web.enabled`: Toggles on/off the `tree` and `net_web` graphs, respectively.
91
+ `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
92
 
94
93
  `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
94
 
@@ -98,7 +97,6 @@ Force values will likely need to be played with depending on the div size and nu
98
97
  ```yaml
99
98
  graph:
100
99
  tree:
101
- # enabled: true
102
100
  dag_lvl_dist: 100
103
101
  force:
104
102
  charge: -100
@@ -107,7 +105,6 @@ graph:
107
105
  strength_y: 0.1
108
106
  y_val: 0.9
109
107
  net_web:
110
- # enabled: true
111
108
  force:
112
109
  charge: -300
113
110
  strength_x: 0.3
@@ -138,13 +135,13 @@ Graph colors are determined by css variables which may be defined like so -- any
138
135
  --graph-particles-color: grey;
139
136
  /* label text */
140
137
  --graph-text-color: black;
141
- /* */
142
138
  ```
143
139
 
144
140
  ## Data
145
141
  Graph data is generated in the following format:
146
142
 
147
143
  For the net-web graph, `graph-net-web.json`,`links` are built from `backlinks` and `attributed` metadata generated in `jekyll-wikilinks`:
144
+
148
145
  ```json
149
146
  // graph-net-web.json
150
147
  {
@@ -154,8 +151,8 @@ For the net-web graph, `graph-net-web.json`,`links` are built from `backlinks` a
154
151
  "url": "<relative-url>", // site.baseurl is handled for you here
155
152
  "label": "<note's-title>",
156
153
  "neighbors": {
157
- "nodes": [<neighbor-node>, ...],
158
- "links": [<neighbor-link>, ...],
154
+ "nodes": [<neighbor-node-id>, ...],
155
+ "links": [<neighbor-link-id>, ...],
159
156
  }
160
157
  },
161
158
  ...
@@ -169,7 +166,9 @@ For the net-web graph, `graph-net-web.json`,`links` are built from `backlinks` a
169
166
  ]
170
167
  }
171
168
  ```
169
+
172
170
  For the tree graph, `graph-tree.json`, `links` are built from a tree data structure constructed in `jekyll-namespaces`:
171
+
173
172
  ```json
174
173
  // graph-tree.json
175
174
  {
@@ -179,8 +178,8 @@ For the tree graph, `graph-tree.json`, `links` are built from a tree data struct
179
178
  "url": "<relative-url>", // site.baseurl wil be handled for you here
180
179
  "label": "<note's-title>",
181
180
  "relatives": {
182
- "nodes": [<relative-node>, ...],
183
- "links": [<relative-link>, ...],
181
+ "nodes": [<relative-node-id>, ...],
182
+ "links": [<relative-link-id>, ...],
184
183
  }
185
184
  },
186
185
  ...
@@ -194,4 +193,5 @@ For the tree graph, `graph-tree.json`, `links` are built from a tree data struct
194
193
  ]
195
194
  }
196
195
  ```
196
+
197
197
  Unless otherwise defined, both json files are generated into `_site/assets/`.
data/bin/console CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "bundler/setup"
5
- require "jekyll/graph"
5
+ require "jekyll-graph"
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
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
@@ -34,6 +35,6 @@ Gem::Specification.new do |spec|
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.2"
38
- spec.add_runtime_dependency "jekyll-wikilinks", "~> 0.0.6"
38
+ spec.add_runtime_dependency "jekyll-namespaces", "~> 0.0.3"
39
+ spec.add_runtime_dependency "jekyll-wikilinks", "~> 0.0.8"
39
40
  end
@@ -5,12 +5,14 @@ module Jekyll
5
5
  module Graph
6
6
 
7
7
  class PluginConfig
8
+
9
+ ASSETS_KEY = "assets"
8
10
  CONFIG_KEY = "graph"
9
11
  ENABLED_KEY = "enabled"
10
12
  EXCLUDE_KEY = "exclude"
11
13
  NET_WEB_KEY = "net_web"
12
- PATH_ASSETS_KEY = "assets_path"
13
- PATH_SCRIPTS_KEY = "scripts_path"
14
+ PATH_KEY = "path"
15
+ SCRIPTS_KEY = "scripts"
14
16
  TREE_KEY = "tree"
15
17
  TYPE_KEY = "type"
16
18
 
@@ -39,18 +41,22 @@ module Jekyll
39
41
  return option(EXCLUDE_KEY).include?(type.to_s)
40
42
  end
41
43
 
42
- def has_custom_write_path?
43
- return !!option(PATH_ASSETS_KEY)
44
+ def has_custom_assets_path?
45
+ return option_path(ASSETS_KEY)
44
46
  end
45
47
 
46
48
  def has_custom_scripts_path?
47
- return !!option(PATH_SCRIPTS_KEY)
49
+ return option_path(SCRIPTS_KEY)
48
50
  end
49
51
 
50
52
  def option(key)
51
53
  @config[CONFIG_KEY] && @config[CONFIG_KEY][key]
52
54
  end
53
55
 
56
+ def option_path(key)
57
+ @config[CONFIG_KEY] && @config[CONFIG_KEY][PATH_KEY] && @config[CONFIG_KEY][PATH_KEY][key]
58
+ end
59
+
54
60
  def option_net_web(key)
55
61
  @config[CONFIG_KEY] && @config[CONFIG_KEY][NET_WEB_KEY] && @config[CONFIG_KEY][NET_WEB_KEY][key]
56
62
  end
@@ -66,11 +72,11 @@ module Jekyll
66
72
  end
67
73
 
68
74
  def path_assets
69
- return has_custom_write_path? ? option(PATH_ASSETS_KEY) : "/assets"
75
+ return has_custom_assets_path? ? option_path(ASSETS_KEY) : "/assets"
70
76
  end
71
77
 
72
78
  def path_scripts
73
- return has_custom_scripts_path? ? option(PATH_SCRIPTS_KEY) : File.join(path_assets, "js")
79
+ return has_custom_scripts_path? ? File.join(path_assets, option_path(SCRIPTS_KEY)) : File.join(path_assets, "js")
74
80
  end
75
81
 
76
82
  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() {
@@ -29,9 +30,11 @@ export default class JekyllGraph {
29
30
  let hoverNode = null;
30
31
  let hoverLink = null;
31
32
 
32
- const Graph = ForceGraph()
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,15 +104,32 @@ 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
113
  let assetsPath = '{{ site.graph.assets_path }}' !== '' ? '{{ site.graph.assets_path }}' : '/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
+ }
119
+
120
+ // node height vars
121
+ this.shifted = [];
122
+ this.numSiblingsLeft = [];
123
+
124
+ // hover vars
125
+ const highlightNodes = new Set();
126
+ const highlightLinks = new Set();
127
+ let hoverNode = null;
128
+ let hoverLink = null;
110
129
 
111
- // relatives: replace ids with full object
130
+ // relatives: replace ids with full objects
112
131
  data.nodes.forEach(node => {
132
+ // relatives
113
133
  let relativeNodes = [];
114
134
  node.relatives.nodes.forEach(nNodeId => {
115
135
  relativeNodes.push(data.nodes.find(node => node.id === nNodeId));
@@ -120,16 +140,11 @@ export default class JekyllGraph {
120
140
  });
121
141
  node.relatives.nodes = relativeNodes;
122
142
  node.relatives.links = relativeLinks;
143
+ // siblings
144
+ this.numSiblingsLeft[node.parent] = node.siblings.length;
123
145
  });
124
146
 
125
- const highlightNodes = new Set();
126
- const highlightLinks = new Set();
127
- let hoverNode = null;
128
- let hoverLink = null;
129
-
130
- const Graph = ForceGraph()
131
-
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')
@@ -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 {
@@ -255,11 +289,11 @@ export default class JekyllGraph {
255
289
  //
256
290
  if (this.isCurrentPage(node)) {
257
291
  // turn glow on
258
- ctx.shadowBlur = 30;
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 = 30;
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
@@ -3,7 +3,7 @@
3
3
  module Jekyll
4
4
  module Graph
5
5
 
6
- VERSION = "0.0.2"
6
+ VERSION = "0.0.3"
7
7
 
8
8
  end
9
9
  end
data/lib/jekyll-graph.rb CHANGED
@@ -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.nil?
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.nil?
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.debug("No documents to process.")
54
+ Jekyll.logger.warn("Jekyll-Graph: No documents to process.")
54
55
  end
55
56
 
56
57
  # write graph
@@ -64,7 +65,6 @@ 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
@@ -76,13 +76,12 @@ module Jekyll
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
- def register_static_file(static_file)
120
- # tests fail without manually adding the static file, but actual site builds seem to do ok
121
- # ...although there does seem to be a race condition which causes a rebuild to be necessary in order to detect the graph data file
122
- if $graph_conf.testing
123
- @site.static_files << static_file if !@site.static_files.include?(static_file)
124
- end
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.
@@ -143,6 +141,8 @@ module Jekyll
143
141
  def set_relatives(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|
144
+ # set relatives
145
+
146
146
  ancestor_node_ids, descendent_node_ids = @site.tree.get_all_relative_ids(json_node[:id])
147
147
  relative_node_ids = ancestor_node_ids.concat(descendent_node_ids)
148
148
  json_node[:relatives][:nodes] = relative_node_ids if !relative_node_ids.nil?
@@ -152,6 +152,10 @@ module Jekyll
152
152
 
153
153
  json_relative_links = json_links.select { |l| lineage_ids.include?(l[:source]) && lineage_ids.include?(l[:target]) }
154
154
  json_node[:relatives][:links] = json_relative_links if !json_relative_links.nil?
155
+
156
+ # set siblings
157
+
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 "Processing graph nodes for doc: ", doc.data['title']
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 "Net-Web node missing: ", missing_link_name
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: '',
@@ -235,12 +238,12 @@ module Jekyll
235
238
  return net_web_nodes, net_web_links
236
239
  end
237
240
 
238
- def generate_json_tree(node, json_parent="", tree_nodes=[], tree_links=[])
241
+ def generate_json_tree(node, json_parent="", tree_nodes=[], tree_links=[], level=0)
239
242
  #
240
243
  # missing nodes
241
244
  #
242
245
  if node.missing
243
- Jekyll.logger.warn("Document for tree node missing: ", node.namespace)
246
+ Jekyll.logger.warn("Jekyll-Graph: Document for tree node missing: ", node.namespace)
244
247
 
245
248
  leaf = node.namespace.split('.').pop()
246
249
  missing_node = {
@@ -248,18 +251,22 @@ module Jekyll
248
251
  label: leaf.gsub('-', ' '),
249
252
  namespace: node.namespace,
250
253
  url: "",
254
+ level: level,
251
255
  relatives: {
252
256
  nodes: [],
253
257
  links: [],
254
258
  },
259
+ siblings: [],
255
260
  }
256
- tree_nodes << missing_node
261
+ # non-root handling
257
262
  if !json_parent.empty?
263
+ missing_node[:parent] = json_parent[:id]
258
264
  tree_links << {
259
265
  source: json_parent[:id],
260
266
  target: node.namespace,
261
267
  }
262
268
  end
269
+ tree_nodes << missing_node
263
270
  json_parent = missing_node
264
271
  #
265
272
  # existing nodes
@@ -270,22 +277,26 @@ module Jekyll
270
277
  label: node.title,
271
278
  namespace: node.namespace,
272
279
  url: relative_url(node.url),
280
+ level: level,
273
281
  relatives: {
274
282
  nodes: [],
275
283
  links: [],
276
284
  },
285
+ siblings: [],
277
286
  }
278
- tree_nodes << existing_node
287
+ # non-root handling
279
288
  if !json_parent.empty?
289
+ existing_node[:parent] = json_parent[:id]
280
290
  tree_links << {
281
291
  source: json_parent[:id],
282
292
  target: node.url,
283
293
  }
284
294
  end
295
+ tree_nodes << existing_node
285
296
  json_parent = existing_node
286
297
  end
287
298
  node.children.each do |child|
288
- self.generate_json_tree(child, json_parent, tree_nodes, tree_links)
299
+ self.generate_json_tree(child, json_parent, tree_nodes, tree_links, (level + 1))
289
300
  end
290
301
  return tree_nodes, tree_links
291
302
  end
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - manunamz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-17 00:00:00.000000000 Z
11
+ date: 2021-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll-namespaces
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.2
19
+ version: 0.0.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.2
26
+ version: 0.0.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jekyll-wikilinks
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.6
33
+ version: 0.0.8
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.6
40
+ version: 0.0.8
41
41
  description:
42
42
  email:
43
43
  - manunamz@pm.me
@@ -65,7 +65,8 @@ files:
65
65
  - lib/jekyll-graph/tags.rb
66
66
  - lib/jekyll-graph/version.rb
67
67
  homepage: https://github.com/manunamz/jekyll-graph
68
- licenses: []
68
+ licenses:
69
+ - GPL3
69
70
  metadata:
70
71
  homepage_uri: https://github.com/manunamz/jekyll-graph
71
72
  source_code_uri: https://github.com/manunamz/jekyll-graph
@@ -85,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
86
  - !ruby/object:Gem::Version
86
87
  version: '0'
87
88
  requirements: []
88
- rubygems_version: 3.2.17
89
+ rubygems_version: 3.2.27
89
90
  signing_key:
90
91
  specification_version: 4
91
92
  summary: Add d3 graph generation to jekyll.