External.js: Allow boot code to remain as tiddlers in tiddlywikicore.js (#7210)

* Allow boot code to remain as tiddlers

* Sync up with tiddlywiki5.html

* Add \whitespace trim

* Add download-full-wiki button

* Simplify ExportTiddlyWikiCore code

No longer needs the if-boot-code-is-missing part of the code.

* Replace space btw icon and button text with CSS
This commit is contained in:
cdruan 2023-01-19 08:52:12 -08:00 committed by GitHub
parent 5d650e87dd
commit aa8f7f77d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 89 additions and 41 deletions

View File

@ -1,5 +1,6 @@
title: $:/core/save/all-external-js
\whitespace trim
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\define saveTiddlerFilter()
[is[tiddler]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/core]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] $(publishFilter)$

View File

@ -1,5 +1,6 @@
title: $:/core/save/offline-external-js
\whitespace trim
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\define saveTiddlerFilter()
[is[tiddler]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/core]] -[[$:/plugins/tiddlywiki/filesystem]] -[[$:/plugins/tiddlywiki/tiddlyweb]] -[[$:/boot/boot.css]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] +[sort[title]] $(publishFilter)$

View File

@ -0,0 +1,3 @@
title: $:/core/templates/tiddlywiki.js/load-tiddler
_load(window,<$macrocall $name="jsontiddler" $output="text/raw"/>);

View File

@ -1,15 +1,48 @@
title: $:/core/templates/tiddlywiki5.js
\rules only filteredtranscludeinline transcludeinline codeinline
/*
{{ $:/core/copyright.txt ||$:/core/templates/plain-text-tiddler}}
`*/
`<!--~~ Library modules ~~-->
{{{ [is[system]type[application/javascript]library[yes]] ||$:/core/templates/plain-text-tiddler}}}
<!--~~ Boot prefix ~~-->
{{ $:/boot/bootprefix.js ||$:/core/templates/plain-text-tiddler}}
<!--~~ Core plugin ~~-->
{{$:/core/templates/tiddlywiki5.js/tiddlers}}
<!--~~ Boot kernel ~~-->
{{ $:/boot/boot.js ||$:/core/templates/plain-text-tiddler}}
`/*
`{{ $:/core/copyright.txt ||$:/core/templates/plain-text-tiddler}}`
*/
$tw = (typeof $tw === 'undefined') ? Object.create(null) : $tw;
$tw.preloadTiddlers = $tw.preloadTiddlers || [];
_load = function(window,tiddler) {
"use strict";
var f;
$tw.preloadTiddlers.push(tiddler);
if(tiddler.library === "yes") {
var module = { exports:{} };
var moduleName = function moduleName(path) {
var word = path.split("/").pop();
word = word.substring(0,word.indexOf(".")) || word;
return word;
}
f = new Function("module",tiddler.text);
f(module);
window[moduleName(tiddler.title)] = module.exports;
} else {
f = new Function("window",tiddler.text);
f(window);
}
}
/* ~~ Library modules ~~ */
`{{{ [is[system]type[application/javascript]library[yes]] ||$:/core/templates/tiddlywiki.js/load-tiddler}}}`
/* ~~ Boot kernel prologue ~~ */
`{{ $:/boot/bootprefix.js ||$:/core/templates/tiddlywiki.js/load-tiddler}}`
/* ~~ Core tiddlers ~~ */
`{{$:/core/templates/tiddlywiki5.js/tiddlers}}`
/* ~~ Boot kernel ~~ */
`{{ $:/boot/boot.js ||$:/core/templates/tiddlywiki.js/load-tiddler}}`

View File

@ -1,48 +1,50 @@
title: $:/core/templates/tiddlywiki5-external-js.html
\rules only filteredtranscludeinline transcludeinline
<!doctype html>
{{$:/core/templates/MOTW.html}}<html lang="{{{ [{$:/language}get[name]] }}}">
<$set name="saveTiddlerAndShadowsFilter" filter="[subfilter<saveTiddlerFilter>] [subfilter<saveTiddlerFilter>plugintiddlers[]]">
`<!doctype html>
`{{$:/core/templates/MOTW.html}}`<html lang="`<$text text={{{ [{$:/language}get[name]] }}}/>`">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<!--~~ Raw markup for the top of the head section ~~-->
{{{ [all[shadows+tiddlers]tag[$:/tags/RawMarkupWikified/TopHead]] ||$:/core/templates/raw-static-tiddler}}}
`{{{ [enlist<saveTiddlerAndShadowsFilter>tag[$:/tags/RawMarkupWikified/TopHead]] ||$:/core/templates/raw-static-tiddler}}}`
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta name="application-name" content="TiddlyWiki" />
<meta name="generator" content="TiddlyWiki" />
<meta name="tiddlywiki-version" content="{{$:/core/templates/version}}" />
<meta name="tiddlywiki-version" content="`{{$:/core/templates/version}}`" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="mobile-web-app-capable" content="yes"/>
<meta name="format-detection" content="telephone=no" />
<meta name="copyright" content="{{$:/core/copyright.txt}}" />
<meta name="copyright" content="`{{$:/core/copyright.txt}}`" />
<link id="faviconLink" rel="shortcut icon" href="favicon.ico">
<title>{{$:/core/wiki/title}}</title>
<title>`{{$:/core/wiki/title}}`</title>
<!--~~ This is a Tiddlywiki file. The points of interest in the file are marked with this pattern ~~-->
<!--~~ Raw markup ~~-->
{{{ [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}}}
`{{{ [enlist<saveTiddlerAndShadowsFilter>tag[$:/core/wiki/rawmarkup]] ||$:/core/templates/plain-text-tiddler}}}`
`{{{ [enlist<saveTiddlerAndShadowsFilter>tag[$:/tags/RawMarkup]] ||$:/core/templates/plain-text-tiddler}}}`
`{{{ [enlist<saveTiddlerAndShadowsFilter>tag[$:/tags/RawMarkupWikified]] ||$:/core/templates/raw-static-tiddler}}}`
</head>
<body class="tc-body">
<!--~~ Raw markup for the top of the body section ~~-->
{{{ [all[shadows+tiddlers]tag[$:/tags/RawMarkupWikified/TopBody]] ||$:/core/templates/raw-static-tiddler}}}
`{{{ [enlist<saveTiddlerAndShadowsFilter>tag[$:/tags/RawMarkupWikified/TopBody]] ||$:/core/templates/raw-static-tiddler}}}`
<!--~~ Static styles ~~-->
<div id="styleArea">
{{$:/boot/boot.css||$:/core/templates/css-tiddler}}
`{{$:/boot/boot.css||$:/core/templates/css-tiddler}}`
</div>
<!--~~ Static content for Google and browsers without JavaScript ~~-->
<noscript>
<div id="splashArea">
{{$:/core/templates/static.area}}
`{{$:/core/templates/static.area}}`
</div>
</noscript>
<!--~~ Ordinary tiddlers ~~-->
{{$:/core/templates/store.area.template.html}}
`{{$:/core/templates/store.area.template.html}}`
<!--~~ Raw markup for the bottom of the body section ~~-->
{{{ [all[shadows+tiddlers]tag[$:/tags/RawMarkupWikified/BottomBody]] ||$:/core/templates/raw-static-tiddler}}}
`{{{ [enlist<saveTiddlerAndShadowsFilter>tag[$:/tags/RawMarkupWikified/BottomBody]] ||$:/core/templates/raw-static-tiddler}}}`
<!--~~ Load external JavaScripts ~~-->
<script src="`{{{ [<coreURL>] }}}`" onerror="alert('Error: Cannot load `{{{ [<coreURL>] }}}`');"></script>
</body>
<!--~~ Load external JS ~~-->
<script src="{{{ [<coreURL>] }}}" onerror="alert('Error: Cannot load {{{ [<coreURL>] }}}');"></script>
</html>
</html>`
</$set>

View File

@ -0,0 +1,18 @@
title: $:/core/ui/DownloadFullWiki
\whitespace trim
\rules except wikilink
To download the standard single-file version of your wiki:
<$wikify name="site-title" text={{$:/config/SaveWikiButton/Filename}}>
<$let publishFilter="""-[[$:/config/SaveWikiButton/Template]] -[[$:/plugins/tiddlywiki/filesystem]] -[[$:/plugins/tiddlywiki/tiddlyweb]]""">
<$button tooltip="Download fully standalone wiki" aria-label="download full wiki" class="tc-btn-big-green">
<$action-sendmessage $message="tm-download-file" $param="$:/core/save/all" publishFilter=<<publishFilter>> filename=<<site-title>>/>
{{$:/core/images/download-button}}
<span class="tc-tiny-gap-left">
Download full wiki
</span>
</$button>
</$let>
</$wikify>

View File

@ -1,11 +1,6 @@
title: $:/core/ui/ExportTiddlyWikiCore
\define jsFileName() tiddlywikicore-$(version)$.js
\define noExportMsg()
It appears that you have a wiki with an external ~TiddlyWiki core. The export action cannot be performed.
<p>You will need to view the page source in your browser. Then go to the very bottom the the source, find the last `<script>`
element, and right-click its `src` URI. Save the link as ''$(jsFileName)$''</p>
\end
\rules except wikilink
\whitespace trim
@ -17,16 +12,11 @@ Export the TiddlyWiki core JavaScript code for running with external JavaScript:
tooltip="Export the TiddlyWiki core code for running with external JavaScript"
aria-label="export TiddlyWiki core"
class="tc-btn-big-green">
<$list
filter="[[$:/boot/boot.js]is[missing]]"
variable="ignore"
emptyMessage="<$action-sendmessage $message='tm-download-file' $param='$:/core/templates/tiddlywiki5.js' filename=<<jsFileName>>/>" >
<$action-setfield $tiddler=<<qualify "$:/temp/alert">> text=<<noExportMsg>> subtitle="Export ~TiddllyWiki Core"/>
<$action-sendmessage $message="tm-modal" $param=<<qualify "$:/temp/alert">>/>
</$list>
<$action-sendmessage $message='tm-download-file' $param='$:/core/templates/tiddlywiki5.js' filename=<<jsFileName>>/>
{{$:/core/images/download-button}}
&#32;
<span class="tc-tiny-gap-left">
Download TiddlyWiki core
</span>
</$button>
[[Further information|https://tiddlywiki.com/#Using%20the%20external%20JavaScript%20template]]