From 77c9918338f9ff9a81f1365bba54df98e9f80080 Mon Sep 17 00:00:00 2001 From: Tobias Beer Date: Tue, 20 Jan 2015 12:06:09 +0100 Subject: [PATCH 1/5] shows better message for backup dir with custom store.php relates to #1387 --- core/language/en-GB/ControlPanel.multids | 1 + core/ui/ControlPanel/Saving.tid | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/core/language/en-GB/ControlPanel.multids b/core/language/en-GB/ControlPanel.multids index 8fbaf59cc..f616a42bc 100644 --- a/core/language/en-GB/ControlPanel.multids +++ b/core/language/en-GB/ControlPanel.multids @@ -61,6 +61,7 @@ Saving/TiddlySpot/Password: Password Saving/TiddlySpot/ServerURL: Server URL Saving/TiddlySpot/UploadDir: Upload Directory Saving/TiddlySpot/UserName: Wiki Name +Saving/TiddlySpot/RelativeURL: relative to ''Server URL'' Settings/AutoSave/Caption: Autosave Settings/AutoSave/Disabled/Description: Do not save changes automatically Settings/AutoSave/Enabled/Description: Save changes automatically diff --git a/core/ui/ControlPanel/Saving.tid b/core/ui/ControlPanel/Saving.tid index 10583513d..f1d31f18e 100644 --- a/core/ui/ControlPanel/Saving.tid +++ b/core/ui/ControlPanel/Saving.tid @@ -9,7 +9,12 @@ http://$(userName)$.tiddlyspot.com/backup/ \define backupLink() <$reveal type="nomatch" state="$:/UploadName" text=""> <$set name="userName" value={{$:/UploadName}}> +<$reveal type="match" state="$:/UploadURL" text=""> >><$macrocall $name="backupURL" $type="text/plain" $output="text/plain"/> + +<$reveal type="nomatch" state="$:/UploadURL" text=""> +<> + \end From e50453000588f58e7e3f6712d478ac8da1be55b8 Mon Sep 17 00:00:00 2001 From: Tobias Beer Date: Fri, 23 Jan 2015 11:26:14 +0100 Subject: [PATCH 2/5] 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 --- core/language/en-GB/ControlPanel.multids | 3 +- core/modules/macros/serverpath.js | 41 ++++++++++++++++++++++++ core/ui/ControlPanel/Saving.tid | 7 ++-- 3 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 core/modules/macros/serverpath.js diff --git a/core/language/en-GB/ControlPanel.multids b/core/language/en-GB/ControlPanel.multids index f616a42bc..6c8d989fa 100644 --- a/core/language/en-GB/ControlPanel.multids +++ b/core/language/en-GB/ControlPanel.multids @@ -56,12 +56,11 @@ Saving/TiddlySpot/Backups: Backups Saving/TiddlySpot/Description: These settings are only used when saving to http://tiddlyspot.com or a compatible remote server Saving/TiddlySpot/Filename: Upload Filename Saving/TiddlySpot/Heading: ~TiddlySpot -Saving/TiddlySpot/Hint: //The server URL defaults to `http://.tiddlyspot.com/store.cgi` and can be changed to use a custom server address// +Saving/TiddlySpot/Hint: //The server URL defaults to `http://.tiddlyspot.com/store.cgi` and can be changed to use a custom server address, e.g. `http://me.com/store.php`.// Saving/TiddlySpot/Password: Password Saving/TiddlySpot/ServerURL: Server URL Saving/TiddlySpot/UploadDir: Upload Directory Saving/TiddlySpot/UserName: Wiki Name -Saving/TiddlySpot/RelativeURL: relative to ''Server URL'' Settings/AutoSave/Caption: Autosave Settings/AutoSave/Disabled/Description: Do not save changes automatically Settings/AutoSave/Enabled/Description: Save changes automatically diff --git a/core/modules/macros/serverpath.js b/core/modules/macros/serverpath.js new file mode 100644 index 000000000..7fe47a2c1 --- /dev/null +++ b/core/modules/macros/serverpath.js @@ -0,0 +1,41 @@ +/*\ +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 f1d31f18e..65b3b687e 100644 --- a/core/ui/ControlPanel/Saving.tid +++ b/core/ui/ControlPanel/Saving.tid @@ -10,10 +10,10 @@ http://$(userName)$.tiddlyspot.com/backup/ <$reveal type="nomatch" state="$:/UploadName" text=""> <$set name="userName" value={{$:/UploadName}}> <$reveal type="match" state="$:/UploadURL" text=""> ->><$macrocall $name="backupURL" $type="text/plain" $output="text/plain"/> +<> <$reveal type="nomatch" state="$:/UploadURL" text=""> -<> +<$macrocall $name=serverpath source={{$:/UploadURL}} target={{$:/UploadBackupDir}}>> @@ -33,5 +33,4 @@ http://$(userName)$.tiddlyspot.com/backup/ |<> |<$edit-text tiddler="$:/UploadDir" default="." tag="input"/> | |<> |<$edit-text tiddler="$:/UploadBackupDir" default="." tag="input"/> | -<> - +<> \ No newline at end of file From 4a05bd10e948d9d44b9b231873fda45836c2a0d0 Mon Sep 17 00:00:00 2001 From: Tobias Beer Date: Thu, 29 Jan 2015 00:38:08 +0100 Subject: [PATCH 3/5] 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}}>> From e4bd0c86330614cdc250e3807ab64c559512c906 Mon Sep 17 00:00:00 2001 From: Tobias Beer Date: Tue, 3 Feb 2015 15:18:38 +0100 Subject: [PATCH 4/5] added documentation temporary documentation demo: http://goto.bplaced.net/tw5/5.1.7.html#ResolvePath --- .../{resolvePath.js => resolve_path.js} | 4 ++-- .../tw5.com/tiddlers/macros/ResolvePath.tid | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) rename core/modules/macros/{resolvePath.js => resolve_path.js} (83%) create mode 100644 editions/tw5.com/tiddlers/macros/ResolvePath.tid diff --git a/core/modules/macros/resolvePath.js b/core/modules/macros/resolve_path.js similarity index 83% rename from core/modules/macros/resolvePath.js rename to core/modules/macros/resolve_path.js index 22bedb7de..d84d87563 100644 --- a/core/modules/macros/resolvePath.js +++ b/core/modules/macros/resolve_path.js @@ -1,5 +1,5 @@ /*\ -title: $:/core/modules/macros/resolvePath.js +title: $:/core/modules/macros/resolvepath.js type: application/javascript module-type: macro @@ -12,7 +12,7 @@ Resolves a relative path for an absolute rootpath. /*global $tw: false */ "use strict"; -exports.name = "resolvePath"; +exports.name = "resolvepath"; exports.params = [ {name: "source"}, diff --git a/editions/tw5.com/tiddlers/macros/ResolvePath.tid b/editions/tw5.com/tiddlers/macros/ResolvePath.tid new file mode 100644 index 000000000..be0a2951f --- /dev/null +++ b/editions/tw5.com/tiddlers/macros/ResolvePath.tid @@ -0,0 +1,23 @@ +created: 20150203152000000 +modified: 20150203152000000 +title: ResolvePath +type: text/vnd.tiddlywiki +caption: resolvepath + +The ''resolvepath'' macro constructs a url for a relative source path with respect to an absolute root path, trailing filenames being cut-off. + +! Parameters + +|!Position |!Name |!Description |!Default | +|1st |source |the relative path to be appended| | +|2nd |root |the absolute path to be appended to | | + +! Examples + +A trivial example to show how the macro works: + +``` +<> +``` + +<> \ No newline at end of file From 32fd03d2f5d423d98928e1128a364522585af3e0 Mon Sep 17 00:00:00 2001 From: Tobias Beer Date: Tue, 3 Feb 2015 15:19:03 +0100 Subject: [PATCH 5/5] rename macro --- core/modules/macros/{resolve_path.js => resolvepath.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename core/modules/macros/{resolve_path.js => resolvepath.js} (100%) diff --git a/core/modules/macros/resolve_path.js b/core/modules/macros/resolvepath.js similarity index 100% rename from core/modules/macros/resolve_path.js rename to core/modules/macros/resolvepath.js