From def9b553a8ac967dc06bd5d052c8cdafae460ba7 Mon Sep 17 00:00:00 2001 From: twMat Date: Sat, 15 Jan 2022 13:57:51 +0100 Subject: [PATCH 01/35] typo in EventCatcherWidget.tid (#6399) --- editions/tw5.com/tiddlers/widgets/EventCatcherWidget.tid | 1 - 1 file changed, 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/widgets/EventCatcherWidget.tid b/editions/tw5.com/tiddlers/widgets/EventCatcherWidget.tid index 265e02a68..7f5e9a4d7 100644 --- a/editions/tw5.com/tiddlers/widgets/EventCatcherWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/EventCatcherWidget.tid @@ -25,7 +25,6 @@ Use of the event catcher widget is beneficial when using large numbers of other The content of the `<$eventcatcher>` widget is displayed normally. |!Attribute |!Description | - |selector |A CSS selector. Only events originating inside a DOM node with this selector will be trapped | |//{any attributes starting with $}// |<<.from-version "5.2.0">> Each attribute name (excluding the $) specifies the name of an event, and the value specifies the action string to be invoked. For example: `$click=<>` | |tag |Optional. The HTML element the widget creates to capture the events, defaults to:
» `span` when parsed in inline-mode
» `div` when parsed in block-mode | From 5548186c93ce2d7b655224dcf2e0bcda0d5f951c Mon Sep 17 00:00:00 2001 From: twMat Date: Mon, 17 Jan 2022 11:11:20 +0100 Subject: [PATCH 02/35] Update size attribute in EditTextWidget.tid (#6403) ref: https://github.com/Jermolene/TiddlyWiki5/issues/6165 --- editions/tw5.com/tiddlers/widgets/EditTextWidget.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid b/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid index 725294020..617f90c57 100644 --- a/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid @@ -28,7 +28,7 @@ The content of the `<$edit-text>` widget is ignored. |autocomplete |<<.from-version 5.1.23>> An optional string to provide a hint to the browser how to handle autocomplete for this input | |tag |Overrides the generated HTML editing element tag. For a multi-line editor use `tag=textarea`. For a single-line editor use `tag=input` | |type |Overrides the generated HTML editing element `type` attribute | -|size |The size of the input field (in characters) | +|size |The size of the input field (in characters). This exact result depends on browser and font. Use the `class` attribute to style width for precise control | |autoHeight |Either "yes" or "no" to specify whether to automatically resize `textarea` editors to fit their content (defaults to "yes") | |minHeight |Minimum height for automatically resized `textarea` editors, specified in CSS length units such as "px", "em" or "%" | |rows|Sets the rows attribute of a generated textarea | From c43b013539010f19e301eebb6e3e9b841a58c9f9 Mon Sep 17 00:00:00 2001 From: twMat Date: Tue, 18 Jan 2022 20:27:54 +0100 Subject: [PATCH 03/35] Paragraph on "anchor links" for Linking in WikiText.tid (#6404) --- .../tw5.com/tiddlers/wikitext/Linking in WikiText.tid | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/wikitext/Linking in WikiText.tid b/editions/tw5.com/tiddlers/wikitext/Linking in WikiText.tid index 52201129b..b64d0806a 100644 --- a/editions/tw5.com/tiddlers/wikitext/Linking in WikiText.tid +++ b/editions/tw5.com/tiddlers/wikitext/Linking in WikiText.tid @@ -116,4 +116,10 @@ In order to get the desired result, the LinkWidget can be used directly like thi <>>{{!!caption}}">> -See also another example of [[constructing dynamic links|Concatenating text and variables using macro substitution]]. \ No newline at end of file +See also another example of [[constructing dynamic links|Concatenating text and variables using macro substitution]]. + +! Linking within tiddlers - "anchor links" + +In TiddlyWiki anchor links can help us link to target points and distinct sections within rendered tiddlers. They can help the reader navigate longer tiddler content. + +See [[Anchor Links using HTML]] for more information. From b02a82ba0fd1bcce34c3f409c8974503ae76a29c Mon Sep 17 00:00:00 2001 From: twMat Date: Wed, 19 Jan 2022 12:13:08 +0100 Subject: [PATCH 04/35] Update list-links-draggabe Macro.tid (#6405) The commented problem is, I presume, resolved now that we can directly edit fields in the current tiddler. --- editions/tw5.com/tiddlers/macros/list-links-draggable Macro.tid | 2 -- 1 file changed, 2 deletions(-) diff --git a/editions/tw5.com/tiddlers/macros/list-links-draggable Macro.tid b/editions/tw5.com/tiddlers/macros/list-links-draggable Macro.tid index 5abf2b256..2c7a0510c 100644 --- a/editions/tw5.com/tiddlers/macros/list-links-draggable Macro.tid +++ b/editions/tw5.com/tiddlers/macros/list-links-draggable Macro.tid @@ -7,8 +7,6 @@ type: text/vnd.tiddlywiki The <<.def list-links-draggable>> [[macro|Macros]] renders the ListField of a tiddler as a list of links that can be reordered via [[drag and drop|Drag and Drop]]. -Note: The list must be contained in a different tiddler. I.e. If the list is populated in the list field of the current tiddler, the drag and drop action will have no effect. - !! Parameters ;tiddler From f0bd06b38dd02897be6b34e6dbe9fc8b3c49c138 Mon Sep 17 00:00:00 2001 From: btheado Date: Sun, 23 Jan 2022 04:44:01 -0500 Subject: [PATCH 05/35] Add doc related to WikiText parser modes (#6415) * Added macros for displaying wikitext examples in a table * Added documentation for WikiText parsing * Changed recognize to British spelling * Add links to the new wikitext parser tiddlers --- editions/tw5.com/tiddlers/concepts/Pragma.tid | 4 +- .../tiddlers/system/wikitext-macros.tid | 16 ++++- .../tiddlers/widgets/MacroCallWidget.tid | 4 +- .../tiddlers/widgets/TranscludeWidget.tid | 13 ++-- .../tw5.com/tiddlers/widgets/WikifyWidget.tid | 4 +- .../tiddlers/wikitext/HTML in WikiText.tid | 8 ++- .../wikitext/Macro Calls in WikiText.tid | 6 +- .../wikitext/Transclusion in WikiText.tid | 3 +- .../tiddlers/wikitext/Widgets in WikiText.tid | 6 +- .../parser/Block Mode WikiText (Examples).tid | 51 +++++++++++++ .../wikitext/parser/Block Mode WikiText.tid | 35 +++++++++ .../wikitext/parser/Inline Mode WikiText.tid | 26 +++++++ ...aces where the parser ignores WikiText.tid | 14 ++++ .../wikitext/parser/WikiText Parser Modes.tid | 13 ++++ .../WikiText parser mode transitions.tid | 59 +++++++++++++++ .../WikiText parser mode_ HTML examples.tid | 72 +++++++++++++++++++ .../WikiText parser mode_ macro examples.tid | 55 ++++++++++++++ ...ext parser mode_ transclusion examples.tid | 56 +++++++++++++++ .../wikitext/parser/table-example.tid | 8 +++ 19 files changed, 430 insertions(+), 23 deletions(-) create mode 100644 editions/tw5.com/tiddlers/wikitext/parser/Block Mode WikiText (Examples).tid create mode 100644 editions/tw5.com/tiddlers/wikitext/parser/Block Mode WikiText.tid create mode 100644 editions/tw5.com/tiddlers/wikitext/parser/Inline Mode WikiText.tid create mode 100644 editions/tw5.com/tiddlers/wikitext/parser/Places where the parser ignores WikiText.tid create mode 100644 editions/tw5.com/tiddlers/wikitext/parser/WikiText Parser Modes.tid create mode 100644 editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode transitions.tid create mode 100644 editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ HTML examples.tid create mode 100644 editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ macro examples.tid create mode 100644 editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ transclusion examples.tid create mode 100644 editions/tw5.com/tiddlers/wikitext/parser/table-example.tid diff --git a/editions/tw5.com/tiddlers/concepts/Pragma.tid b/editions/tw5.com/tiddlers/concepts/Pragma.tid index 3adc97954..05a29a2cc 100644 --- a/editions/tw5.com/tiddlers/concepts/Pragma.tid +++ b/editions/tw5.com/tiddlers/concepts/Pragma.tid @@ -1,6 +1,6 @@ created: 20150219175930000 -modified: 20180928145730028 -tags: Concepts +modified: 20220122182842041 +tags: Concepts [[WikiText Parser Modes]] title: Pragma type: text/vnd.tiddlywiki diff --git a/editions/tw5.com/tiddlers/system/wikitext-macros.tid b/editions/tw5.com/tiddlers/system/wikitext-macros.tid index 5b9c190be..908b8f473 100644 --- a/editions/tw5.com/tiddlers/system/wikitext-macros.tid +++ b/editions/tw5.com/tiddlers/system/wikitext-macros.tid @@ -1,7 +1,8 @@ created: 20150117184156000 -modified: 20150117184616000 -title: $:/editions/tw5.com/wikitext-macros +modified: 20220122143551571 tags: $:/tags/Macro +title: $:/editions/tw5.com/wikitext-macros +type: text/vnd.tiddlywiki \define wikitext-example(src)
@@ -43,6 +44,17 @@ $$$
\end +\define wikitext-example-table-header() wiki textrenders as + +\define wikitext-example-table-row(id, code) + +<<__id__>><$codeblock code=<<__code__>>/> + +<<__code__>> + + +\end + \define tw-code(tiddler) <$codeblock language={{$tiddler$!!type}} code={{$tiddler$}}/> \end diff --git a/editions/tw5.com/tiddlers/widgets/MacroCallWidget.tid b/editions/tw5.com/tiddlers/widgets/MacroCallWidget.tid index e85562aab..e163c1d41 100644 --- a/editions/tw5.com/tiddlers/widgets/MacroCallWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/MacroCallWidget.tid @@ -1,6 +1,6 @@ caption: macrocall created: 20131024141900000 -modified: 20200928102843275 +modified: 20220122193731433 tags: Widgets title: MacroCallWidget type: text/vnd.tiddlywiki @@ -38,6 +38,8 @@ You can see several examples of the macro call widget within the core: * Listing field information: [[$:/snippets/allfields]] * Generating `data:` URIs: [[$:/themes/tiddlywiki/starlight/styles.tid]] +See also [[WikiText parser mode: macro examples]] + ! Content and Attributes The content of the `<$macrocall>` widget is ignored. diff --git a/editions/tw5.com/tiddlers/widgets/TranscludeWidget.tid b/editions/tw5.com/tiddlers/widgets/TranscludeWidget.tid index 0501d7091..ae57fc2f2 100644 --- a/editions/tw5.com/tiddlers/widgets/TranscludeWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/TranscludeWidget.tid @@ -1,9 +1,9 @@ +caption: transclude created: 20130824142500000 -modified: 20140717175900970 +modified: 20220122190609396 tags: Widgets title: TranscludeWidget type: text/vnd.tiddlywiki -caption: transclude ! Introduction @@ -22,12 +22,12 @@ The TranscludeWidget treats any contained content as a fallback if the target of ! Parsing modes -TiddlyWiki parses text in two modes: +TiddlyWiki [[parses text in two modes|WikiText Parser Modes]]: -* ''inline'' mode recognises character formatting such as emphasis, links -* ''block'' mode recognises all the ''inline'' formatting, and adds block formatting such as tables, headings and lists +* [[inline mode|Inline Mode WikiText]] recognises character formatting such as emphasis, links +* [[block mode|Block Mode WikiText]] recognises all the ''inline'' formatting, and adds block formatting such as tables, headings and lists -Usually, the mode is determined by whether the transclude widget itself has been parsed in block or inline mode. This can be overridden with the `mode` attribute. +Usually, the mode is determined by whether the transclude widget itself has been parsed in block or inline mode. This can be overridden with the <<.attr mode>> attribute. For example, consider tiddler "A" with this content: @@ -57,6 +57,7 @@ This can be fixed by amending tiddler "A": #<$transclude tiddler="B" mode="block"/> # Item two ``` +See also these [[other examples|WikiText parser mode: transclusion examples]]. ! ~SubTiddler Access diff --git a/editions/tw5.com/tiddlers/widgets/WikifyWidget.tid b/editions/tw5.com/tiddlers/widgets/WikifyWidget.tid index b058587fa..87b76a99d 100644 --- a/editions/tw5.com/tiddlers/widgets/WikifyWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/WikifyWidget.tid @@ -1,6 +1,6 @@ caption: wikify created: 20160321144949700 -modified: 20161017122117062 +modified: 20220122191540121 tags: Widgets title: WikifyWidget type: text/vnd.tiddlywiki @@ -17,7 +17,7 @@ The content of the `<$wikify>` widget is the scope for the value assigned to the |name |The name of the variable to assign | |text |The text to parse and render | |type |The ContentType of the text (defaults to `text/vnd.tiddlywiki`) | -|mode |The parse mode: `block` (the default) or `inline` | +|mode |The parse mode: [[block|Block Mode WikiText]] (the default) or [[inline|Inline Mode WikiText]] | |output |Keyword indicating the desired output type, defaulting to `text` (see below) | The available output types are: diff --git a/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid b/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid index ec19e8a84..8244367db 100644 --- a/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid +++ b/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid @@ -1,6 +1,6 @@ caption: HTML created: 20131205160816081 -modified: 20210614100305329 +modified: 20220122192311669 tags: WikiText title: HTML in WikiText type: text/vnd.tiddlywiki @@ -35,9 +35,11 @@ some text ! Block mode versus Inline mode -To get the content of an HTML element to be parsed in block mode, the opening tag must be followed by two linebreaks. +To get the content of an HTML element to be [[parsed|WikiText Parser Modes]] in [[block mode|Block Mode WikiText]], the opening tag must be followed by two linebreaks. -Without the two linebreaks, the tag content will be parsed in inline mode which means that block mode formatting such as wikitext tables, lists and headings is not recognised. +Without the two linebreaks, the tag content will be [[parsed|WikiText Parser Modes]] in [[inline mode|Inline Mode WikiText]] which means that block mode formatting such as wikitext tables, lists and headings is not recognised. + +See also [[WikiText parser mode: HTML examples]] and [[WikiText parser mode transitions]]. ! Self closing elements diff --git a/editions/tw5.com/tiddlers/wikitext/Macro Calls in WikiText.tid b/editions/tw5.com/tiddlers/wikitext/Macro Calls in WikiText.tid index f4899fbd6..b79d98134 100644 --- a/editions/tw5.com/tiddlers/wikitext/Macro Calls in WikiText.tid +++ b/editions/tw5.com/tiddlers/wikitext/Macro Calls in WikiText.tid @@ -1,9 +1,9 @@ +caption: Macro Calls created: 20150220182252000 -modified: 20150221221340000 +modified: 20220122193853161 tags: WikiText title: Macro Calls in WikiText type: text/vnd.tiddlywiki -caption: Macro Calls To call a [[macro|Macros]], place `<<`double angle brackets`>>` around the name and any parameter values. @@ -19,7 +19,7 @@ The syntax is actually a shorthand for a <<.wlink MacroCallWidget>> widget. The As macros are simply parameterised [[variables|Variables]], a variable's value can be inserted using the same techniques. -[[Examples|Macro Calls in WikiText (Examples)]] +[[Examples|Macro Calls in WikiText (Examples)]] and [[more examples|WikiText parser mode: macro examples]] !! Named vs.unnamed parameters diff --git a/editions/tw5.com/tiddlers/wikitext/Transclusion in WikiText.tid b/editions/tw5.com/tiddlers/wikitext/Transclusion in WikiText.tid index 5e15dd6a7..f7de5d83d 100644 --- a/editions/tw5.com/tiddlers/wikitext/Transclusion in WikiText.tid +++ b/editions/tw5.com/tiddlers/wikitext/Transclusion in WikiText.tid @@ -1,6 +1,6 @@ caption: Transclusion created: 20131205160146648 -modified: 20150220161347000 +modified: 20220122193352028 tags: WikiText title: Transclusion in WikiText type: text/vnd.tiddlywiki @@ -48,3 +48,4 @@ See also: * TemplateTiddlers * TranscludeWidget * [[Transclusion and Substitution]] +* [[WikiText parser mode: transclusion examples]] diff --git a/editions/tw5.com/tiddlers/wikitext/Widgets in WikiText.tid b/editions/tw5.com/tiddlers/wikitext/Widgets in WikiText.tid index 5ef9253c9..ee0841af6 100644 --- a/editions/tw5.com/tiddlers/wikitext/Widgets in WikiText.tid +++ b/editions/tw5.com/tiddlers/wikitext/Widgets in WikiText.tid @@ -1,6 +1,6 @@ caption: Widgets created: 20131205160840915 -modified: 20161020210726813 +modified: 20220122193129241 tags: WikiText title: Widgets in WikiText type: text/vnd.tiddlywiki @@ -20,8 +20,8 @@ Note that widgets inherit all the features of [[HTML in WikiText]]: ** Macro invocations (eg `attr=<>`) ** Transclusions (eg, `attr={{MyTiddler!!field}}`) ** Filtered transclusions (eg, `attr={{{ [filter[op]] }}}`) -* The content of a widget is parsed in inline mode unless the opening tag is followed by two linebreaks, which forces block mode -** 'Inline mode' means that 'block mode' parse rules like headings, tables and lists are not recognised +* The content of a widget is [[parsed|WikiText Parser Modes]] in [[inline mode|Inline Mode WikiText]] unless the opening tag is followed by two linebreaks, which forces [[block mode|Block Mode WikiText]] +** [[inline mode|Inline Mode WikiText]] means that [[block mode|Block Mode WikiText]] parse rules like headings, tables and lists are not recognised See [[HTML in WikiText]] for more details. diff --git a/editions/tw5.com/tiddlers/wikitext/parser/Block Mode WikiText (Examples).tid b/editions/tw5.com/tiddlers/wikitext/parser/Block Mode WikiText (Examples).tid new file mode 100644 index 000000000..b9fe9fd81 --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/parser/Block Mode WikiText (Examples).tid @@ -0,0 +1,51 @@ +created: 20220115152811251 +modified: 20220115161035903 +tags: [[Block Mode WikiText]] +title: Block Mode WikiText (Examples) +type: text/vnd.tiddlywiki + +[[Paragraphs|Paragraphs in WikiText]] are the most common WikiText. It is important to know they do not end until a blank line is encountered. Once a paragraph starts the parser will be in ''inline mode''. Until that blank line is encountered other ''block mode'' syntax will be ignored: + +<<< +<ignored until +the paragraph ends (i.e. a blank line is encountered). +For example: +* List item punctuation is ignored +* So is this horizontal rule: +--- +|tables|are|ignored| +! headings are ignored +<<< +multi-line block quotes are ignored +<<< +'>> +<<< + +To get the parser to recognise the above ''block mode'' WikiText, a blank line needs to be inserted after the "For example:" line. The blank line will be treated as the end of the paragraph and the parser will start recognising ''block mode'' punctuation again. Like this: + +<<< +<ignored until +the paragraph ends (i.e. a blank line is encountered). +For example, here is a blank line: + +* due to above blank line, +* list items work +* the following horizontal rule also works: +--- +|!tables|!work| +|cell 1| cell 2| +! Headings work +<<< +multi-line block quotes work +<<< +; Term +: Definition of that term +Another paragraph can start here, but it will not end until blank line +'>> +<<< + +All the block mode examples above except for the paragraph are written one line after the other without blanks between. Those types of WikiText don't require the extra blank line to terminate. \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/wikitext/parser/Block Mode WikiText.tid b/editions/tw5.com/tiddlers/wikitext/parser/Block Mode WikiText.tid new file mode 100644 index 000000000..9501f672c --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/parser/Block Mode WikiText.tid @@ -0,0 +1,35 @@ +caption: block parser mode +created: 20220110234234616 +modified: 20220122182842032 +tags: [[WikiText Parser Modes]] +title: Block Mode WikiText +type: text/vnd.tiddlywiki + +Some WikiText is recognised only while the parser is in block mode. + +Common characteristics of such block mode WikiText: + +* At least one entire line is required to delimit the WikiText. +* The closing punctuation must come at the end of the line (in some cases the end of the line //is// the closing punctuation. + +|!~WikiText|!Punctuation| +|[[Block Quotes in WikiText]] |Multi-line block quotes are enclosed by lines containing only the text `<<<`; single line block quotes are also possible.| +|[[Code Blocks in WikiText]]|Enclosed by lines containing only the text ```| +|[[Definitions in WikiText]]|Each term is on its own line and each definition is on its own line.| +|[[Hard Linebreaks in WikiText]]|Enclosed by lines containing only the text `"""`.| +|[[Headings in WikiText]]|Entire line starting with `!`.| +|[[Horizontal Rules in WikiText]]|A line containing only the text `---`.| +|[[Lists in WikiText]]|Each list item is on its own line.| +|[[Paragraphs in WikiText]]|Any text other than the start punctuation of one of the other block mode WikiText will start a paragraph. Even the start punctuation of inline mode WikiText will start a paragraph. The parser includes all following lines into the paragraph until it encounters a blank line.| +|[[Styles and Classes in WikiText]]|Enclosed by lines starting with `@@`.| +|[[Tables in WikiText]]|Each table row is a line starting and ending with `|`.| +|[[Typed Blocks in WikiText]]|Enclosed by lines starting with `$$`.| + +The above WikiText types are only recognised in ''block mode''. However, the text <<.em enclosed>> by most of them will be parsed in ''inline mode'' ([[Block Quotes in WikiText]] and [[Styles and Classes in WikiText]] are the two exceptions in which the parser will continue in ''block mode''). While in ''inline mode'' the parser may encounter something which moves it to ''block mode'' (see [[WikiText parser mode transitions]]). + +At the end of the terminating line, the parser will return to ''block mode''. +<<.tip 'Note: [[Hard Linebreaks in WikiText]] require an extra blank line after the trailing `"""` before the parser will return to block mode'>>. + +If the punctuation for the above types of WikiText is encountered while the parser is in ''inline mode'', it will be //ignored// and output as-is. + +[[Examples|Block Mode WikiText (Examples)]] \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/wikitext/parser/Inline Mode WikiText.tid b/editions/tw5.com/tiddlers/wikitext/parser/Inline Mode WikiText.tid new file mode 100644 index 000000000..88afd8372 --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/parser/Inline Mode WikiText.tid @@ -0,0 +1,26 @@ +caption: inline parser mode +created: 20220111000108618 +modified: 20220122182842036 +tags: [[WikiText Parser Modes]] +title: Inline Mode WikiText +type: text/vnd.tiddlywiki + +Some WikiText is recognised only while the parser is in inline mode. + +These WikiText types can be expressed without an entire line of text. They aren't required to be all on one line, just that they <<.em can>> be expressed within a single line. And as such, more than one can appear within a single line. In other words, line endings are not involved while the parser tries to find where the particular WikiText begins and ends While the parser is in inline mode, it will recognise the punctuation for these WikiText types: + +* [[Dashes in WikiText]] +* [[Formatting in WikiText]] +* [[HTML in WikiText]] +* [[Images in WikiText]] +* [[Linking in WikiText]] +* [[Macro Calls in WikiText]] +* [[Styles and Classes in WikiText]] (single line version only) +* [[Transclusion in WikiText]] +* [[Variables in WikiText]] +* [[Widgets in WikiText]] + +<<.tip """[[Macro Calls in WikiText]] and [[Transclusion in WikiText]] will be recognised in block mode if the macro call or transclusion spans an entire line.""">> +<<.tip """The other ''inline mode'' WikiText types are technically <<.em only>> detected while the parser is in ''inline mode''. However, the opening punctuation will also trigger the start of [[Paragraphs in WikiText]] which will automatically cause the parser to go into ''inline mode''. Therefore, practically speaking, it is just as useful to consider these WikiText types as recognised while the parser is in either ''inline mode'' or ''block mode''""">> + +While processing the //enclosed// text of some of these WikiText types, the parser [[will not look for new WikiText|Places where the parser ignores WikiText]]. But for rest of these WikiText types, the parser will continue in ''inline mode'' for the //enclosed// text. While parsing that text, it might encounter something which [[moves it to block mode|WikiText parser mode transitions]]. \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/wikitext/parser/Places where the parser ignores WikiText.tid b/editions/tw5.com/tiddlers/wikitext/parser/Places where the parser ignores WikiText.tid new file mode 100644 index 000000000..afb9db192 --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/parser/Places where the parser ignores WikiText.tid @@ -0,0 +1,14 @@ +caption: ignore parser mode +created: 20220111000929700 +modified: 20220122182842038 +tags: [[WikiText Parser Modes]] +title: Places where the parser ignores WikiText +type: text/vnd.tiddlywiki + +Text enclosed by these constructs is skipped by the parser and WikiText punctuation will be ignored: + +|[[Code Blocks in WikiText]]|One of the main purposes of code blocks is to suppress wikitext expansion. Once the code block starts, the parser will ignore all WikiText punctuation until the code block ends.| +|[[Images in WikiText]]|`[[img|literal image link text]]` - the text enclosed by square braces will be ignored. This means, for example, [[transclusions|Transclusion in WikiText]] and [[macro calls|Macro Calls in WikiText]] cannot be used to dynamically construct the link text| +|[[Linking in WikiText]]|`[[literal link target|literal link text]]` - the text enclosed by square braces will be ignored. This means, for example, [[transclusions|Transclusion in WikiText]] and [[macro calls|Macro Calls in WikiText]] cannot be used to dynamically construct the link target or the link text| +|[[Macro Calls in WikiText]]|`<>" {{transclusion_ignored}}>>` - while processing the text enclosed by a macro call, the parser will follow special rules for detecting macro parameters. These rules do not include detection of WikiText. However, after the parameters are substituted into the macro definition, the result will be parsed using [[normal rules|Wiki Text Parser Modes]]. This will likely result in the detection of any WikiText.| + diff --git a/editions/tw5.com/tiddlers/wikitext/parser/WikiText Parser Modes.tid b/editions/tw5.com/tiddlers/wikitext/parser/WikiText Parser Modes.tid new file mode 100644 index 000000000..df97ebf35 --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/parser/WikiText Parser Modes.tid @@ -0,0 +1,13 @@ +created: 20220110233944530 +modified: 20220122182842030 +tags: WikiText +title: WikiText Parser Modes +type: text/vnd.tiddlywiki + +The WikiText parser has three modes: + +* ''pragma mode'' - the parser will recognise only [[pragma mode WikiText|Pragma]] punctuation +* ''block mode'' - the parser will recognise only [[block mode WikiText|Block Mode WikiText]] punctuation +* ''inline mode'' - the parser will recognise only [[inline mode WikiText|Inline Mode WikiText]] + +The parser [[transitions between these modes|WikiText parser mode transitions]] based on the text it encounters. In addition, there are [[places where the parser ignores WikiText|Places where the parser ignores WikiText]] punctuation. \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode transitions.tid b/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode transitions.tid new file mode 100644 index 000000000..009c3d3f3 --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode transitions.tid @@ -0,0 +1,59 @@ +created: 20220110235808139 +modified: 20220122184232928 +tags: [[WikiText Parser Modes]] +title: WikiText parser mode transitions +type: text/vnd.tiddlywiki + +This is a <<.em rough>> diagram whose lines mostly correspond to the parser mode transitions described below: +<$railroad text=""" +{<"pragma mode"> +{( + {<"inline mode"> +} | + ({<"block mode"> + +("<<<" | "@@" | "$$") + } + "other block mode start punct") + {<"inline mode"> +} + ) + +( + "block mode close punctuation" | + ("blank line" "html open tag") + )} + +("transclude widget" | "macrocall") +} +"""/> + +!! Start mode + +By default the parser starts in [[block mode|Block Mode WikiText]]. However, a tiddler can instead be transcluded with [[inline mode|Inline Mode WikiText]] in which case [[block mode WikiText|Block Mode WikiText]] will not be recognised. + +At the start of text only, the parser will also recognise any [[pragma mode WikiText|Pragma]]. + +!! Transitions from pragma mode + +At the start of text, the parser will recognise any [[pragma|Pragma]]. If none are found then it will move to [[inline|Inline Mode WikiText]] or [[block|Block Mode WikiText]] mode depending on the transclusion mode. If any [[pragma|Pragma]] are found then it will continue looking for [[pragma|Pragma]] until it finds one or more blank lines not followed by the start of a new pragma. + +!! Transitions from block mode + +When the parser encounters most [[block mode|Block Mode WikiText]] start punctuation it transitions to [[inline mode|Inline Mode WikiText]]. This means +he text enclosed by most [[block mode|Block Mode WikiText]] constructs will be parsed using [[inline mode|Inline Mode WikiText]]. + +<<.tip """The start "punctuation" for a paragraph is "invisible". Even for paragraphs the parser moves to [[inline mode|Inline Mode WikiText]]""">> + +However, there are a few constructs whose enclosed text is parsed using [[block mode|Block Mode WikiText]]: + +* [[Multi-line block quotes|Block Quotes in WikiText]] +* [[Multi-line style blocks|Styles and Classes in WikiText]] +* [[Typed blocks|Typed Blocks in WikiText]] + +When the start punctuation for these are encountered, the enclosed text will continue to be parsed in [[block mode|Block Mode WikiText]]. + +[[Horizontal rules|Horizontal Rules in WikiText]] are another special case. They do not enclose any text, so there is no opportunity for the parser to transition to [[inline mode|Inline Mode WikiText]]. + +Opening [[widget|Widgets in WikiText]] or [[HTML|HTML in WikiText]] tags provide another way the parser can transition. When such a tag is <<.em not>> followed by a blank line, then the contents enclosed by the tag will be parsed in [[inline mode|Inline Mode WikiText]]. See the [[HTML examples|WikiText parser mode: HTML examples]]. + +!! Transitions from inline mode + +* The parser will move back to [[block mode|Block Mode WikiText]] after the end of a line which terminates [[block mode|Block Mode WikiText]] ~WikiText. In other words, when the block mode close punctuation is encountered. +* When the opening [[widget|Widgets in WikiText]] or [[HTML|HTML in WikiText]] tag is followed by a blank line, then the contents enclosed by the tag will be parsed in [[block mode|Block Mode WikiText]]. See the [[HTML examples|WikiText parser mode: HTML examples]]. +* Transcluded text and text pulled in via a macro call can transition the parser away from [[inline mode|Inline Mode WikiText]]. See [[transclusion examples|WikiText parser mode: transclusion examples]] and [[macro examples|WikiText parser mode: macro examples]] for more details. \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ HTML examples.tid b/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ HTML examples.tid new file mode 100644 index 000000000..fc068e44e --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ HTML examples.tid @@ -0,0 +1,72 @@ +created: 20220122153235162 +modified: 20220122180508134 +tags: [[WikiText parser mode transitions]] +title: WikiText parser mode: HTML examples +type: text/vnd.tiddlywiki + +< + +* blank line after open tag allows +* block mode punctuation (i.e. this list) to +* be recognised + +">> + +--- + +The open tag blank line "trick" also works inside of punctuation only recognised in inline mode (such as [[Formatting in WikiText]]): + +< + +* list item one +* list item two +''">> + +--- + +< +* Open tag without a blank line means +* block mode punctuation (i.e. this list) will +* NOT be recognised. + +Paragraphs are only recognised in block mode. Even with blank lines, new paragraphs are not recognised. + +This also is not a new paragraph. +">> + +--- + +[[Tables in WikiText]] is one construct for which the open tag blank line "trick" cannot work. In order for the parser to recognise a table row, the entire row must be on a single line. + +Adding a blank link after an open tag within a table cell causes the row to span mulitple lines and the parser ceases to be able to recognise it as a table row. + +<> + +< + +* list is recognised +* but the surrounding table row is not +|">> + +--- + +The only way to get [[block mode|Block Mode WikiText]] punctuation recognised in [[wikitext tables|Tables in WikiText]] is to use <<.wlink TranscludeWidget>> with <<.attr mode>> = <<.value block>>. + +<|'>> + +Note that <<.wlink MacroCallWidget>> does not have a similar <<.attr mode>> attribute and the content of macro definitions can only be parsed in [[inline mode|Inline Mode WikiText]] + +--- + +The less convenient ``, ``, ` +
` html tags can be used as a foolproof way to get [[block mode|Block Mode WikiText]] punctuation recognised inside of table cells. + +< +
+ +* list item one +* list item two + + +|nested|table| +
">> \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ macro examples.tid b/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ macro examples.tid new file mode 100644 index 000000000..07a08db46 --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ macro examples.tid @@ -0,0 +1,55 @@ +created: 20220122144742419 +modified: 20220122180929683 +tags: [[WikiText parser mode transitions]] +title: WikiText parser mode: macro examples +type: text/vnd.tiddlywiki + +\define boringtable() +|cell one|cell two| +|cell three|cell four| +\end +With the macro `boringtable` defined as: +<$codeblock code=<>/> +then +<> +<>">> +< + +<> + +""">> +<">> +<">> +< + +""">> +
+ +The list syntax is recognised in [[block mode|Block Mode WikiText]] and the enclosed contents are parsed using [[inline mode|Inline Mode WikiText]]. When the parser encounters a [[wikitext macro call|Macro Calls in WikiText]] it will use the current parse mode to parse the contents of the macro. The contents of the macro contains table syntax which is only recognised in [[block mode|Block Mode WikiText]]. + +Therefore, in #1 above the table syntax is not recognised. In #2 above, the blank line after the open `div` tag moves the parser back into [[block mode|Block Mode WikiText]], the macro call inherits it and the table is recognised. + +When calling macros using the [[widget|MacroCallWidget]], the parse mode will be inline (#3 and #4 above) unless it is written as an open tag with a following blank line (#5 above). + +<<.tip "See also [[WikiText parser mode: transclusion examples]] for similar examples">> + +--- + +These examples have slightly different behavior. In the previous section, the macro calls were enclosed within list items. In these examples, the macro calls are at the top level: +<> +<>">> +< + +<> + +""">> +<">> +<">> +< + +""">> +
+ +Of these examples, only the two <<.wlink MacroCallWidget>> tags which are not followed by a blank line are parsed using [[inline mode|Inline Mode WikiText]]. + +<<.tip "See also [[WikiText parser mode: transclusion examples]] for similar examples">> \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ transclusion examples.tid b/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ transclusion examples.tid new file mode 100644 index 000000000..3030377b2 --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/parser/WikiText parser mode_ transclusion examples.tid @@ -0,0 +1,56 @@ +created: 20220122145022547 +modified: 20220122180845946 +tags: [[WikiText parser mode transitions]] +title: WikiText parser mode: transclusion examples +type: text/vnd.tiddlywiki + + +Given the tiddler [[table-example]] defined with these contents: +<$codeblock code={{table-example}}/> +then +<> +<> +< + +{{table-example}} + +""">> +<">> +<">> +< + +""">> +<">> +
+ +The list syntax is recognised in [[block mode|Block Mode WikiText]] and the enclosed contents are parsed using [[inline mode|Inline Mode WikiText]]. When the parser encounters a [[wikitext transclusion|Transclusion in WikiText]] it will use the current parse mode to parse the contents of the transcluded tiddler. The contents of the example tiddler contains table syntax which is only recognised in [[block mode|Block Mode WikiText]]. + +Therefore, in #1 above the table syntax is not recognised. In #2 above, the blank line after the open `div` tag moves the parser back into [[block mode|Block Mode WikiText]], the transcluded text inherits it and the table is recognised. + +When transcluding tiddlers using the [[widget|TranscludeWidget]], the parse mode will be inline (#3 and #4 above) unless it is written as an open tag with a following blank line (#5 above). + +<<.tip "See also [[WikiText parser mode: macro examples]] for similar examples. The only difference here is <<.wlink TranscludeWidget>> has a <<.attr mode>> attribute (extra example #6) which allows the parse mode to be explicitly overridden rather than come implicitly based on the they way the tag is written">> + +--- + +In these examples, the transclusions are at the top level instead of enclosed in list items: + +<> +<> +< + +{{table-example}} + +""">> +<">> +<">> +< + +""">> +<">> +
+ + +Of these examples, only the two <<.wlink TranscludeWidget>> tags which are not followed by a blank line and the widget call using <<.attr mode>>=<<.value inline>> are parsed using [[inline mode|Inline Mode WikiText]]. + +<<.tip "See also [[WikiText parser mode: macro examples]] for similar examples">> \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/wikitext/parser/table-example.tid b/editions/tw5.com/tiddlers/wikitext/parser/table-example.tid new file mode 100644 index 000000000..4611d79b6 --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/parser/table-example.tid @@ -0,0 +1,8 @@ +created: 20220118023452157 +modified: 20220118023529825 +tags: [[WikiText parser mode transitions (Examples)]] +title: table-example +type: text/vnd.tiddlywiki + +|cell one|cell two| +|cell three|cell four| \ No newline at end of file From d6384df6fc80147982f33907aef94a37d9d52b19 Mon Sep 17 00:00:00 2001 From: btheado Date: Sun, 23 Jan 2022 13:24:25 -0500 Subject: [PATCH 06/35] Add warnings about non-recursive nature of dynamic attribute values (#6417) --- editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid b/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid index 8244367db..d510c3d08 100644 --- a/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid +++ b/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid @@ -1,6 +1,6 @@ caption: HTML created: 20131205160816081 -modified: 20220122192311669 +modified: 20220123174919252 tags: WikiText title: HTML in WikiText type: text/vnd.tiddlywiki @@ -94,6 +94,7 @@ attr={{tiddler}} attr={{!!field}} attr={{tiddler!!field}} ``` +<<.warning "The attribute's value will be the exact text retrieved from the TextReference. Any wiki syntax in that text will be left as-is.">> !! Variable Attribute Values @@ -104,6 +105,7 @@ Variable attribute values are indicated with double angle brackets around a [[ma ... ``` +<<.warning "The text from the macro's definition will be retrieved and text substitution will be performed (i.e. <<.param $param$>> and <<.param $(...)$>> syntax). The attribute's value will be the resulting text. Any wiki syntax in that text (including further macro calls and variable references) will be left as-is.">> !! Filtered Attribute Values @@ -114,4 +116,4 @@ This example shows how to add a prefix to a value: ``` <$text text={{{ [addprefix[$:/myprefix/]] }}} /> ``` - +<<.warning "The attribute's value will be the exact text from the first item in the resulting list. Any wiki syntax in that text will be left as-is.">> From 4cdfa4e3f9d8b2ce5580624192840b0627fece28 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Sun, 23 Jan 2022 18:35:38 +0000 Subject: [PATCH 07/35] Update tm-download-file docs to mention the filename parameter --- .../tiddlers/messages/WidgetMessage_ tm-download-file.tid | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-download-file.tid b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-download-file.tid index 5e5229213..128966501 100644 --- a/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-download-file.tid +++ b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-download-file.tid @@ -1,5 +1,5 @@ created: 20140811112201235 -modified: 20141110133723696 +modified: 20220123141646321 tags: Messages title: WidgetMessage: tm-download-file type: text/vnd.tiddlywiki @@ -11,6 +11,11 @@ The download file message causes the current saver module to prompt the user to |param |Title of a tiddler to use as a template for the new tiddler | |paramObject |Optional hashmap of variable values to use for the rendering | +The following variable names have special behaviour: + +|!Name |!Description | +|filename |Filename for the downloaded file (note that this is a hint to the browser, and the actual filename used may be different) | + The download file message is usually generated with the ButtonWidget. The download file message is handled by the TiddlyWiki core SyncMechanism which invokes the current [[SaverModule|SaverModules]]. From da7cf7a4f3aa974fe5c0e6d50590051192fdfb5a Mon Sep 17 00:00:00 2001 From: Marxsal Date: Tue, 25 Jan 2022 09:59:59 -0800 Subject: [PATCH 08/35] QualifyWidget documentation (#6422) --- ...om_widget-examples_qualify-transcluded.tid | 14 +++++++ .../tiddlers/widgets/QualifyWidget.tid | 39 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 editions/tw5.com/tiddlers/widgets/$__editions_tw5.com_widget-examples_qualify-transcluded.tid create mode 100644 editions/tw5.com/tiddlers/widgets/QualifyWidget.tid diff --git a/editions/tw5.com/tiddlers/widgets/$__editions_tw5.com_widget-examples_qualify-transcluded.tid b/editions/tw5.com/tiddlers/widgets/$__editions_tw5.com_widget-examples_qualify-transcluded.tid new file mode 100644 index 000000000..3211c9f5d --- /dev/null +++ b/editions/tw5.com/tiddlers/widgets/$__editions_tw5.com_widget-examples_qualify-transcluded.tid @@ -0,0 +1,14 @@ +created: 20220125161941555 +modified: 20220125162920771 +tags: [[Widget Examples]] +title: $:/editions/tw5.com/widget-examples/qualify-transcluded +type: text/vnd.tiddlywiki + +<$macrocall $name=".example" n="1" +eg="""<$qualify title="BaseTiddler" name="iamnotanumber"> +
    +
  • <>
  • +
  • <>
  • +
+ +"""/> \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/widgets/QualifyWidget.tid b/editions/tw5.com/tiddlers/widgets/QualifyWidget.tid new file mode 100644 index 000000000..47b82fe89 --- /dev/null +++ b/editions/tw5.com/tiddlers/widgets/QualifyWidget.tid @@ -0,0 +1,39 @@ +caption: vars +created: 20220125160004463 +modified: 20220125163041347 +tags: Widgets +title: QualifyWidget + +! Introduction + +The <<.wid qualify>> widget sets a variable +to a unique string that encodes its position within the widget tree, as identified by the stack of transcluded tiddlers that lead to that position. + +Internally, it is implemented using the transclusion variable. + +! Content and Attributes + +The content of the <<.wid qualify>> widget is the scope for the value assigned to the <<.var name>> variable. + +|!Attribute |!Description | +|//title// |The prefix for the string, normally a tiddler title | +|//name// |The name of the variable to be set to the unique string | + +! Examples + +The two examples below are identical, but produce different results because the second one has been transcluded from [[another tiddler|$:/editions/tw5.com/widget-examples/qualify-transcluded]]. + +Each example shows the result of calling <<.var qualify>> and then the value of the <<.vlink transclusion>> variable. +<$macrocall $name=".example" n="1" +eg="""<$qualify title="BaseTiddler" name="iamnotanumber"> +
    +
  • <>
  • +
  • <>
  • +
+ +"""/> +{{$:/editions/tw5.com/widget-examples/qualify-transcluded}} + +! Remarks + +In most cases it will be simpler to use the [[qualify Macro]]. \ No newline at end of file From 75d10a2dc3f240755c43d17f225d39f482b8f1b4 Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Thu, 27 Jan 2022 18:35:18 +0100 Subject: [PATCH 09/35] Fix: bug with importvariables widget when importing block mode widgets. fixes #6424 (#6426) --- core/modules/widgets/importvariables.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/modules/widgets/importvariables.js b/core/modules/widgets/importvariables.js index faa2448de..0cda68138 100644 --- a/core/modules/widgets/importvariables.js +++ b/core/modules/widgets/importvariables.js @@ -46,7 +46,7 @@ ImportVariablesWidget.prototype.execute = function(tiddlerList) { this.tiddlerList = tiddlerList || this.wiki.filterTiddlers(this.filter,this); // Accumulate the <$set> widgets from each tiddler $tw.utils.each(this.tiddlerList,function(title) { - var parser = widgetPointer.wiki.parseTiddler(title); + var parser = widgetPointer.wiki.parseTiddler(title,{parseAsInline:true}); if(parser) { var parseTreeNode = parser.tree[0]; while(parseTreeNode && parseTreeNode.type === "set") { From f4365e4bb411d005b560408a79809536dc435ed4 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Fri, 28 Jan 2022 11:24:06 +0000 Subject: [PATCH 10/35] Macro: remove confusing advice See https://talk.tiddlywiki.org/t/wikitext-parsing-and-rendering-in-macros/2218 --- editions/tw5.com/tiddlers/concepts/Macros.tid | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/editions/tw5.com/tiddlers/concepts/Macros.tid b/editions/tw5.com/tiddlers/concepts/Macros.tid index 239045d56..afd388090 100644 --- a/editions/tw5.com/tiddlers/concepts/Macros.tid +++ b/editions/tw5.com/tiddlers/concepts/Macros.tid @@ -1,5 +1,5 @@ created: 20140211171341271 -modified: 20200103092706002 +modified: 20220128112317724 tags: Concepts Reference title: Macros type: text/vnd.tiddlywiki @@ -14,8 +14,6 @@ They are created using the `\define` [[pragma|Pragma]]. (Behind the scenes, this The snippet and its incoming parameter values are treated as simple strings of characters with no WikiText meaning, at least until the placeholders have been filled in and the macro call has returned. This means that a macro can assemble and return the complete syntax of a ~WikiText component, such as a [[link|Linking in WikiText]]. (See [[Transclusion and Substitution]] for further discussion of this.) -The string returned by a macro call is parsed separately from any surrounding ~WikiText components. So a safe way to insert a special character sequence (such as `[[` or `<`) without triggering its normal ~WikiText meaning is to wrap it in a macro. - Within a snippet itself, the only markup detected is `$name$` (a placeholder for a macro parameter) and `$(name)$` (a placeholder for a [[variable|Variables]]). The <<.mlink dumpvariables>> macro lists all variables (including macros) that are available at that position in the widget tree. From 1a0c831216c397c6fef8e5685e47857193411a1b Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Sat, 29 Jan 2022 11:02:47 +0000 Subject: [PATCH 11/35] Add sha256 operator --- core/modules/filters/crypto.js | 27 +++++++++++++++++++ .../tiddlers/filters/sha256 Operator.tid | 18 +++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 core/modules/filters/crypto.js create mode 100644 editions/tw5.com/tiddlers/filters/sha256 Operator.tid diff --git a/core/modules/filters/crypto.js b/core/modules/filters/crypto.js new file mode 100644 index 000000000..24f1a0df9 --- /dev/null +++ b/core/modules/filters/crypto.js @@ -0,0 +1,27 @@ +/*\ +title: $:/core/modules/filters/crypto.js +type: application/javascript +module-type: filteroperator + +Filter operators for cryptography, using the Stanford JavaScript library + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.sha256 = function(source,operator,options) { + var results = [], + length = parseInt(operator.operand,10) || 20, + sha256 = function(text) { + return sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(text)).substr(0,length); + }; + source(function(tiddler,title) { + results.push(sha256(title)); + }); + return results; +}; + +})(); diff --git a/editions/tw5.com/tiddlers/filters/sha256 Operator.tid b/editions/tw5.com/tiddlers/filters/sha256 Operator.tid new file mode 100644 index 000000000..fbc5b4406 --- /dev/null +++ b/editions/tw5.com/tiddlers/filters/sha256 Operator.tid @@ -0,0 +1,18 @@ +caption: sha256 +created: 20220129105504961 +modified: 20220129105504961 +op-input: a [[selection of titles|Title Selection]] +op-output: the base64 encoded sha256 of the input, truncated to the specified length +op-parameter: the number of characters to return, up to a maximum of 64 +op-parameter-name: L +op-purpose: apply sha256 hash to a string +tags: [[Filter Operators]] [[String Operators]] +title: sha256 Operator +type: text/vnd.tiddlywiki +from-version: 5.1.14 + +Hashes are a way of turning strings of arbitrary length into obfuscated strings of fixed length. They are often used in situations where items need to be stored by name but it is inconvenient to allow arbitrary length strings. + +See Wikipedia for details of the [[sha256|https://en.wikipedia.org/wiki/SHA-2]] operation. + +<<.operator-examples "sha256">> From df1b1316c8cae76a1412d8023375b775da611d4b Mon Sep 17 00:00:00 2001 From: Marxsal Date: Sat, 29 Jan 2022 07:39:29 -0800 Subject: [PATCH 12/35] One word change to 'Images in WikiText' (#6430) --- editions/tw5.com/tiddlers/wikitext/Images in WikiText.tid | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editions/tw5.com/tiddlers/wikitext/Images in WikiText.tid b/editions/tw5.com/tiddlers/wikitext/Images in WikiText.tid index a0a2ddcf8..abcd13486 100644 --- a/editions/tw5.com/tiddlers/wikitext/Images in WikiText.tid +++ b/editions/tw5.com/tiddlers/wikitext/Images in WikiText.tid @@ -1,6 +1,6 @@ caption: Images created: 20131205160221762 -modified: 20210519160846733 +modified: 20220129152627668 tags: WikiText [[Working with TiddlyWiki]] title: Images in WikiText type: text/vnd.tiddlywiki @@ -14,7 +14,7 @@ Images can be included in WikiText with the following syntax: [img[https://tiddlywiki.com/favicon.ico]] ``` -You can also insert images from the editor toolbar. Click ''picture'' (<<.icon $:/core/images/picture>>) and select a picture file. +You can also insert image tiddlers from the editor toolbar. Click ''picture'' (<<.icon $:/core/images/picture>>) and select a picture file. If the image source is the title of an image tiddler then that tiddler is directly displayed. Otherwise it is interpreted as a URL and an HTML `` tag is generated with the `src` attribute containing the URL. From edb5dc3fdcb9197cd250109b48761d1b21621986 Mon Sep 17 00:00:00 2001 From: RJ Skerry-Ryan Date: Sat, 29 Jan 2022 09:41:09 -0800 Subject: [PATCH 13/35] Add keyword-spacing rule to .eslintrc.yml to reflect the project code style. (#6431) - Update .eslintignore to ignore "third party" code. - Add a "lint" script to package.json so `npm run lint` runs eslint on the repo. --- .eslintignore | 17 +++++------------ .eslintrc.yml | 18 +++++++++++++++++- package.json | 7 +++++-- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/.eslintignore b/.eslintignore index 30a0dae7c..9e586b92e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,15 +1,8 @@ -# Known minified files +# Ignore "third party" code whose style we will not change. /boot/sjcl.js +/core/modules/utils/base64-utf8/base64-utf8.module.js /core/modules/utils/base64-utf8/base64-utf8.module.min.js /core/modules/utils/diff-match-patch/diff_match_patch.js -/plugins/tiddlywiki/async/files/async.min.v1.5.0.js -/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/anyword-hint.js -/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/css-hint.js -/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/html-hint.js -/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/javascript-hint.js -/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/show-hint.js -/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/xml-hint.js -/plugins/tiddlywiki/codemirror-closebrackets/files/addon/edit/closebrackets.js -/plugins/tiddlywiki/codemirror-closebrackets/files/addon/edit/matchbrackets.js -/plugins/tiddlywiki/codemirror-closetag/files/addon/edit/closetag.js -/plugins/tiddlywiki/codemirror-closetag/files/addon/fold/xml-fold.js +/core/modules/utils/diff-match-patch/diff_match_patch_uncompressed.js +/core/modules/utils/dom/csscolorparser.js +/plugins/tiddlywiki/*/files/ diff --git a/.eslintrc.yml b/.eslintrc.yml index 105ca829e..049af59e4 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -64,7 +64,23 @@ rules: init-declarations: 'off' jsx-quotes: error key-spacing: 'off' - keyword-spacing: 'off' + keyword-spacing: + - error + - before: true + after: false + overrides: + 'case': + after: true + 'do': + 'after': true + 'else': + after: true + 'return': + after: true + 'throw': + after: true + 'try': + after: true line-comment-position: 'off' linebreak-style: 'off' lines-around-comment: 'off' diff --git a/package.json b/package.json index 7414b15be..6db272278 100644 --- a/package.json +++ b/package.json @@ -23,13 +23,16 @@ "tiddlywiki5", "wiki" ], - "dependencies": {}, "devDependencies": { - "eslint": "^7.10.0" + "eslint": "^7.32.0" }, "bundleDependencies": [], "license": "BSD", "engines": { "node": ">=0.8.2" + }, + "scripts": { + "lint": "eslint ." } + } From 7d2994388bb0e5db91338244d3e1e644ec42be28 Mon Sep 17 00:00:00 2001 From: Rizwan Date: Sun, 30 Jan 2022 16:37:32 +0530 Subject: [PATCH 14/35] Remove 2 whitespaces (#6434) These whitespaces were messing the list rendering --- plugins/tiddlywiki/highlight/howto.tid | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/tiddlywiki/highlight/howto.tid b/plugins/tiddlywiki/highlight/howto.tid index e2b5a77c1..5c867412b 100644 --- a/plugins/tiddlywiki/highlight/howto.tid +++ b/plugins/tiddlywiki/highlight/howto.tid @@ -1,9 +1,9 @@ title: $:/plugins/tiddlywiki/highlight/howto ! Supporting Additional Languages - + The [[highlight.js|https://github.com/highlightjs/highlight.js]] project supports many languages. Only a subset of these languages are supported by the plugin. It is possible for users to change the set of languages supported by the plugin by following these steps: - + # Go to the highlight.js project [[download page|https://highlightjs.org/download/]], select the language definitions to include, and press the Download button to download a zip archive containing customised support files for a highlight.js syntax highlighting server. # Locate the `highlight.pack.js` file in the highlight plugin -- on a stock Debian 8 system running Tiddlywiki5 under node-js it is located at `/usr/local/lib/node_modules/tiddlywiki/plugins/tiddlywiki/highlight/files/highlight.pack.js`. # Replace the plugin `highlight.pack.js` file located in step 2 with the one from the downloaded archive obtained in step 1. From 7f0fb2b610caa144aa7a84a498677ef4cc1ae5f3 Mon Sep 17 00:00:00 2001 From: twMat Date: Sun, 30 Jan 2022 12:17:39 +0100 Subject: [PATCH 15/35] [doc] Update Importing Tiddlers.tid - attempt 2 (#6432) --- editions/tw5.com/tiddlers/features/Importing Tiddlers.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/features/Importing Tiddlers.tid b/editions/tw5.com/tiddlers/features/Importing Tiddlers.tid index 33662ff4a..a837d7d73 100644 --- a/editions/tw5.com/tiddlers/features/Importing Tiddlers.tid +++ b/editions/tw5.com/tiddlers/features/Importing Tiddlers.tid @@ -22,5 +22,5 @@ Most files are imported as individual tiddlers. The exceptions are: !! Importing content from other ~TiddlyWiki browser windows -Tiddlers can be imported from other ~TiddlyWiki browser windows via [[Drag and Drop]]. Drag a tiddler link or tag from one ~TiddlyWiki browser window to another. Dragging a link will import a single tiddler while dragging a tag pill will import all of the tiddlers that carry that tag. +Tiddlers can be imported from other ~TiddlyWiki browser windows via [[Drag and Drop]]. Drag a TiddlyWiki internal link or a tag from one ~TiddlyWiki browser window to another. Dragging an internal link will import a single tiddler while dragging a tag pill will import all of the tiddlers that carry that tag. From 13faeaa0bd91125425c8e780122a4c3b7133e36b Mon Sep 17 00:00:00 2001 From: RJ Skerry-Ryan Date: Sun, 30 Jan 2022 03:23:00 -0800 Subject: [PATCH 16/35] Markdown: Let WikiText parsing handle the creation of LaTeX widgets. (#6428) * Markdown: Let WikiText parsing handle the creation of LaTeX widgets. When embedding LaTeX snippets in inline HTML nodes, such as TiddlyRemember macros or HTML tables, the parsing of latex nodes breaks the WikiText by splitting it into pieces around the latex node. This commit fixes the issue by converting the Remarkable katex nodes back to text, using a newline to indicate a block katex snippet. This is then re-parsed by the WikiText KaTeX plugin. TESTED: Created a test wiki with: ``` $ node tiddlywiki.js test --init markdowndemo $ node tiddlywiki.js test --listen ``` * Verified markdown + KaTeX support still works as expected. * Verified that embedding LaTeX snippets in inline HTML works (e.g. `$x^2$`). * Verified the markdown + KaTeX support works as expected with renderWikiText set to `false`. * Style: Remove spaces between if and opening parentheses. --- .../markdown/config_renderWikiTextPragma.tid | 2 +- plugins/tiddlywiki/markdown/wrapper.js | 55 +++++++++++-------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/plugins/tiddlywiki/markdown/config_renderWikiTextPragma.tid b/plugins/tiddlywiki/markdown/config_renderWikiTextPragma.tid index c3cd6d482..aaead7955 100644 --- a/plugins/tiddlywiki/markdown/config_renderWikiTextPragma.tid +++ b/plugins/tiddlywiki/markdown/config_renderWikiTextPragma.tid @@ -1,3 +1,3 @@ title: $:/config/markdown/renderWikiTextPragma -\rules only html image macrocallinline syslink transcludeinline wikilink filteredtranscludeblock macrocallblock transcludeblock \ No newline at end of file +\rules only html image macrocallinline syslink transcludeinline wikilink filteredtranscludeblock macrocallblock transcludeblock latex-parser \ No newline at end of file diff --git a/plugins/tiddlywiki/markdown/wrapper.js b/plugins/tiddlywiki/markdown/wrapper.js index cf673dce8..704ce4689 100755 --- a/plugins/tiddlywiki/markdown/wrapper.js +++ b/plugins/tiddlywiki/markdown/wrapper.js @@ -36,22 +36,26 @@ var accumulatingTypes = { "text": true, "softbreak": true }; +// If rendering WikiText, we treat katex nodes as text. +if(pluginOpts.renderWikiText) { + accumulatingTypes["katex"] = true; +} var md = new Remarkable(remarkableOpts); // If tiddlywiki/katex plugin is present, use remarkable-katex to enable katex support. -if ($tw.modules.titles["$:/plugins/tiddlywiki/katex/katex.min.js"]) { +if($tw.modules.titles["$:/plugins/tiddlywiki/katex/katex.min.js"]) { var rk = require("$:/plugins/tiddlywiki/markdown/remarkable-katex.js"); md = md.use(rk); } -if (parseAsBoolean("$:/config/markdown/linkify")) { +if(parseAsBoolean("$:/config/markdown/linkify")) { md = md.use(linkify); } function findTagWithType(nodes, startPoint, type, level) { for (var i = startPoint; i < nodes.length; i++) { - if (nodes[i].type === type && nodes[i].level === level) { + if(nodes[i].type === type && nodes[i].level === level) { return i; } } @@ -77,7 +81,7 @@ function convertNodes(remarkableTree, isStartOfInline) { var accumulatedText = ''; function withChildren(currentIndex, currentLevel, closingType, nodes, callback) { var j = findTagWithType(nodes, currentIndex + 1, closingType, currentLevel); - if (j === false) { + if(j === false) { console.error("Failed to find a " + closingType + " node after position " + currentIndex); console.log(nodes); return currentIndex + 1; @@ -101,7 +105,7 @@ function convertNodes(remarkableTree, isStartOfInline) { switch (currentNode.type) { case "paragraph_open": // If the paragraph is a "tight" layout paragraph, don't wrap children in a

tag. - if (currentNode.tight) { + if(currentNode.tight) { i = withChildren(i, currentNode.level, "paragraph_close", remarkableTree, function(children) { Array.prototype.push.apply(out, children); }); @@ -128,14 +132,14 @@ function convertNodes(remarkableTree, isStartOfInline) { case "link_open": i = withChildren(i, currentNode.level, "link_close", remarkableTree, function(children) { - if (currentNode.href[0] !== "#") { + if(currentNode.href[0] !== "#") { // External link var attributes = { class: { type: "string", value: "tc-tiddlylink-external" }, href: { type: "string", value: currentNode.href }, rel: { type: "string", value: "noopener noreferrer" } }; - if (pluginOpts.linkNewWindow) { + if(pluginOpts.linkNewWindow) { attributes.target = { type: "string", value: "_blank" }; } out.push({ @@ -186,7 +190,7 @@ function convertNodes(remarkableTree, isStartOfInline) { break; case "softbreak": - if (remarkableOpts.breaks) { + if(remarkableOpts.breaks) { out.push({ type: "element", tag: "br", @@ -208,7 +212,7 @@ function convertNodes(remarkableTree, isStartOfInline) { var elementTag = currentNode.type.slice(0, 2); i = withChildren(i, currentNode.level, elementTag + "_close", remarkableTree, function(children) { var attributes = {}; - if (currentNode.align) { + if(currentNode.align) { attributes.style = { type: "string", value: "text-align:" + currentNode.align }; } out.push({ @@ -237,17 +241,24 @@ function convertNodes(remarkableTree, isStartOfInline) { break; case "katex": - out.push({ - type: "latex", - attributes: { - text: { type: "text", value: currentNode.content }, - displayMode: { type: "text", value: currentNode.block ? "true" : "false" } - } - }); + // If rendering WikiText, convert the katex node back to text for parsing by the WikiText LaTeX parser. + if(pluginOpts.renderWikiText) { + // If this is a block, add a newline to trigger the KaTeX plugins block detection. + var displayModeSuffix = currentNode.block ? "\n" : ""; + accumulatedText = accumulatedText + "$$" + currentNode.content + displayModeSuffix + "$$"; + } else { + out.push({ + type: "latex", + attributes: { + text: { type: "text", value: currentNode.content }, + displayMode: { type: "text", value: currentNode.block ? "true" : "false" } + } + }); + } break; default: - if (currentNode.type.substr(currentNode.type.length - 5) === "_open") { + if(currentNode.type.substr(currentNode.type.length - 5) === "_open") { var tagName = currentNode.type.substr(0, currentNode.type.length - 5); i = wrappedElement(tagName, i, currentNode.level, tagName + "_close", remarkableTree); } else { @@ -261,7 +272,7 @@ function convertNodes(remarkableTree, isStartOfInline) { } // We test to see if we process the block now, or if there's // more to accumulate first. - if (accumulatedText + if(accumulatedText && ( remarkableOpts.breaks || (i+1) >= remarkableTree.length || @@ -271,7 +282,7 @@ function convertNodes(remarkableTree, isStartOfInline) { // The Markdown compiler thinks this is just text. // Hand off to the WikiText parser to see if there's more to render // But only if it's configured to, and we have more than whitespace - if (!pluginOpts.renderWikiText || accumulatedText.match(/^\s*$/)) { + if(!pluginOpts.renderWikiText || accumulatedText.match(/^\s*$/)) { out.push({ type: "text", text: accumulatedText @@ -281,7 +292,7 @@ function convertNodes(remarkableTree, isStartOfInline) { // handle as a block-level parse. Otherwise not. var parseAsInline = !(isStartOfInline && i === 0); var textToParse = accumulatedText; - if (pluginOpts.renderWikiTextPragma !== "") { + if(pluginOpts.renderWikiTextPragma !== "") { textToParse = pluginOpts.renderWikiTextPragma + "\n" + textToParse; } var wikiParser = $tw.wiki.parseText("text/vnd.tiddlywiki", textToParse, { @@ -292,7 +303,7 @@ function convertNodes(remarkableTree, isStartOfInline) { // If we parsed as a block, but the root element the WikiText parser gave is a paragraph, // we should discard the paragraph, since the way Remarkable nests its nodes, this "inline" // node is always inside something else that's a block-level element - if (!parseAsInline + if(!parseAsInline && rs.length === 1 && rs[0].type === "element" && rs[0].tag === "p" @@ -301,7 +312,7 @@ function convertNodes(remarkableTree, isStartOfInline) { } // If the original text element started with a space, add it back in - if (rs.length > 0 + if(rs.length > 0 && rs[0].type === "text" && (accumulatedText[0] === " " || accumulatedText[0] === "\n") ) { From bd447f0716653085be1f1a88509444ae4f6b8467 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Mon, 31 Jan 2022 17:05:55 +0000 Subject: [PATCH 17/35] Add talk.tiddlywiki.org as the official forum for the community --- .../tw5.com/tiddlers/community/Forums.tid | 29 ++++++++++--------- .../tiddlers/hellothere/HelloThere.tid | 6 ++-- .../tiddlers/releasenotes/Releases.tid | 6 ++-- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/editions/tw5.com/tiddlers/community/Forums.tid b/editions/tw5.com/tiddlers/community/Forums.tid index 2a2663a65..f3baacf21 100644 --- a/editions/tw5.com/tiddlers/community/Forums.tid +++ b/editions/tw5.com/tiddlers/community/Forums.tid @@ -1,28 +1,31 @@ created: 20140721121924384 -modified: 20201222114755959 +modified: 20220131165124489 tags: Community title: Forums type: text/vnd.tiddlywiki -! Users +! Official Forums -The ~TiddlyWiki discussion groups are mailing lists for talking about ~TiddlyWiki: requests for help, announcements of new releases and plugins, debating new features, or just sharing experiences. You can participate via the associated website, or subscribe via email. +The new official forum for talking about ~TiddlyWiki: requests for help, announcements of new releases and plugins, debating new features, or just sharing experiences. You can participate via the associated website, or subscribe via email. -* The main ~TiddlyWiki group: https://groups.google.com/group/TiddlyWiki -*> Note that you do not need a Google Account to join the discussion groups. Subscribe by sending an email to mailto:tiddlywiki+subscribe@googlegroups.com. -** An enhanced group search facility is available on [[mail-archive.com|https://www.mail-archive.com/tiddlywiki@googlegroups.com/]] -* Watch recordings of our regular [[TiddlyWiki Hangouts]] -* Follow [[@TiddlyWiki on Twitter|http://twitter.com/TiddlyWiki]] for the latest news -* New: Join us on our live chat at https://gitter.im/TiddlyWiki/public ! -* There is also a discord available at https://discord.gg/HFFZVQ8 +https://talk.tiddlywiki.org/ +Note that talk.tiddlywiki.org is a community run service that we host and maintain ourselves. The modest running costs are covered by community contributions. -! Developers +For the convenience of existing users, we also continue to operate the original ~TiddlyWiki group (hosted on Google Groups since 2005): + +https://groups.google.com/group/TiddlyWiki + +! Developer Forums {{Developers}} -New releases of TiddlyWiki, TiddlyDesktop and TiddlyFox are announced via the discussion groups and [[Twitter|https://twitter.com/TiddlyWiki]] (you can also subscribe to an Atom/RSS feed of [[TiddlyWiki releases from GitHub|https://github.com/jermolene/tiddlywiki5/releases.atom]]) +! Other Forums -! Documentation +* [[TiddlyWiki Subreddit|https://www.reddit.com/r/TiddlyWiki5/]] +* Chat with Gitter at https://gitter.im/TiddlyWiki/public ! +* Chat on Discord at https://discord.gg/HFFZVQ8 + +!! Documentation There is also a discussion group specifically for discussing TiddlyWiki documentation improvement initiatives: https://groups.google.com/group/tiddlywikidocs diff --git a/editions/tw5.com/tiddlers/hellothere/HelloThere.tid b/editions/tw5.com/tiddlers/hellothere/HelloThere.tid index 0ac644e72..6eb2a0057 100644 --- a/editions/tw5.com/tiddlers/hellothere/HelloThere.tid +++ b/editions/tw5.com/tiddlers/hellothere/HelloThere.tid @@ -1,6 +1,6 @@ created: 20130822170200000 list: [[A Gentle Guide to TiddlyWiki]] [[Discover TiddlyWiki]] [[Some of the things you can do with TiddlyWiki]] [[Ten reasons to switch to TiddlyWiki]] Examples [[What happened to the original TiddlyWiki?]] [[HelloThumbnail - TWEUM2017]] -modified: 20211208115833846 +modified: 20220131164555580 tags: TableOfContents title: HelloThere type: text/vnd.tiddlywiki @@ -18,8 +18,8 @@ Use it to keep your [[to-do list|TaskManagementExample]], to plan an [[essay or Unlike conventional online services, TiddlyWiki lets you choose where to keep your data, guaranteeing that in the decades to come you will [[still be able to use|Future Proof]] the notes you take today.

- -{{$:/core/images/help}} Forum + +{{$:/core/images/help}} ~TalkTW {{$:/core/images/video}} ~YouTube diff --git a/editions/tw5.com/tiddlers/releasenotes/Releases.tid b/editions/tw5.com/tiddlers/releasenotes/Releases.tid index c33908fde..c48d6df65 100644 --- a/editions/tw5.com/tiddlers/releasenotes/Releases.tid +++ b/editions/tw5.com/tiddlers/releasenotes/Releases.tid @@ -1,7 +1,9 @@ created: 20150419144523070 -modified: 20150420114530386 +modified: 20220131165321472 tags: About title: Releases type: text/vnd.tiddlywiki -<> \ No newline at end of file +New releases of TiddlyWiki, TiddlyDesktop and TiddlyFox are announced via the [[official discussion groups|Forums]] and [[Twitter|https://twitter.com/TiddlyWiki]] (you can also subscribe to an Atom/RSS feed of [[TiddlyWiki releases from GitHub|https://github.com/jermolene/tiddlywiki5/releases.atom]]) + +<> From e49dda3b4860cdf82fcae4e19dd91f2629f4c219 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Tue, 1 Feb 2022 09:36:30 +0000 Subject: [PATCH 18/35] Fix search results cutoff on narrow screens Fixes #6440 --- core/modules/widgets/scrollable.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/modules/widgets/scrollable.js b/core/modules/widgets/scrollable.js index aadc040df..eb541c263 100644 --- a/core/modules/widgets/scrollable.js +++ b/core/modules/widgets/scrollable.js @@ -159,8 +159,6 @@ ScrollableWidget.prototype.render = function(parent,nextSibling) { // Create elements this.outerDomNode = this.document.createElement("div"); $tw.utils.setStyle(this.outerDomNode,[ - {overflowY: "auto"}, - {overflowX: "auto"}, {webkitOverflowScrolling: "touch"} ]); this.innerDomNode = this.document.createElement("div"); From 1b3c2557b88dc31bf3494f5509f158c64a6b8b6c Mon Sep 17 00:00:00 2001 From: Cameron Fischer Date: Mon, 7 Feb 2022 11:39:29 -0500 Subject: [PATCH 19/35] Fixed issue: deprecated regexp could cause crash (#6438) * Fixed issue: deprecated regexp could cause crash * Different fix which will bother plugins less --- core/modules/filters.js | 6 ++++-- editions/test/tiddlers/tests/test-filters.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/modules/filters.js b/core/modules/filters.js index 06fa603b5..e0a2779e3 100644 --- a/core/modules/filters.js +++ b/core/modules/filters.js @@ -95,10 +95,12 @@ function parseFilterOperation(operators,filterString,p) { if(nextBracketPos === -1) { throw "Missing closing bracket in filter expression"; } - if(!operator.regexp) { + if(operator.regexp) { + operand.text = ""; + } else { operand.text = filterString.substring(p,nextBracketPos); - operator.operands.push(operand); } + operator.operands.push(operand); p = nextBracketPos + 1; } diff --git a/editions/test/tiddlers/tests/test-filters.js b/editions/test/tiddlers/tests/test-filters.js index 05c5e3c83..12e24bcc5 100644 --- a/editions/test/tiddlers/tests/test-filters.js +++ b/editions/test/tiddlers/tests/test-filters.js @@ -256,6 +256,16 @@ Tests the filtering mechanism. expect(wiki.filterTiddlers("[modifier/Jo/]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,a fourth tiddler,one"); expect(console.log).toHaveBeenCalledWith("WARNING: Filter", "modifier", "has a deprecated regexp operand", /Jo/); }); + + it("should handle regular expression operands without crashing", function() { + spyOn(console, 'log'); + // We don't really care about the results. Just don't get RSoD. + expect(() => wiki.filterTiddlers("[all/current/]")).not.toThrow(); + expect(() => wiki.filterTiddlers("[prefix/anything/]")).not.toThrow(); + expect(() => wiki.filterTiddlers("[title/anything/]")).not.toThrow(); + expect(() => wiki.filterTiddlers("[/anything/]")).not.toThrow(); + expect(() => wiki.filterTiddlers("[//]")).not.toThrow(); + }); it("should handle the prefix operator", function() { expect(wiki.filterTiddlers("[prefix[Tiddler]]").join(",")).toBe("TiddlerOne,Tiddler Three"); From 33f40c47c68d8148d7ff91abb3655a7df2f3d5b3 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Mon, 7 Feb 2022 16:53:36 +0000 Subject: [PATCH 20/35] Use code-body: yes for more templates Fixes #6444 --- editions/prerelease/tiddlers/system/download-empty.tid | 1 + .../demonstrations/CustomStoryTiddlerTemplateDemo.tid/Styles.tid | 1 + .../CustomStoryTiddlerTemplateDemo.tid/Template.tid | 1 + .../CustomStoryTiddlerTemplateDemo.tid/TiddlerTemplateFilter.tid | 1 + editions/tw5.com/tiddlers/system/download-empty.tid | 1 + themes/tiddlywiki/vanilla/base.tid | 1 + themes/tiddlywiki/vanilla/sticky.tid | 1 + 7 files changed, 7 insertions(+) diff --git a/editions/prerelease/tiddlers/system/download-empty.tid b/editions/prerelease/tiddlers/system/download-empty.tid index 9e0c48c4f..2c0eaa259 100644 --- a/editions/prerelease/tiddlers/system/download-empty.tid +++ b/editions/prerelease/tiddlers/system/download-empty.tid @@ -1,4 +1,5 @@ title: $:/editions/tw5.com/download-empty +code-body: yes \define saveTiddlerFilter() [[$:/core]] [[$:/isEncrypted]] [[$:/themes/tiddlywiki/snowwhite]] [[$:/themes/tiddlywiki/vanilla]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] [[$:/config/OfficialPluginLibrary]] +[sort[title]] diff --git a/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/Styles.tid b/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/Styles.tid index c0b812f8f..ac3a4f8eb 100644 --- a/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/Styles.tid +++ b/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/Styles.tid @@ -1,5 +1,6 @@ title: $:/_tw5.com/CustomStoryTiddlerTemplateDemo/Styles tags: $:/tags/Stylesheet +code-body: yes .tc-custom-tiddler-template { border: 3px solid <>; diff --git a/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/Template.tid b/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/Template.tid index bda589174..9f30274c4 100644 --- a/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/Template.tid +++ b/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/Template.tid @@ -1,4 +1,5 @@ title: $:/_tw5.com/CustomStoryTiddlerTemplateDemo/Template +code-body: yes \define list-item-styles() transform: translate($(left)$%,$(top)$%) scale(0.3) rotate($(angle)$deg); diff --git a/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/TiddlerTemplateFilter.tid b/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/TiddlerTemplateFilter.tid index dddb3d62a..cdbccb2b6 100644 --- a/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/TiddlerTemplateFilter.tid +++ b/editions/tw5.com/tiddlers/demonstrations/CustomStoryTiddlerTemplateDemo.tid/TiddlerTemplateFilter.tid @@ -1,5 +1,6 @@ title: $:/_tw5.com/CustomStoryTiddlerTemplateDemo/Filter tags: $:/tags/StoryTiddlerTemplateFilter list-before: $:/config/StoryTiddlerTemplateFilters/default +code-body: yes [tag[$:/tags/TiddlerList]then[$:/_tw5.com/CustomStoryTiddlerTemplateDemo/Template]] diff --git a/editions/tw5.com/tiddlers/system/download-empty.tid b/editions/tw5.com/tiddlers/system/download-empty.tid index e34226189..055fa2022 100644 --- a/editions/tw5.com/tiddlers/system/download-empty.tid +++ b/editions/tw5.com/tiddlers/system/download-empty.tid @@ -1,4 +1,5 @@ title: $:/editions/tw5.com/download-empty +code-body: yes \define saveTiddlerFilter() [[$:/core]] [[$:/isEncrypted]] [[$:/themes/tiddlywiki/snowwhite]] [[$:/themes/tiddlywiki/vanilla]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 0c9a1b9cd..83798d8df 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -1,5 +1,6 @@ title: $:/themes/tiddlywiki/vanilla/base tags: [[$:/tags/Stylesheet]] +code-body: yes \define custom-background-datauri() <$set name="background" value={{$:/themes/tiddlywiki/vanilla/settings/backgroundimage}}> diff --git a/themes/tiddlywiki/vanilla/sticky.tid b/themes/tiddlywiki/vanilla/sticky.tid index 545440dd7..f7c174fd6 100644 --- a/themes/tiddlywiki/vanilla/sticky.tid +++ b/themes/tiddlywiki/vanilla/sticky.tid @@ -1,4 +1,5 @@ title: $:/themes/tiddlywiki/vanilla/sticky +code-body: yes <$reveal state="$:/themes/tiddlywiki/vanilla/options/stickytitles" type="match" text="yes"> `` From 8e50ad1243fdec6b55cbaa589fed73738e7fd85d Mon Sep 17 00:00:00 2001 From: Marxsal Date: Mon, 7 Feb 2022 09:32:06 -0800 Subject: [PATCH 21/35] Change 'Drop here' to 'Drop now' in import msg (#6435) --- core/language/en-GB/Misc.multids | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/language/en-GB/Misc.multids b/core/language/en-GB/Misc.multids index 273c3b57d..b677494e6 100644 --- a/core/language/en-GB/Misc.multids +++ b/core/language/en-GB/Misc.multids @@ -14,7 +14,7 @@ ConfirmAction: Do you wish to proceed? Count: count DefaultNewTiddlerTitle: New Tiddler Diffs/CountMessage: <> differences -DropMessage: Drop here (or use the 'Escape' key to cancel) +DropMessage: Drop now (or use the 'Escape' key to cancel) Encryption/Cancel: Cancel Encryption/ConfirmClearPassword: Do you wish to clear the password? This will remove the encryption applied when saving this wiki Encryption/PromptSetPassword: Set a new password for this TiddlyWiki From 965d8ee014071540f71b6e9dcb0d7794c653839e Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Tue, 8 Feb 2022 15:40:15 +0000 Subject: [PATCH 22/35] Update release note --- .../prerelease/tiddlers/Release 5.2.2.tid | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/editions/prerelease/tiddlers/Release 5.2.2.tid b/editions/prerelease/tiddlers/Release 5.2.2.tid index 664c50ac4..893c795b7 100644 --- a/editions/prerelease/tiddlers/Release 5.2.2.tid +++ b/editions/prerelease/tiddlers/Release 5.2.2.tid @@ -1,6 +1,6 @@ caption: 5.2.2 -created: 20211208115905247 -modified: 20211208115905247 +created: 20220208152620527 +modified: 20220208152620527 tags: ReleaseNotes title: Release 5.2.2 type: text/vnd.tiddlywiki @@ -18,9 +18,18 @@ type: text/vnd.tiddlywiki ! Bug Fixes * <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/60187dc59e6546d9ca8e6a35418f782a9627cda0">> importing/upgrading encrypted single file wikis +* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/issues/6389">> RadioWidget not using default value if the field or index is missing +* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/issues/6376">> [[WidgetMessage: tm-edit-text-operation]] crash with ''wrap-lines'' operation if prefix or suffix is missing +* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/issues/6395">> processing of $:/tags/RawMarkupWikified/TopHead tiddlers +* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/issues/6398">> issue whereby renaming tags could result in duplicate tags +* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/issues/6426">> issue with ImportVariablesWidget when importing block mode widgets +* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/6428">> issue with ~LaTeX content within Markdown tiddlers +* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/issues/6440">> search results obscured on narrow screens +* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/6438">> crash when using deprecated regexp operands for filter operators ! Usability Improvements +* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6435">> wording of drag and drop banner (from "drop here" to "drop now") * <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/853a899c77766e47eade1dfa5822640ef9915637">> wrapping and wikification of field names in field viewer * <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/0186c6490fbd1d8fd4de7c3fa99ccf4d129fbd80">> missing whitespace between description and MIME type in edit template dropdown for the ''type'' field * <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/c7e8c87f85b54f60302ff8e396a7569d996e3f67">> incorrect usage of code view for certain system tiddlers @@ -38,10 +47,15 @@ type: text/vnd.tiddlywiki * <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/commit/54cfda76ee353190f1cf0210b9071894fb1a5690">> support for ''code-body'' field set to ''yes'' to trigger display of a tiddler in the code view * <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/commit/66ae1d6930796a9eb062fdb64a755adab8f39294">> classes to the ImageWidget to indicate whether it is loading, loaded or has encountered an error * <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/6381">> sourceURL tags to $:/boot/boot.js and $:/boot/bootprefix.js, enabling them to be accessed in the browser debugger more easily +* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/6410">> support to [[WidgetMessage: tm-scroll]] for scrolling without animating +* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/commit/1a0c831216c397c6fef8e5685e47857193411a1b">> [[sha256 Operator]] + ! Developer Improvements -* +* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/6409">> support for ''renderEnd()'' method for storyviews + + ! Node.js Improvements From 5022516c614432f25dca2baf0c165a9256899a98 Mon Sep 17 00:00:00 2001 From: Bram Chen Date: Wed, 9 Feb 2022 00:01:30 +0800 Subject: [PATCH 23/35] Update chinese language files (#6449) * Update chinese field descriptions * Revised chinese translations for `DropMessage` --- languages/zh-Hans/Misc.multids | 2 +- languages/zh-Hant/Misc.multids | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/languages/zh-Hans/Misc.multids b/languages/zh-Hans/Misc.multids index e72b68fb2..7b8edb4b8 100644 --- a/languages/zh-Hans/Misc.multids +++ b/languages/zh-Hans/Misc.multids @@ -14,7 +14,7 @@ ConfirmAction: 是否要继续? Count: 计数 DefaultNewTiddlerTitle: 新条目 Diffs/CountMessage: <> 个差异 -DropMessage: 拖放到此处 (或按 ESC 键取消) +DropMessage: 现在放下(或按 ESC 键取消) Encryption/Cancel: 取消 Encryption/ConfirmClearPassword: 您要清除密码吗?当保存此维基时,这将删除已套用的加密 Encryption/Username: 用户名称 diff --git a/languages/zh-Hant/Misc.multids b/languages/zh-Hant/Misc.multids index 8d56cfc51..3b67b65ba 100644 --- a/languages/zh-Hant/Misc.multids +++ b/languages/zh-Hant/Misc.multids @@ -14,7 +14,7 @@ ConfirmAction: 是否要繼續? Count: 計數 DefaultNewTiddlerTitle: 新條目 Diffs/CountMessage: <> 個差異 -DropMessage: 拖放到此處 (或按 ESC 鍵取消) +DropMessage: 現在放下(或按 ESC 鍵取消) Encryption/Cancel: 取消 Encryption/ConfirmClearPassword: 您要清除密碼嗎?當儲存此維基時,這將刪除已套用的加密 Encryption/Username: 使用者名稱 From d3ea98fcef6e655e9aa71cc47bf4cfa3405758f0 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Mon, 14 Feb 2022 10:44:42 +0000 Subject: [PATCH 24/35] Menubar plugin: fix class handling for dropdowns Fixes #6457 --- plugins/tiddlywiki/menubar/menu.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tiddlywiki/menubar/menu.tid b/plugins/tiddlywiki/menubar/menu.tid index 2d8f06aaa..1d592cbfa 100644 --- a/plugins/tiddlywiki/menubar/menu.tid +++ b/plugins/tiddlywiki/menubar/menu.tid @@ -55,7 +55,7 @@ tags: $:/tags/PageTemplate <$list filter="[addprefix[$:/config/plugins/menubar/MenuItems/Visibility/]get[text]] ~show +[match[show]]" variable="ignore"> <$set name="dropdown-state" value=<>> <$set name="dropdown-state" value={{{ [addsuffix] }}}> -<$reveal type="popup" state=<> position={{{ [get[dropdown-position]else[below]] }}} class={{{ [get[dropdown]get[class]] }}} tag="div"> +<$reveal type="popup" state=<> position={{{ [get[dropdown-position]else[below]] }}} class={{{ [get[class]] }}} tag="div">
<$transclude/>
From 37a6ff8521262ff133c080610cb2212e9c19f123 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Sat, 19 Feb 2022 09:20:32 +0000 Subject: [PATCH 25/35] Move tm-rename-tiddler handling from navigator widget into startup module This reverses an August 2015 change in 68e15c10641e2eda1e64cf29954786a07326a920; the original rationale was wrong: there is nothing related to the navigator widget in the implementation of the tm-rename-tiddler message --- core/modules/startup/rootwidget.js | 10 ++++++++++ core/modules/widgets/navigator.js | 13 +------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/core/modules/startup/rootwidget.js b/core/modules/startup/rootwidget.js index 721f84d5d..8c2f9158d 100644 --- a/core/modules/startup/rootwidget.js +++ b/core/modules/startup/rootwidget.js @@ -51,6 +51,16 @@ exports.startup = function() { element.focus(event.paramObject); } }); + // Install the tm-rename-tiddler message + $tw.rootWidget.addEventListener("tm-rename-tiddler",function(event) { + var options = {}, + paramObject = event.paramObject || {}, + from = paramObject.from || event.tiddlerTitle, + to = paramObject.to; + options.dontRenameInTags = (paramObject.renameInTags === "false" || paramObject.renameInTags === "no") ? true : false; + options.dontRenameInLists = (paramObject.renameInLists === "false" || paramObject.renameInLists === "no") ? true : false; + $tw.wiki.renameTiddler(from,to,options); + }); // Install the scroller $tw.pageScroller = new $tw.utils.PageScroller(); $tw.rootWidget.addEventListener("tm-scroll",function(event) { diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index e67b2fa15..4007e64d9 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -44,8 +44,7 @@ NavigatorWidget.prototype.render = function(parent,nextSibling) { {type: "tm-fold-tiddler", handler: "handleFoldTiddlerEvent"}, {type: "tm-fold-other-tiddlers", handler: "handleFoldOtherTiddlersEvent"}, {type: "tm-fold-all-tiddlers", handler: "handleFoldAllTiddlersEvent"}, - {type: "tm-unfold-all-tiddlers", handler: "handleUnfoldAllTiddlersEvent"}, - {type: "tm-rename-tiddler", handler: "handleRenameTiddlerEvent"} + {type: "tm-unfold-all-tiddlers", handler: "handleUnfoldAllTiddlersEvent"} ]); this.parentDomNode = parent; this.computeAttributes(); @@ -636,16 +635,6 @@ NavigatorWidget.prototype.handleUnfoldAllTiddlersEvent = function(event) { }); }; -NavigatorWidget.prototype.handleRenameTiddlerEvent = function(event) { - var options = {}, - paramObject = event.paramObject || {}, - from = paramObject.from || event.tiddlerTitle, - to = paramObject.to; - options.dontRenameInTags = (paramObject.renameInTags === "false" || paramObject.renameInTags === "no") ? true : false; - options.dontRenameInLists = (paramObject.renameInLists === "false" || paramObject.renameInLists === "no") ? true : false; - this.wiki.renameTiddler(from,to,options); -}; - exports.navigator = NavigatorWidget; })(); From 1d16206188ebd5ca7481a7f565bf5fc4c08239fd Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Sat, 19 Feb 2022 09:38:48 +0000 Subject: [PATCH 26/35] Add support for tm-relink-tiddler message --- core/modules/startup/rootwidget.js | 24 ++++++++++------- .../WidgetMessage_ tm-relink-tiddler.tid | 26 +++++++++++++++++++ .../WidgetMessage_ tm-rename-tiddler.tid | 6 +++-- 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-relink-tiddler.tid diff --git a/core/modules/startup/rootwidget.js b/core/modules/startup/rootwidget.js index 8c2f9158d..41f3fe03f 100644 --- a/core/modules/startup/rootwidget.js +++ b/core/modules/startup/rootwidget.js @@ -51,16 +51,20 @@ exports.startup = function() { element.focus(event.paramObject); } }); - // Install the tm-rename-tiddler message - $tw.rootWidget.addEventListener("tm-rename-tiddler",function(event) { - var options = {}, - paramObject = event.paramObject || {}, - from = paramObject.from || event.tiddlerTitle, - to = paramObject.to; - options.dontRenameInTags = (paramObject.renameInTags === "false" || paramObject.renameInTags === "no") ? true : false; - options.dontRenameInLists = (paramObject.renameInLists === "false" || paramObject.renameInLists === "no") ? true : false; - $tw.wiki.renameTiddler(from,to,options); - }); + // Install the tm-rename-tiddler and tm-relink-tiddler messages + var makeRenameHandler = function(method) { + return function(event) { + var options = {}, + paramObject = event.paramObject || {}, + from = paramObject.from || event.tiddlerTitle, + to = paramObject.to; + options.dontRenameInTags = (paramObject.renameInTags === "false" || paramObject.renameInTags === "no") ? true : false; + options.dontRenameInLists = (paramObject.renameInLists === "false" || paramObject.renameInLists === "no") ? true : false; + $tw.wiki[method](from,to,options); + }; + }; + $tw.rootWidget.addEventListener("tm-rename-tiddler",makeRenameHandler("renameTiddler")); + $tw.rootWidget.addEventListener("tm-relink-tiddler",makeRenameHandler("relinkTiddler")); // Install the scroller $tw.pageScroller = new $tw.utils.PageScroller(); $tw.rootWidget.addEventListener("tm-scroll",function(event) { diff --git a/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-relink-tiddler.tid b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-relink-tiddler.tid new file mode 100644 index 000000000..1da5103b0 --- /dev/null +++ b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-relink-tiddler.tid @@ -0,0 +1,26 @@ +caption: tm-relink-tiddler +created: 20220219093748993 +modified: 20220219093748993 +tags: Messages navigator-message +title: WidgetMessage: tm-relink-tiddler +type: text/vnd.tiddlywiki + +<<.from-version "5.2.2">> The `tm-relink-tiddler` message relinks a tiddler by deleting it and recreating it with a new title. Unlike the [[WidgetMessage: tm-rename-tiddler]] message, this message does not rename the tiddler, it just relinks the references to it. + +The relink tiddler message requires the following properties on the `event` object: + +|!Name |!Description | +|from |Current title of tiddler | +|to |New title of tiddler | +|renameInTags |Optional value "no" to disable renaming in tags fields of other tiddlers (defaults to "yes") | +|renameInLists |Optional value "no" to disable renaming in list fields of other tiddlers (defaults to "yes") | + +The relink tiddler message is usually generated with the ButtonWidget and is handled by the core. + +! Examples + +To relink Tiddler1 to Tiddler2 in tags and list fields of other tiddlers: + +``` +<$action-sendmessage $message="tm-relink-tiddler" from="Tiddler1" to="Tiddler2" /> +``` diff --git a/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-rename-tiddler.tid b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-rename-tiddler.tid index d18f523e6..630a45c56 100644 --- a/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-rename-tiddler.tid +++ b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-rename-tiddler.tid @@ -1,6 +1,6 @@ caption: tm-rename-tiddler created: 20190909133618113 -modified: 20190909133618113 +modified: 20220219093748993 tags: Messages navigator-message title: WidgetMessage: tm-rename-tiddler type: text/vnd.tiddlywiki @@ -13,7 +13,9 @@ The `tm-rename-tiddler` message renames a tiddler by deleting it and recreating |renameInTags |<<.from-version "5.1.23">> Optional value "no" to disable renaming in tags fields of other tiddlers (defaults to "yes") | |renameInLists |<<.from-version "5.1.23">> Optional value "no" to disable renaming in list fields of other tiddlers (defaults to "yes") | -The rename tiddler message is usually generated with the ButtonWidget and is handled by the NavigatorWidget. +The very similar [[WidgetMessage: tm-relink-tiddler]] message does not rename the tiddler, it just relinks the references to it. + +The rename tiddler message is usually generated with the ButtonWidget and is handled by the core. ! Examples From 59572cd75d5d4a32d3337a6db79ddeda601f0ea7 Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Sun, 20 Feb 2022 12:23:27 +0100 Subject: [PATCH 27/35] Extend tm-open-window to support optional top and left position for new browser window (#6470) * feat: extend tm-open-window to support optional top and left position for new browser window * fix: whitespace correction * Update WidgetMessage_ tm-open-window.tid --- core/modules/startup/windows.js | 4 +++- .../messages/WidgetMessage_ tm-open-window.tid | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/modules/startup/windows.js b/core/modules/startup/windows.js index 75786d026..95207a9ec 100644 --- a/core/modules/startup/windows.js +++ b/core/modules/startup/windows.js @@ -32,13 +32,15 @@ exports.startup = function() { template = paramObject.template || "$:/core/templates/single.tiddler.window", width = paramObject.width || "700", height = paramObject.height || "600", + top = paramObject.top, + left = paramObject.left, variables = $tw.utils.extend({},paramObject,{currentTiddler: title}); // Open the window var srcWindow, srcDocument; // In case that popup blockers deny opening a new window try { - srcWindow = window.open("","external-" + title,"scrollbars,width=" + width + ",height=" + height), + srcWindow = window.open("","external-" + title,"scrollbars,width=" + width + ",height=" + height + (top ? ",top=" + top : "" ) + (left ? ",left=" + left : "" )), srcDocument = srcWindow.document; } catch(e) { diff --git a/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-open-window.tid b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-open-window.tid index 9e452fd7d..a8f7c35f1 100644 --- a/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-open-window.tid +++ b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-open-window.tid @@ -1,11 +1,11 @@ caption: tm-open-window created: 20160424181447704 -modified: 20211117042202771 +modified: 20220219125413255 tags: Messages title: WidgetMessage: tm-open-window type: text/vnd.tiddlywiki -The `tm-open-window` [[message|Message]] opens a tiddler in a new //browser// window. If no parameters are specified, the current tiddler is opened in a new window. Similiar to `tm-modal` any additional parameters passed via the <<.param "paramObject">> are provided as variables to the new window. +The `tm-open-window` [[message|Messages]] opens a tiddler in a new //browser// window. If no parameters are specified, the current tiddler is opened in a new window. Similiar to `tm-modal` any additional parameters passed via the <<.param "paramObject">> are provided as variables to the new window. |!Name |!Description | |param |Title of the tiddler to be opened in a new browser window, defaults to <<.var "currentTiddler">> if empty | @@ -13,12 +13,14 @@ The `tm-open-window` [[message|Message]] opens a tiddler in a new //browser// wi |windowTitle |Title string for the opened window | |width |Width of the new browser window | |height |Height of the new browser window | +|left|<<.from-version "5.2.2">> Optional, left position of new browser window| +|top|<<.from-version "5.2.2">> Optional, top position of new browser window| |paramObject |Hashmap of variables to be provided to the modal, contains all extra parameters passed to the widget sending the message. | The `tm-open-window` message is best generated with the ActionSendMessageWidget, which in turn is triggered by a widget such as the ButtonWidget. It is handled by the core itself. -<<.tip """When used with the ActionSendMessage Widget, <<.param 'param'>> becomes <<.param '$param'>> """>> -<<.tip """Parameters <<.param template>>, <<.param windowTitle>>, <<.param width>>, and <<.param height>> require the ActionSendMessageWidget.""">> +<<.tip """When used with the ActionSendMessageWidget, <<.param 'param'>> becomes <<.param '$param'>> """>> +<<.tip """Parameters <<.param template>>, <<.param windowTitle>>, <<.param width>>, <<.param height>>, <<.param left>> and <<.param top>> require the ActionSendMessageWidget.""">> <$macrocall $name='wikitext-example-without-html' From 1d0af90ba2c6d70e3fae7d7099b591dbe1eb71ee Mon Sep 17 00:00:00 2001 From: Joshua Fontany Date: Mon, 21 Feb 2022 01:48:29 -0800 Subject: [PATCH 28/35] Extend lookup operator to work with fields and indexes (#5742) * extend lookup op flexibility with 2 parameters * bumped .from macro to .24 * aligned syntax * lookup fixes * bugfix * docs * messed up the tests somehow * docs fix * lookup bugfix * docs * docs * call self.displayError * Revert "call self.displayError" This reverts commit 5d599aa9795f9d816c55378ab6df0a1a691ceed0. * storylist * tests * tests pass --- core/modules/filters/lookup.js | 35 ++++++++++++++--- editions/test/tiddlers/tests/test-filters.js | 2 + .../examples/lookup Operator (Examples).tid | 5 +++ .../tiddlers/filters/lookup Operator.tid | 38 ++++++++++++++----- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/core/modules/filters/lookup.js b/core/modules/filters/lookup.js index 2174e8c47..aaf81729d 100644 --- a/core/modules/filters/lookup.js +++ b/core/modules/filters/lookup.js @@ -5,9 +5,11 @@ module-type: filteroperator Filter operator that looks up values via a title prefix -[lookup:[]] +[lookup::[],[]] -Prepends the prefix to the selected items and returns the specified field value +Prepends the prefix to the selected items and returns the specified +field or index value. If the 2nd suffix does not exist, it defaults to field. +If the second operand is missing it defaults to "text" for fields, and "0" for indexes \*/ (function(){ @@ -20,10 +22,31 @@ Prepends the prefix to the selected items and returns the specified field value Export our filter function */ exports.lookup = function(source,operator,options) { - var results = []; - source(function(tiddler,title) { - results.push(options.wiki.getTiddlerText(operator.operand + title) || operator.suffix || ''); - }); + var results = [], + suffixes = operator.suffixes || [], + defaultSuffix = suffixes[0] ? (suffixes[0][0] || "") : "", + indexSuffix = (suffixes[1] && suffixes[1][0] === "index") ? true : false, + target; + if(operator.operands.length == 2) { + target = operator.operands[1] + } else { + target = indexSuffix ? "0": "text"; + } + if(indexSuffix) { + source(function(tiddler,title) { + var data = options.wiki.extractTiddlerDataItem(operator.operands[0]+title,target,defaultSuffix); + results.push(data); + }); + } else { + source(function(tiddler,title) { + var value = defaultSuffix; + var targetTiddler = options.wiki.getTiddler(operator.operands[0]+title); + if(targetTiddler && targetTiddler.getFieldString(target)) { + value = targetTiddler.getFieldString(target); + } + results.push(value); + }); + } return results; }; diff --git a/editions/test/tiddlers/tests/test-filters.js b/editions/test/tiddlers/tests/test-filters.js index 12e24bcc5..3eebd1dc3 100644 --- a/editions/test/tiddlers/tests/test-filters.js +++ b/editions/test/tiddlers/tests/test-filters.js @@ -211,6 +211,8 @@ Tests the filtering mechanism. it("should handle the lookup operator", function() { expect(wiki.filterTiddlers("Six Seventh 8 +[lookup[Tiddler]]").join(",")).toBe("Missing inaction from TiddlerOne,,Tidd"); expect(wiki.filterTiddlers("Six Seventh 8 +[lookup:8[Tiddler]]").join(",")).toBe("Missing inaction from TiddlerOne,8,Tidd"); + expect(wiki.filterTiddlers("Six Seventh 8 +[lookup:8[Tiddler],[text]]").join(",")).toBe("Missing inaction from TiddlerOne,8,Tidd"); + expect(wiki.filterTiddlers("Six Seventh 8 +[lookup[Tiddler],[tags]]").join(",")).toBe(",one,one"); }); it("should retrieve shadow tiddlers", function() { diff --git a/editions/tw5.com/tiddlers/filters/examples/lookup Operator (Examples).tid b/editions/tw5.com/tiddlers/filters/examples/lookup Operator (Examples).tid index 9aa2cdd5a..0ad0fb6fc 100644 --- a/editions/tw5.com/tiddlers/filters/examples/lookup Operator (Examples).tid +++ b/editions/tw5.com/tiddlers/filters/examples/lookup Operator (Examples).tid @@ -6,3 +6,8 @@ type: text/vnd.tiddlywiki <<.operator-example 1 "[all[shadows+tiddlers]tag[$:/tags/PageControls]lookup[$:/config/PageControlButtons/Visibility/]]" "Retrieve the visibility status of each page control button">> <<.operator-example 2 "[all[shadows+tiddlers]tag[$:/tags/PageControls]lookup:show[$:/config/PageControlButtons/Visibility/]]" "Retrieve the visibility status of each page control button, this time with a default value">> +<<.operator-example 3 "[all[tiddlers]has[plugin-type]removeprefix[$:/plugins/tiddlywiki/]lookup:missing-description:field[$:/plugins/tiddlywiki/],[description]]" "Retrieve the description of all plugin-tiddlers that are in the `$:/plugins/tiddlywiki/` namespace.">> +<<.operator-example 4 "OriginalTiddlerPaths +[lookup:missing-index:index[$:/config/],[HelloThere]]" "Lookup the original tiddler path on disk for the [[Hello There]] tiddler.">> +<<.operator-example 5 "OriginalTiddlerPaths +[lookup:missing-index:index[$:/config/],[MissingTiddler]]" "Lookup the original tiddler path on disk for the [[MissingTiddler]] tiddler.">> +<<.operator-example 6 "HistoryList MissingHistoryList +[lookup:missing-0:index[$:/]]" "Retrieve index `0` from the `$:/HistoryList` and `$:/MissingHistoryList`.">> +<<.operator-example 7 "OriginalTiddlerPaths MissingTiddlerPaths +[lookup:missing-tiddler:index[$:/config/],[$:/key-test]]" "Retrieve index `$:/key-test` from `$:/config/OriginalTiddlerPaths` and `$:/config/MissingTiddlerPaths`.">> diff --git a/editions/tw5.com/tiddlers/filters/lookup Operator.tid b/editions/tw5.com/tiddlers/filters/lookup Operator.tid index 9cbd6d5b5..33c47690c 100644 --- a/editions/tw5.com/tiddlers/filters/lookup Operator.tid +++ b/editions/tw5.com/tiddlers/filters/lookup Operator.tid @@ -1,24 +1,42 @@ caption: lookup created: 20170907103639431 -modified: 20170907144703051 +modified: 20210116081305739 op-input: a [[selection of titles|Title Selection]] -op-output: the lookup values corresponding to each input title -op-parameter: prefix applied to input titles to yield title of lookup tiddler from which value is retrieved -op-parameter-name: P -op-purpose: applies a prefix to each input title to yield the title of a tiddler from which the final value is retrieved -op-suffix: the default value to be used for missing lookups -op-suffix-name: D +op-output: the lookup values corresponding to each lookup tiddler +op-parameter: prefix applied to input titles to yield title of lookup tiddler from which value is retrieved. Now accepts 1 or 2 parameters, see below for details +op-parameter-name: P, T +op-purpose: applies a prefix to each input title to yield the title of a tiddler from which the final value is retrieved. With a single parameter, the default field is "text" and the default index is "0". If a second parameter is provided, that becomes the target field or index. +op-suffix: the default value to be used for missing lookups. This operator can now accept a second suffix of `:index`, see below for details +op-suffix-name: D, I tags: [[Filter Operators]] title: lookup Operator type: text/vnd.tiddlywiki <<.from-version "5.1.15">> -The action of this operator is as follows: +The action of this operator is as follows with 1 parameter: * Apply the specified prefix to each input tiddler title, yielding a new list of tiddler titles -* Transclude the value of each of those tiddlers -** Substitute the default value for missing or empty tiddlers +* Transclude the value of the `text` field each of those tiddlers +** Substitute the default value for missing or empty values +* Return the list of values + +<<.from-version "5.1.24">> + +The use of the `:index` second suffix changes the default lookup location from field: `text` to index: `0`. This is used if no 2nd parameter is provided. + +The action of this operator is as follows with 2 parameters: + +If there are two parameters provided, use the second parameter as the target field or index. + +<<.note """If there is only one parameter given, the filter checks for a second suffix equal to "index". If this suffix is found, the default target index is "0". +In all other cases, the default target field is "text".""">> + +Then: + +* Apply the specified prefix to each input tiddler title, yielding a new list of tiddler titles +* Transclude the value of the target field or index +** Substitute the default value for missing or empty values * Return the list of values <<.operator-examples "lookup">> From d5ff723d4cf82e56efbe2a76ca7198a35e43f1c6 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Mon, 21 Feb 2022 09:49:55 +0000 Subject: [PATCH 29/35] Update version tag for #5742 --- editions/tw5.com/tiddlers/filters/lookup Operator.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/filters/lookup Operator.tid b/editions/tw5.com/tiddlers/filters/lookup Operator.tid index 33c47690c..1a7279f60 100644 --- a/editions/tw5.com/tiddlers/filters/lookup Operator.tid +++ b/editions/tw5.com/tiddlers/filters/lookup Operator.tid @@ -21,7 +21,7 @@ The action of this operator is as follows with 1 parameter: ** Substitute the default value for missing or empty values * Return the list of values -<<.from-version "5.1.24">> +<<.from-version "5.2.2">> The use of the `:index` second suffix changes the default lookup location from field: `text` to index: `0`. This is used if no 2nd parameter is provided. From d6d2bc455c46a333b7572ef493cbbaf49b7e54fb Mon Sep 17 00:00:00 2001 From: Joshua Fontany Date: Mon, 21 Feb 2022 01:53:06 -0800 Subject: [PATCH 30/35] Fix server options (#5899) * removed illegal cahracter in filename * fixes required plugin options & updates docs * Update dev docs * call self.displayError * Revert "call self.displayError" This reverts commit 5d599aa9795f9d816c55378ab6df0a1a691ceed0. * adds path based auth (backwards compatible) * refactor per-route auth * get status bug * server options * server options * server options, new 'server-settings' param * reflow * fix boot.origin * refactor new parameters * restore sitetitle as servername option * Soft reset to master * docs update * tweak wording * docs * cleanup * remove literal string * cleanup docs * formatting * Remove per-path auth * revert get-status * fold in PR 5538 * remove server-options * remove doc * required-plugins a server-parameter, not option --- core/modules/server/server.js | 49 ++++++++++++++----- .../from Heigele and Jurke/Syncadaptor.tid | 4 +- .../tiddlers/webserver/Using HTTPS.tid | 19 ++++++- .../WebServer API_ Get All Tiddlers.tid | 2 +- .../webserver/WebServer Authorization.tid | 18 +++++-- .../webserver/WebServer Parameter_ admin.tid | 8 +++ .../WebServer Parameter_ required-plugins.tid | 8 +++ .../WebServer Parameter_ tls-passphrase.tid | 10 ++++ 8 files changed, 98 insertions(+), 20 deletions(-) create mode 100644 editions/tw5.com/tiddlers/webserver/WebServer Parameter_ admin.tid create mode 100644 editions/tw5.com/tiddlers/webserver/WebServer Parameter_ required-plugins.tid create mode 100644 editions/tw5.com/tiddlers/webserver/WebServer Parameter_ tls-passphrase.tid diff --git a/core/modules/server/server.js b/core/modules/server/server.js index b4859a2b4..eea7a5dbd 100644 --- a/core/modules/server/server.js +++ b/core/modules/server/server.js @@ -34,7 +34,6 @@ function Server(options) { this.authenticators = options.authenticators || []; this.wiki = options.wiki; this.boot = options.boot || $tw.boot; - this.servername = $tw.utils.transliterateToSafeASCII(this.wiki.getTiddlerText("$:/SiteTitle") || "TiddlyWiki5"); // Initialise the variables this.variables = $tw.utils.extend({},this.defaultVariables); if(options.variables) { @@ -44,7 +43,8 @@ function Server(options) { } } } - $tw.utils.extend({},this.defaultVariables,options.variables); + // Setup the default required plugins + this.requiredPlugins = this.get("required-plugins").split(','); // Initialise CSRF this.csrfDisable = this.get("csrf-disable") === "yes"; // Initialize Gzip compression @@ -52,14 +52,24 @@ function Server(options) { // Initialize browser-caching this.enableBrowserCache = this.get("use-browser-cache") === "yes"; // Initialise authorization - var authorizedUserName = (this.get("username") && this.get("password")) ? this.get("username") : "(anon)"; + var authorizedUserName; + if(this.get("username") && this.get("password")) { + authorizedUserName = this.get("username"); + } else if(this.get("credentials")) { + authorizedUserName = "(authenticated)"; + } else { + authorizedUserName = "(anon)"; + } this.authorizationPrincipals = { readers: (this.get("readers") || authorizedUserName).split(",").map($tw.utils.trim), writers: (this.get("writers") || authorizedUserName).split(",").map($tw.utils.trim) } + if(this.get("admin") || authorizedUserName !== "(anon)") { + this.authorizationPrincipals["admin"] = (this.get("admin") || authorizedUserName).split(',').map($tw.utils.trim) + } // Load and initialise authenticators $tw.modules.forEachModuleOfType("authenticator", function(title,authenticatorDefinition) { - // console.log("Loading server route " + title); + // console.log("Loading authenticator " + title); self.addAuthenticator(authenticatorDefinition.AuthenticatorClass); }); // Load route handlers @@ -71,15 +81,21 @@ function Server(options) { this.listenOptions = null; this.protocol = "http"; var tlsKeyFilepath = this.get("tls-key"), - tlsCertFilepath = this.get("tls-cert"); + tlsCertFilepath = this.get("tls-cert"), + tlsPassphrase = this.get("tls-passphrase"); if(tlsCertFilepath && tlsKeyFilepath) { this.listenOptions = { key: fs.readFileSync(path.resolve(this.boot.wikiPath,tlsKeyFilepath),"utf8"), - cert: fs.readFileSync(path.resolve(this.boot.wikiPath,tlsCertFilepath),"utf8") + cert: fs.readFileSync(path.resolve(this.boot.wikiPath,tlsCertFilepath),"utf8"), + passphrase: tlsPassphrase || '' }; this.protocol = "https"; } this.transport = require(this.protocol); + // Name the server and init the boot state + this.servername = $tw.utils.transliterateToSafeASCII(this.get("server-name") || this.wiki.getTiddlerText("$:/SiteTitle") || "TiddlyWiki5"); + this.boot.origin = this.get("origin")? this.get("origin"): this.protocol+"://"+this.get("host")+":"+this.get("port"); + this.boot.pathPrefix = this.get("path-prefix") || ""; } /* @@ -150,6 +166,7 @@ function sendResponse(request,response,statusCode,headers,data,encoding) { Server.prototype.defaultVariables = { port: "8080", host: "127.0.0.1", + "required-plugins": "$:/plugins/tiddlywiki/filesystem,$:/plugins/tiddlywiki/tiddlyweb", "root-tiddler": "$:/core/save/all", "root-render-type": "text/plain", "root-serve-type": "text/html", @@ -239,15 +256,15 @@ Server.prototype.requestHandler = function(request,response,options) { state.pathPrefix = options.pathPrefix || this.get("path-prefix") || ""; state.sendResponse = sendResponse.bind(self,request,response); // Get the principals authorized to access this resource - var authorizationType = this.methodMappings[request.method] || "readers"; + state.authorizationType = options.authorizationType || this.methodMappings[request.method] || "readers"; // Check for the CSRF header if this is a write - if(!this.csrfDisable && authorizationType === "writers" && request.headers["x-requested-with"] !== "TiddlyWiki") { + if(!this.csrfDisable && state.authorizationType === "writers" && request.headers["x-requested-with"] !== "TiddlyWiki") { response.writeHead(403,"'X-Requested-With' header required to login to '" + this.servername + "'"); response.end(); return; } // Check whether anonymous access is granted - state.allowAnon = this.isAuthorized(authorizationType,null); + state.allowAnon = this.isAuthorized(state.authorizationType,null); // Authenticate with the first active authenticator if(this.authenticators.length > 0) { if(!this.authenticators[0].authenticateRequest(request,response,state)) { @@ -256,7 +273,7 @@ Server.prototype.requestHandler = function(request,response,options) { } } // Authorize with the authenticated username - if(!this.isAuthorized(authorizationType,state.authenticatedUsername)) { + if(!this.isAuthorized(state.authorizationType,state.authenticatedUsername)) { response.writeHead(401,"'" + state.authenticatedUsername + "' is not authorized to access '" + this.servername + "'"); response.end(); return; @@ -322,8 +339,16 @@ Server.prototype.listen = function(port,host,prefix) { port = process.env[port] || 8080; } // Warn if required plugins are missing - if(!this.wiki.getTiddler("$:/plugins/tiddlywiki/tiddlyweb") || !this.wiki.getTiddler("$:/plugins/tiddlywiki/filesystem")) { - $tw.utils.warning("Warning: Plugins required for client-server operation (\"tiddlywiki/filesystem\" and \"tiddlywiki/tiddlyweb\") are missing from tiddlywiki.info file"); + var missing = []; + for (var index=0; index 0) { + var error = "Warning: Plugin(s) required for client-server operation are missing.\n"+ + "\""+ missing.join("\", \"")+"\""; + $tw.utils.warning(error); } // Create the server var server; diff --git a/editions/dev/tiddlers/from Heigele and Jurke/Syncadaptor.tid b/editions/dev/tiddlers/from Heigele and Jurke/Syncadaptor.tid index 377bc47e5..37c4558d9 100644 --- a/editions/dev/tiddlers/from Heigele and Jurke/Syncadaptor.tid +++ b/editions/dev/tiddlers/from Heigele and Jurke/Syncadaptor.tid @@ -1,10 +1,10 @@ chapter.of: Extended Persistence created: 20140708084850294 -modified: 20140717181245449 +modified: 20210720193245000 sub.num: 3 tags: doc title: Syncadaptor A module with ``module-type: syncadaptor`` provides functionality to get a list of tiddlers (this list is provided as ~SkinnyTiddlers, which are normal tiddlers without the text field) and to load, save and delete single tiddlers. A syncadaptor can also provide functions to login and logout so that syncadaptor modules can be used to synchronize tiddlers with a remote server. -The syncer module only uses one syncadaptor and honours a special [[system tiddler|System Tiddlers]] [[$:/config/SyncFilter]] containing a [[filter string|Tags and Filter Mechanism]]. Tiddlers matching this filter string are not saved to the server with a syncadapter. It uses the [[WebServer API|https://tiddlywiki.com/#WebServer%20API%3A%20Get%20All%20Tiddlers]] to load modified tiddlers from the server, which returns only non-system tiddlers. \ No newline at end of file +The syncer module only uses one syncadaptor and honours a special [[system tiddler|System Tiddlers]] [[$:/config/SyncFilter]] containing a [[filter string|Tags and Filter Mechanism]]. Tiddlers matching this filter string are saved to the server with a syncadapter. It uses the [[WebServer API|https://tiddlywiki.com/#WebServer%20API%3A%20Get%20All%20Tiddlers]] to load modified tiddlers from the server, which returns only non-system tiddlers. diff --git a/editions/tw5.com/tiddlers/webserver/Using HTTPS.tid b/editions/tw5.com/tiddlers/webserver/Using HTTPS.tid index 52d3aab96..5451de585 100644 --- a/editions/tw5.com/tiddlers/webserver/Using HTTPS.tid +++ b/editions/tw5.com/tiddlers/webserver/Using HTTPS.tid @@ -1,12 +1,14 @@ created: 20180702160923664 -modified: 20180703100549667 +modified: 20211111023610539 tags: [[WebServer Guides]] title: Using HTTPS type: text/vnd.tiddlywiki By default, TiddlyWiki's WebServer serves resources over the insecure HTTP protocol. The risk is minimal if it is only being used within a private, trusted network but in many situations it is desirable to use a secure HTTPS connection. -HTTPS requires the server to be configured with a certificate via a "cert" file and a "key" file, configured via the [[tls-cert|WebServer Parameter: tls-cert]] and [[tls-key|WebServer Parameter: tls-key]] parameters +HTTPS requires the server to be configured with a certificate via a "cert" file and a "key" file, configured via the [[tls-cert|WebServer Parameter: tls-cert]] and [[tls-key|WebServer Parameter: tls-key]] parameters. + +The optional [[tls-passphrase|WebServer Parameter: tls-passphrase]] parameter allows the server to use certificate files that have been generated with a passphrase/password. Certificates can be obtained from a certification authority such as https://letsencrypt.org/, or you can create a self-signed certificate for internal testing. @@ -17,3 +19,16 @@ openssl req -newkey rsa:2048 -new -nodes -keyout mywikifolder/key.pem -out mywik openssl x509 -req -days 365 -in mywikifolder/csr.pem -signkey mywikifolder/key.pem -out mywikifolder/server.crt tiddlywiki mywikifolder --listen username=joe password=bloggs tls-key=key.pem tls-cert=server.crt ``` + +If using a [[tls-passphrase|WebServer Parameter: tls-passphrase]] to generate the certificate files, the commands would change as below: + +* remove the `-nodes` flag, which specifies "no encryption" +* replace `TLS_PASSPHRASE` in the `-passout` and `-passin` parameters in the below commands with your chosen string. + +This is the simplest, but __least secure method,__ of passing a passphrase to the certificate utility. See [[this Stack Exchange anwser on openssl certificates|https://security.stackexchange.com/questions/106525/generate-csr-and-private-key-with-password-with-openssl]] and the [[openssl|https://www.openssl.org/docs/man1.0.2/man1/openssl.html]] and [[openssl-passphrase-options|https://www.openssl.org/docs/manmaster/man1/openssl-passphrase-options.html]] page in the openssl utility documentation. + +``` +openssl req -newkey rsa:2048 -passout pass:TLS_PASSPHRASE -new -keyout mywikifolder/key.pem -out mywikifolder/csr.pem -passout pass:TLS_PASSPHRASE +openssl x509 -req -days 365 -in mywikifolder/csr.pem -signkey mywikifolder/key.pem -out mywikifolder/server.crt -passin pass:TLS_PASSPHRASE +tiddlywiki mywikifolder --listen username=joe password=bloggs tls-key=key.pem tls-cert=server.crt tls-passphrase=TLS_PASSPHRASE +``` diff --git a/editions/tw5.com/tiddlers/webserver/WebServer API_ Get All Tiddlers.tid b/editions/tw5.com/tiddlers/webserver/WebServer API_ Get All Tiddlers.tid index 52ca8964f..45bd1e27e 100644 --- a/editions/tw5.com/tiddlers/webserver/WebServer API_ Get All Tiddlers.tid +++ b/editions/tw5.com/tiddlers/webserver/WebServer API_ Get All Tiddlers.tid @@ -20,7 +20,7 @@ In order to avoid denial of service attacks with malformed filters in the defaul To enable a particular filter, create a tiddler with the title "$:/config/Server/ExternalFilters/" concatenated with the filter text, and the text field set to "yes". For example, the TiddlyWeb plugin includes the following shadow tiddler to enable the filter that it requires: ``` -title: $:/config/Server/ExternalFilters/[all[tiddlers]] -[[$:/isEncrypted]] -[prefix[$:/temp/]] -[prefix[$:/status/]] +title: $:/config/Server/ExternalFilters/[all[tiddlers]] -[[$:/isEncrypted]] -[prefix[$:/temp/]] -[prefix[$:/status/]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] -[[$:/library/sjcl.js]] -[[$:/core]] text: yes ``` diff --git a/editions/tw5.com/tiddlers/webserver/WebServer Authorization.tid b/editions/tw5.com/tiddlers/webserver/WebServer Authorization.tid index 49ba60a6c..89cae2d58 100644 --- a/editions/tw5.com/tiddlers/webserver/WebServer Authorization.tid +++ b/editions/tw5.com/tiddlers/webserver/WebServer Authorization.tid @@ -1,18 +1,24 @@ created: 20180630194006239 -modified: 20180904174030250 +modified: 20211122004159427 tags: WebServer title: WebServer Authorization type: text/vnd.tiddlywiki -''Authorization'' is the process of determining which resources may be accessed by a particular user. It occurs after [[authentication|WebServer Authentication]] has determined the identity of the user. TiddlyWiki's WebServer implements a simple authorization scheme which permits independent control of who has read and write access to a wiki. +''Authorization'' is the process of determining which resources may be accessed by a particular user. It occurs after [[authentication|WebServer Authentication]] has determined the identity of the user. TiddlyWiki's WebServer implements a simple authorization scheme which permits independent control of who has administrator access to the server, and read and write access to a wiki. -The WebServer parameters [[readers|WebServer Parameter: readers]] and [[writers|WebServer Parameter: writers]] each contain a comma separated list of //principals// (which is to say, either usernames or certain special tokens) which should have read or write access respectively. +The WebServer parameters [[admin|WebServer Parameter: admin]], [[readers|WebServer Parameter: readers]] and [[writers|WebServer Parameter: writers]] each contain a comma separated list of //principals// (which is to say, either usernames or certain special tokens) which should have read or write access respectively. The available special tokens are: * ''(anon)'' - indicates all anonymous users * ''(authenticated)'' - indicates all authenticated users +!! Admin Functions + +<<.tip"""The ''(anon)'' token is not valid for the [[admin|WebServer Parameter: admin]] parameter.""">> + +At this time, no server functions are restricted to ''admin'' authorized users in the unmodified [[Tiddlywiki server|WebServer]]. Third party plugins can leverage this to restrict routes or commands to a subset of authorized users. + !! Read-only Mode Read-only mode is engaged when the current user is not authorized to write to the current wiki. @@ -39,3 +45,9 @@ In the following example, read access is granted to all authenticated users, but ``` tiddlywiki mywikifolder --listen credentials=myusers.csv "readers=(authenticated)" writers=mary ``` + +In the following example, read and write access is granted to all authenticated users, but only "mary" is granted admin access: + +``` +tiddlywiki mywikifolder --listen credentials=myusers.csv "readers=(authenticated)" "writers=(authenticated)" admin=mary +``` diff --git a/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ admin.tid b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ admin.tid new file mode 100644 index 000000000..6eb8a3264 --- /dev/null +++ b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ admin.tid @@ -0,0 +1,8 @@ +caption: admin +created: 20211111015634164 +modified: 20211111023141767 +tags: [[WebServer Parameters]] +title: WebServer Parameter: admin +type: text/vnd.tiddlywiki + +The [[web server configuration parameter|WebServer Parameters]] ''admin'' is used to specify the security principals with administrator access to the [[WebServer]]. Does not accept the ''(anon)'' special token. See [[WebServer Authorization]] for more details. diff --git a/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ required-plugins.tid b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ required-plugins.tid new file mode 100644 index 000000000..edbc09417 --- /dev/null +++ b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ required-plugins.tid @@ -0,0 +1,8 @@ +caption: required-plugins +created: 20211226160733000 +modified: 20211226160754000 +tags: [[WebServer Parameters]] +title: WebServer Parameter: required-plugins +type: text/vnd.tiddlywiki + +The [[web server configuration parameter|WebServer Parameters]] ''required-plugins'' is used to specify the plugins required to start the [[WebServer]]. It take a comma seperated list of plugin titles. The WebServer will issue a warnign in the console if the required plugins are not loaded. This parameter defaults to `$:/plugins/tiddlywiki/filesystem,$:/plugins/tiddlywiki/tiddlyweb`. diff --git a/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ tls-passphrase.tid b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ tls-passphrase.tid new file mode 100644 index 000000000..31c08c7c0 --- /dev/null +++ b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ tls-passphrase.tid @@ -0,0 +1,10 @@ +caption: tls-passphrase +created: 20211111004416873 +modified: 20211111022120158 +tags: [[WebServer Parameters]] +title: WebServer Parameter: tls-passphrase +type: text/vnd.tiddlywiki + +The optional [[web server configuration parameter|WebServer Parameters]] ''tls-passphrase'' contains the "certificate passphrase", a string used to decrypt the certificate file used when running the web server under HTTPS. + +See [[Using HTTPS]] for details. From 8af99878cc04e0941f7b618757325646a169ffee Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Mon, 21 Feb 2022 09:56:05 +0000 Subject: [PATCH 31/35] Add version tags for #5899 --- editions/tw5.com/tiddlers/webserver/Using HTTPS.tid | 2 +- .../tw5.com/tiddlers/webserver/WebServer Parameter_ admin.tid | 2 +- .../webserver/WebServer Parameter_ required-plugins.tid | 2 +- .../tiddlers/webserver/WebServer Parameter_ tls-passphrase.tid | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/editions/tw5.com/tiddlers/webserver/Using HTTPS.tid b/editions/tw5.com/tiddlers/webserver/Using HTTPS.tid index 5451de585..d364f53f6 100644 --- a/editions/tw5.com/tiddlers/webserver/Using HTTPS.tid +++ b/editions/tw5.com/tiddlers/webserver/Using HTTPS.tid @@ -8,7 +8,7 @@ By default, TiddlyWiki's WebServer serves resources over the insecure HTTP proto HTTPS requires the server to be configured with a certificate via a "cert" file and a "key" file, configured via the [[tls-cert|WebServer Parameter: tls-cert]] and [[tls-key|WebServer Parameter: tls-key]] parameters. -The optional [[tls-passphrase|WebServer Parameter: tls-passphrase]] parameter allows the server to use certificate files that have been generated with a passphrase/password. +<<.from-version "5.2.2">> The optional [[tls-passphrase|WebServer Parameter: tls-passphrase]] parameter allows the server to use certificate files that have been generated with a passphrase/password. Certificates can be obtained from a certification authority such as https://letsencrypt.org/, or you can create a self-signed certificate for internal testing. diff --git a/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ admin.tid b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ admin.tid index 6eb8a3264..07c123dfa 100644 --- a/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ admin.tid +++ b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ admin.tid @@ -5,4 +5,4 @@ tags: [[WebServer Parameters]] title: WebServer Parameter: admin type: text/vnd.tiddlywiki -The [[web server configuration parameter|WebServer Parameters]] ''admin'' is used to specify the security principals with administrator access to the [[WebServer]]. Does not accept the ''(anon)'' special token. See [[WebServer Authorization]] for more details. +<<.from-version "5.2.2">> The [[web server configuration parameter|WebServer Parameters]] ''admin'' is used to specify the security principals with administrator access to the [[WebServer]]. Does not accept the ''(anon)'' special token. See [[WebServer Authorization]] for more details. diff --git a/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ required-plugins.tid b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ required-plugins.tid index edbc09417..492a8f537 100644 --- a/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ required-plugins.tid +++ b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ required-plugins.tid @@ -5,4 +5,4 @@ tags: [[WebServer Parameters]] title: WebServer Parameter: required-plugins type: text/vnd.tiddlywiki -The [[web server configuration parameter|WebServer Parameters]] ''required-plugins'' is used to specify the plugins required to start the [[WebServer]]. It take a comma seperated list of plugin titles. The WebServer will issue a warnign in the console if the required plugins are not loaded. This parameter defaults to `$:/plugins/tiddlywiki/filesystem,$:/plugins/tiddlywiki/tiddlyweb`. +<<.from-version "5.2.2">> The [[web server configuration parameter|WebServer Parameters]] ''required-plugins'' is used to specify the plugins required to start the [[WebServer]]. It take a comma seperated list of plugin titles. The WebServer will issue a warnign in the console if the required plugins are not loaded. This parameter defaults to `$:/plugins/tiddlywiki/filesystem,$:/plugins/tiddlywiki/tiddlyweb`. diff --git a/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ tls-passphrase.tid b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ tls-passphrase.tid index 31c08c7c0..abd0cda36 100644 --- a/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ tls-passphrase.tid +++ b/editions/tw5.com/tiddlers/webserver/WebServer Parameter_ tls-passphrase.tid @@ -5,6 +5,6 @@ tags: [[WebServer Parameters]] title: WebServer Parameter: tls-passphrase type: text/vnd.tiddlywiki -The optional [[web server configuration parameter|WebServer Parameters]] ''tls-passphrase'' contains the "certificate passphrase", a string used to decrypt the certificate file used when running the web server under HTTPS. +<<.from-version "5.2.2">> The optional [[web server configuration parameter|WebServer Parameters]] ''tls-passphrase'' contains the "certificate passphrase", a string used to decrypt the certificate file used when running the web server under HTTPS. See [[Using HTTPS]] for details. From 6b4e5c74ad34d006266afb56f48f611b06555bc3 Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Mon, 21 Feb 2022 16:05:34 +0100 Subject: [PATCH 32/35] Add "some" flag to search operator (#6293) --- core/modules/filters/search.js | 1 + core/modules/wiki.js | 24 ++++++++++-- editions/test/tiddlers/tests/test-filters.js | 37 ++++++++++++++++++- .../tiddlers/filters/examples/search.tid | 7 +++- editions/tw5.com/tiddlers/filters/search.tid | 19 +++++----- 5 files changed, 72 insertions(+), 16 deletions(-) diff --git a/core/modules/filters/search.js b/core/modules/filters/search.js index adcb076a0..dcb534c07 100644 --- a/core/modules/filters/search.js +++ b/core/modules/filters/search.js @@ -40,6 +40,7 @@ exports.search = function(source,operator,options) { invert: invert, field: fields, excludeField: excludeFields, + some: hasFlag("some"), caseSensitive: hasFlag("casesensitive"), literal: hasFlag("literal"), whitespace: hasFlag("whitespace"), diff --git a/core/modules/wiki.js b/core/modules/wiki.js index a784a5d43..99abe6b47 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -1201,23 +1201,28 @@ Return an array of tiddler titles that match a search string text: The text string to search for options: see below Options available: - source: an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title) + source: an iterator function for the source tiddlers, called source(iterator), + where iterator is called as iterator(tiddler,title) exclude: An array of tiddler titles to exclude from the search invert: If true returns tiddlers that do not contain the specified string caseSensitive: If true forces a case sensitive search field: If specified, restricts the search to the specified field, or an array of field names anchored: If true, forces all but regexp searches to be anchored to the start of text excludeField: If true, the field options are inverted to specify the fields that are not to be searched + The search mode is determined by the first of these boolean flags to be true literal: searches for literal string whitespace: same as literal except runs of whitespace are treated as a single space regexp: treats the search term as a regular expression - words: (default) treats search string as a list of tokens, and matches if all tokens are found, regardless of adjacency or ordering + words: (default) treats search string as a list of tokens, and matches if all tokens are found, + regardless of adjacency or ordering + some: treats search string as a list of tokens, and matches if at least ONE token is found */ exports.search = function(text,options) { options = options || {}; var self = this, t, + regExpStr="", invert = !!options.invert; // Convert the search string into a regexp for each term var terms, searchTermsRegExps, @@ -1244,7 +1249,18 @@ exports.search = function(text,options) { searchTermsRegExps = null; console.log("Regexp error parsing /(" + text + ")/" + flags + ": ",e); } - } else { + } else if(options.some) { + terms = text.trim().split(/ +/); + if(terms.length === 1 && terms[0] === "") { + searchTermsRegExps = null; + } else { + searchTermsRegExps = []; + for(t=0; t <$macrocall $name=".operator-example" n="8" eg="[!is[system]search::literal,casesensitive[The first]]" ie="non-system tiddlers containing a case-sensitive match for the literal phrase <<.word 'The first'>>"/> <$macrocall $name=".operator-example" n="9" eg="[search:caption,description:casesensitive,words[arch]]" ie="any tiddlers containing a case-sensitive match for the word `arch` in their <<.field caption>> or <<.field description>> fields"/> +<$macrocall $name=".operator-example" n="10" eg="[search:tags:some[how test]]" ie="any tiddlers containing at least 1 of the search terms in the field: <<.field tags>>"/> +<$macrocall $name=".operator-example" n="11" eg="[search:tags:some,casesensitive[how test]]" ie="any tiddlers containing at least 1 of the case-sensitive search terms in the field: <<.field tags>>"/> +<$macrocall $name=".operator-example" n="12" eg="[search:tags,title:some,anchored[how test]]" ie="any tiddlers containing at least 1 of anchored search terms in the fields: <<.field tags>> and <<.field title>>"/> + + diff --git a/editions/tw5.com/tiddlers/filters/search.tid b/editions/tw5.com/tiddlers/filters/search.tid index 3aba89bf1..94d9d3222 100644 --- a/editions/tw5.com/tiddlers/filters/search.tid +++ b/editions/tw5.com/tiddlers/filters/search.tid @@ -1,15 +1,15 @@ +caption: search created: 20140410103123179 -modified: 20190731212738712 +modified: 20211129120739275 +op-input: a [[selection of titles|Title Selection]] +op-neg-output: those input tiddlers in which <<.em not>> all of the search terms can be found +op-output: those input tiddlers in which <<.em all>> of the search terms can be found in the value of field <<.place F>> +op-parameter: one or more search terms, separated by spaces, or a literal search string +op-purpose: filter the input by searching tiddler content +op-suffix: the <<.op search>> operator uses a rich suffix, see below for details tags: [[Filter Operators]] [[Common Operators]] [[Field Operators]] [[Negatable Operators]] title: search Operator type: text/vnd.tiddlywiki -caption: search -op-purpose: filter the input by searching tiddler content -op-input: a [[selection of titles|Title Selection]] -op-suffix: the <<.op search>> operator uses a rich suffix, see below for details -op-parameter: one or more search terms, separated by spaces, or a literal search string -op-output: those input tiddlers in which <<.em all>> of the search terms can be found in the value of field <<.place F>> -op-neg-output: those input tiddlers in which <<.em not>> all of the search terms can be found <<.from-version "5.1.18">> The search filter operator was significantly enhanced in 5.1.18. Earlier versions do not support the extended syntax and therefore do not permit searching multiple fields, or the ''literal'' or ''casesensitive'' options. @@ -38,7 +38,8 @@ The available flags are: ** ''literal'': considers the search string to be a literal string, and requires an exact match ** ''whitespace'': considers the search string to be a literal string, but will consider all runs of whitespace to be equivalent to a single space. Thus `A B` matches `A B` ** ''regexp'': treats the search string as a regular expression. Note that the ''regexp'' option obviates the need for the older <<.olink regexp>> operator. -** ''words'': (the default) treats the search string as a list of tokens separated by whitespace, and matches if all of the tokens appear in the string (regardless of ordering and whether there is other text in between) +** ''words'': (the default) treats the search string as a list of tokens separated by whitespace, and matches if ''all of the tokens'' appear in the string (regardless of ordering and whether there is other text in between) +** ''some'': <<.from-version "5.2.1">> treats the search string as a list of tokens separated by whitespace, and matches if ''at least one'' of the tokens appear in the string * ''casesensitive'': if present, this flag forces a case-sensitive match, where upper and lower case letters are considered different. By default, upper and lower case letters are considered identical for matching purposes. * ''anchored'': <<.from-version "5.1.20">> anchors the search to the start of the string (applies to ''whitespace'', ''literal'' and ''words'' modes) From af87727ffcb1c3e4c84ac9d1686a15e28004a36b Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Mon, 21 Feb 2022 15:06:39 +0000 Subject: [PATCH 33/35] Adjust version tag for #6293 --- editions/tw5.com/tiddlers/filters/search.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/filters/search.tid b/editions/tw5.com/tiddlers/filters/search.tid index 94d9d3222..6a6438b9f 100644 --- a/editions/tw5.com/tiddlers/filters/search.tid +++ b/editions/tw5.com/tiddlers/filters/search.tid @@ -39,7 +39,7 @@ The available flags are: ** ''whitespace'': considers the search string to be a literal string, but will consider all runs of whitespace to be equivalent to a single space. Thus `A B` matches `A B` ** ''regexp'': treats the search string as a regular expression. Note that the ''regexp'' option obviates the need for the older <<.olink regexp>> operator. ** ''words'': (the default) treats the search string as a list of tokens separated by whitespace, and matches if ''all of the tokens'' appear in the string (regardless of ordering and whether there is other text in between) -** ''some'': <<.from-version "5.2.1">> treats the search string as a list of tokens separated by whitespace, and matches if ''at least one'' of the tokens appear in the string +** ''some'': <<.from-version "5.2.2">> treats the search string as a list of tokens separated by whitespace, and matches if ''at least one'' of the tokens appear in the string * ''casesensitive'': if present, this flag forces a case-sensitive match, where upper and lower case letters are considered different. By default, upper and lower case letters are considered identical for matching purposes. * ''anchored'': <<.from-version "5.1.20">> anchors the search to the start of the string (applies to ''whitespace'', ''literal'' and ''words'' modes) From a4ab42da8a5c9a5dcada28c9423211c4f73d1ec4 Mon Sep 17 00:00:00 2001 From: Cameron Fischer Date: Mon, 21 Feb 2022 10:07:30 -0500 Subject: [PATCH 34/35] findListingsOfTiddler should cache results (#6327) * findListingsOfTiddler uses FieldIndexer now * Turns out FieldIndexer can't help listed[] --- core/modules/wiki.js | 25 ++++++++++++++------ editions/test/tiddlers/tests/test-filters.js | 5 ++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 99abe6b47..23d0c0d26 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -639,14 +639,25 @@ Lookup a given tiddler and return a list of all the tiddlers that include it in */ exports.findListingsOfTiddler = function(targetTitle,fieldName) { fieldName = fieldName || "list"; - var titles = []; - this.each(function(tiddler,title) { - var list = $tw.utils.parseStringArray(tiddler.fields[fieldName]); - if(list && list.indexOf(targetTitle) !== -1) { - titles.push(title); - } + var wiki = this; + var listings = this.getGlobalCache("listings-" + fieldName,function() { + var listings = Object.create(null); + wiki.each(function(tiddler,title) { + var list = $tw.utils.parseStringArray(tiddler.fields[fieldName]); + if(list) { + for(var i = 0; i < list.length; i++) { + var listItem = list[i], + listing = listings[listItem] || []; + if (listing.indexOf(title) === -1) { + listing.push(title); + } + listings[listItem] = listing; + } + } + }); + return listings; }); - return titles; + return listings[targetTitle] || []; }; /* diff --git a/editions/test/tiddlers/tests/test-filters.js b/editions/test/tiddlers/tests/test-filters.js index 12d372a5b..2115e4d7d 100644 --- a/editions/test/tiddlers/tests/test-filters.js +++ b/editions/test/tiddlers/tests/test-filters.js @@ -395,6 +395,11 @@ Tests the filtering mechanism. expect(wiki.filterTiddlers("[list[TiddlerSeventh]sort[title]]").join(",")).toBe("a fourth tiddler,MissingTiddler,Tiddler Three,TiddlerOne"); expect(wiki.filterTiddlers("[tag[one]list[TiddlerSeventh]sort[title]]").join(",")).toBe("a fourth tiddler,MissingTiddler,Tiddler Three,TiddlerOne"); }); + + it("should handle the listed operator", function() { + expect(wiki.filterTiddlers("TiddlerOne MissingTiddler +[listed[]]").join(",")).toBe('one,hasList'); + expect(wiki.filterTiddlers("one two +[listed[tags]]").join(",")).toBe('TiddlerOne,$:/TiddlerTwo,Tiddler Three'); + }); it("should handle the next operator", function() { expect(wiki.filterTiddlers("[[Tiddler Three]next[TiddlerSeventh]]").join(",")).toBe("a fourth tiddler"); From ab3109d84b4ae748cc1fa0dc62b54acb5b9851b8 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Mon, 21 Feb 2022 15:24:06 +0000 Subject: [PATCH 35/35] Add support for directly setting style.* attributes on HTML elements (#6388) * Support direct style attributes on the element widget * Fix tests Not all parse tree nodes have an "orderedAttributes" member (eg. the error message generated at https://github.com/Jermolene/TiddlyWiki5/blob/5613bcc8849bd979505eb442c7c2b9b0d2eeff19/core/modules/widgets/transclude.js#L73-L75) * Ensure ordering isn't insertion dependent if orderedAttributes is missing * Add docs --- core/modules/widgets/widget.js | 44 +++++++++++++------ .../tiddlers/wikitext/HTML in WikiText.tid | 20 +++++++++ 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/core/modules/widgets/widget.js b/core/modules/widgets/widget.js index 0ba2444b6..c6b49f04a 100755 --- a/core/modules/widgets/widget.js +++ b/core/modules/widgets/widget.js @@ -314,24 +314,40 @@ excludeEventAttributes: ignores attributes whose name begins with "on" Widget.prototype.assignAttributes = function(domNode,options) { options = options || {}; var self = this; - $tw.utils.each(this.attributes,function(v,a) { - // Check exclusions - if(options.excludeEventAttributes && a.substr(0,2) === "on") { - v = undefined; + var assignAttribute = function(name,value) { + // Check for excluded attribute names + if(options.excludeEventAttributes && name.substr(0,2) === "on") { + value = undefined; } - if(v !== undefined) { - var b = a.split(":"); - // Setting certain attributes can cause a DOM error (eg xmlns on the svg element) - try { - if (b.length == 2 && b[0] == "xlink"){ - domNode.setAttributeNS("http://www.w3.org/1999/xlink",b[1],v); - } else { - domNode.setAttributeNS(null,a,v); + if(value !== undefined) { + // Handle the xlink: namespace + var namespace = null; + if(name.substr(0,6) === "xlink:" && name.length > 6) { + namespace = "http://www.w3.org/1999/xlink"; + name = name.substr(6); + } + // Handle styles + if(name.substr(0,6) === "style." && name.length > 6) { + domNode.style[$tw.utils.unHyphenateCss(name.substr(6))] = value; + } else { + // Setting certain attributes can cause a DOM error (eg xmlns on the svg element) + try { + domNode.setAttributeNS(namespace,name,value); + } catch(e) { } - } catch(e) { } } - }); + } + // Not all parse tree nodes have the orderedAttributes property + if(this.parseTreeNode.orderedAttributes) { + $tw.utils.each(this.parseTreeNode.orderedAttributes,function(attribute,index) { + assignAttribute(attribute.name,self.attributes[attribute.name]); + }); + } else { + $tw.utils.each(Object.keys(self.attributes).sort(),function(name) { + assignAttribute(name,self.attributes[name]); + }); + } }; /* diff --git a/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid b/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid index d510c3d08..db6f00429 100644 --- a/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid +++ b/editions/tw5.com/tiddlers/wikitext/HTML in WikiText.tid @@ -58,6 +58,26 @@ In an extension of conventional HTML syntax, attributes of elements/widgets can * a transclusion of a [[macro/variable|Macros in WikiText]] * as the result of a [[Filter Expression]] +!! Style Attributes + +<<.from-version "5.2.2">> TiddlyWiki supports the usual HTML ''style'' attribute for assigning CSS styles to elements: + +``` +
Hello
+``` + +In an extension to HTML, TiddlyWiki also supports accessing individual CSS styles as independent attributes. For example: + +``` +
Hello
+``` + +The advantage of this syntax is that it simplifies assigning computed values to CSS styles. For example: + +``` +
Hello
+``` + !! Literal Attribute Values Literal attribute values can use several different styles of quoting: