mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 01:20:30 +00:00
Merge pull request #1392 from tobibeer/1387-fix-tiddlyspot-backup-url
Add resolvepath macro
This commit is contained in:
commit
d340277cb2
@ -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/Description: These settings are only used when saving to http://tiddlyspot.com or a compatible remote server
|
||||||
Saving/TiddlySpot/Filename: Upload Filename
|
Saving/TiddlySpot/Filename: Upload Filename
|
||||||
Saving/TiddlySpot/Heading: ~TiddlySpot
|
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/Password: Password
|
||||||
Saving/TiddlySpot/ServerURL: Server URL
|
Saving/TiddlySpot/ServerURL: Server URL
|
||||||
Saving/TiddlySpot/UploadDir: Upload Directory
|
Saving/TiddlySpot/UploadDir: Upload Directory
|
||||||
|
29
core/modules/macros/resolvepath.js
Normal file
29
core/modules/macros/resolvepath.js
Normal 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);
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
@ -9,7 +9,12 @@ http://$(userName)$.tiddlyspot.com/backup/
|
|||||||
\define backupLink()
|
\define backupLink()
|
||||||
<$reveal type="nomatch" state="$:/UploadName" text="">
|
<$reveal type="nomatch" state="$:/UploadName" text="">
|
||||||
<$set name="userName" value={{$:/UploadName}}>
|
<$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>
|
</$set>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
\end
|
\end
|
||||||
@ -29,4 +34,3 @@ http://$(userName)$.tiddlyspot.com/backup/
|
|||||||
|<<lingo TiddlySpot/BackupDir>> |<$edit-text tiddler="$:/UploadBackupDir" default="." tag="input"/> |
|
|<<lingo TiddlySpot/BackupDir>> |<$edit-text tiddler="$:/UploadBackupDir" default="." tag="input"/> |
|
||||||
|
|
||||||
<<lingo TiddlySpot/Hint>>
|
<<lingo TiddlySpot/Hint>>
|
||||||
|
|
||||||
|
23
editions/tw5.com/tiddlers/macros/ResolvePath.tid
Normal file
23
editions/tw5.com/tiddlers/macros/ResolvePath.tid
Normal 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">>
|
Loading…
Reference in New Issue
Block a user