From 8321d2e6fcd34707058c2ae991f4d6762b813893 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 5 Sep 2018 08:38:47 +0100 Subject: [PATCH 1/4] Docs: webserver and read-only mode --- .../tiddlers/webserver/WebServer Authorization.tid | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/webserver/WebServer Authorization.tid b/editions/tw5.com/tiddlers/webserver/WebServer Authorization.tid index 8bd2e0566..49ba60a6c 100644 --- a/editions/tw5.com/tiddlers/webserver/WebServer Authorization.tid +++ b/editions/tw5.com/tiddlers/webserver/WebServer Authorization.tid @@ -1,5 +1,5 @@ created: 20180630194006239 -modified: 20180701174944267 +modified: 20180904174030250 tags: WebServer title: WebServer Authorization type: text/vnd.tiddlywiki @@ -13,6 +13,17 @@ The available special tokens are: * ''(anon)'' - indicates all anonymous users * ''(authenticated)'' - indicates all authenticated users +!! Read-only Mode + +Read-only mode is engaged when the current user is not authorized to write to the current wiki. + +User interface features concerned with creating or editing content are disabled in read-only mode: + +* ''clone'', ''delete'', ''new-here'' and ''new-journal-here'' tiddler toolbar buttons +* ''import'', ''manager'', ''new-tiddler'' ''new-image'' and ''new-journal'' page control buttons + +The tiddler $:/status/IsReadOnly is set to `yes` when read-only mode is engaged. + !! Examples These example use the [[credentials|WebServer Parameter: credentials]] parameter to specify the location of a file containing usernames and passwords. From 3d10a35fb772a066f4e7b33507fe07fd1992423d Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 5 Sep 2018 08:44:27 +0100 Subject: [PATCH 2/4] Add support for externalising TW's JavaScript (#3423) * Explore externalising TiddlyWiki's JS core into a separate file * Fix missing newline after copyright notice * Add an error alert if tiddlywiki.js can't be loaded --- .../external-js/save-all-external-js.tid | 6 +++ core/templates/external-js/tiddlywiki.js.tid | 15 +++++++ .../external-js/tiddlywiki.js.tiddlers.tid | 9 ++++ .../tiddlywiki5-external-js.html.tid | 41 +++++++++++++++++++ editions/tw5.com/tiddlywiki.info | 5 ++- 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 core/templates/external-js/save-all-external-js.tid create mode 100644 core/templates/external-js/tiddlywiki.js.tid create mode 100644 core/templates/external-js/tiddlywiki.js.tiddlers.tid create mode 100644 core/templates/external-js/tiddlywiki5-external-js.html.tid diff --git a/core/templates/external-js/save-all-external-js.tid b/core/templates/external-js/save-all-external-js.tid new file mode 100644 index 000000000..31476e663 --- /dev/null +++ b/core/templates/external-js/save-all-external-js.tid @@ -0,0 +1,6 @@ +title: $:/core/save/all-external-js + +\define saveTiddlerFilter() +[is[tiddler]] -[prefix[$:/state/popup/]] -[[$:/HistoryList]] -[[$:/core]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] $(publishFilter)$ +\end +{{$:/core/templates/tiddlywiki5-external-js.html}} diff --git a/core/templates/external-js/tiddlywiki.js.tid b/core/templates/external-js/tiddlywiki.js.tid new file mode 100644 index 000000000..a8170663f --- /dev/null +++ b/core/templates/external-js/tiddlywiki.js.tid @@ -0,0 +1,15 @@ +title: $:/core/templates/tiddlywiki5.js + +\rules only filteredtranscludeinline transcludeinline codeinline + +/* +{{ $:/core/copyright.txt ||$:/core/templates/plain-text-tiddler}} +`*/ +` +{{{ [is[system]type[application/javascript]library[yes]] ||$:/core/templates/plain-text-tiddler}}} + +{{ $:/boot/bootprefix.js ||$:/core/templates/plain-text-tiddler}} + +{{$:/core/templates/tiddlywiki5.js/tiddlers}} + +{{ $:/boot/boot.js ||$:/core/templates/plain-text-tiddler}} diff --git a/core/templates/external-js/tiddlywiki.js.tiddlers.tid b/core/templates/external-js/tiddlywiki.js.tiddlers.tid new file mode 100644 index 000000000..52b2c293f --- /dev/null +++ b/core/templates/external-js/tiddlywiki.js.tiddlers.tid @@ -0,0 +1,9 @@ +title: $:/core/templates/tiddlywiki5.js/tiddlers + +` +$tw.preloadTiddlerArray(`<$text text=<>/>`); +$tw.preloadTiddlerArray([{ + title: "$:/config/SaveWikiButton/Template", + text: "$:/core/save/all-external-js" +}]); +` diff --git a/core/templates/external-js/tiddlywiki5-external-js.html.tid b/core/templates/external-js/tiddlywiki5-external-js.html.tid new file mode 100644 index 000000000..91e423edc --- /dev/null +++ b/core/templates/external-js/tiddlywiki5-external-js.html.tid @@ -0,0 +1,41 @@ +title: $:/core/templates/tiddlywiki5-external-js.html + +\rules only filteredtranscludeinline transcludeinline + +{{$:/core/templates/MOTW.html}} + + + + + + + + + + + + + +{{$:/core/wiki/title}} + + + +{{{ [all[shadows+tiddlers]tag[$:/core/wiki/rawmarkup]] [all[shadows+tiddlers]tag[$:/tags/RawMarkup]] ||$:/core/templates/plain-text-tiddler}}} +{{{ [all[shadows+tiddlers]tag[$:/tags/RawMarkupWikified]] ||$:/core/templates/raw-static-tiddler}}} + + + +
+{{$:/boot/boot.css||$:/core/templates/css-tiddler}} +
+ + + +{{$:/core/templates/store.area.template.html}} + + + diff --git a/editions/tw5.com/tiddlywiki.info b/editions/tw5.com/tiddlywiki.info index a845845d3..aa3cd5707 100644 --- a/editions/tw5.com/tiddlywiki.info +++ b/editions/tw5.com/tiddlywiki.info @@ -48,7 +48,10 @@ "--rendertiddler","$:/core/templates/static.template.html","static.html","text/plain", "--rendertiddler","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain", "--rendertiddlers","[!is[system]]","$:/core/templates/static.tiddler.html","static","text/plain", - "--rendertiddler","$:/core/templates/static.template.css","static/static.css","text/plain"] + "--rendertiddler","$:/core/templates/static.template.css","static/static.css","text/plain"], + "external-js": [ + "--rendertiddler","$:/core/save/all-external-js","index.html","text/plain", + "--rendertiddler","$:/core/templates/tiddlywiki5.js","tiddlywiki.js","text/plain"] }, "config": { "retain-original-tiddler-path": true From f2a38960fce1bb70f1090012334bee452d59f45f Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 5 Sep 2018 08:57:29 +0100 Subject: [PATCH 3/4] Fix external JS template to work with the TW5 webserver It's a bit gross that we have to change the filename used to reference the JS file. This is to make it work with the webserver. At the moment, the webserver exposes system tiddlers as plain text renderings, and ordinary tiddlers as full HTML renderings through a view template. So we have to use a system tiddler title for the JS file. The workaround I'm thinking of is to remove the blanket exposure of system tiddlers, and instead have a list of system tiddlers that are specifically exposed through a namespace like `127.0.0.1:8080\lib\tiddlywiki.js`. That can't clash with a tiddler title because tiddler titles are URI encoded and so can't contain slashes. --- core/templates/external-js/tiddlywiki5-external-js.html.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/templates/external-js/tiddlywiki5-external-js.html.tid b/core/templates/external-js/tiddlywiki5-external-js.html.tid index 91e423edc..611da06b0 100644 --- a/core/templates/external-js/tiddlywiki5-external-js.html.tid +++ b/core/templates/external-js/tiddlywiki5-external-js.html.tid @@ -37,5 +37,5 @@ title: $:/core/templates/tiddlywiki5-external-js.html {{$:/core/templates/store.area.template.html}} - + From f9eed0dc87bbe73bae3806fc4b09e3c112bc8bed Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 5 Sep 2018 09:10:42 +0100 Subject: [PATCH 4/4] Docs about using the web server with external JS --- ...Using the external JavaScript template.tid | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 editions/tw5.com/tiddlers/Using the external JavaScript template.tid diff --git a/editions/tw5.com/tiddlers/Using the external JavaScript template.tid b/editions/tw5.com/tiddlers/Using the external JavaScript template.tid new file mode 100644 index 000000000..c6c2373cb --- /dev/null +++ b/editions/tw5.com/tiddlers/Using the external JavaScript template.tid @@ -0,0 +1,19 @@ +created: 20180905075846391 +modified: 20180905080955513 +tags: [[WebServer Guides]] +title: Using the external JavaScript template +type: text/vnd.tiddlywiki + +Setting the [[root-tiddler|WebServer Parameter: root-tiddler]] parameter to `$:/core/save/all-external-js` switches to a special template that externalises TiddlyWiki's core JavaScript into a separate file. For example: + +``` +tiddlywiki editions/tw5.com-server/ --listen host=0.0.0.0 "root-tiddler=$:/core/save/all-external-js" +``` + +!! Background + +TiddlyWiki in the single file configuration ordinarily packs everything into a single file: your data, and the JavaScript, CSS and HTML comprising TiddlyWiki itself. This lack of dependencies is usually very convenient: it means that it is impossible for the parts of a TiddlyWiki to become separated, and enormously improves the changes of it still functioning in the future. + +However, there is some inefficiency in this arrangement because the core code is repeatedly loaded and saved every time the content of the wiki is saved. This inefficiency is partially ameliorated when working in the client server configuration because once the wiki is loaded by the browser the synchronisation process only transmits individual tiddlers back and forth to the server. + +The remaining inefficiency when working in the client server configuration is that the single page wiki that is initially loaded will contain a copy of the entire core code of TiddlyWiki, making it impossible for the browser to cache it. \ No newline at end of file