diff --git a/core/modules/filters/encodings.js b/core/modules/filters/encodings.js index 9ab38c54e..23c743a03 100644 --- a/core/modules/filters/encodings.js +++ b/core/modules/filters/encodings.js @@ -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) { diff --git a/core/modules/utils/filesystem.js b/core/modules/utils/filesystem.js index cb542493f..1ba34323e 100644 --- a/core/modules/utils/filesystem.js +++ b/core/modules/utils/filesystem.js @@ -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; diff --git a/core/modules/widgets/genesis.js b/core/modules/widgets/genesis.js index 6d30f3c36..c8403a3d4 100644 --- a/core/modules/widgets/genesis.js +++ b/core/modules/widgets/genesis.js @@ -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 }]; diff --git a/core/ui/EditTemplate.tid b/core/ui/EditTemplate.tid index 4d6dec5d6..5aed61a73 100644 --- a/core/ui/EditTemplate.tid +++ b/core/ui/EditTemplate.tid @@ -46,9 +46,7 @@ title: $:/core/ui/EditTemplate <$keyboard key="((cancel-edit-tiddler))" actions=<> tag="div"> <$keyboard key="((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="[] [encodeuricomponent[]addprefix[tc-btn-]]"> <$transclude tiddler=<>/> - diff --git a/core/ui/EditTemplate/controls.tid b/core/ui/EditTemplate/controls.tid index 3e2f5e3f3..3e94d371d 100644 --- a/core/ui/EditTemplate/controls.tid +++ b/core/ui/EditTemplate/controls.tid @@ -7,6 +7,6 @@ $:/config/EditToolbarButtons/Visibility/$(listItem)$ \whitespace trim
<$view field="title"/> -<$list filter="[all[shadows+tiddlers]tag[$:/tags/EditToolbar]!has[draft.of]]" variable="listItem"><$reveal type="nomatch" state=<> text="hide"><$transclude tiddler=<>/> +<$list filter="[all[shadows+tiddlers]tag[$:/tags/EditToolbar]!has[draft.of]]" variable="listItem"><$let tv-config-toolbar-class={{{ [enlist] [encodeuricomponent[]addprefix[tc-btn-]] +[join[ ]]}}}><$reveal type="nomatch" state=<> text="hide"><$transclude tiddler=<>/>
diff --git a/editions/test/tiddlers/tests/data/filters/Base64.tid b/editions/test/tiddlers/tests/data/filters/Base64.tid new file mode 100644 index 000000000..17f1defff --- /dev/null +++ b/editions/test/tiddlers/tests/data/filters/Base64.tid @@ -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 + +

(SmVyZW15MTIzNA==) +() +(Jeremy1234) +()

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/genesis-widget/Block.tid b/editions/test/tiddlers/tests/data/genesis-widget/Block.tid new file mode 100644 index 000000000..dfa5dacaf --- /dev/null +++ b/editions/test/tiddlers/tests/data/genesis-widget/Block.tid @@ -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 $type="$reveal" type=nomatch $mode=block> + +Block forced block + + +<$genesis $type="$reveal" type=nomatch $mode=inline> + +Block forced inline + + +<$genesis $type=$reveal type=nomatch>Inline +<$genesis $type=$reveal type=nomatch $mode=block>Inline forced block +<$genesis $type=$reveal type=nomatch $mode=inline>Inline forced inline ++ +title: ExpectedResult + +

Block

Block forced block

Block forced inline

Inline

Inline forced block
Inline forced inline

\ No newline at end of file diff --git a/editions/tw5.com/tiddlers/filters/decodebase64 Operator.tid b/editions/tw5.com/tiddlers/filters/decodebase64 Operator.tid new file mode 100644 index 000000000..6760af8d3 --- /dev/null +++ b/editions/tw5.com/tiddlers/filters/decodebase64 Operator.tid @@ -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">> diff --git a/editions/tw5.com/tiddlers/filters/encodebase64 Operator.tid b/editions/tw5.com/tiddlers/filters/encodebase64 Operator.tid new file mode 100644 index 000000000..ddbc73078 --- /dev/null +++ b/editions/tw5.com/tiddlers/filters/encodebase64 Operator.tid @@ -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">> diff --git a/editions/tw5.com/tiddlers/widgets/GenesisWidget.tid b/editions/tw5.com/tiddlers/widgets/GenesisWidget.tid index 9292e39ba..83bb36e6d 100644 --- a/editions/tw5.com/tiddlers/widgets/GenesisWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/GenesisWidget.tid @@ -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 | diff --git a/plugins/tiddlywiki/dynannotate/modules/dynannotate.js b/plugins/tiddlywiki/dynannotate/modules/dynannotate.js index cd47c07c7..12d8f7155 100644 --- a/plugins/tiddlywiki/dynannotate/modules/dynannotate.js +++ b/plugins/tiddlywiki/dynannotate/modules/dynannotate.js @@ -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;