mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 17:10:29 +00:00
Merge branch 'master' into parameterised-transclusions
This commit is contained in:
commit
0d1667c467
@ -16,6 +16,22 @@ Filter operator for applying decodeURIComponent() to each item.
|
||||
Export our filter functions
|
||||
*/
|
||||
|
||||
exports.decodebase64 = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
results.push($tw.utils.base64Decode(title));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
exports.encodebase64 = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
results.push($tw.utils.base64Encode(title));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
exports.decodeuricomponent = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
|
@ -238,7 +238,7 @@ exports.generateTiddlerFileInfo = function(tiddler,options) {
|
||||
} else {
|
||||
// Save as a .tid or a text/binary file plus a .meta file
|
||||
var tiddlerType = tiddler.fields.type || "text/vnd.tiddlywiki";
|
||||
if(tiddlerType === "text/vnd.tiddlywiki") {
|
||||
if(tiddlerType === "text/vnd.tiddlywiki" || tiddler.hasField("_canonical_uri")) {
|
||||
// Save as a .tid file
|
||||
fileInfo.type = "application/x-tiddler";
|
||||
fileInfo.hasMetaFile = false;
|
||||
|
@ -46,6 +46,7 @@ GenesisWidget.prototype.execute = function() {
|
||||
this.genesisRemappable = this.getAttribute("$remappable","yes") === "yes";
|
||||
this.genesisNames = this.getAttribute("$names","");
|
||||
this.genesisValues = this.getAttribute("$values","");
|
||||
this.genesisIsBlock = this.getAttribute("$mode",this.parseTreeNode.isBlock && "block") === "block";
|
||||
// Do not create a child widget if the $type attribute is missing or blank
|
||||
if(!this.genesisType) {
|
||||
this.makeChildWidgets(this.parseTreeNode.children);
|
||||
@ -60,6 +61,7 @@ GenesisWidget.prototype.execute = function() {
|
||||
tag: nodeTag,
|
||||
attributes: {},
|
||||
orderedAttributes: [],
|
||||
isBlock: this.genesisIsBlock,
|
||||
children: this.parseTreeNode.children || [],
|
||||
isNotRemappable: !this.genesisRemappable
|
||||
}];
|
||||
|
@ -46,9 +46,7 @@ title: $:/core/ui/EditTemplate
|
||||
<$keyboard key="((cancel-edit-tiddler))" actions=<<cancel-delete-tiddler-actions "cancel">> tag="div">
|
||||
<$keyboard key="((save-tiddler))" actions=<<save-tiddler-actions>> tag="div">
|
||||
<$list filter="[all[shadows+tiddlers]tag[$:/tags/EditTemplate]!has[draft.of]]" variable="listItem">
|
||||
<$set name="tv-config-toolbar-class" filter="[<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]]">
|
||||
<$transclude tiddler=<<listItem>>/>
|
||||
</$set>
|
||||
</$list>
|
||||
</$keyboard>
|
||||
</$keyboard>
|
||||
|
@ -7,6 +7,6 @@ $:/config/EditToolbarButtons/Visibility/$(listItem)$
|
||||
\whitespace trim
|
||||
<div class="tc-tiddler-title tc-tiddler-edit-title">
|
||||
<$view field="title"/>
|
||||
<span class="tc-tiddler-controls tc-titlebar"><$list filter="[all[shadows+tiddlers]tag[$:/tags/EditToolbar]!has[draft.of]]" variable="listItem"><$reveal type="nomatch" state=<<config-title>> text="hide"><$transclude tiddler=<<listItem>>/></$reveal></$list></span>
|
||||
<span class="tc-tiddler-controls tc-titlebar"><$list filter="[all[shadows+tiddlers]tag[$:/tags/EditToolbar]!has[draft.of]]" variable="listItem"><$let tv-config-toolbar-class={{{ [enlist<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]] +[join[ ]]}}}><$reveal type="nomatch" state=<<config-title>> text="hide"><$transclude tiddler=<<listItem>>/></$reveal></$let></$list></span>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
|
19
editions/test/tiddlers/tests/data/filters/Base64.tid
Normal file
19
editions/test/tiddlers/tests/data/filters/Base64.tid
Normal file
@ -0,0 +1,19 @@
|
||||
title: Filters/Base64
|
||||
description: Test {encode|decode}base64 operators
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
(<$text text={{{ [[Jeremy1234]encodebase64[]] }}}/>)
|
||||
(<$text text={{{ [[]encodebase64[]] }}}/>)
|
||||
(<$text text={{{ [[SmVyZW15MTIzNA==]decodebase64[]] }}}/>)
|
||||
(<$text text={{{ [[]decodebase64[]] }}}/>)
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>(SmVyZW15MTIzNA==)
|
||||
()
|
||||
(Jeremy1234)
|
||||
()</p>
|
30
editions/test/tiddlers/tests/data/genesis-widget/Block.tid
Normal file
30
editions/test/tiddlers/tests/data/genesis-widget/Block.tid
Normal file
@ -0,0 +1,30 @@
|
||||
title: Genesis/Block
|
||||
description: genesis widget distinguishes between block and inline
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$genesis $type="$reveal" type=nomatch>
|
||||
|
||||
Block
|
||||
</$genesis>
|
||||
|
||||
<$genesis $type="$reveal" type=nomatch $mode=block>
|
||||
|
||||
Block forced block
|
||||
</$genesis>
|
||||
|
||||
<$genesis $type="$reveal" type=nomatch $mode=inline>
|
||||
|
||||
Block forced inline
|
||||
</$genesis>
|
||||
|
||||
<$genesis $type=$reveal type=nomatch>Inline</$genesis>
|
||||
<$genesis $type=$reveal type=nomatch $mode=block>Inline forced block</$genesis>
|
||||
<$genesis $type=$reveal type=nomatch $mode=inline>Inline forced inline</$genesis>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<div class=" tc-reveal"><p>Block</p></div><div class=" tc-reveal"><p>Block forced block</p></div><span class=" tc-reveal"><p>Block forced inline</p></span><p><span class=" tc-reveal">Inline</span><div class=" tc-reveal">Inline forced block</div><span class=" tc-reveal">Inline forced inline</span></p>
|
16
editions/tw5.com/tiddlers/filters/decodebase64 Operator.tid
Normal file
16
editions/tw5.com/tiddlers/filters/decodebase64 Operator.tid
Normal file
@ -0,0 +1,16 @@
|
||||
caption: decodebase64
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input with base 64 decoding applied
|
||||
op-parameter:
|
||||
op-parameter-name:
|
||||
op-purpose: apply base 64 decoding to a string
|
||||
tags: [[Filter Operators]] [[String Operators]]
|
||||
title: decodebase64 Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
from-version: 5.2.6
|
||||
|
||||
See Mozilla Developer Network for details of [[base 64 encoding|https://developer.mozilla.org/en-US/docs/Glossary/Base64]]. TiddlyWiki uses [[library code from @nijikokun|https://gist.github.com/Nijikokun/5192472]] to handle the conversion.
|
||||
|
||||
The input strings must be base64 encoded. The output strings are binary data.
|
||||
|
||||
<<.operator-examples "decodebase64">>
|
16
editions/tw5.com/tiddlers/filters/encodebase64 Operator.tid
Normal file
16
editions/tw5.com/tiddlers/filters/encodebase64 Operator.tid
Normal file
@ -0,0 +1,16 @@
|
||||
caption: encodebase64
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input with base 64 encoding applied
|
||||
op-parameter:
|
||||
op-parameter-name:
|
||||
op-purpose: apply base 64 encoding to a string
|
||||
tags: [[Filter Operators]] [[String Operators]]
|
||||
title: encodebase64 Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
from-version: 5.2.6
|
||||
|
||||
See Mozilla Developer Network for details of [[base 64 encoding|https://developer.mozilla.org/en-US/docs/Glossary/Base64]]. TiddlyWiki uses [[library code from @nijikokun|https://gist.github.com/Nijikokun/5192472]] to handle the conversion.
|
||||
|
||||
The input strings are interpreted as binary data. The output strings are base64 encoded.
|
||||
|
||||
<<.operator-examples "encodebase64">>
|
@ -17,6 +17,7 @@ The content of the <<.wid genesis>> widget is used as the content of the dynamic
|
||||
|$type |The type of widget or element to create (an initial `$` indicates a widget, otherwise an HTML element will be created) |
|
||||
|$names |An optional filter evaluating to the names of a list of attributes to be applied to the widget |
|
||||
|$values |An optional filter evaluating to the values corresponding to the list of names specified in <<.attr $names>> |
|
||||
|$mode |An optional override of the parsing mode. May be "inline" or "block" |
|
||||
|//{other attributes starting with $}// |Other attributes starting with a single dollar sign are reserved for future use |
|
||||
|//{attributes starting with $$}// |Attributes starting with two dollar signs are applied as attributes to the output widget, but with the attribute name changed to use a single dollar sign |
|
||||
|//{attributes not starting with $}// |Any other attributes that do not start with a dollar are applied as attributes to the output widget |
|
||||
|
@ -38,23 +38,28 @@ DynannotateWidget.prototype.render = function(parent,nextSibling) {
|
||||
// Create our DOM nodes
|
||||
var isSnippetMode = this.isSnippetMode();
|
||||
this.domContent = $tw.utils.domMaker("div",{
|
||||
"class": "tc-dynannotation-selection-container"
|
||||
"class": "tc-dynannotation-selection-container",
|
||||
document: this.document
|
||||
});
|
||||
if(isSnippetMode) {
|
||||
this.domContent.setAttribute("hidden","hidden");
|
||||
this.domContent.setAttribute("hidden","hidden");
|
||||
}
|
||||
this.domAnnotations = $tw.utils.domMaker("div",{
|
||||
"class": "tc-dynannotation-annotation-wrapper"
|
||||
"class": "tc-dynannotation-annotation-wrapper",
|
||||
document: this.document
|
||||
});
|
||||
this.domSnippets = $tw.utils.domMaker("div",{
|
||||
"class": "tc-dynannotation-snippet-wrapper"
|
||||
"class": "tc-dynannotation-snippet-wrapper",
|
||||
document: this.document
|
||||
});
|
||||
this.domSearches = $tw.utils.domMaker("div",{
|
||||
"class": "tc-dynannotation-search-wrapper"
|
||||
"class": "tc-dynannotation-search-wrapper",
|
||||
document: this.document
|
||||
});
|
||||
this.domWrapper = $tw.utils.domMaker("div",{
|
||||
"class": "tc-dynannotation-wrapper",
|
||||
children: [this.domContent,this.domAnnotations,this.domSnippets,this.domSearches]
|
||||
children: [this.domContent,this.domAnnotations,this.domSnippets,this.domSearches],
|
||||
document: this.document
|
||||
})
|
||||
parent.insertBefore(this.domWrapper,nextSibling);
|
||||
this.domNodes.push(this.domWrapper);
|
||||
@ -64,16 +69,18 @@ DynannotateWidget.prototype.render = function(parent,nextSibling) {
|
||||
}
|
||||
// Render our child widgets
|
||||
this.renderChildren(this.domContent,null);
|
||||
if(isSnippetMode) {
|
||||
// Apply search snippets
|
||||
this.applySnippets();
|
||||
} else {
|
||||
// Get the list of annotation tiddlers
|
||||
this.getAnnotationTiddlers();
|
||||
// Apply annotations
|
||||
this.applyAnnotations();
|
||||
// Apply search overlays
|
||||
this.applySearch();
|
||||
if(!this.document.isTiddlyWikiFakeDom) {
|
||||
if(isSnippetMode) {
|
||||
// Apply search snippets
|
||||
this.applySnippets();
|
||||
} else {
|
||||
// Get the list of annotation tiddlers
|
||||
this.getAnnotationTiddlers();
|
||||
// Apply annotations
|
||||
this.applyAnnotations();
|
||||
// Apply search overlays
|
||||
this.applySearch();
|
||||
}
|
||||
}
|
||||
// Save the width of the wrapper so that we can tell when it changes
|
||||
this.wrapperWidth = this.domWrapper.offsetWidth;
|
||||
|
Loading…
Reference in New Issue
Block a user