mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-03-30 23:36:56 +00:00
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
This commit is contained in:
parent
77c9918338
commit
e504530005
@ -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
|
||||
|
41
core/modules/macros/serverpath.js
Normal file
41
core/modules/macros/serverpath.js
Normal file
@ -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;
|
||||
};
|
||||
|
||||
})();
|
@ -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>>
|
Loading…
x
Reference in New Issue
Block a user