From 4a05bd10e948d9d44b9b231873fda45836c2a0d0 Mon Sep 17 00:00:00 2001 From: Tobias Beer Date: Thu, 29 Jan 2015 00:38:08 +0100 Subject: [PATCH] renamed to resolvePath using $tw.utils.resolvePath adapted ControlPanel / Saving accordingly --- core/modules/macros/resolvePath.js | 29 +++++++++++++++++++++ core/modules/macros/serverpath.js | 41 ------------------------------ core/ui/ControlPanel/Saving.tid | 2 +- 3 files changed, 30 insertions(+), 42 deletions(-) create mode 100644 core/modules/macros/resolvePath.js delete mode 100644 core/modules/macros/serverpath.js diff --git a/core/modules/macros/resolvePath.js b/core/modules/macros/resolvePath.js new file mode 100644 index 000000000..22bedb7de --- /dev/null +++ b/core/modules/macros/resolvePath.js @@ -0,0 +1,29 @@ +/*\ +title: $:/core/modules/macros/resolvePath.js +type: application/javascript +module-type: macro + +Resolves a relative path for an absolute rootpath. + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.name = "resolvePath"; + +exports.params = [ + {name: "source"}, + {name: "root"} +]; + +/* +Run the macro +*/ +exports.run = function(source, root) { + return $tw.utils.resolvePath(source, root); +}; + +})(); diff --git a/core/modules/macros/serverpath.js b/core/modules/macros/serverpath.js deleted file mode 100644 index 7fe47a2c1..000000000 --- a/core/modules/macros/serverpath.js +++ /dev/null @@ -1,41 +0,0 @@ -/*\ -title: $:/core/modules/macros/serverpath.js -type: application/javascript -module-type: macro - -Outputs a server-path based on parameters, -by default appends a relative path to an absolute one, -e.g. constructs path to TiddlySpot backup directory - -\*/ -(function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ -"use strict"; - -exports.name = "serverpath"; - -exports.params = [ - {name: "source"}, - {name: "target"}, - {name: "mode"} -]; - -/* -Run the macro -*/ -exports.run = function(source, target, mode) { - var result = target; - mode = mode || ""; - switch (mode){ - case "": - case "append-relative": - target = ("." == target || "./" == target) ? "" : target; - result = source.substr(0,1+source.lastIndexOf('/')) + target; - break; - } - return result; -}; - -})(); diff --git a/core/ui/ControlPanel/Saving.tid b/core/ui/ControlPanel/Saving.tid index 65b3b687e..5c54b37df 100644 --- a/core/ui/ControlPanel/Saving.tid +++ b/core/ui/ControlPanel/Saving.tid @@ -13,7 +13,7 @@ http://$(userName)$.tiddlyspot.com/backup/ <> <$reveal type="nomatch" state="$:/UploadURL" text=""> -<$macrocall $name=serverpath source={{$:/UploadURL}} target={{$:/UploadBackupDir}}>> +<$macrocall $name=resolvePath source={{$:/UploadBackupDir}} root={{$:/UploadURL}}>>