From 86909368056b1cabaea4b91063b23bc9ac59ef2f Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Fri, 23 Jun 2023 16:58:46 +0100 Subject: [PATCH] Cleanup and clarify --- ...awmarkup-bottombody.js => init-sqlite3.js} | 40 +++++++++---------- .../sqlite3store/rawmarkup-bottombody.tid | 2 +- .../sqlite3store/rawmarkup-bottomhead.tid | 7 ++++ plugins/tiddlywiki/sqlite3store/rawmarkup.tid | 6 --- .../{rawmarkup.js => sql-wiki-store.js} | 19 +++------ .../tiddlywiki/sqlite3store/suppress-boot.js | 23 +++++++++++ 6 files changed, 55 insertions(+), 42 deletions(-) rename plugins/tiddlywiki/sqlite3store/{rawmarkup-bottombody.js => init-sqlite3.js} (69%) create mode 100644 plugins/tiddlywiki/sqlite3store/rawmarkup-bottomhead.tid delete mode 100644 plugins/tiddlywiki/sqlite3store/rawmarkup.tid rename plugins/tiddlywiki/sqlite3store/{rawmarkup.js => sql-wiki-store.js} (96%) create mode 100644 plugins/tiddlywiki/sqlite3store/suppress-boot.js diff --git a/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.js b/plugins/tiddlywiki/sqlite3store/init-sqlite3.js similarity index 69% rename from plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.js rename to plugins/tiddlywiki/sqlite3store/init-sqlite3.js index 826c49693..839fa9e34 100644 --- a/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.js +++ b/plugins/tiddlywiki/sqlite3store/init-sqlite3.js @@ -1,17 +1,20 @@ /*\ -title: $:/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.js -type: text/plain +title: $:/plugins/tiddlywiki/sqlite3store/init-sqlite3.js +type: application/javascript -Startup code injected as raw markup at the bottom of the body section +Initialise sqlite3 and then boot TiddlyWiki + +This file is spliced into the HTML file to be executed after the boot kernel has been loaded. \*/ (function() { -// Get the main tiddler store -var storeEl = document.querySelector("script.tiddlywiki-tiddler-store"); -var tiddlerStore = JSON.parse(storeEl.textContent); +// Get the main tiddler store out of the HTML file +var storeEl = document.querySelector("script.tiddlywiki-tiddler-store"), + tiddlerStore = JSON.parse(storeEl.textContent); +// Helper to get a tiddler from the store by title function getTiddler(title) { for(var t=0; t{ // Save a reference to the sqlite3 object @@ -61,4 +57,4 @@ self.sqlite3InitModule().then((sqlite3)=>{ }); })(); -//# sourceURL=$:/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.js \ No newline at end of file +//# sourceURL=$:/plugins/tiddlywiki/sqlite3store/init-sqlite3.js \ No newline at end of file diff --git a/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.tid b/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.tid index 06d52e70f..ee187883a 100644 --- a/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.tid +++ b/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.tid @@ -2,5 +2,5 @@ title: $:/plugins/tiddlywiki/sqlite3store/rawmarkup/bottombody tags: $:/tags/RawMarkupWikified/BottomBody `` diff --git a/plugins/tiddlywiki/sqlite3store/rawmarkup-bottomhead.tid b/plugins/tiddlywiki/sqlite3store/rawmarkup-bottomhead.tid new file mode 100644 index 000000000..041b72b9b --- /dev/null +++ b/plugins/tiddlywiki/sqlite3store/rawmarkup-bottomhead.tid @@ -0,0 +1,7 @@ +title: $:/plugins/tiddlywiki/sqlite3store/rawmarkup-bottomhead +tags: $:/tags/RawMarkupWikified + +`` diff --git a/plugins/tiddlywiki/sqlite3store/rawmarkup.tid b/plugins/tiddlywiki/sqlite3store/rawmarkup.tid deleted file mode 100644 index 09a7ead3e..000000000 --- a/plugins/tiddlywiki/sqlite3store/rawmarkup.tid +++ /dev/null @@ -1,6 +0,0 @@ -title: $:/plugins/tiddlywiki/sqlite3store/rawmarkup -tags: $:/tags/RawMarkupWikified - -`` diff --git a/plugins/tiddlywiki/sqlite3store/rawmarkup.js b/plugins/tiddlywiki/sqlite3store/sql-wiki-store.js similarity index 96% rename from plugins/tiddlywiki/sqlite3store/rawmarkup.js rename to plugins/tiddlywiki/sqlite3store/sql-wiki-store.js index 12ee3d221..5ec0c6c3b 100644 --- a/plugins/tiddlywiki/sqlite3store/rawmarkup.js +++ b/plugins/tiddlywiki/sqlite3store/sql-wiki-store.js @@ -1,22 +1,15 @@ /*\ -title: $:/plugins/tiddlywiki/sqlite3store/rawmarkup.js -type: text/plain +title: $:/plugins/tiddlywiki/sqlite3store/sql-wiki-store.js +type: application/javascript -Startup code injected as raw markup +A sqlite3 implementation of a wiki store object + +This file is spliced into the HTML file to be executed before the boot kernel has been loaded. \*/ (function() { -// Initialse skeleton TiddlyWiki global because we run before bootprefix.js and boot.js -window.$tw = window.$tw || Object.create(null); -$tw.hooks = $tw.hooks || { names: {}}; -$tw.boot = $tw.boot || {}; -$tw.boot.preloadDirty = $tw.boot.preloadDirty || []; - -// Tell TiddlyWiki not to boot itself -$tw.boot.suppressBoot = true; - $tw.Wiki = function(options) { // Create a test database and store and retrieve some data var db = new $tw.sqlite3.oo1.DB("/tiddlywiki.sqlite3","ct"); @@ -480,4 +473,4 @@ $tw.Wiki = function(options) { }; })(); -//# sourceURL=$:/plugins/tiddlywiki/sqlite3store/rawmarkup.js \ No newline at end of file +//# sourceURL=$:/plugins/tiddlywiki/sqlite3store/sql-wiki-store.js \ No newline at end of file diff --git a/plugins/tiddlywiki/sqlite3store/suppress-boot.js b/plugins/tiddlywiki/sqlite3store/suppress-boot.js new file mode 100644 index 000000000..e7389c732 --- /dev/null +++ b/plugins/tiddlywiki/sqlite3store/suppress-boot.js @@ -0,0 +1,23 @@ +/*\ +title: $:/plugins/tiddlywiki/sqlite3store/suppress-boot.js +type: application/javascript + +Suppress the usual synchronous startup process so that it can instead be done within the callback from sqlite3 initialisation. + +This file is spliced into the HTML file to be executed before the boot kernel has been loaded. + +\*/ + +(function() { + +// Initialse skeleton TiddlyWiki global because we run before bootprefix.js and boot.js +window.$tw = window.$tw || Object.create(null); +$tw.hooks = $tw.hooks || { names: {}}; +$tw.boot = $tw.boot || {}; +$tw.boot.preloadDirty = $tw.boot.preloadDirty || []; + +// Tell TiddlyWiki not to boot itself +$tw.boot.suppressBoot = true; + +})(); +//# sourceURL=$:/plugins/tiddlywiki/sqlite3store/suppress-boot.js \ No newline at end of file