1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Merge pull request #1392 from tobibeer/1387-fix-tiddlyspot-backup-url

Add resolvepath macro
This commit is contained in:
Jeremy Ruston 2015-02-03 14:22:48 +00:00
commit d340277cb2
4 changed files with 60 additions and 4 deletions

View File

@ -56,7 +56,7 @@ 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

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

View File

@ -9,7 +9,12 @@ http://$(userName)$.tiddlyspot.com/backup/
\define backupLink()
<$reveal type="nomatch" state="$:/UploadName" text="">
<$set name="userName" value={{$:/UploadName}}>
<a href=<<backupURL>>><$macrocall $name="backupURL" $type="text/plain" $output="text/plain"/></a>
<$reveal type="match" state="$:/UploadURL" text="">
<<backupURL>>
</$reveal>
<$reveal type="nomatch" state="$:/UploadURL" text="">
<$macrocall $name=resolvePath source={{$:/UploadBackupDir}} root={{$:/UploadURL}}>>
</$reveal>
</$set>
</$reveal>
\end
@ -28,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>>

View File

@ -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:
```
<<resolvepath "./backup" "http://mysite.com/store.php">>
```
<<resolvepath "./backup" "http://mysite.com/store.php">>