Skip to content

Commit

Permalink
Merge pull request #1392 from tobibeer/1387-fix-tiddlyspot-backup-url
Browse files Browse the repository at this point in the history
Add resolvepath macro
  • Loading branch information
Jermolene committed Feb 3, 2015
2 parents 6a01ec5 + 32fd03d commit d340277
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/language/en-GB/ControlPanel.multids
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions core/modules/macros/resolvepath.js
Original file line number Diff line number Diff line change
@@ -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);
};

})();
10 changes: 7 additions & 3 deletions core/ui/ControlPanel/Saving.tid
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>>
23 changes: 23 additions & 0 deletions editions/tw5.com/tiddlers/macros/ResolvePath.tid
Original file line number Diff line number Diff line change
@@ -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">>

0 comments on commit d340277

Please sign in to comment.