/
getexportimage.js
65 lines (55 loc) · 1.54 KB
/
getexportimage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*\
title: $:/plugins/welford/twstaticblog/export/get-export-image.js
type: application/javascript
module-type: macro
returns the formatted link tiddler to a tiddler
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
*/
exports.name = "tv-get-export-image-link";
exports.params = [
];
var TAG_EXP_ATTR = "tag";
var FRAMEWORK_EXP_ATTR = "framework";
var POSTS_EXP_ATTR = "posts";
var INDEX_EXP_ATTR = "index";
var FRAMEWORK_TAG = "blog-framework";
var TAG_LINK_ATTR = "taglink";
var INDEX_POST = "index";
/*
Run the macro
*/
exports.run = function() {
var title = this.getVariable("currentTiddler");
var attr = this.getVariable("tv-subfolder-links");
var path_to_root="./"
if(
this.imageSource.indexOf("http:") != -1
|| this.imageSource.indexOf("https:") != -1
){
return this.imageSource;
}
//------------------------------------------------------
//correcting the root location based on attribute type...
//reference the folder stucture description above for more details
//generic blog posts are 3 layers deep
if(attr==POSTS_EXP_ATTR){
path_to_root="../../../"
}
//autogenerated tag posts and framework stuff go in the same place for convenience [root]/tag/...
else if(attr==TAG_EXP_ATTR){
path_to_root="../"
}
//index.html and framework stuff are special and go in the root
else if(attr==INDEX_EXP_ATTR || attr==FRAMEWORK_EXP_ATTR){
path_to_root="./"
}
var finalLink = path_to_root;
return (finalLink).toLocaleLowerCase() + this.imageSource;
};
})();