mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-25 23:03:15 +00:00
renamed to resolvePath using $tw.utils.resolvePath
adapted ControlPanel / Saving accordingly
This commit is contained in:
parent
e504530005
commit
4a05bd10e9
29
core/modules/macros/resolvePath.js
Normal file
29
core/modules/macros/resolvePath.js
Normal file
|
@ -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);
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
|
@ -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;
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
|
|
@ -13,7 +13,7 @@ http://$(userName)$.tiddlyspot.com/backup/
|
||||||
<<backupURL>>
|
<<backupURL>>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
<$reveal type="nomatch" state="$:/UploadURL" text="">
|
<$reveal type="nomatch" state="$:/UploadURL" text="">
|
||||||
<$macrocall $name=serverpath source={{$:/UploadURL}} target={{$:/UploadBackupDir}}>>
|
<$macrocall $name=resolvePath source={{$:/UploadBackupDir}} root={{$:/UploadURL}}>>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
</$set>
|
</$set>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user