mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
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:
parent
5d650e87dd
commit
aa8f7f77d6
@ -1,5 +1,6 @@
|
|||||||
title: $:/core/save/all-external-js
|
title: $:/core/save/all-external-js
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
|
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
|
||||||
\define saveTiddlerFilter()
|
\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)$
|
[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)$
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
title: $:/core/save/offline-external-js
|
title: $:/core/save/offline-external-js
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
|
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
|
||||||
\define saveTiddlerFilter()
|
\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)$
|
[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)$
|
||||||
|
3
core/templates/external-js/tiddlywiki.js.load.tid
Normal file
3
core/templates/external-js/tiddlywiki.js.load.tid
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
title: $:/core/templates/tiddlywiki.js/load-tiddler
|
||||||
|
|
||||||
|
_load(window,<$macrocall $name="jsontiddler" $output="text/raw"/>);
|
@ -1,15 +1,48 @@
|
|||||||
|
|
||||||
title: $:/core/templates/tiddlywiki5.js
|
title: $:/core/templates/tiddlywiki5.js
|
||||||
|
|
||||||
\rules only filteredtranscludeinline transcludeinline codeinline
|
\rules only filteredtranscludeinline transcludeinline codeinline
|
||||||
|
|
||||||
/*
|
`/*
|
||||||
{{ $:/core/copyright.txt ||$:/core/templates/plain-text-tiddler}}
|
`{{ $:/core/copyright.txt ||$:/core/templates/plain-text-tiddler}}`
|
||||||
`*/
|
*/
|
||||||
`<!--~~ Library modules ~~-->
|
|
||||||
{{{ [is[system]type[application/javascript]library[yes]] ||$:/core/templates/plain-text-tiddler}}}
|
$tw = (typeof $tw === 'undefined') ? Object.create(null) : $tw;
|
||||||
<!--~~ Boot prefix ~~-->
|
|
||||||
{{ $:/boot/bootprefix.js ||$:/core/templates/plain-text-tiddler}}
|
$tw.preloadTiddlers = $tw.preloadTiddlers || [];
|
||||||
<!--~~ Core plugin ~~-->
|
|
||||||
{{$:/core/templates/tiddlywiki5.js/tiddlers}}
|
_load = function(window,tiddler) {
|
||||||
<!--~~ Boot kernel ~~-->
|
"use strict";
|
||||||
{{ $:/boot/boot.js ||$:/core/templates/plain-text-tiddler}}
|
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}}`
|
||||||
|
@ -1,48 +1,50 @@
|
|||||||
title: $:/core/templates/tiddlywiki5-external-js.html
|
title: $:/core/templates/tiddlywiki5-external-js.html
|
||||||
|
|
||||||
\rules only filteredtranscludeinline transcludeinline
|
<$set name="saveTiddlerAndShadowsFilter" filter="[subfilter<saveTiddlerFilter>] [subfilter<saveTiddlerFilter>plugintiddlers[]]">
|
||||||
<!doctype html>
|
`<!doctype html>
|
||||||
{{$:/core/templates/MOTW.html}}<html lang="{{{ [{$:/language}get[name]] }}}">
|
`{{$:/core/templates/MOTW.html}}`<html lang="`<$text text={{{ [{$:/language}get[name]] }}}/>`">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||||
<!--~~ Raw markup for the top of the head section ~~-->
|
<!--~~ 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 http-equiv="X-UA-Compatible" content="IE=Edge"/>
|
||||||
<meta name="application-name" content="TiddlyWiki" />
|
<meta name="application-name" content="TiddlyWiki" />
|
||||||
<meta name="generator" 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="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||||
<meta name="mobile-web-app-capable" content="yes"/>
|
<meta name="mobile-web-app-capable" content="yes"/>
|
||||||
<meta name="format-detection" content="telephone=no" />
|
<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">
|
<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 ~~-->
|
<!--~~ This is a Tiddlywiki file. The points of interest in the file are marked with this pattern ~~-->
|
||||||
|
|
||||||
<!--~~ Raw markup ~~-->
|
<!--~~ Raw markup ~~-->
|
||||||
{{{ [all[shadows+tiddlers]tag[$:/core/wiki/rawmarkup]] [all[shadows+tiddlers]tag[$:/tags/RawMarkup]] ||$:/core/templates/plain-text-tiddler}}}
|
`{{{ [enlist<saveTiddlerAndShadowsFilter>tag[$:/core/wiki/rawmarkup]] ||$:/core/templates/plain-text-tiddler}}}`
|
||||||
{{{ [all[shadows+tiddlers]tag[$:/tags/RawMarkupWikified]] ||$:/core/templates/raw-static-tiddler}}}
|
`{{{ [enlist<saveTiddlerAndShadowsFilter>tag[$:/tags/RawMarkup]] ||$:/core/templates/plain-text-tiddler}}}`
|
||||||
|
`{{{ [enlist<saveTiddlerAndShadowsFilter>tag[$:/tags/RawMarkupWikified]] ||$:/core/templates/raw-static-tiddler}}}`
|
||||||
</head>
|
</head>
|
||||||
<body class="tc-body">
|
<body class="tc-body">
|
||||||
<!--~~ Raw markup for the top of the body section ~~-->
|
<!--~~ 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 ~~-->
|
<!--~~ Static styles ~~-->
|
||||||
<div id="styleArea">
|
<div id="styleArea">
|
||||||
{{$:/boot/boot.css||$:/core/templates/css-tiddler}}
|
`{{$:/boot/boot.css||$:/core/templates/css-tiddler}}`
|
||||||
</div>
|
</div>
|
||||||
<!--~~ Static content for Google and browsers without JavaScript ~~-->
|
<!--~~ Static content for Google and browsers without JavaScript ~~-->
|
||||||
<noscript>
|
<noscript>
|
||||||
<div id="splashArea">
|
<div id="splashArea">
|
||||||
{{$:/core/templates/static.area}}
|
`{{$:/core/templates/static.area}}`
|
||||||
</div>
|
</div>
|
||||||
</noscript>
|
</noscript>
|
||||||
<!--~~ Ordinary tiddlers ~~-->
|
<!--~~ Ordinary tiddlers ~~-->
|
||||||
{{$:/core/templates/store.area.template.html}}
|
`{{$:/core/templates/store.area.template.html}}`
|
||||||
<!--~~ Raw markup for the bottom of the body section ~~-->
|
<!--~~ 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>
|
</body>
|
||||||
<!--~~ Load external JS ~~-->
|
</html>`
|
||||||
<script src="{{{ [<coreURL>] }}}" onerror="alert('Error: Cannot load {{{ [<coreURL>] }}}');"></script>
|
</$set>
|
||||||
</html>
|
|
18
core/ui/DownloadFullWiki.tid
Normal file
18
core/ui/DownloadFullWiki.tid
Normal 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>
|
@ -1,11 +1,6 @@
|
|||||||
title: $:/core/ui/ExportTiddlyWikiCore
|
title: $:/core/ui/ExportTiddlyWikiCore
|
||||||
|
|
||||||
\define jsFileName() tiddlywikicore-$(version)$.js
|
\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
|
\rules except wikilink
|
||||||
\whitespace trim
|
\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"
|
tooltip="Export the TiddlyWiki core code for running with external JavaScript"
|
||||||
aria-label="export TiddlyWiki core"
|
aria-label="export TiddlyWiki core"
|
||||||
class="tc-btn-big-green">
|
class="tc-btn-big-green">
|
||||||
<$list
|
<$action-sendmessage $message='tm-download-file' $param='$:/core/templates/tiddlywiki5.js' filename=<<jsFileName>>/>
|
||||||
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>
|
|
||||||
{{$:/core/images/download-button}}
|
{{$:/core/images/download-button}}
|
||||||
 
|
<span class="tc-tiny-gap-left">
|
||||||
Download TiddlyWiki core
|
Download TiddlyWiki core
|
||||||
|
</span>
|
||||||
</$button>
|
</$button>
|
||||||
|
|
||||||
[[Further information|https://tiddlywiki.com/#Using%20the%20external%20JavaScript%20template]]
|
[[Further information|https://tiddlywiki.com/#Using%20the%20external%20JavaScript%20template]]
|
||||||
|
Loading…
Reference in New Issue
Block a user