1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 01:20:30 +00:00

Merge branch 'master' into geospatial-plugin

This commit is contained in:
jeremy@jermolene.com 2023-05-30 18:42:49 +01:00
commit cf44e0b8e4
30 changed files with 248 additions and 54 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
.DS_Store
.c9/
.vs/
.vscode/
tmp/
output/

View File

@ -569,26 +569,17 @@ $tw.utils.getTypeEncoding = function(ext) {
return typeInfo ? typeInfo.encoding : "utf8";
};
var polyfill =[
"// this polyfills the globalThis variable",
"// using the this variable on a getter ",
"// inserted into the prototype of globalThis",
"(function() {",
" if (typeof globalThis === 'object') return;",
" // node.green says this is available since 0.10.48",
" Object.prototype.__defineGetter__('__temp__', function() {",
" return this;",
" });",
" __temp__.globalThis = __temp__;",
" delete Object.prototype.__temp__;",
"}());"
].join("\n");
var globalCheck =[
" if(Object.keys(globalThis).length){",
" console.log(Object.keys(globalThis));",
" Object.defineProperty(Object.prototype, '__temp__', {",
" get: function () { return this; },",
" configurable: true",
" });",
" if(Object.keys(__temp__).length){",
" console.log(Object.keys(__temp__));",
" delete Object.prototype.__temp__;",
" throw \"Global assignment is not allowed within modules on node.\";",
" }"
" }",
" delete Object.prototype.__temp__;",
].join('\n');
/*
@ -604,7 +595,6 @@ $tw.utils.evalGlobal = function(code,context,filename,sandbox,allowGlobals) {
});
// Add the code prologue and epilogue
code = [
(!$tw.browser ? polyfill : ""),
"(function(" + contextNames.join(",") + ") {",
" (function(){\n" + code + "\n;})();",
(!$tw.browser && sandbox && !allowGlobals) ? globalCheck : "",

View File

@ -18,7 +18,7 @@ All parameters are optional with safe defaults, and can be specified in any orde
* ''anon-username'' - the username for signing edits for anonymous users
* ''username'' - optional username for basic authentication
* ''password'' - optional password for basic authentication
* ''authenticated-user-header'' - optional name of header to be used for trusted authentication
* ''authenticated-user-header'' - optional name of request header to be used for trusted authentication.
* ''readers'' - comma-separated list of principals allowed to read from this wiki
* ''writers'' - comma-separated list of principals allowed to write to this wiki
* ''csrf-disable'' - set to "yes" to disable CSRF checks (defaults to "no")

View File

@ -37,7 +37,7 @@ HeaderAuthenticator.prototype.authenticateRequest = function(request,response,st
return false;
} else {
// authenticatedUsername will be undefined for anonymous users
state.authenticatedUsername = username;
state.authenticatedUsername = $tw.utils.decodeURIComponentSafe(username);
return true;
}
};

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
The edit template body cascade is a [[cascade|Cascades]] used by the default edit template to choose the template for displaying the tiddler body.
The core edit template body cascade can be found in $:/core/ui/EditTemplate/body
The default edit template body cascade consists of:
# If the tiddler has the field ''_canonical_uri'' then use the template $:/core/ui/EditTemplate/body/canonical-uri to display the remote URL
@ -13,4 +15,4 @@ The default edit template body cascade consists of:
You can see the current settings for the view template body cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Edit Template Body'' tab.
<<list-links "[tag[Edit Template Body Cascade]]">>
<<list-links "[tag[Edit Template Body Cascade]]">>

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
The field editor cascade is a [[cascade|Cascades]] used to choose a template for rendering the field editor within the [[EditTemplate|$:/core/ui/EditTemplate/fields]].
The core field editor cascade can be found in $:/core/ui/EditTemplate/fields
The default field editor cascade only contains one element:
# Use the tiddler $:/core/ui/EditTemplate/fieldEditor/default to render the field
@ -14,4 +16,4 @@ See [[Customizing EditTemplate field rendering]] for more details.
You can see the current settings for the field editor cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Field Editor'' tab.
<<list-links "[tag[Tiddler Field Editor Cascade]]">>
<<list-links "[tag[Tiddler Field Editor Cascade]]">>

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
"Story tiddler template" refers to the template used to display a tiddler within the story river.
The core story tiddler template can be found in $:/core/ui/StoryTiddlerTemplate
The [[Story Tiddler Template Cascade]] is used to choose the template to be used for a particular tiddler. By default, the edit template is used for tiddlers in draft mode, and the view template used otherwise.
See also:

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
The tiddler colour cascade is a [[cascade|Cascades]] used to choose which colour should be used for a particular tiddler.
Core tiddler colour cascades can be found in $:/core/macros/tag, $:/core/ui/Components/tag-link, $:/core/ui/EditTemplate/tags, $:/core/ui/TagPickerTagTemplate, $:/core/ui/TagTemplate and $:/core/ui/ViewTemplate/title
The default tiddler colour cascade consists of:
# If the tiddler has a ''color'' field, use the value as the colour
@ -13,4 +15,4 @@ The default tiddler colour cascade consists of:
You can see the current settings for the tiddler colour cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Tiddler Colour'' tab.
<<list-links "[tag[Tiddler Colour Cascade]]">>
<<list-links "[tag[Tiddler Colour Cascade]]">>

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
The tiddler icon cascade is a [[cascade|Cascades]] used to choose which icon should be used for a particular tiddler.
The core tiddler icon cascade can be found in $:/core/ui/TiddlerIcon
The default tiddler icon cascade consists of:
# If the tiddler has an ''icon'' field, use the value as the title of the icon tiddler
@ -13,4 +15,4 @@ The default tiddler icon cascade consists of:
You can see the current settings for the tiddler icon cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Tiddler Icon'' tab.
<<list-links "[tag[Tiddler Icon Cascade]]">>
<<list-links "[tag[Tiddler Icon Cascade]]">>

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
The view template title cascade is a [[cascade|Cascades]] used by the default view template to choose the template for displaying the tiddler title.
The core view template title cascade can be found in $:/core/ui/ViewTemplate/title
The default view template title cascade consists of:
# If the tiddler title starts with `$:/` then use the template $:/core/ui/ViewTemplate/title/system which causes the `$:/` prefix to be displayed in pale text
@ -13,4 +15,4 @@ The default view template title cascade consists of:
You can see the current settings for the view template title cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''View Template Title'' tab.
<<list-links "[tag[View Template Title Cascade]]">>
<<list-links "[tag[View Template Title Cascade]]">>

View File

@ -1,10 +1,10 @@
created: 20220917113154900
modified: 20230419103154329
modified: 20230518143557045
tags: Pragmas
title: Pragma: \parameters
type: text/vnd.tiddlywiki
<<.from-version "5.3.0">> The ''\parameters'' [[pragma|Pragmas]] is used within [[procedure|Procedure Definitions]] and [[widget|Widget Definitions]] definitions to declare the parameters that are expected, and their default values. It is a shortcut syntax for the ParametersWidget.
<<.from-version "5.3.0">> The ''\parameters'' [[pragma|Pragmas]] is used within [[procedure|Procedure Definitions]] and [[widget|Custom Widgets]] definitions to declare the parameters that are expected, and their default values. It is a shortcut syntax for the ParametersWidget.
```
\parameters (<name>[:<default-value>],<name>[:<default-value>]...)
@ -16,3 +16,11 @@ For example:
\parameters (firstname:"Joe",lastname:"Blogs")
```
To illustrate the use of ''\parameters'' pragma, see [[Core Icons]] which are parameterised. The first parameter `size` specified the size at which the icon should be rendered. For example see the text of [[$:/core/images/print-button]] tiddler. The first line defines the size parameter as `\parameters (size:"22pt")`
<<wikitext-example-without-html """{{$:/core/images/print-button|16px}}
<$transclude $tiddler="$:/core/images/print-button" size="32px"/>
""">>
In the above example, the first line shows a simple transclusion of [[$:/core/images/print-button]] icon with `size` parameter passed by position and is set to 16px. The second line is a transclusion of image with `size` parameter passed by name and is set to 32px.

View File

@ -1,5 +1,5 @@
created: 20221007132845007
modified: 20230419103154329
modified: 20230518152756112
tags: Pragmas
title: Pragma: \procedure
type: text/vnd.tiddlywiki
@ -52,4 +52,59 @@ Procedure definitions can be nested by specifying the name of the procedure in t
\end special-button
<<special-button>>
""">>
! Use of Parameters Inside Procedures
The parameters can be declared inside procedures. The parameters widget is necessary in a procedure if you want to use computed default values. For example:
<<wikitext-example-without-html
src:"""\procedure myproc()
<$parameters name={{$:/SiteTitle}} desc={{$:/SiteSubtitle}}>
This is <<name>> demonstrates <<desc>>.
</$parameters>
\end
<<myproc>>
""">>
!! Caution in Using Positional Parameters
Procedures are a shortcut syntax for the SetVariableWidget with an implicit ParametersWidget, so generally there is no reason to have multiple parameters widgets within a definition. In the below example when passing `x` to `myproc`, it will also be set to `a`:
<<wikitext-example-without-html
src:"""\procedure myproc(x:10)
\parameters (a:100, b:200)
x=<<x>>, a=<<a>>, b=<<b>>
\end
<<myproc 50>>
""">>
The reason for that result is clearer if we consider an equivalent with explicit parameters widgets.
<$macrocall $name=wikitext-example-without-html
src='<$let myprog="""
\parameters (x:10)
\parameters (a:100, b:200)
x=<<x>>, a=<<a>>, b=<<b>>
""">
<<myprog 50>>
</$let>'
/>
This is because those two parameters widgets are entirely independent. They are both processed as if the other parameter widget is not there.
<<.tip "The positional parameters are only required when using the parameterised transclusion shortcut syntax, and that in other cases it is generally clearer to use named parameters.">>
To prevent such situation of above example, pass parameters by name as below.
<<wikitext-example-without-html
src:"""\procedure myproc(x:10)
\parameters (a:100, b:200)
x=<<x>>, a=<<a>>, b=<<b>>
\end
<<myproc x:50>>
""">>

View File

@ -17,14 +17,6 @@ It looks like this browser doesn't run JavaScript. You can use one of these stat
---
{{HelloThere}}
{{TiddlyWiki}}
{{Features}}
{{Community}}
{{HelpingTiddlyWiki}}
</$reveal>

View File

@ -4,6 +4,10 @@ tags: [[WebServer Authentication]]
title: WebServer Header Authentication
type: text/vnd.tiddlywiki
Header authentication is a web integration technique enabling external entities to securely pass details of the authenticated user to an application. It is commonly used for "single sign on" in corporate environments.
Header authentication is a web integration technique enabling external entities to securely pass details of the authenticated user to an application.
Header authentication is activated if is configured via the [[authenticated-user-header|WebServer Parameter: authenticated-user-header]]
!! Usage in SSO
Header authentication is commonly used for "single sign on" in corporate environments. When doing header authentication, the user is not prompted for a username and password on TiddlyWiki. Instead, the user is required to login at a SSO proxy server. When the user authenticates themselves to the SSO proxy server, the proxy server redirects the user request to the TiddlyWiki server with this additional request header containing the username. Then TiddlyWiki server is able to use the value of this request header to identify the user.

View File

@ -1,8 +1,16 @@
caption: authenticated-user-header
created: 20180630180213047
modified: 20180702140416583
modified: 20230522184416583
tags: [[WebServer Parameters]]
title: WebServer Parameter: authenticated-user-header
type: text/vnd.tiddlywiki
The [[web server configuration parameter|WebServer Parameters]] ''authenticated-user-header'' activates [[header authentication|WebServer Header Authentication]] by specifying the name of the HTTP header that will be used to pass the username to TiddlyWiki.
The [[web server configuration parameter|WebServer Parameters]] ''authenticated-user-header'' activates [[header authentication|WebServer Header Authentication]] by specifying the name of the HTTP header field that will be used to pass the username to TiddlyWiki.
For example, if the ''authenticated-user-header'' is set to ''X-Authenticated-User'', then the HTTP request must include a header field ''X-Authenticated-User'' with a value that is the username:
```http
X-Authenticated-User: JeremyRuston
```
<<.from-version "5.3.0">> Value of this header field should be URI-encoded before transit on the client (using `encodeURIComponent` JS function or [[encodeuricomponent Operator]]), and will be URI-decoded by the server.

View File

@ -1,6 +1,6 @@
caption: parameters
created: 20220909111836951
modified: 20230419103154328
modified: 20230518134032228
tags: Widgets
title: ParametersWidget
type: text/vnd.tiddlywiki
@ -48,14 +48,5 @@ These attributes provide low level access to the contents of the transcluding wi
* The `$slotFillParseTreeNodes` attribute provides access to the raw parse tree nodes corresponding to the filled slots within the contents of the transcluding widget. Represented in JSON as an object with keys of the slot name and values being an array of parse tree nodes
! Examples
{{ParametersWidget (Examples)}}
Here the <<.wlink ParametersWidget>> widget is used to declare a parameter whose default value is transcluded from another tiddler.
<$macrocall $name='wikitext-example-without-html'
src="""\procedure mymacro()
<$parameters name={{$:/SiteTitle}} age="21">
My name is <<name>> and my age is <<age>>.
</$parameters>
\end
<$transclude $variable="mymacro" age="19"/>"""/>

View File

@ -0,0 +1,39 @@
created: 20230518124403282
modified: 20230518135109977
tags: ParametersWidget
title: ParametersWidget (Examples)
''Example i'': Shows transclusion of [[Sample Tiddler Template]]. The template tiddler has two parameters `name` and `age` and here their default values are used.
<$macrocall $name=".example" n="1" eg="""<$transclude $tiddler="Sample Tiddler Template" />"""/>
''Example ii'': Shows, another transclusion of [[Sample Tiddler Template]], here the value of `age` is passed, but `name` uses its default value.
<$macrocall $name=".example" n="2" eg="""<$transclude $tiddler="Sample Tiddler Template" age=33/>"""/>
''Example iii'': Shows, another transclusion of [[Sample Tiddler Template]], here the value of both `name` and `age` are passed.
<$macrocall $name=".example" n="3" eg="""<$transclude $tiddler="Sample Tiddler Template" age=45 name="Jeremy Ruston" />"""/>
In the simple form the above transclusion is equivalent to
<$macrocall $name=".example" n="3.1" eg="""{{Sample Tiddler Template|Jeremy Ruston|45}}"""/>
In this simple form, parameters passed by position not by name. So the first value is passed to the first parameter, here `name` and the second value is passed to the second parameter, here `age`.
''Remarks''
# Passing parameter by name is good practice and is recommended for clarity. So for parameterized transclusions, the use of <<.wid transclude>> is recommended over simple form transclusion.
# When passing parameters value by position, you cannot pass the second parameter while the first one has not been passed.
''Example iv'': Here the <<.wlink ParametersWidget>> widget is used to declare a parameter whose default value is transcluded from another tiddler.
<$macrocall $name=".example" n="4" eg="""\procedure myproc()
<$parameters name={{$:/SiteTitle}} age="21">
My name is <<name>> and my age is <<age>>.
</$parameters>
\end
<$transclude $variable="myproc" age="19"/>
"""/>

View File

@ -0,0 +1,9 @@
created: 20230518124140604
description: This example tiddler is used to illustrate some of the new features in Parameterized Transclusions
modified: 20230518125337219
tags: [[ParametersWidget Examples]] Demonstrations
title: Sample Tiddler Template
<$parameters name=Jeremy age="21">
My name is <<name>> and my age is <<age>>.
</$parameters>

View File

@ -18,7 +18,7 @@ listen 命令使用[[命名的命令参数|NamedCommandParameters]]
* ''anon-username'' - 匿名用户的编辑署名
* ''username'' - 可选的基础验证用户名称
* ''password'' - 可选的基础验证密码
* ''authenticated-user-header'' - 可选的标头名称,用于受信任身份验证
* ''authenticated-user-header'' - 可选的请求标头名称,用于受信任身份验证
* ''readers'' - 允许读取此维基,以逗号分隔的用户名称的清单
* ''writers'' - 允许写入此维基,以逗号分隔的用户名称的清单
* ''csrf-disable'' - 设置为 "yes" 以禁用 CSRF 检查 (默认为 "no")

View File

@ -18,7 +18,7 @@ listen 命令使用[[命名的命令參數|NamedCommandParameters]]
* ''anon-username'' - 匿名使用者的編輯署名
* ''username'' - 可選的基本驗證使用者名稱
* ''password'' - 可選的基本驗證密碼
* ''authenticated-user-header'' - 可選的標頭名稱,用於受信任身份驗證
* ''authenticated-user-header'' - 可選的 HTTP 請求功能參數名稱,用於受信任身份驗證
* ''readers'' - 允許讀取此維基,以逗號分隔的使用者名稱的清單
* ''writers'' - 允許寫入此維基,以逗號分隔的使用者名稱的清單
* ''csrf-disable'' - 設定為 "yes" 以停用 CSRF 檢查 (預設為 "no")

View File

@ -531,3 +531,5 @@ Michelle Saad, @michsa, 2023-03-08
Yukai Chou, @muzimuzhi, 2023-04-07
Carmine Guida, @carmineguida, 2023-05-17
Tavin Cole, @tavin, 2023/05/25

View File

@ -0,0 +1,4 @@
title: $:/language/codemirror/
showTrailingSpace/hint: Show trailing space
showTrailingSpace/info: Trailing space on each line will be decorated as per theme CSS.

View File

@ -0,0 +1,3 @@
title: $:/config/codemirror/showTrailingSpace
type: bool
text: true

View File

@ -0,0 +1,5 @@
.cm-trailingspace {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAAB/qH1jAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QUXCToH00Y1UgAAACFJREFUCNdjPMDBUc/AwNDAAAFMTAwMDA0OP34wQgX/AQBYgwYEx4f9lQAAAABJRU5ErkJggg==);
background-position: bottom left;
background-repeat: repeat-x;
}

View File

@ -0,0 +1,27 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
if (prev == CodeMirror.Init) prev = false;
if (prev && !val)
cm.removeOverlay("trailingspace");
else if (!prev && val)
cm.addOverlay({
token: function(stream) {
for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
if (i > stream.pos) { stream.pos = i; return null; }
stream.pos = l;
return "trailingspace";
},
name: "trailingspace"
});
});
});

View File

@ -0,0 +1,19 @@
{
"tiddlers": [
{
"file": "addon/edit/trailingspace.css",
"fields": {
"type": "text/css",
"title": "$:/plugins/tiddlywiki/codemirror/addon/edit/trailingspace.css",
"tags": "[[$:/tags/Stylesheet]]"
}
},{
"file": "addon/edit/trailingspace.js",
"fields": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/codemirror/addon/edit/trailingspace.js",
"module-type": "codemirror"
}
}
]
}

View File

@ -0,0 +1,7 @@
{
"title": "$:/plugins/tiddlywiki/codemirror-trailingspace",
"name": "CodeMirror Show Trailing Space",
"description": "Show trailing space in CodeMirror",
"parent-plugin": "$:/plugins/tiddlywiki/codemirror",
"list": "readme"
}

View File

@ -0,0 +1,7 @@
title: $:/plugins/tiddlywiki/codemirror-trailingspace/readme
This plugin contains the [[trailingspace|https://codemirror.net/5/doc/manual.html#addon_trailingspace]]
addon for CodeMirror, and provides a default style (red squiggles).
First install the [[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]].

View File

@ -0,0 +1,11 @@
title: $:/core/ui/ControlPanel/Settings/codemirror/showTrailingSpace
tags: $:/tags/ControlPanel/Settings/CodeMirror
caption: {{$:/language/codemirror/showTrailingSpace/hint}}
\define lingo-base() $:/language/codemirror/showTrailingSpace/
<<lingo hint>>
<$checkbox tiddler="$:/config/codemirror/showTrailingSpace" field="text" checked="true" unchecked="false" default="true">
<$link to="$:/config/codemirror/showTrailingSpace"><<lingo info>></$link>
</$checkbox>

View File

@ -10,7 +10,7 @@
},{
"file": "codemirror.css",
"fields": {
"type": "text/vnd.tiddlywiki",
"type": "text/css",
"title": "$:/plugins/tiddlywiki/codemirror/lib/codemirror.css",
"tags": "[[$:/tags/Stylesheet]]"
}