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
print-window-tiddler
Tobias Beer 2015-01-23 11:26:14 +01:00
rodzic 77c9918338
commit e504530005
3 zmienionych plików z 45 dodań i 6 usunięć

Wyświetl plik

@ -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://<wikiname>.tiddlyspot.com/store.cgi` and can be changed to use a custom server address//
Saving/TiddlySpot/Hint: //The server URL defaults to `http://<wikiname>.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

Wyświetl plik

@ -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;
};
})();

Wyświetl plik

@ -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="">
<a href=<<backupURL>>><$macrocall $name="backupURL" $type="text/plain" $output="text/plain"/></a>
<<backupURL>>
</$reveal>
<$reveal type="nomatch" state="$:/UploadURL" text="">
<<lingo TiddlySpot/RelativeURL>>
<$macrocall $name=serverpath source={{$:/UploadURL}} target={{$:/UploadBackupDir}}>>
</$reveal>
</$set>
</$reveal>
@ -33,5 +33,4 @@ http://$(userName)$.tiddlyspot.com/backup/
|<<lingo TiddlySpot/UploadDir>> |<$edit-text tiddler="$:/UploadDir" default="." tag="input"/> |
|<<lingo TiddlySpot/BackupDir>> |<$edit-text tiddler="$:/UploadBackupDir" default="." tag="input"/> |
<<lingo TiddlySpot/Hint>>
<<lingo TiddlySpot/Hint>>