pathchain 1.1.6 → 1.1.8
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.
- package/maker.js +15 -16
- package/package.json +1 -1
package/maker.js
CHANGED
|
@@ -234,7 +234,7 @@ function path(text, elements, author, ancestor, format = 'MM DD YYYY HH:mm:SSS [
|
|
|
234
234
|
const current_link = link(elements[i], "", "", author, "");
|
|
235
235
|
if (i > 0) {
|
|
236
236
|
updater.setLinkNext(prev_link, current_link);
|
|
237
|
-
updater.
|
|
237
|
+
updater.setLinkPrev(current_link, prev_link);
|
|
238
238
|
}
|
|
239
239
|
prev_link = current_link;
|
|
240
240
|
}
|
|
@@ -311,11 +311,23 @@ function label(text, author, ancestor, format = 'MM DD YYYY HH:mm:SSS [GMT]Z') {
|
|
|
311
311
|
function link(target, prev, next, author, ancestor, format = 'MM DD YYYY HH:mm:SSS [GMT]Z') {
|
|
312
312
|
// Load the link protocol buffer definition
|
|
313
313
|
const link_pb = pb(fs.readFileSync('node_modules/pathchain/proto/link.proto'));
|
|
314
|
+
var target_type = "";
|
|
314
315
|
|
|
315
316
|
// Validate target
|
|
316
317
|
if (target === "") {
|
|
317
318
|
return "The link must be linking something. The target cannot be null.";
|
|
318
319
|
}
|
|
320
|
+
else{
|
|
321
|
+
var splitted_target = target.split("/");
|
|
322
|
+
console.log("Splitted target: ", splitted_target);
|
|
323
|
+
target_type = splitted_target[splitted_target.length - 2];
|
|
324
|
+
console.log("Target type: ", target_type);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Homogenize the author.
|
|
328
|
+
// Break down the target address
|
|
329
|
+
// Make a copy of it inside *author* address if it is not public or if the original author is different than *author*
|
|
330
|
+
// What the fuck
|
|
319
331
|
|
|
320
332
|
// Handle author and author folder
|
|
321
333
|
let author_folder = author;
|
|
@@ -338,21 +350,8 @@ function link(target, prev, next, author, ancestor, format = 'MM DD YYYY HH:mm:S
|
|
|
338
350
|
if (prev === "") { prev = link_hash; }
|
|
339
351
|
if (next === "") { next = link_hash; }
|
|
340
352
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
if (checker.checkFile(`files/${author_folder}nodes/${target}`)) {
|
|
344
|
-
target_type = "nodes";
|
|
345
|
-
} else if (checker.checkFile(`files/${author_folder}paths/${target}`)) {
|
|
346
|
-
target_type = "paths";
|
|
347
|
-
} else if (checker.checkFile(`files/${author_folder}labels/${target}`)) {
|
|
348
|
-
target_type = "labels";
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
if (target_type) {
|
|
352
|
-
target = `${target_type}/${target}`;
|
|
353
|
-
console.log(`Target is a ${target_type.slice(0, -1)}`);
|
|
354
|
-
} else {
|
|
355
|
-
console.log("Warning: Target type not recognized");
|
|
353
|
+
if (!checker.checkFile(`files/${target}`)) {
|
|
354
|
+
return "Target was not found!";
|
|
356
355
|
}
|
|
357
356
|
|
|
358
357
|
// Encode the link data into a protocol buffer
|
package/package.json
CHANGED