From 9b3ca525ee08b2cb34404fd11dcbb35b7a33e457 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 20 Mar 2024 15:13:50 +0000 Subject: [PATCH] Introduce multiwikiclient plugin Routes are now rationalised, too. --- editions/multiwikiserver/tiddlywiki.info | 1 + .../multiwikiclient/GettingStarted.tid | 16 + .../SaveWikiButtonTemplate.tid | 3 + .../config-tiddlers-filter.tid | 2 + .../configOfficialPluginLibrary.tid | 7 + .../multiwikiclient/css-tiddler.tid | 7 + .../html-div-skinny-tiddler.tid | 9 + .../multiwikiclient/html-div-tiddler.tid | 9 + .../html-json-skinny-tiddler.tid | 3 + .../multiwikiclient/html-json-tiddler.tid | 3 + .../tiddlywiki/multiwikiclient/icon-cloud.tid | 4 + .../multiwikiclient/javascript-tiddler.tid | 7 + .../multiwikiclient/multiwikiclientadaptor.js | 351 ++++++++++++++++++ .../tiddlywiki/multiwikiclient/plugin.info | 7 + plugins/tiddlywiki/multiwikiclient/readme.tid | 8 + .../multiwikiclient/readonly-styles.tid | 27 ++ .../multiwikiclient/save-offline.tid | 7 + .../multiwikiclient/save-wiki-button.tid | 26 ++ plugins/tiddlywiki/multiwikiclient/styles.tid | 44 +++ .../syncer-actions-copy-logs.tid | 6 + .../syncer-actions-login-status.tid | 9 + .../multiwikiclient/syncer-actions-login.tid | 8 + .../multiwikiclient/syncer-actions-logout.tid | 8 + .../syncer-actions-refresh.tid | 9 + .../syncer-actions-save-snapshot.tid | 9 + .../multiwikiclient/tags-syncerdropdown.tid | 2 + .../modules/commands/mws-test-server.js | 9 +- .../routes/handlers/delete-bag-tiddler.js | 35 ++ .../routes/handlers/delete-recipe-tiddler.js | 39 -- .../routes/handlers/get-bag-tiddler-blob.js | 9 +- .../routes/handlers/get-bag-tiddler.js | 12 +- .../modules/routes/handlers/get-bag.js | 15 +- .../routes/handlers/get-recipe-tiddler.js | 13 +- .../handlers/get-recipe-tiddlers-json.js | 11 +- .../modules/routes/handlers/get-recipe.js | 4 +- .../modules/routes/handlers/get-status.js | 42 --- .../routes/handlers/post-bag-tiddlers.js | 13 +- .../modules/routes/handlers/put-bag.js | 9 +- .../routes/handlers/put-recipe-tiddler.js | 12 +- .../modules/routes/handlers/put-recipe.js | 9 +- .../modules/store/sql-tiddler-store.js | 2 +- .../system-files/styles.css.tid | 5 - .../multiwikiserver/templates/get-bag.tid | 4 +- .../multiwikiserver/templates/get-index.tid | 6 +- .../templates/post-bag-tiddlers.tid | 4 +- 45 files changed, 679 insertions(+), 166 deletions(-) create mode 100644 plugins/tiddlywiki/multiwikiclient/GettingStarted.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/SaveWikiButtonTemplate.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/config-tiddlers-filter.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/configOfficialPluginLibrary.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/css-tiddler.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/html-div-skinny-tiddler.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/html-div-tiddler.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/html-json-skinny-tiddler.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/html-json-tiddler.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/icon-cloud.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/javascript-tiddler.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/multiwikiclientadaptor.js create mode 100644 plugins/tiddlywiki/multiwikiclient/plugin.info create mode 100644 plugins/tiddlywiki/multiwikiclient/readme.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/readonly-styles.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/save-offline.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/save-wiki-button.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/styles.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/syncer-actions-copy-logs.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/syncer-actions-login-status.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/syncer-actions-login.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/syncer-actions-logout.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/syncer-actions-refresh.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/syncer-actions-save-snapshot.tid create mode 100644 plugins/tiddlywiki/multiwikiclient/tags-syncerdropdown.tid create mode 100644 plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-bag-tiddler.js delete mode 100644 plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-recipe-tiddler.js delete mode 100644 plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-status.js diff --git a/editions/multiwikiserver/tiddlywiki.info b/editions/multiwikiserver/tiddlywiki.info index e16e3c3da..b190fa7d7 100644 --- a/editions/multiwikiserver/tiddlywiki.info +++ b/editions/multiwikiserver/tiddlywiki.info @@ -3,6 +3,7 @@ "plugins": [ "tiddlywiki/tiddlyweb", "tiddlywiki/filesystem", + "tiddlywiki/multiwikiclient", "tiddlywiki/multiwikiserver" ], "themes": [ diff --git a/plugins/tiddlywiki/multiwikiclient/GettingStarted.tid b/plugins/tiddlywiki/multiwikiclient/GettingStarted.tid new file mode 100644 index 000000000..08df08c07 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/GettingStarted.tid @@ -0,0 +1,16 @@ +title: GettingStarted +tags: $:/tags/GettingStarted +caption: Step 1
Syncing + +Welcome to ~TiddlyWiki and the ~TiddlyWiki community + +Visit https://tiddlywiki.com/ to find out more about ~TiddlyWiki and what it can do. + +! Syncing Changes to the Server + +Before you can start storing important information in ~TiddlyWiki it is important to make sure that your changes are being reliably saved by the server. + +# Create a new tiddler using the {{$:/core/images/new-button}} button in the sidebar on the right +# Click the {{$:/core/images/done-button}} button at the top right of the new tiddler +# Check the ~TiddlyWiki command line for a message confirming the tiddler has been saved +# Refresh the page in the browser to and verify that the new tiddler has been correctly saved diff --git a/plugins/tiddlywiki/multiwikiclient/SaveWikiButtonTemplate.tid b/plugins/tiddlywiki/multiwikiclient/SaveWikiButtonTemplate.tid new file mode 100644 index 000000000..45b8959ce --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/SaveWikiButtonTemplate.tid @@ -0,0 +1,3 @@ +title: $:/config/SaveWikiButton/Template + +$:/plugins/tiddlywiki/multiwikiclient/save/offline \ No newline at end of file diff --git a/plugins/tiddlywiki/multiwikiclient/config-tiddlers-filter.tid b/plugins/tiddlywiki/multiwikiclient/config-tiddlers-filter.tid new file mode 100644 index 000000000..4e5c951db --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/config-tiddlers-filter.tid @@ -0,0 +1,2 @@ +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/plugins/tiddlywiki/multiwikiclient/configOfficialPluginLibrary.tid b/plugins/tiddlywiki/multiwikiclient/configOfficialPluginLibrary.tid new file mode 100644 index 000000000..d2a07991a --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/configOfficialPluginLibrary.tid @@ -0,0 +1,7 @@ +title: $:/config/OfficialPluginLibrary +tags: $:/tags/PluginLibrary +url: https://tiddlywiki.com/library/v5.1.23/index.html +caption: {{$:/language/OfficialPluginLibrary}} +enabled: no + +The official plugin library is disabled when using the client-server configuration. Instead, plugins should be installed via the `tiddlywiki.info` file, as described [[here|https://tiddlywiki.com/#Installing%20a%20plugin%20from%20the%20plugin%20library]]. \ No newline at end of file diff --git a/plugins/tiddlywiki/multiwikiclient/css-tiddler.tid b/plugins/tiddlywiki/multiwikiclient/css-tiddler.tid new file mode 100644 index 000000000..821fa1186 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/css-tiddler.tid @@ -0,0 +1,7 @@ +title: $:/core/templates/css-tiddler + +`` data-tiddler-revision="`<>`" data-tiddler-bag="default" type="text/css">`<$view field="text" format="text" />`` \ No newline at end of file diff --git a/plugins/tiddlywiki/multiwikiclient/html-div-skinny-tiddler.tid b/plugins/tiddlywiki/multiwikiclient/html-div-skinny-tiddler.tid new file mode 100644 index 000000000..010a603b5 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/html-div-skinny-tiddler.tid @@ -0,0 +1,9 @@ +title: $:/core/templates/html-div-skinny-tiddler + +`` revision="`<>`" bag="default" _is_skinny=""> +

+`
diff --git a/plugins/tiddlywiki/multiwikiclient/html-div-tiddler.tid b/plugins/tiddlywiki/multiwikiclient/html-div-tiddler.tid
new file mode 100644
index 000000000..ff27343fc
--- /dev/null
+++ b/plugins/tiddlywiki/multiwikiclient/html-div-tiddler.tid
@@ -0,0 +1,9 @@
+title: $:/core/templates/html-div-tiddler
+
+`` revision="`<>`" bag="default">
+
`<$view field="text" format="htmltextencoded" />`
+` diff --git a/plugins/tiddlywiki/multiwikiclient/html-json-skinny-tiddler.tid b/plugins/tiddlywiki/multiwikiclient/html-json-skinny-tiddler.tid new file mode 100644 index 000000000..ce953fbf2 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/html-json-skinny-tiddler.tid @@ -0,0 +1,3 @@ +title: $:/core/templates/html-json-skinny-tiddler + +<$text text=<>/><$jsontiddler tiddler=<> exclude="text" escapeUnsafeScriptChars="yes" $revision=<> $bag="default" $_is_skinny=""/> diff --git a/plugins/tiddlywiki/multiwikiclient/html-json-tiddler.tid b/plugins/tiddlywiki/multiwikiclient/html-json-tiddler.tid new file mode 100644 index 000000000..f357321fb --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/html-json-tiddler.tid @@ -0,0 +1,3 @@ +title: $:/core/templates/html-json-tiddler + +<$jsontiddler tiddler=<> escapeUnsafeScriptChars="yes" $revision=<> $bag="default"/> diff --git a/plugins/tiddlywiki/multiwikiclient/icon-cloud.tid b/plugins/tiddlywiki/multiwikiclient/icon-cloud.tid new file mode 100644 index 000000000..e448bc548 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/icon-cloud.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/multiwikiclient/icon/cloud +tags: $:/tags/Image + + \ No newline at end of file diff --git a/plugins/tiddlywiki/multiwikiclient/javascript-tiddler.tid b/plugins/tiddlywiki/multiwikiclient/javascript-tiddler.tid new file mode 100644 index 000000000..dc4bc4db9 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/javascript-tiddler.tid @@ -0,0 +1,7 @@ +title: $:/core/templates/javascript-tiddler + +`` data-tiddler-revision="`<>`" data-tiddler-bag="default" type="text/javascript">`<$view field="text" format="text" />`` \ No newline at end of file diff --git a/plugins/tiddlywiki/multiwikiclient/multiwikiclientadaptor.js b/plugins/tiddlywiki/multiwikiclient/multiwikiclientadaptor.js new file mode 100644 index 000000000..d2f0a235b --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/multiwikiclientadaptor.js @@ -0,0 +1,351 @@ +/*\ +title: $:/plugins/tiddlywiki/multiwikiclient/multiwikiclientadaptor.js +type: application/javascript +module-type: syncadaptor + +A sync adaptor module for synchronising with MultiWikiServer-compatible servers + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +var CONFIG_HOST_TIDDLER = "$:/config/multiwikiclient/host", + DEFAULT_HOST_TIDDLER = "$protocol$//$host$/"; + +function MultiWikiClientAdaptor(options) { + this.wiki = options.wiki; + this.host = this.getHost(); + this.recipe = this.wiki.getTiddlerText("$:/config/multiwikiclient/recipe"); + this.logger = new $tw.utils.Logger("MultiWikiClientAdaptor"); + this.isLoggedIn = false; + this.isReadOnly = false; + this.logoutIsAvailable = true; +} + +MultiWikiClientAdaptor.prototype.name = "multiwikiclient"; + +MultiWikiClientAdaptor.prototype.supportsLazyLoading = true; + +MultiWikiClientAdaptor.prototype.setLoggerSaveBuffer = function(loggerForSaving) { + this.logger.setSaveBuffer(loggerForSaving); +}; + +MultiWikiClientAdaptor.prototype.isReady = function() { + return true; +}; + +MultiWikiClientAdaptor.prototype.getHost = function() { + var text = this.wiki.getTiddlerText(CONFIG_HOST_TIDDLER,DEFAULT_HOST_TIDDLER), + substitutions = [ + {name: "protocol", value: document.location.protocol}, + {name: "host", value: document.location.host}, + {name: "pathname", value: document.location.pathname} + ]; + for(var t=0; t//<revision>:<hash> +``` +*/ +MultiWikiClientAdaptor.prototype.parseEtag = function(etag) { + var firstSlash = etag.indexOf("/"), + lastSlash = etag.lastIndexOf("/"), + colon = etag.lastIndexOf(":"); + if(firstSlash === -1 || lastSlash === -1 || colon === -1) { + return null; + } else { + return { + bag: $tw.utils.decodeURIComponentSafe(etag.substring(1,firstSlash)), + title: $tw.utils.decodeURIComponentSafe(etag.substring(firstSlash + 1,lastSlash)), + revision: etag.substring(lastSlash + 1,colon) + }; + } +}; + +if($tw.browser && document.location.protocol.substr(0,4) === "http" ) { + exports.adaptorClass = MultiWikiClientAdaptor; +} + +})(); diff --git a/plugins/tiddlywiki/multiwikiclient/plugin.info b/plugins/tiddlywiki/multiwikiclient/plugin.info new file mode 100644 index 000000000..a1ee7eb0d --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/plugin.info @@ -0,0 +1,7 @@ +{ + "title": "$:/plugins/tiddlywiki/multiwikiclient", + "name": "MultiWikiClient", + "description": "Synchronise changes from the browser to TiddlyWiki ~MultiWikiServer", + "list": "readme", + "plugin-priority": 10 +} diff --git a/plugins/tiddlywiki/multiwikiclient/readme.tid b/plugins/tiddlywiki/multiwikiclient/readme.tid new file mode 100644 index 000000000..8fe63b142 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/readme.tid @@ -0,0 +1,8 @@ +title: $:/plugins/tiddlywiki/multiwikiclient/readme + +This plugin runs in the browser to synchronise tiddler changes to and from a TiddlyWiki server running ~MultiWikiServer. + + +This plugin is inert when run under Node.js. Disabling this plugin via the browser can not be undone via the browser since this plugin provides the mechanism to synchronize settings with the server. + +Changes made while offline are saved in memory and automatically synchonised with the server when the connection is re-established. However, if the browser tab is closed or another URL is loaded, the in-memory changes will be lost. The [[https://tiddlywiki.com/#BrowserStorage Plugin]] may be added to provide temporary filesystem storage of tiddler changes made while offline and enable them to be synchronised with the server the next time the wiki is loaded in the same browser. diff --git a/plugins/tiddlywiki/multiwikiclient/readonly-styles.tid b/plugins/tiddlywiki/multiwikiclient/readonly-styles.tid new file mode 100644 index 000000000..4269ba799 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/readonly-styles.tid @@ -0,0 +1,27 @@ +title: $:/plugins/tiddlywiki/multiwikiclient/readonly +tags: [[$:/tags/Stylesheet]] + +\define button-selector(title) +button.$title$, .tc-drop-down button.$title$, div.$title$ +\end + +\define hide-edit-controls() +<$reveal state="$:/status/IsReadOnly" type="match" text="yes" default="yes"> +<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fclone>>`,` +<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fdelete>>`,` +<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fedit>>`,` +<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fnew-here>>`,` +<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fnew-journal-here>>`,` +<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fimport>>`,` +<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fmanager>>`,` +<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fnew-image>>`,` +<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fnew-journal>>`,` +<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fnew-tiddler>> `{ + display: none; +}` +</$reveal> +\end + +\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline macrocallblock + +<<hide-edit-controls>> diff --git a/plugins/tiddlywiki/multiwikiclient/save-offline.tid b/plugins/tiddlywiki/multiwikiclient/save-offline.tid new file mode 100644 index 000000000..20c420cd8 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/save-offline.tid @@ -0,0 +1,7 @@ +title: $:/plugins/tiddlywiki/multiwikiclient/save/offline + +\import [subfilter{$:/core/config/GlobalImportFilter}] +\define saveTiddlerFilter() +[is[tiddler]] -[[$:/boot/boot.css]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] -[[$:/plugins/tiddlywiki/filesystem]] -[[$:/plugins/tiddlywiki/multiwikiclient]] -[prefix[$:/temp/]] +[sort[title]] $(publishFilter)$ +\end +{{$:/core/templates/tiddlywiki5.html}} diff --git a/plugins/tiddlywiki/multiwikiclient/save-wiki-button.tid b/plugins/tiddlywiki/multiwikiclient/save-wiki-button.tid new file mode 100644 index 000000000..07e72d335 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/save-wiki-button.tid @@ -0,0 +1,26 @@ +title: $:/core/ui/Buttons/save-wiki +tags: $:/tags/PageControls +caption: {{$:/plugins/tiddlywiki/multiwikiclient/icon/cloud}} Server status +description: Status of synchronisation with server + +\whitespace trim +\define config-title() +$:/config/PageControlButtons/Visibility/$(listItem)$ +\end +<$button popup=<<qualify "$:/state/popup/save-wiki">> tooltip="Status of synchronisation with server" aria-label="Server status" class=<<tv-config-toolbar-class>> selectedClass="tc-selected"> +<span class="tc-dirty-indicator"> +<$list filter="[<tv-config-toolbar-icons>match[yes]]"> +{{$:/plugins/tiddlywiki/multiwikiclient/icon/cloud}} +</$list> +<$list filter="[<tv-config-toolbar-text>match[yes]]"> +<span class="tc-btn-text"><$text text="Server status"/></span> +</$list> +</span> +</$button> +<$reveal state=<<qualify "$:/state/popup/save-wiki">> type="popup" position="belowleft" animate="yes"> +<div class="tc-drop-down"> +<$list filter="[all[shadows+tiddlers]tag[$:/tags/SyncerDropdown]!has[draft.of]]" variable="listItem"> +<$transclude tiddler=<<listItem>>/> +</$list> +</div> +</$reveal> diff --git a/plugins/tiddlywiki/multiwikiclient/styles.tid b/plugins/tiddlywiki/multiwikiclient/styles.tid new file mode 100644 index 000000000..8fba4ec14 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/styles.tid @@ -0,0 +1,44 @@ +title: $:/plugins/tiddlywiki/multiwikiclient/styles +tags: [[$:/tags/Stylesheet]] + +\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline macrocallblock + +body.tc-dirty span.tc-dirty-indicator svg { + transition: fill 250ms ease-in-out; +} + +body .tc-image-cloud-idle { + fill: <<colour background>>; + transition: opacity 250ms ease-in-out; + opacity: 1; + display: unset; +} + +body.tc-dirty .tc-image-cloud-idle { + opacity: 0; + display: none; +} + +body .tc-image-cloud-progress { + transition: opacity 250ms ease-in-out; + transform-origin: 50% 50%; + transform: rotate(359deg); + animation: animation-rotate-slow 2s infinite linear; + fill: <<colour background>>; + display: none; + opacity: 0; +} + +body.tc-dirty .tc-image-cloud-progress { + opacity: 1; + display: unset; +} + +@keyframes animation-rotate-slow { + from { + transform: rotate(0deg); + } + to { + transform: scale(359deg); + } +} diff --git a/plugins/tiddlywiki/multiwikiclient/syncer-actions-copy-logs.tid b/plugins/tiddlywiki/multiwikiclient/syncer-actions-copy-logs.tid new file mode 100644 index 000000000..4457f7529 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/syncer-actions-copy-logs.tid @@ -0,0 +1,6 @@ +title: $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/copy-logs +tags: $:/tags/SyncerDropdown + +<$button message="tm-copy-syncer-logs-to-clipboard" class="tc-btn-invisible"> +{{$:/core/images/copy-clipboard}} Copy syncer logs to clipboard +</$button> diff --git a/plugins/tiddlywiki/multiwikiclient/syncer-actions-login-status.tid b/plugins/tiddlywiki/multiwikiclient/syncer-actions-login-status.tid new file mode 100644 index 000000000..6ebf98fcd --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/syncer-actions-login-status.tid @@ -0,0 +1,9 @@ +title: $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/login-status +tags: $:/tags/SyncerDropdown + +<$reveal state="$:/status/IsLoggedIn" type="match" text="yes"> +<div class="tc-drop-down-info"> +You are logged in<$reveal state="$:/status/UserName" type="nomatch" text="" default=""> as <strong><$text text={{$:/status/UserName}}/></strong></$reveal><$reveal state="$:/status/IsReadOnly" type="match" text="yes" default="no"> (read-only)</$reveal> +</div> +<hr/> +</$reveal> diff --git a/plugins/tiddlywiki/multiwikiclient/syncer-actions-login.tid b/plugins/tiddlywiki/multiwikiclient/syncer-actions-login.tid new file mode 100644 index 000000000..02cd2b6f6 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/syncer-actions-login.tid @@ -0,0 +1,8 @@ +title: $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/login +tags: $:/tags/SyncerDropdown + +<$reveal state="$:/status/IsLoggedIn" type="nomatch" text="yes"> +<$button message="tm-login" class="tc-btn-invisible"> +{{$:/core/images/unlocked-padlock}} Login +</$button> +</$reveal> diff --git a/plugins/tiddlywiki/multiwikiclient/syncer-actions-logout.tid b/plugins/tiddlywiki/multiwikiclient/syncer-actions-logout.tid new file mode 100644 index 000000000..cab5f261f --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/syncer-actions-logout.tid @@ -0,0 +1,8 @@ +title: $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/logout +tags: $:/tags/SyncerDropdown + +<$reveal state="$:/status/IsLoggedIn" type="match" text="yes"> +<$button message="tm-logout" class="tc-btn-invisible"> +{{$:/core/images/cancel-button}} Logout +</$button> +</$reveal> diff --git a/plugins/tiddlywiki/multiwikiclient/syncer-actions-refresh.tid b/plugins/tiddlywiki/multiwikiclient/syncer-actions-refresh.tid new file mode 100644 index 000000000..ea95a67d6 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/syncer-actions-refresh.tid @@ -0,0 +1,9 @@ +title: $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/refresh +tags: $:/tags/SyncerDropdown + +<$reveal state="$:/status/IsLoggedIn" type="match" text="yes"> +<$button tooltip="Get latest changes from the server" aria-label="Refresh from server" class="tc-btn-invisible"> +<$action-sendmessage $message="tm-server-refresh"/> +{{$:/core/images/refresh-button}}<span class="tc-btn-text"><$text text="Get latest changes from the server"/></span> +</$button> +</$reveal> diff --git a/plugins/tiddlywiki/multiwikiclient/syncer-actions-save-snapshot.tid b/plugins/tiddlywiki/multiwikiclient/syncer-actions-save-snapshot.tid new file mode 100644 index 000000000..db9b16e15 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/syncer-actions-save-snapshot.tid @@ -0,0 +1,9 @@ +title: $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/save-snapshot +tags: $:/tags/SyncerDropdown + +<$button class="tc-btn-invisible"> +<$wikify name="site-title" text={{$:/config/SaveWikiButton/Filename}}> +<$action-sendmessage $message="tm-download-file" $param={{$:/config/SaveWikiButton/Template}} filename=<<site-title>>/> +</$wikify> +{{$:/core/images/download-button}} Save snapshot for offline use +</$button> diff --git a/plugins/tiddlywiki/multiwikiclient/tags-syncerdropdown.tid b/plugins/tiddlywiki/multiwikiclient/tags-syncerdropdown.tid new file mode 100644 index 000000000..4b5774eb9 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiclient/tags-syncerdropdown.tid @@ -0,0 +1,2 @@ +title: $:/tags/SyncerDropdown +list: $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/login-status $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/login $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/refresh $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/logout $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/save-snapshot $:/plugins/tiddlywiki/multiwikiclient/syncer-actions/copy-logs diff --git a/plugins/tiddlywiki/multiwikiserver/modules/commands/mws-test-server.js b/plugins/tiddlywiki/multiwikiserver/modules/commands/mws-test-server.js index ea7184e54..483400411 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/commands/mws-test-server.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/commands/mws-test-server.js @@ -113,14 +113,15 @@ TestRunner.prototype.runTest = function(testSpec,callback) { const testSpecs = [ { - description: "Check server status", + description: "Check index page", method: "GET", - path: "/wiki/recipe-alpha/status", + path: "/", headers: { accept: "*/*" }, - expectedResult: (jsonData,data) => { - return jsonData.username === "Joe Bloggs"; + expectedResult: (jsonData,data,headers) => { + console.log(JSON.stringify(data).slice(1,100)) + return JSON.stringify(data).slice(1,100) === "\\n<!doctype html>\\n<head>\\n\\t<meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html;charset=utf-8\\\" "; } }, { diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-bag-tiddler.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-bag-tiddler.js new file mode 100644 index 000000000..f0d4fbb98 --- /dev/null +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-bag-tiddler.js @@ -0,0 +1,35 @@ +/*\ +title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/delete-bag-tiddler.js +type: application/javascript +module-type: mws-route + +DELETE /bags/:bag_name/tiddler/:title + +\*/ +(function() { + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.method = "DELETE"; + +exports.path = /^\/bags\/([^\/]+)\/tiddlers\/(.+)$/; + +exports.handler = function(request,response,state) { + // Get the parameters + var bag_name = $tw.utils.decodeURIComponentSafe(state.params[0]), + title = $tw.utils.decodeURIComponentSafe(state.params[1]); + if(bag_name) { + $tw.mws.store.deleteTiddler(title,bag_name); + response.writeHead(204, "OK", { + "Content-Type": "text/plain" + }); + response.end(); + } else { + response.writeHead(404); + response.end(); + } +}; + +}()); diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-recipe-tiddler.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-recipe-tiddler.js deleted file mode 100644 index 06279ce13..000000000 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-recipe-tiddler.js +++ /dev/null @@ -1,39 +0,0 @@ -/*\ -title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/delete-recipe-tiddler.js -type: application/javascript -module-type: mws-route - -DELETE /wiki/:recipe_name/recipes/:bag_name/tiddler/:title - -NOTE: Urls currently include the recipe name twice. This is temporary to minimise the changes to the TiddlyWeb plugin - -\*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ -"use strict"; - -exports.method = "DELETE"; - -exports.path = /^\/wiki\/([^\/]+)\/bags\/([^\/]+)\/tiddlers\/(.+)$/; - -exports.handler = function(request,response,state) { - // Get the parameters - var recipe_name = $tw.utils.decodeURIComponentSafe(state.params[0]), - bag_name = $tw.utils.decodeURIComponentSafe(state.params[1]), - title = $tw.utils.decodeURIComponentSafe(state.params[2]); - var recipeBags = $tw.mws.store.getRecipeBags(recipe_name); - if(recipeBags.indexOf(bag_name) !== -1) { - $tw.mws.store.deleteTiddler(title,bag_name); - response.writeHead(204, "OK", { - "Content-Type": "text/plain" - }); - response.end(); - } else { - response.writeHead(404); - response.end(); - } -}; - -}()); diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag-tiddler-blob.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag-tiddler-blob.js index 90dbe196b..1cf6e3242 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag-tiddler-blob.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag-tiddler-blob.js @@ -3,7 +3,7 @@ title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/get-bag-tiddler-blo type: application/javascript module-type: mws-route -GET /wiki/:bag_name/bags/:bag_name/tiddler/:title/blob +GET /bags/:bag_name/tiddler/:title/blob \*/ (function() { @@ -14,14 +14,13 @@ GET /wiki/:bag_name/bags/:bag_name/tiddler/:title/blob exports.method = "GET"; -exports.path = /^\/wiki\/([^\/]+)\/bags\/([^\/]+)\/tiddlers\/([^\/]+)\/blob$/; +exports.path = /^\/bags\/([^\/]+)\/tiddlers\/([^\/]+)\/blob$/; exports.handler = function(request,response,state) { // Get the parameters const bag_name = $tw.utils.decodeURIComponentSafe(state.params[0]), - bag_name_2 = $tw.utils.decodeURIComponentSafe(state.params[1]), - title = $tw.utils.decodeURIComponentSafe(state.params[2]); - if(bag_name === bag_name_2) { + title = $tw.utils.decodeURIComponentSafe(state.params[1]); + if(bag_name) { const result = $tw.mws.store.getBagTiddlerStream(title,bag_name); if(result) { response.writeHead(200, "OK",{ diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag-tiddler.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag-tiddler.js index 9db23c3ed..56a536a45 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag-tiddler.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag-tiddler.js @@ -3,9 +3,8 @@ title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/get-bag-tiddler.js type: application/javascript module-type: mws-route -GET /wiki/:bag_name/bags/:bag_name/tiddler/:title +GET /bags/:bag_name/tiddler/:title -NOTE: Urls currently include the bag name twice. This is temporary to minimise the changes to the TiddlyWeb plugin \*/ (function() { @@ -16,15 +15,14 @@ NOTE: Urls currently include the bag name twice. This is temporary to minimise t exports.method = "GET"; -exports.path = /^\/wiki\/([^\/]+)\/bags\/([^\/]+)\/tiddlers\/(.+)$/; +exports.path = /^\/bags\/([^\/]+)\/tiddlers\/(.+)$/; exports.handler = function(request,response,state) { // Get the parameters var bag_name = $tw.utils.decodeURIComponentSafe(state.params[0]), - bag_name_2 = $tw.utils.decodeURIComponentSafe(state.params[1]), - title = $tw.utils.decodeURIComponentSafe(state.params[2]), - result = bag_name === bag_name_2 && $tw.mws.store.getBagTiddler(title,bag_name); - if(bag_name === bag_name_2 && result) { + title = $tw.utils.decodeURIComponentSafe(state.params[1]), + result = bag_name && $tw.mws.store.getBagTiddler(title,bag_name); + if(bag_name && result) { // If application/json is requested then this is an API request, and gets the response in JSON if(request.headers.accept && request.headers.accept.indexOf("application/json") !== -1) { var tiddlerFields = {}, diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag.js index d390ab217..49df49f4a 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-bag.js @@ -3,10 +3,8 @@ title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/get-bag.js type: application/javascript module-type: mws-route -GET /wiki/:bag_name/bags/:bag_name/ -GET /wiki/:bag_name/bags/:bag_name - -NOTE: Urls currently include the bag name twice. This is temporary to minimise the changes to the TiddlyWeb plugin +GET /bags/:bag_name/ +GET /bags/:bag_name \*/ (function() { @@ -17,19 +15,18 @@ NOTE: Urls currently include the bag name twice. This is temporary to minimise t exports.method = "GET"; -exports.path = /^\/wiki\/([^\/]+)\/bags\/([^\/]+)(\/?)$/; +exports.path = /^\/bags\/([^\/]+)(\/?)$/; exports.handler = function(request,response,state) { // Redirect if there is no trailing slash. We do this so that the relative URL specified in the upload form works correctly - if(state.params[2] !== "/") { + if(state.params[1] !== "/") { state.redirect(301,state.urlInfo.path + "/"); return; } // Get the parameters var bag_name = $tw.utils.decodeURIComponentSafe(state.params[0]), - bag_name_2 = $tw.utils.decodeURIComponentSafe(state.params[1]), - bagTiddlers = bag_name === bag_name_2 && $tw.mws.store.getBagTiddlers(bag_name); - if(bag_name === bag_name_2 && bagTiddlers) { + bagTiddlers = bag_name && $tw.mws.store.getBagTiddlers(bag_name); + if(bag_name && bagTiddlers) { // If application/json is requested then this is an API request, and gets the response in JSON if(request.headers.accept && request.headers.accept.indexOf("application/json") !== -1) { state.sendResponse(200,{"Content-Type": "application/json"},JSON.stringify(bagTiddlers),"utf8"); diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe-tiddler.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe-tiddler.js index 4a1eee781..b7e1b1333 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe-tiddler.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe-tiddler.js @@ -3,9 +3,7 @@ title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/get-recipe-tiddler. type: application/javascript module-type: mws-route -GET /wiki/:recipe_name/recipes/:recipe_name/tiddler/:title - -NOTE: Urls currently include the recipe name twice. This is temporary to minimise the changes to the TiddlyWeb plugin +GET /recipes/:recipe_name/tiddler/:title \*/ (function() { @@ -16,15 +14,14 @@ NOTE: Urls currently include the recipe name twice. This is temporary to minimis exports.method = "GET"; -exports.path = /^\/wiki\/([^\/]+)\/recipes\/([^\/]+)\/tiddlers\/(.+)$/; +exports.path = /^\/recipes\/([^\/]+)\/tiddlers\/(.+)$/; exports.handler = function(request,response,state) { // Get the parameters var recipe_name = $tw.utils.decodeURIComponentSafe(state.params[0]), - recipe_name_2 = $tw.utils.decodeURIComponentSafe(state.params[1]), - title = $tw.utils.decodeURIComponentSafe(state.params[2]), - tiddlerInfo = recipe_name === recipe_name_2 && $tw.mws.store.getRecipeTiddler(title,recipe_name); - if(recipe_name === recipe_name_2 && tiddlerInfo && tiddlerInfo.tiddler) { + title = $tw.utils.decodeURIComponentSafe(state.params[1]), + tiddlerInfo = recipe_name && $tw.mws.store.getRecipeTiddler(title,recipe_name); + if(recipe_name && tiddlerInfo && tiddlerInfo.tiddler) { // If application/json is requested then this is an API request, and gets the response in JSON if(request.headers.accept && request.headers.accept.indexOf("application/json") !== -1) { var tiddlerFields = {}, diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe-tiddlers-json.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe-tiddlers-json.js index ebab92699..6812b9ded 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe-tiddlers-json.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe-tiddlers-json.js @@ -3,9 +3,7 @@ title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/get-recipe-tiddlers type: application/javascript module-type: mws-route -GET /wiki/:recipe_name/recipes/:recipe_name/tiddlers.json?filter=:filter - -NOTE: Urls currently include the recipe name twice. This is temporary to minimise the changes to the TiddlyWeb plugin +GET /recipes/:recipe_name/tiddlers.json?filter=:filter \*/ (function() { @@ -16,13 +14,12 @@ NOTE: Urls currently include the recipe name twice. This is temporary to minimis exports.method = "GET"; -exports.path = /^\/wiki\/([^\/]+)\/recipes\/([^\/]+)\/tiddlers.json$/; +exports.path = /^\/recipes\/([^\/]+)\/tiddlers.json$/; exports.handler = function(request,response,state) { // Get the parameters - var recipe_name = $tw.utils.decodeURIComponentSafe(state.params[0]), - recipe_name_2 = $tw.utils.decodeURIComponentSafe(state.params[1]); - if(recipe_name === recipe_name_2) { + var recipe_name = $tw.utils.decodeURIComponentSafe(state.params[0]); + if(recipe_name) { // Get the tiddlers in the recipe var recipeTiddlers = $tw.mws.store.getRecipeTiddlers(recipe_name); // Get a skinny version of each tiddler diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe.js index 1ad3ddfe6..484366300 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-recipe.js @@ -36,7 +36,7 @@ exports.handler = function(request,response,state) { $:/boot/bootprefix.js $:/core $:/library/sjcl.js - $:/plugins/tiddlywiki/tiddlyweb + $:/plugins/tiddlywiki/multiwikiclient $:/themes/tiddlywiki/snowwhite $:/themes/tiddlywiki/vanilla ` @@ -57,7 +57,7 @@ exports.handler = function(request,response,state) { response.write(",\n") } }); - response.write(JSON.stringify({title: "$:/config/tiddlyweb/host",text: "$protocol$//$host$$pathname$/"})); + response.write(JSON.stringify({title: "$:/config/multiwikiclient/recipe",text: recipe_name})); response.write(",\n") response.write(template.substring(markerPos + marker.length)) // Finish response diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-status.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-status.js deleted file mode 100644 index 1ec927f73..000000000 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/get-status.js +++ /dev/null @@ -1,42 +0,0 @@ -/*\ -title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/get-status.js -type: application/javascript -module-type: mws-route - -GET /wiki/:recipe_name/status - -\*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ -"use strict"; - -exports.method = "GET"; - -exports.path = /^\/wiki\/([^\/]+)\/status$/; - -exports.handler = function(request,response,state) { - // Get the recipe name from the parameters - var recipe_name = $tw.utils.decodeURIComponentSafe(state.params[0]); - // Compose the response - var text = JSON.stringify({ - username: "Joe Bloggs", - anonymous: false, - read_only: false, - logout_is_available: false, - space: { - recipe: recipe_name - }, - tiddlywiki_version: $tw.version - }); - // Send response - if(text) { - state.sendResponse(200,{"Content-Type": "application/json"},text,"utf8"); - } else { - response.writeHead(404); - response.end(); - } -}; - -}()); diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/post-bag-tiddlers.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/post-bag-tiddlers.js index a4a95183e..d44db0a50 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/post-bag-tiddlers.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/post-bag-tiddlers.js @@ -3,9 +3,7 @@ title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/post-bag-tiddlers.j type: application/javascript module-type: mws-route -POST /wiki/:bag_name/bags/:bag_name/tiddlers/ - -NOTE: Urls currently include the bag name twice. This is temporary to minimise the changes to the TiddlyWeb plugin +POST /bags/:bag_name/tiddlers/ \*/ (function() { @@ -16,7 +14,7 @@ NOTE: Urls currently include the bag name twice. This is temporary to minimise t exports.method = "POST"; -exports.path = /^\/wiki\/([^\/]+)\/bags\/([^\/]+)\/tiddlers\/$/; +exports.path = /^\/bags\/([^\/]+)\/tiddlers\/$/; exports.bodyFormat = "stream"; @@ -27,12 +25,7 @@ exports.handler = function(request,response,state) { fs = require("fs"), processIncomingStream = require("$:/plugins/tiddlywiki/multiwikiserver/routes/helpers/multipart-forms.js").processIncomingStream; // Get the parameters - var bag_name = $tw.utils.decodeURIComponentSafe(state.params[0]), - bag_name_2 = $tw.utils.decodeURIComponentSafe(state.params[1]); - // Require the bag names to match - if(bag_name !== bag_name_2) { - return state.sendResponse(400,{"Content-Type": "text/plain"},"Bad Request: bag names do not match"); - } + var bag_name = $tw.utils.decodeURIComponentSafe(state.params[0]); // Process the incoming data processIncomingStream({ store: $tw.mws.store, diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-bag.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-bag.js index 22ffcaa7c..06b8a57af 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-bag.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-bag.js @@ -3,9 +3,7 @@ title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/put-bag.js type: application/javascript module-type: mws-route -PUT /wiki/:bag_name/bags/:bag_name - -NOTE: Urls currently include the bag name twice. This is temporary to minimise the changes to the TiddlyWeb plugin +PUT /bags/:bag_name \*/ (function() { @@ -16,14 +14,13 @@ NOTE: Urls currently include the bag name twice. This is temporary to minimise t exports.method = "PUT"; -exports.path = /^\/wiki\/([^\/]+)\/bags\/(.+)$/; +exports.path = /^\/bags\/(.+)$/; exports.handler = function(request,response,state) { // Get the parameters var bag_name = $tw.utils.decodeURIComponentSafe(state.params[0]), - bag_name_2 = $tw.utils.decodeURIComponentSafe(state.params[1]), data = $tw.utils.parseJSONSafe(state.data); - if(bag_name === bag_name_2 && data) { + if(bag_name && data) { const result = $tw.mws.store.createBag(bag_name,data.description); if(!result) { state.sendResponse(204,{ diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-recipe-tiddler.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-recipe-tiddler.js index 69dbb685d..e5239d9eb 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-recipe-tiddler.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-recipe-tiddler.js @@ -3,9 +3,7 @@ title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/put-recipe-tiddler. type: application/javascript module-type: mws-route -PUT /wiki/:recipe_name/recipes/:recipe_name/tiddlers/:title - -NOTE: Urls currently include the recipe name twice. This is temporary to minimise the changes to the TiddlyWeb plugin +PUT /recipes/:recipe_name/tiddlers/:title \*/ (function() { @@ -16,13 +14,12 @@ NOTE: Urls currently include the recipe name twice. This is temporary to minimis exports.method = "PUT"; -exports.path = /^\/wiki\/([^\/]+)\/recipes\/([^\/]+)\/tiddlers\/(.+)$/; +exports.path = /^\/recipes\/([^\/]+)\/tiddlers\/(.+)$/; exports.handler = function(request,response,state) { // Get the parameters var recipe_name = $tw.utils.decodeURIComponentSafe(state.params[0]), - recipe_name_2 = $tw.utils.decodeURIComponentSafe(state.params[1]), - title = $tw.utils.decodeURIComponentSafe(state.params[2]), + title = $tw.utils.decodeURIComponentSafe(state.params[1]), fields = $tw.utils.parseJSONSafe(state.data); // Pull up any subfields in the `fields` object if(typeof fields.fields === "object") { @@ -37,8 +34,7 @@ exports.handler = function(request,response,state) { fields[name] = $tw.utils.stringifyList(value); } }); - // Require the recipe names to match - if(recipe_name === recipe_name_2) { + if(recipe_name) { var result = $tw.mws.store.saveRecipeTiddler(fields,recipe_name); if(result) { response.writeHead(204, "OK",{ diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-recipe.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-recipe.js index bff94699a..8c260b36b 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-recipe.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/put-recipe.js @@ -3,9 +3,7 @@ title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/put-recipe.js type: application/javascript module-type: mws-route -PUT /wiki/:recipe_name/recipes/:recipe_name - -NOTE: Urls currently include the recipe name twice. This is temporary to minimise the changes to the TiddlyWeb plugin +PUT /recipes/:recipe_name \*/ (function() { @@ -16,14 +14,13 @@ NOTE: Urls currently include the recipe name twice. This is temporary to minimis exports.method = "PUT"; -exports.path = /^\/wiki\/([^\/]+)\/recipes\/(.+)$/; +exports.path = /^\/recipes\/(.+)$/; exports.handler = function(request,response,state) { // Get the parameters var recipe_name = $tw.utils.decodeURIComponentSafe(state.params[0]), - recipe_name_2 = $tw.utils.decodeURIComponentSafe(state.params[1]), data = $tw.utils.parseJSONSafe(state.data); - if(recipe_name === recipe_name_2 && data) { + if(recipe_name && data) { const result = $tw.mws.store.createRecipe(recipe_name,data.bag_names,data.description); if(!result) { state.sendResponse(204,{ diff --git a/plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js b/plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js index 3e7a81262..ffe95f860 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-store.js @@ -92,7 +92,7 @@ SqlTiddlerStore.prototype.processOutgoingTiddler = function(tiddlerFields,tiddle }); if(attachment_blob !== null) { delete fields.text; - fields._canonical_uri = `/wiki/${encodeURIComponent(bag_name)}/bags/${encodeURIComponent(bag_name)}/tiddlers/${encodeURIComponent(tiddlerFields.title)}/blob`; + fields._canonical_uri = `/bags/${encodeURIComponent(bag_name)}/tiddlers/${encodeURIComponent(tiddlerFields.title)}/blob`; } return fields; }; diff --git a/plugins/tiddlywiki/multiwikiserver/system-files/styles.css.tid b/plugins/tiddlywiki/multiwikiserver/system-files/styles.css.tid index 0f1449c55..1c67f142e 100644 --- a/plugins/tiddlywiki/multiwikiserver/system-files/styles.css.tid +++ b/plugins/tiddlywiki/multiwikiserver/system-files/styles.css.tid @@ -98,11 +98,6 @@ body { color: currentcolor; } -.mws-favicon.tc-image-loading, .mws-favicon-small.tc-image-loading, -.mws-favicon.tc-image-error, .mws-favicon-small.tc-image-error { - visibility: hidden; -} - .mws-favicon { object-fit: contain; width: 4em; diff --git a/plugins/tiddlywiki/multiwikiserver/templates/get-bag.tid b/plugins/tiddlywiki/multiwikiserver/templates/get-bag.tid index 2c8e43e2f..94ffe504d 100644 --- a/plugins/tiddlywiki/multiwikiserver/templates/get-bag.tid +++ b/plugins/tiddlywiki/multiwikiserver/templates/get-bag.tid @@ -1,7 +1,7 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/get-bag ! <$image - source=`/wiki/${ [<bag-name>encodeuricomponent[]] }$/bags/${ [<bag-name>encodeuricomponent[]] }$/tiddlers/%24%3A%2Ffavicon.ico` + source=`/bags/${ [<bag-name>encodeuricomponent[]] }$/tiddlers/%24%3A%2Ffavicon.ico` class="mws-favicon-small" width="32px" > @@ -43,7 +43,7 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/get-bag <ul> <$list filter="[<bag-titles>jsonget[]sort[]]"> <li> -<a href=`/wiki/${ [<bag-name>encodeuricomponent[]] }$/bags/${ [<bag-name>encodeuricomponent[]] }$/tiddlers/${ [<currentTiddler>encodeuricomponent[]] }$` rel="noopener noreferrer" target="_blank"> +<a href=`/bags/${ [<bag-name>encodeuricomponent[]] }$/tiddlers/${ [<currentTiddler>encodeuricomponent[]] }$` rel="noopener noreferrer" target="_blank"> <$text text=<<currentTiddler>>/> </a> </li> diff --git a/plugins/tiddlywiki/multiwikiserver/templates/get-index.tid b/plugins/tiddlywiki/multiwikiserver/templates/get-index.tid index b9c6cd7fd..693d9190f 100644 --- a/plugins/tiddlywiki/multiwikiserver/templates/get-index.tid +++ b/plugins/tiddlywiki/multiwikiserver/templates/get-index.tid @@ -3,9 +3,9 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/get-index \procedure bagPill(element-tag:"span",is-topmost:"no") \whitespace trim <$genesis $type=<<element-tag>> class={{{ mws-bag-pill [<is-topmost>match[yes]then[mws-bag-pill-topmost]] +[join[ ]] }}}> - <a class="mws-bag-pill-link" href=`/wiki/${ [<bag-name>encodeuricomponent[]] }$/bags/${ [<bag-name>encodeuricomponent[]] }$` rel="noopener noreferrer" target="_blank"> + <a class="mws-bag-pill-link" href=`/bags/${ [<bag-name>encodeuricomponent[]] }$` rel="noopener noreferrer" target="_blank"> <img - src=`/wiki/${ [<bag-name>encodeuricomponent[]] }$/bags/${ [<bag-name>encodeuricomponent[]] }$/tiddlers/%24%3A%2Ffavicon.ico` + src=`/bags/${ [<bag-name>encodeuricomponent[]] }$/tiddlers/%24%3A%2Ffavicon.ico` class="mws-favicon-small" /> <span class="mws-bag-pill-label"> @@ -29,7 +29,7 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/get-index > <div class="mws-wiki-card-image"> <img - src=`/wiki/${ [<recipe-name>encodeuricomponent[]] }$/recipes/${ [<recipe-name>encodeuricomponent[]] }$/tiddlers/%24%3A%2Ffavicon.ico` + src=`/recipes/${ [<recipe-name>encodeuricomponent[]] }$/tiddlers/%24%3A%2Ffavicon.ico` class="mws-favicon" /> </div> diff --git a/plugins/tiddlywiki/multiwikiserver/templates/post-bag-tiddlers.tid b/plugins/tiddlywiki/multiwikiserver/templates/post-bag-tiddlers.tid index 01d0fa898..9a24e2bf3 100644 --- a/plugins/tiddlywiki/multiwikiserver/templates/post-bag-tiddlers.tid +++ b/plugins/tiddlywiki/multiwikiserver/templates/post-bag-tiddlers.tid @@ -1,7 +1,7 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/post-bag-tiddlers ! <$image - source=`/wiki/${ [<bag-name>encodeuricomponent[]] }$/bags/${ [<bag-name>encodeuricomponent[]] }$/tiddlers/%24%3A%2Ffavicon.ico` + source=`/bags/${ [<bag-name>encodeuricomponent[]] }$/tiddlers/%24%3A%2Ffavicon.ico` class="mws-favicon-small" width="32px" > @@ -23,7 +23,7 @@ The following tiddlers were successfully imported: <ul> <$list filter="[<imported-titles>jsonget[]sort[]]"> <li> -<a href=`/wiki/${ [<bag-name>encodeuricomponent[]] }$/bags/${ [<bag-name>encodeuricomponent[]] }$/tiddlers/${ [<currentTiddler>encodeuricomponent[]] }$` rel="noopener noreferrer" target="_blank"> +<a href=`/bags/${ [<bag-name>encodeuricomponent[]] }$/tiddlers/${ [<currentTiddler>encodeuricomponent[]] }$` rel="noopener noreferrer" target="_blank"> <$text text=<<currentTiddler>>/> </a> </li>