mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-10-03 01:10:45 +00:00
Merge branch 'master' into demo-alternate-store
This commit is contained in:
commit
83e7d32c8e
@ -1,6 +1,4 @@
|
|||||||
title: $:/core/images/new-journal-button
|
title: $:/core/images/new-journal-button
|
||||||
tags: $:/tags/Image
|
tags: $:/tags/Image
|
||||||
|
|
||||||
<$parameters size="22pt" day=<<now "DD">>>
|
<$parameters size="22pt" day=<<now "DD">>><svg width=<<size>> height=<<size>> class="tc-image-new-journal-button tc-image-button" viewBox="0 0 128 128"><g fill-rule="evenodd"><path d="M102.545 112.818v11.818c0 1.306 1.086 2.364 2.425 2.364h6.06c1.34 0 2.425-1.058 2.425-2.364v-11.818h12.12c1.34 0 2.425-1.058 2.425-2.363v-5.91c0-1.305-1.085-2.363-2.424-2.363h-12.121V90.364c0-1.306-1.086-2.364-2.425-2.364h-6.06c-1.34 0-2.425 1.058-2.425 2.364v11.818h-12.12c-1.34 0-2.425 1.058-2.425 2.363v5.91c0 1.305 1.085 2.363 2.424 2.363h12.121zM60.016 4.965c-4.781-2.76-10.897-1.118-13.656 3.66L5.553 79.305A9.993 9.993 0 009.21 92.963l51.04 29.468c4.78 2.76 10.897 1.118 13.655-3.66l40.808-70.681a9.993 9.993 0 00-3.658-13.656L60.016 4.965zm-3.567 27.963a6 6 0 106-10.393 6 6 0 00-6 10.393zm31.697 17.928a6 6 0 106-10.392 6 6 0 00-6 10.392z"/><text class="tc-fill-background" font-family="Helvetica" font-size="47.172" font-weight="bold" transform="rotate(30 25.742 95.82)"><tspan x="42" y="77.485" text-anchor="middle"><$text text=<<day>>/></tspan></text></g></svg></$parameters>
|
||||||
<svg width=<<size>> height=<<size>> class="tc-image-new-journal-button tc-image-button" viewBox="0 0 128 128"><g fill-rule="evenodd"><path d="M102.545 112.818v11.818c0 1.306 1.086 2.364 2.425 2.364h6.06c1.34 0 2.425-1.058 2.425-2.364v-11.818h12.12c1.34 0 2.425-1.058 2.425-2.363v-5.91c0-1.305-1.085-2.363-2.424-2.363h-12.121V90.364c0-1.306-1.086-2.364-2.425-2.364h-6.06c-1.34 0-2.425 1.058-2.425 2.364v11.818h-12.12c-1.34 0-2.425 1.058-2.425 2.363v5.91c0 1.305 1.085 2.363 2.424 2.363h12.121zM60.016 4.965c-4.781-2.76-10.897-1.118-13.656 3.66L5.553 79.305A9.993 9.993 0 009.21 92.963l51.04 29.468c4.78 2.76 10.897 1.118 13.655-3.66l40.808-70.681a9.993 9.993 0 00-3.658-13.656L60.016 4.965zm-3.567 27.963a6 6 0 106-10.393 6 6 0 00-6 10.393zm31.697 17.928a6 6 0 106-10.392 6 6 0 00-6 10.392z"/><text class="tc-fill-background" font-family="Helvetica" font-size="47.172" font-weight="bold" transform="rotate(30 25.742 95.82)"><tspan x="42" y="77.485" text-anchor="middle"><$text text=<<day>>/></tspan></text></g></svg>
|
|
||||||
</$parameters>
|
|
@ -38,6 +38,7 @@ exports.startup = function() {
|
|||||||
url: params.url,
|
url: params.url,
|
||||||
method: params.method,
|
method: params.method,
|
||||||
body: params.body,
|
body: params.body,
|
||||||
|
binary: params.binary,
|
||||||
oncompletion: params.oncompletion,
|
oncompletion: params.oncompletion,
|
||||||
onprogress: params.onprogress,
|
onprogress: params.onprogress,
|
||||||
bindStatus: params["bind-status"],
|
bindStatus: params["bind-status"],
|
||||||
|
@ -90,6 +90,7 @@ wiki: wiki to be used for executing action strings
|
|||||||
url: URL for request
|
url: URL for request
|
||||||
method: method eg GET, POST
|
method: method eg GET, POST
|
||||||
body: text of request body
|
body: text of request body
|
||||||
|
binary: set to "yes" to force binary processing of response payload
|
||||||
oncompletion: action string to be invoked on completion
|
oncompletion: action string to be invoked on completion
|
||||||
onprogress: action string to be invoked on progress updates
|
onprogress: action string to be invoked on progress updates
|
||||||
bindStatus: optional title of tiddler to which status ("pending", "complete", "error") should be written
|
bindStatus: optional title of tiddler to which status ("pending", "complete", "error") should be written
|
||||||
@ -110,6 +111,7 @@ function HttpClientRequest(options) {
|
|||||||
this.bindProgress = options["bindProgress"];
|
this.bindProgress = options["bindProgress"];
|
||||||
this.method = options.method || "GET";
|
this.method = options.method || "GET";
|
||||||
this.body = options.body || "";
|
this.body = options.body || "";
|
||||||
|
this.binary = options.binary || "";
|
||||||
this.variables = options.variables;
|
this.variables = options.variables;
|
||||||
var url = options.url;
|
var url = options.url;
|
||||||
$tw.utils.each(options.queryStrings,function(value,name) {
|
$tw.utils.each(options.queryStrings,function(value,name) {
|
||||||
@ -156,6 +158,8 @@ HttpClientRequest.prototype.send = function(callback) {
|
|||||||
type: this.method,
|
type: this.method,
|
||||||
headers: this.requestHeaders,
|
headers: this.requestHeaders,
|
||||||
data: this.body,
|
data: this.body,
|
||||||
|
returnProp: this.binary === "" ? "responseText" : "response",
|
||||||
|
responseType: this.binary === "" ? "text" : "arraybuffer",
|
||||||
callback: function(err,data,xhr) {
|
callback: function(err,data,xhr) {
|
||||||
var hasSucceeded = xhr.status >= 200 && xhr.status < 300,
|
var hasSucceeded = xhr.status >= 200 && xhr.status < 300,
|
||||||
completionCode = hasSucceeded ? "complete" : "error",
|
completionCode = hasSucceeded ? "complete" : "error",
|
||||||
@ -175,6 +179,16 @@ HttpClientRequest.prototype.send = function(callback) {
|
|||||||
data: (data || "").toString(),
|
data: (data || "").toString(),
|
||||||
headers: JSON.stringify(headers)
|
headers: JSON.stringify(headers)
|
||||||
};
|
};
|
||||||
|
/* Convert data from binary to base64 */
|
||||||
|
if (xhr.responseType === "arraybuffer") {
|
||||||
|
var binary = "",
|
||||||
|
bytes = new Uint8Array(data),
|
||||||
|
len = bytes.byteLength;
|
||||||
|
for (var i=0; i<len; i++) {
|
||||||
|
binary += String.fromCharCode(bytes[i]);
|
||||||
|
}
|
||||||
|
resultVariables.data = window.btoa(binary);
|
||||||
|
}
|
||||||
self.wiki.addTiddler(new $tw.Tiddler(self.wiki.getTiddler(requestTrackerTitle),{
|
self.wiki.addTiddler(new $tw.Tiddler(self.wiki.getTiddler(requestTrackerTitle),{
|
||||||
status: completionCode,
|
status: completionCode,
|
||||||
}));
|
}));
|
||||||
@ -212,6 +226,7 @@ Make an HTTP request. Options are:
|
|||||||
callback: function invoked with (err,data,xhr)
|
callback: function invoked with (err,data,xhr)
|
||||||
progress: optional function invoked with (lengthComputable,loaded,total)
|
progress: optional function invoked with (lengthComputable,loaded,total)
|
||||||
returnProp: string name of the property to return as first argument of callback
|
returnProp: string name of the property to return as first argument of callback
|
||||||
|
responseType: "text" or "arraybuffer"
|
||||||
*/
|
*/
|
||||||
exports.httpRequest = function(options) {
|
exports.httpRequest = function(options) {
|
||||||
var type = options.type || "GET",
|
var type = options.type || "GET",
|
||||||
@ -264,6 +279,7 @@ exports.httpRequest = function(options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
request.responseType = options.responseType || "text";
|
||||||
// Set up the state change handler
|
// Set up the state change handler
|
||||||
request.onreadystatechange = function() {
|
request.onreadystatechange = function() {
|
||||||
if(this.readyState === 4) {
|
if(this.readyState === 4) {
|
||||||
|
@ -49,7 +49,7 @@ ImportVariablesWidget.prototype.execute = function(tiddlerList) {
|
|||||||
this.tiddlerList = tiddlerList || this.wiki.filterTiddlers(this.filter,this);
|
this.tiddlerList = tiddlerList || this.wiki.filterTiddlers(this.filter,this);
|
||||||
// Accumulate the <$set> widgets from each tiddler
|
// Accumulate the <$set> widgets from each tiddler
|
||||||
$tw.utils.each(this.tiddlerList,function(title) {
|
$tw.utils.each(this.tiddlerList,function(title) {
|
||||||
var parser = widgetPointer.wiki.parseTiddler(title,{parseAsInline:true});
|
var parser = widgetPointer.wiki.parseTiddler(title,{parseAsInline:true, configTrimWhiteSpace:true});
|
||||||
if(parser) {
|
if(parser) {
|
||||||
var parseTreeNode = parser.tree[0];
|
var parseTreeNode = parser.tree[0];
|
||||||
while(parseTreeNode && ["setvariable","set","parameters"].indexOf(parseTreeNode.type) !== -1) {
|
while(parseTreeNode && ["setvariable","set","parameters"].indexOf(parseTreeNode.type) !== -1) {
|
||||||
|
@ -41,16 +41,17 @@ TranscludeWidget.prototype.execute = function() {
|
|||||||
this.collectAttributes();
|
this.collectAttributes();
|
||||||
this.collectStringParameters();
|
this.collectStringParameters();
|
||||||
this.collectSlotFillParameters();
|
this.collectSlotFillParameters();
|
||||||
// Get the parse tree nodes that we are transcluding
|
// Get the target text and parse tree nodes that we are transcluding
|
||||||
var target = this.getTransclusionTarget(),
|
var target = this.getTransclusionTarget(),
|
||||||
parseTreeNodes = target.parseTreeNodes;
|
parseTreeNodes;
|
||||||
this.sourceText = target.text;
|
this.sourceText = target.text;
|
||||||
this.parserType = target.type;
|
this.parserType = target.type;
|
||||||
this.parseAsInline = target.parseAsInline;
|
this.parseAsInline = target.parseAsInline;
|
||||||
// Process the transclusion according to the output type
|
// Process the transclusion according to the output type
|
||||||
switch(this.transcludeOutput || "text/html") {
|
switch(this.transcludeOutput || "text/html") {
|
||||||
case "text/html":
|
case "text/html":
|
||||||
// No further processing required
|
// Return the parse tree nodes
|
||||||
|
parseTreeNodes = target.parseTreeNodes;
|
||||||
break;
|
break;
|
||||||
case "text/raw":
|
case "text/raw":
|
||||||
// Just return the raw text
|
// Just return the raw text
|
||||||
@ -158,7 +159,7 @@ TranscludeWidget.prototype.collectSlotFillParameters = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get transcluded parse tree nodes as an object {parser:,text:,type:}
|
Get transcluded parse tree nodes as an object {text:,type:,parseTreeNodes:,parseAsInline:}
|
||||||
*/
|
*/
|
||||||
TranscludeWidget.prototype.getTransclusionTarget = function() {
|
TranscludeWidget.prototype.getTransclusionTarget = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -270,7 +271,6 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
|
|||||||
// Return the parse tree
|
// Return the parse tree
|
||||||
if(parser) {
|
if(parser) {
|
||||||
return {
|
return {
|
||||||
parser: parser,
|
|
||||||
parseTreeNodes: parser.tree,
|
parseTreeNodes: parser.tree,
|
||||||
parseAsInline: parseAsInline,
|
parseAsInline: parseAsInline,
|
||||||
text: parser.source,
|
text: parser.source,
|
||||||
@ -279,7 +279,6 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
|
|||||||
} else {
|
} else {
|
||||||
// If there's no parse tree then return the missing slot value
|
// If there's no parse tree then return the missing slot value
|
||||||
return {
|
return {
|
||||||
parser: null,
|
|
||||||
parseTreeNodes: (this.slotFillParseTrees["ts-missing"] || []),
|
parseTreeNodes: (this.slotFillParseTrees["ts-missing"] || []),
|
||||||
parseAsInline: parseAsInline,
|
parseAsInline: parseAsInline,
|
||||||
text: null,
|
text: null,
|
||||||
|
@ -13,7 +13,7 @@ Widget base class
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/* Maximum permitted depth of the widget tree for recursion detection */
|
/* Maximum permitted depth of the widget tree for recursion detection */
|
||||||
var MAX_WIDGET_TREE_DEPTH = 1000;
|
var MAX_WIDGET_TREE_DEPTH = 500;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Create a widget object for a parse tree node
|
Create a widget object for a parse tree node
|
||||||
|
@ -1086,7 +1086,7 @@ exports.getSubstitutedText = function(text,widget,options) {
|
|||||||
output = $tw.utils.replaceString(output,new RegExp("\\$" + $tw.utils.escapeRegExp(substitute.name) + "\\$","mg"),substitute.value);
|
output = $tw.utils.replaceString(output,new RegExp("\\$" + $tw.utils.escapeRegExp(substitute.name) + "\\$","mg"),substitute.value);
|
||||||
});
|
});
|
||||||
// Substitute any variable references with their values
|
// Substitute any variable references with their values
|
||||||
return output.replace(/\$\((\w+)\)\$/g, function(match,varname) {
|
return output.replace(/\$\(([^\)\$]+)\)\$/g, function(match,varname) {
|
||||||
return widget.getVariable(varname,{defaultValue: ""})
|
return widget.getVariable(varname,{defaultValue: ""})
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
code-body: yes
|
||||||
title: $:/core/ui/AlertTemplate
|
title: $:/core/ui/AlertTemplate
|
||||||
|
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
code-body: yes
|
||||||
title: $:/core/ui/EditTemplate
|
title: $:/core/ui/EditTemplate
|
||||||
|
|
||||||
\define delete-edittemplate-state-tiddlers()
|
\define delete-edittemplate-state-tiddlers()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
title: $:/core/ui/ImportPreviews/Text
|
title: $:/core/ui/ImportPreviews/Text
|
||||||
tags: $:/tags/ImportPreview
|
tags: $:/tags/ImportPreview
|
||||||
caption: {{$:/language/Import/Listing/Preview/Text}}
|
caption: {{$:/language/Import/Listing/Preview/Text}}
|
||||||
|
code-body: yes
|
||||||
|
|
||||||
<$transclude tiddler=<<currentTiddler>> subtiddler=<<payloadTiddler>> mode="block"/>
|
<$transclude tiddler=<<currentTiddler>> subtiddler=<<payloadTiddler>> mode="block"/>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
title: $:/core/ui/PageStylesheet
|
title: $:/core/ui/PageStylesheet
|
||||||
|
code-body: yes
|
||||||
|
|
||||||
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
|
@ -2,6 +2,7 @@ title: $:/core/ui/PageTemplate
|
|||||||
name: {{$:/language/PageTemplate/Name}}
|
name: {{$:/language/PageTemplate/Name}}
|
||||||
description: {{$:/language/PageTemplate/Description}}
|
description: {{$:/language/PageTemplate/Description}}
|
||||||
icon: $:/core/images/layout-button
|
icon: $:/core/images/layout-button
|
||||||
|
code-body: yes
|
||||||
|
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
title: $:/core/ui/RootTemplate
|
title: $:/core/ui/RootTemplate
|
||||||
|
code-body: yes
|
||||||
|
|
||||||
<$transclude tiddler={{{ [{$:/layout}has[text]] ~[[$:/core/ui/PageTemplate]] }}} mode="inline"/>
|
<$transclude tiddler={{{ [{$:/layout}has[text]] ~[[$:/core/ui/PageTemplate]] }}} mode="inline"/>
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
title: $:/core/ui/StoryTiddlerTemplate
|
title: $:/core/ui/StoryTiddlerTemplate
|
||||||
|
code-body: yes
|
||||||
|
|
||||||
<$transclude tiddler={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/StoryTiddlerTemplateFilter]!is[draft]get[text]] :and[has[title]else[$:/core/ui/ViewTemplate]] }}} />
|
<$transclude tiddler={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/StoryTiddlerTemplateFilter]!is[draft]get[text]] :and[has[title]else[$:/core/ui/ViewTemplate]] }}} />
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
title: $:/core/ui/ViewTemplate
|
title: $:/core/ui/ViewTemplate
|
||||||
|
code-body: yes
|
||||||
|
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
\define folded-state()
|
\define folded-state()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
title: $:/core/ui/ViewTemplate/body/default
|
title: $:/core/ui/ViewTemplate/body/default
|
||||||
|
code-body: yes
|
||||||
|
|
||||||
<$transclude>
|
<$transclude>
|
||||||
|
|
||||||
|
@ -2,7 +2,8 @@ title: $:/config/ViewTemplateBodyFilters/
|
|||||||
tags: $:/tags/ViewTemplateBodyFilter
|
tags: $:/tags/ViewTemplateBodyFilter
|
||||||
|
|
||||||
stylesheet: [tag[$:/tags/Stylesheet]then[$:/core/ui/ViewTemplate/body/rendered-plain-text]]
|
stylesheet: [tag[$:/tags/Stylesheet]then[$:/core/ui/ViewTemplate/body/rendered-plain-text]]
|
||||||
system: [prefix[$:/boot/]] [prefix[$:/config/]] [prefix[$:/core/macros]] [prefix[$:/core/save/]] [prefix[$:/core/templates/]] [prefix[$:/core/ui/]split[/]count[]compare:number:eq[4]] [prefix[$:/info/]] [prefix[$:/language/]] [prefix[$:/languages/]] [prefix[$:/snippets/]] [prefix[$:/state/]] [prefix[$:/status/]] [prefix[$:/info/]] [prefix[$:/temp/]] +[!is[image]limit[1]then[$:/core/ui/ViewTemplate/body/code]]
|
core-ui-tags: [tag[$:/tags/PageTemplate]] [tag[$:/tags/EditTemplate]] [tag[$:/tags/ViewTemplate]] [tag[$:/tags/KeyboardShortcut]] [tag[$:/tags/ImportPreview]] [tag[$:/tags/EditPreview]][tag[$:/tags/EditorToolbar]] [tag[$:/tags/Actions]] :then[[$:/core/ui/ViewTemplate/body/code]]
|
||||||
|
system: [prefix[$:/boot/]] [prefix[$:/config/]] [prefix[$:/core/macros]] [prefix[$:/core/save/]] [prefix[$:/core/templates/]] [prefix[$:/info/]] [prefix[$:/language/]] [prefix[$:/languages/]] [prefix[$:/snippets/]] [prefix[$:/state/]] [prefix[$:/status/]] [prefix[$:/info/]] [prefix[$:/temp/]] +[!is[image]limit[1]then[$:/core/ui/ViewTemplate/body/code]]
|
||||||
code-body: [field:code-body[yes]then[$:/core/ui/ViewTemplate/body/code]]
|
code-body: [field:code-body[yes]then[$:/core/ui/ViewTemplate/body/code]]
|
||||||
import: [field:plugin-type[import]then[$:/core/ui/ViewTemplate/body/import]]
|
import: [field:plugin-type[import]then[$:/core/ui/ViewTemplate/body/import]]
|
||||||
plugin: [has[plugin-type]then[$:/core/ui/ViewTemplate/body/plugin]]
|
plugin: [has[plugin-type]then[$:/core/ui/ViewTemplate/body/plugin]]
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
title: $:/tags/ViewTemplateBodyFilter
|
title: $:/tags/ViewTemplateBodyFilter
|
||||||
list: $:/config/ViewTemplateBodyFilters/hide-body $:/config/ViewTemplateBodyFilters/code-body $:/config/ViewTemplateBodyFilters/stylesheet $:/config/ViewTemplateBodyFilters/system $:/config/ViewTemplateBodyFilters/import $:/config/ViewTemplateBodyFilters/plugin $:/config/ViewTemplateBodyFilters/default
|
list: $:/config/ViewTemplateBodyFilters/hide-body $:/config/ViewTemplateBodyFilters/code-body $:/config/ViewTemplateBodyFilters/stylesheet $:/config/ViewTemplateBodyFilters/core-ui-advanced-search $:/config/ViewTemplateBodyFilters/core-ui-tags $:/config/ViewTemplateBodyFilters/system $:/config/ViewTemplateBodyFilters/import $:/config/ViewTemplateBodyFilters/plugin $:/config/ViewTemplateBodyFilters/default
|
||||||
|
|
@ -0,0 +1,23 @@
|
|||||||
|
title: ImportVariables/WithSetWidgets
|
||||||
|
description: Import variables defined with a set widget
|
||||||
|
type: text/vnd.tiddlywiki-multiple
|
||||||
|
tags: [[$:/tags/wiki-test-spec]]
|
||||||
|
|
||||||
|
title: Output
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
\import Definitions
|
||||||
|
<$text text=<<one>>/>,
|
||||||
|
<$text text=<<two>>/>
|
||||||
|
+
|
||||||
|
title: Definitions
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
<$set name="one" value="elephant">
|
||||||
|
<$set name="two" value="giraffe">
|
||||||
|
</$set>
|
||||||
|
</$set>
|
||||||
|
+
|
||||||
|
title: ExpectedResult
|
||||||
|
|
||||||
|
<p>elephant,giraffe</p>
|
@ -0,0 +1,22 @@
|
|||||||
|
title: ImportVariables/WithSetWidgets2
|
||||||
|
description: Import variables defined with a set widget without whitespace pragma
|
||||||
|
type: text/vnd.tiddlywiki-multiple
|
||||||
|
tags: [[$:/tags/wiki-test-spec]]
|
||||||
|
|
||||||
|
title: Output
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
\import Definitions
|
||||||
|
<$text text=<<one>>/>,
|
||||||
|
<$text text=<<two>>/>
|
||||||
|
+
|
||||||
|
title: Definitions
|
||||||
|
|
||||||
|
<$set name="one" value="elephant">
|
||||||
|
<$set name="two" value="giraffe">
|
||||||
|
</$set>
|
||||||
|
</$set>
|
||||||
|
+
|
||||||
|
title: ExpectedResult
|
||||||
|
|
||||||
|
<p>elephant,giraffe</p>
|
@ -0,0 +1,29 @@
|
|||||||
|
title: ImportVariables/WithSetWidgetsAndMacros
|
||||||
|
description: Import variables defined with a set widget without whitespace pragma
|
||||||
|
type: text/vnd.tiddlywiki-multiple
|
||||||
|
tags: [[$:/tags/wiki-test-spec]]
|
||||||
|
|
||||||
|
title: Output
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
\import Definitions
|
||||||
|
<$text text=<<name>>/>,
|
||||||
|
<$text text=<<address>>/>,
|
||||||
|
<$text text=<<one>>/>,
|
||||||
|
<$text text=<<two>>/>
|
||||||
|
+
|
||||||
|
title: Definitions
|
||||||
|
|
||||||
|
\define name() Bugs Bunny
|
||||||
|
\procedure address()
|
||||||
|
Bunny Hill
|
||||||
|
\end
|
||||||
|
|
||||||
|
<$set name="one" value="elephant">
|
||||||
|
<$set name="two" value="giraffe">
|
||||||
|
</$set>
|
||||||
|
</$set>
|
||||||
|
+
|
||||||
|
title: ExpectedResult
|
||||||
|
|
||||||
|
<p>Bugs Bunny,Bunny Hill,elephant,giraffe</p>
|
@ -6,14 +6,16 @@ tags: [[$:/tags/wiki-test-spec]]
|
|||||||
title: Output
|
title: Output
|
||||||
|
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
<$let project="TiddlyWiki" disabled="true">
|
<$set name="var with spaces" value="spaces">
|
||||||
|
<$let project="TiddlyWiki" disabled="true" var-with-dashes="dashes">
|
||||||
<div class=`$(project)$
|
<div class=`$(project)$
|
||||||
${ [[Hello]addsuffix[There]] }$` attrib=`myvalue` otherattrib=`$(1)$` blankattrib=`` quoted="here" disabled=```$(disabled)$```>
|
${ [[Hello]addsuffix[There]] }$` attrib=`myvalue` otherattrib=`$(1)$` blankattrib=`` quoted="here" disabled=```$(disabled)$``` dashes=`$(var-with-dashes)$` spaces=`$(var with spaces)$`>
|
||||||
</div>
|
</div>
|
||||||
</$let>
|
</$let>
|
||||||
|
</$set>
|
||||||
|
|
||||||
+
|
+
|
||||||
title: ExpectedResult
|
title: ExpectedResult
|
||||||
|
|
||||||
<p><div attrib="myvalue" blankattrib="" class="TiddlyWiki
|
<p><div attrib="myvalue" blankattrib="" class="TiddlyWiki
|
||||||
HelloThere" disabled="true" otherattrib="" quoted="here"></div></p>
|
HelloThere" dashes="dashes" disabled="true" otherattrib="" quoted="here" spaces="spaces"></div></p>
|
@ -0,0 +1,88 @@
|
|||||||
|
title: WidgetMessage: tm-http-request Example - Random Dog
|
||||||
|
tags: $:/tags/Global
|
||||||
|
|
||||||
|
\procedure download-dog(url)
|
||||||
|
|
||||||
|
\procedure completion-download-dog()
|
||||||
|
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||||
|
<$action-log msg="In completion-download-dog"/>
|
||||||
|
<$action-log/>
|
||||||
|
<!-- Success -->
|
||||||
|
<$list filter="[<status>compare:number:gteq[200]compare:number:lteq[299]]" variable="ignore">
|
||||||
|
<!-- Create the dog tiddler -->
|
||||||
|
<$action-createtiddler
|
||||||
|
$basetitle=`$:/RandomDog/$(title)$`
|
||||||
|
text=<<data>>
|
||||||
|
tags="$:/tags/RandomDog"
|
||||||
|
type={{{ [<headers>jsonget[content-type]] }}}
|
||||||
|
credits="https://random.dog/"
|
||||||
|
>
|
||||||
|
<$action-log msg="Created tiddler" title=<<createTiddler-title>>/>
|
||||||
|
</$createtiddler>
|
||||||
|
</$list>
|
||||||
|
\end completion-download-dog
|
||||||
|
|
||||||
|
<$action-sendmessage
|
||||||
|
$message="tm-http-request"
|
||||||
|
url=<<url>>
|
||||||
|
method="GET"
|
||||||
|
binary="yes"
|
||||||
|
oncompletion=<<completion-download-dog>>
|
||||||
|
var-title=<<url>>
|
||||||
|
/>
|
||||||
|
\end download-dog
|
||||||
|
|
||||||
|
\procedure get-random-dog()
|
||||||
|
|
||||||
|
\procedure completion-get-json()
|
||||||
|
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||||
|
<$action-log msg="In completion-get-json"/>
|
||||||
|
<$action-log/>
|
||||||
|
<!-- Success -->
|
||||||
|
<$list filter="[<status>compare:number:gteq[200]compare:number:lteq[299]]" variable="ignore">
|
||||||
|
<!-- Download the dog -->
|
||||||
|
<$macrocall $name="download-dog" url={{{ [<data>jsonget[url]] }}}/>
|
||||||
|
</$list>
|
||||||
|
\end completion-get-json
|
||||||
|
|
||||||
|
<$action-sendmessage
|
||||||
|
$message="tm-http-request"
|
||||||
|
url="https://random.dog/woof.json"
|
||||||
|
method="GET"
|
||||||
|
oncompletion=<<completion-get-json>>
|
||||||
|
/>
|
||||||
|
\end get-random-dog
|
||||||
|
|
||||||
|
!! Random Dogs
|
||||||
|
|
||||||
|
This demo uses the API of the website https://random.dog/ to import a random dog image or video.
|
||||||
|
|
||||||
|
<$button actions=<<get-random-dog>>>
|
||||||
|
Import a random dog image or video
|
||||||
|
</$button>
|
||||||
|
|
||||||
|
<$list filter="[tag[$:/tags/RandomDog]limit[1]]" variable="ignore">
|
||||||
|
|
||||||
|
!! Imported Tiddlers
|
||||||
|
|
||||||
|
<$button>
|
||||||
|
<$action-deletetiddler $filter="[tag[$:/tags/RandomDog]]"/>
|
||||||
|
Delete all imported random dogs
|
||||||
|
</$button>
|
||||||
|
|
||||||
|
Export all imported random dogs: <$macrocall $name="exportButton" exportFilter="[tag[$:/tags/RandomDog]]" lingoBase="$:/language/Buttons/ExportTiddlers/"/>
|
||||||
|
|
||||||
|
</$list>
|
||||||
|
|
||||||
|
<ol>
|
||||||
|
<$list filter="[tag[$:/tags/RandomDog]!sort[modified]]">
|
||||||
|
<li>
|
||||||
|
<$link>
|
||||||
|
<$text text=<<currentTiddler>>/>
|
||||||
|
</$link>
|
||||||
|
<div style="width:300px;height:300px;">
|
||||||
|
<$transclude $tiddler=<<currentTiddler>>/>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</$list>
|
||||||
|
</ol>
|
@ -1,5 +1,5 @@
|
|||||||
title: WidgetMessage: tm-http-request Example - Zotero
|
title: WidgetMessage: tm-http-request Example - Zotero
|
||||||
tags: $:/tags/Macro
|
tags: $:/tags/Global
|
||||||
|
|
||||||
\procedure select-zotero-group()
|
\procedure select-zotero-group()
|
||||||
Specify the Zotero group ID to import
|
Specify the Zotero group ID to import
|
||||||
@ -34,7 +34,7 @@ Specify the Zotero group ID to import
|
|||||||
\procedure zotero-get-items(start:"0",limit:"25")
|
\procedure zotero-get-items(start:"0",limit:"25")
|
||||||
|
|
||||||
\procedure completion()
|
\procedure completion()
|
||||||
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
|
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||||
<$action-log msg="In completion"/>
|
<$action-log msg="In completion"/>
|
||||||
<$action-log/>
|
<$action-log/>
|
||||||
<!-- Success -->
|
<!-- Success -->
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
caption: tm-http-request
|
caption: tm-http-request
|
||||||
created: 20230429161453032
|
created: 20230429161453032
|
||||||
modified: 20230429161453032
|
modified: 20230717104212742
|
||||||
tags: Messages
|
tags: Messages
|
||||||
title: WidgetMessage: tm-http-request
|
title: WidgetMessage: tm-http-request
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
@ -18,6 +18,7 @@ The following parameters are used:
|
|||||||
|!Name |!Description |
|
|!Name |!Description |
|
||||||
|method |HTTP method (eg "GET", "POST") |
|
|method |HTTP method (eg "GET", "POST") |
|
||||||
|body |String data to be sent with the request |
|
|body |String data to be sent with the request |
|
||||||
|
|binary |<<.from-version "5.3.1">> Set to "yes" to cause the response body to be treated as binary data and returned in base64 format |
|
||||||
|query-* |Query string parameters with string values |
|
|query-* |Query string parameters with string values |
|
||||||
|header-* |Headers with string values |
|
|header-* |Headers with string values |
|
||||||
|password-header-* |Headers with values taken from the password store |
|
|password-header-* |Headers with values taken from the password store |
|
||||||
@ -49,3 +50,4 @@ Note that the state tiddler $:/state/http-requests contains a number representin
|
|||||||
!! Examples
|
!! Examples
|
||||||
|
|
||||||
* [[Zotero's|https://www.zotero.org/]] API for retrieving reference items: [[WidgetMessage: tm-http-request Example - Zotero]]
|
* [[Zotero's|https://www.zotero.org/]] API for retrieving reference items: [[WidgetMessage: tm-http-request Example - Zotero]]
|
||||||
|
* [[Random Dog's|https://random.dog/]] API for retrieving random pictures of dogs showing how to retrieve binary data: [[WidgetMessage: tm-http-request Example - Random Dogs]]
|
||||||
|
Loading…
Reference in New Issue
Block a user