1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-10-02 00:40:47 +00:00
TiddlyWiki5/core/modules/macros/serverpath.js
Tobias Beer e504530005 introduce serverpath macro
for now, computes path to backup directory, appending the relative path
of UploadBackupDir to the absolute one from the UploadURL

Also added example for store.php to hint
2015-01-23 11:26:14 +01:00

42 lines
776 B
JavaScript

/*\
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;
};
})();