pathchain 1.1.9 → 1.1.10
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 +30 -13
- package/package.json +1 -1
package/maker.js
CHANGED
|
@@ -313,6 +313,15 @@ function link(target, prev, next, author, ancestor, format = 'MM DD YYYY HH:mm:S
|
|
|
313
313
|
const link_pb = pb(fs.readFileSync('node_modules/pathchain/proto/link.proto'));
|
|
314
314
|
var target_type = "";
|
|
315
315
|
|
|
316
|
+
// Handle author and author folder
|
|
317
|
+
let author_folder = author;
|
|
318
|
+
if (author === "") {
|
|
319
|
+
author = pioneer(getter.getCurrentDate(), 'MM DD YYYY HH:mm:SSS [GMT]Z');
|
|
320
|
+
author_folder = "";
|
|
321
|
+
} else {
|
|
322
|
+
author_folder = `${author_folder}/`;
|
|
323
|
+
}
|
|
324
|
+
|
|
316
325
|
// Validate target
|
|
317
326
|
if (target === "") {
|
|
318
327
|
return "The link must be linking something. The target cannot be null.";
|
|
@@ -320,8 +329,24 @@ function link(target, prev, next, author, ancestor, format = 'MM DD YYYY HH:mm:S
|
|
|
320
329
|
else{
|
|
321
330
|
var splitted_target = target.split("/");
|
|
322
331
|
console.log("Splitted target: ", splitted_target);
|
|
323
|
-
|
|
324
|
-
|
|
332
|
+
if(splitted_target.length>1){
|
|
333
|
+
target_type = splitted_target[splitted_target.length - 2];
|
|
334
|
+
console.log("Target type: ", target_type);
|
|
335
|
+
}
|
|
336
|
+
else{
|
|
337
|
+
// Determine the nature of the target (node, path, or label)
|
|
338
|
+
if (checker.checkFile(`files/${author_folder}nodes/${target}`)) {
|
|
339
|
+
target_type = "nodes";
|
|
340
|
+
target = `${author_folder}nodes/${target}`;
|
|
341
|
+
} else if (checker.checkFile(`files/${author_folder}paths/${target}`)) {
|
|
342
|
+
target_type = "paths";
|
|
343
|
+
target = `${author_folder}paths/${target}`;
|
|
344
|
+
} else if (checker.checkFile(`files/${author_folder}labels/${target}`)) {
|
|
345
|
+
target_type = "labels";
|
|
346
|
+
target = `${author_folder}labels/${target}`;
|
|
347
|
+
}
|
|
348
|
+
console.log("Target type determined for single buffer: ", target_type);
|
|
349
|
+
}
|
|
325
350
|
}
|
|
326
351
|
|
|
327
352
|
// Homogenize the author.
|
|
@@ -329,27 +354,19 @@ function link(target, prev, next, author, ancestor, format = 'MM DD YYYY HH:mm:S
|
|
|
329
354
|
// Make a copy of it inside *author* address if it is not public or if the original author is different than *author*
|
|
330
355
|
// What the fuck
|
|
331
356
|
|
|
332
|
-
// Handle author and author folder
|
|
333
|
-
let author_folder = author;
|
|
334
|
-
if (author === "") {
|
|
335
|
-
author = pioneer(getter.getCurrentDate(), 'MM DD YYYY HH:mm:SSS [GMT]Z');
|
|
336
|
-
author_folder = "";
|
|
337
|
-
} else {
|
|
338
|
-
author_folder = `${author_folder}/`;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
357
|
// Create a moment for this link
|
|
342
358
|
const register = dt.format(new Date(), dt.compile(format, true));
|
|
343
359
|
const register_moment_hash = moment(register, 0, 0, 0, 0, 0, format);
|
|
344
360
|
|
|
345
|
-
// Generate a unique hash for this link
|
|
346
|
-
const link_hash = sha256(`${register_moment_hash}_${author}_${prev}_${next}`);
|
|
347
361
|
|
|
348
362
|
// Set default values if not provided
|
|
349
363
|
if (ancestor === "") { ancestor = link_hash; }
|
|
350
364
|
if (prev === "") { prev = link_hash; }
|
|
351
365
|
if (next === "") { next = link_hash; }
|
|
352
366
|
|
|
367
|
+
// Generate a unique hash for this link
|
|
368
|
+
const link_hash = sha256(`${register_moment_hash}_${author}_${prev}_${next}`);
|
|
369
|
+
|
|
353
370
|
if (!checker.checkFile(`files/${target}`)) {
|
|
354
371
|
return "Target was not found!";
|
|
355
372
|
}
|
package/package.json
CHANGED