UNPKG

tiddlywiki-production

Version:
1 lines 15.3 kB
$tw.preloadTiddler({"title":"$:/plugins/tiddlywiki/share","name":"Share","description":"Sharing tiddlers via URLs","list":"readme wizard settings","version":"5.1.22","plugin-type":"plugin","dependents":"","type":"application/json","text":"{\"tiddlers\":{\"$:/DefaultTiddlers\":{\"title\":\"$:/DefaultTiddlers\",\"text\":\"[list[$:/StoryList]]\"},\"$:/SiteSubtitle\":{\"title\":\"$:/SiteSubtitle\",\"text\":\"tools to share tiddlers via URLs\"},\"$:/SiteTitle\":{\"title\":\"$:/SiteTitle\",\"text\":\"Share\"},\"$:/plugins/tiddlywiki/share/above-story\":{\"title\":\"$:/plugins/tiddlywiki/share/above-story\",\"tags\":\"$:/tags/AboveStory\",\"text\":\"<$transclude tiddler=\\\"$:/plugins/tiddlywiki/share/wizard\\\" mode=\\\"block\\\"/>\\n\"},\"$:/config/plugins/share/base-url\":{\"title\":\"$:/config/plugins/share/base-url\",\"text\":\"\"},\"$:/config/plugins/share/exclusions\":{\"title\":\"$:/config/plugins/share/exclusions\",\"text\":\"$:/library/sjcl.js $:/boot/bootprefix.js $:/boot/boot.js $:/boot/boot.css $:/core $:/isEncrypted $:/plugins/tiddlywiki/share $:/status/RequireReloadDueToPluginChange $:/temp/info-plugin $:/themes/tiddlywiki/snowwhite $:/themes/tiddlywiki/vanilla $:/HistoryList [prefix[$:/temp/]] [[$:/build]]\"},\"$:/config/plugins/share/filter\":{\"title\":\"$:/config/plugins/share/filter\",\"text\":\"[all[tiddlers]] -[subfilter{$:/config/plugins/share/exclusions}]\"},\"$:/core/ui/PageTemplate/pluginreloadwarning\":{\"title\":\"$:/core/ui/PageTemplate/pluginreloadwarning\",\"text\":\"<!-- Disable plugin reload warnings -->\\n\"},\"$:/plugins/tiddlywiki/share/rawmarkup.js\":{\"title\":\"$:/plugins/tiddlywiki/share/rawmarkup.js\",\"text\":\"/*\\\\\\ntitle: $:/plugins/tiddlywiki/share/rawmarkup.js\\ntype: application/javascript\\nmodule-type: library\\n\\nRead tiddlers from the browser location hash\\n\\n\\\\*/\\n(function(){\\n\\n/*jslint node: true, browser: true */\\n/*global $tw: false */\\n\\\"use strict\\\";\\n\\n// Get the hash\\nvar rawHash = document.location.hash.substring(1);\\nif(rawHash.charAt(0) === \\\"#\\\") {\\n\\tvar hash;\\n\\ttry{\\n\\t\\thash = decodeURIComponent(rawHash.substring(1));\\n\\t} catch(ex) {\\n\\t\\tconsole.log(\\\"Share plugin: Error decoding location hash\\\",ex);\\n\\t}\\n\\t// Try to parse the hash as JSON\\n\\tif(hash) {\\n\\t\\tvar tiddlers;\\n\\t\\ttry {\\n\\t\\t\\ttiddlers= JSON.parse(hash);\\n\\t\\t} catch(ex) {\\n\\t\\t\\tconsole.log(\\\"Share plugin: Error parsing JSON from location hash\\\",ex);\\n\\t\\t}\\n\\t\\tif(tiddlers) {\\n\\t\\t\\t// Need to initialise these because we run before bootprefix.js and boot.js\\n\\t\\t\\twindow.$tw = window.$tw || {};\\n\\t\\t\\t$tw.boot = $tw.boot || {};\\n\\t\\t\\t$tw.preloadTiddlers = $tw.preloadTiddlers || [];\\n\\t\\t\\t// Prevent TiddlyWiki from booting\\n\\t\\t\\t$tw.boot.suppressBoot = true;\\n\\t\\t\\t// Load our styles\\n\\t\\t\\tvar stylesWrapper = document.createElement(\\\"style\\\");\\n\\t\\t\\tstylesWrapper.innerHTML = tiddlywikiSharePluginStartupWarningCss;\\n\\t\\t\\tdocument.documentElement.appendChild(stylesWrapper);\\n\\t\\t\\t// Display the warning banner\\n\\t\\t\\tvar warningWrapper = document.createElement(\\\"div\\\");\\n\\t\\t\\twarningWrapper.innerHTML = tiddlywikiSharePluginStartupWarningHtml;\\n\\t\\t\\tdocument.documentElement.appendChild(warningWrapper);\\n\\t\\t\\t// Add our event handlers\\n\\t\\t\\tdocument.getElementById(\\\"startup-warning-proceed\\\").addEventListener(\\\"click\\\",actionProceed,false);\\n\\t\\t\\tdocument.getElementById(\\\"startup-warning-cancel\\\").addEventListener(\\\"click\\\",actionCancel,false);\\n\\t\\t\\t// Sort the incoming tiddlers by title\\n\\t\\t\\ttiddlers = tiddlers.sort(function(a,b) {\\n\\t\\t\\t\\tif(a.title < b.title) {\\n\\t\\t\\t\\t\\treturn -1;\\n\\t\\t\\t\\t} else if(a.title > b.title) {\\n\\t\\t\\t\\t\\treturn +1;\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\treturn 0;\\n\\t\\t\\t\\t}\\n\\t\\t\\t});\\n\\t\\t\\t// Load the tiddler preview\\t\\t\\t\\t\\t\\t\\n\\t\\t\\tvar previewWrapper = document.getElementById(\\\"startup-warning-preview\\\");\\n\\t\\t\\tfor(var index=0; index < tiddlers.length; index++) {\\n\\t\\t\\t\\tvar tiddler = tiddlers[index],\\n\\t\\t\\t\\t\\ttiddlerWrapper = document.createElement(\\\"li\\\"),\\n\\t\\t\\t\\t\\ttitleTextWrapper = document.createElement(\\\"span\\\"),\\n\\t\\t\\t\\t\\ttitleText = document.createTextNode(tiddler.title),\\n\\t\\t\\t\\t\\tfieldsTable = document.createElement(\\\"table\\\"),\\n\\t\\t\\t\\t\\tfieldsTableBody = document.createElement(\\\"tbody\\\");\\n\\t\\t\\t\\ttitleTextWrapper.appendChild(titleText);\\n\\t\\t\\t\\ttitleTextWrapper.className = \\\"tiddler-title\\\";\\n\\t\\t\\t\\ttiddlerWrapper.appendChild(titleTextWrapper);\\n\\t\\t\\t\\tfieldsTable.appendChild(fieldsTableBody);\\n\\t\\t\\t\\tvar fields = Object.keys(tiddler).sort();\\n\\t\\t\\t\\tfor(var fieldIndex = 0; fieldIndex < fields.length; fieldIndex++) {\\n\\t\\t\\t\\t\\tvar fieldName = fields[fieldIndex],\\n\\t\\t\\t\\t\\t\\tfieldValue = tiddler[fieldName];\\n\\t\\t\\t\\t\\tif(fieldName !== \\\"title\\\") {\\n\\t\\t\\t\\t\\t\\tvar fieldRow = document.createElement(\\\"tr\\\"),\\n\\t\\t\\t\\t\\t\\t\\tfieldRowHeader = document.createElement(\\\"th\\\"),\\n\\t\\t\\t\\t\\t\\t\\tfieldRowValue = document.createElement(\\\"td\\\");\\n\\t\\t\\t\\t\\t\\tfieldRowHeader.appendChild(document.createTextNode(fieldName));\\n\\t\\t\\t\\t\\t\\tfieldRowValue.appendChild(document.createTextNode(fieldValue));\\n\\t\\t\\t\\t\\t\\tfieldRow.appendChild(fieldRowHeader);\\n\\t\\t\\t\\t\\t\\tfieldRow.appendChild(fieldRowValue);\\n\\t\\t\\t\\t\\t\\tfieldsTableBody.appendChild(fieldRow);\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\ttiddlerWrapper.appendChild(fieldsTable);\\n\\t\\t\\t\\tpreviewWrapper.appendChild(tiddlerWrapper);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n}\\n\\nfunction actionProceed() {\\n\\t// Remove the banner, load our tiddlers, and boot TiddlyWiki\\n\\tremoveWarningBanner();\\n\\t$tw.preloadTiddlers = $tw.preloadTiddlers.concat(tiddlers);\\n\\t$tw.boot.boot();\\n}\\n\\nfunction actionCancel() {\\n\\t// Remove the banner, clear the location hash, and boot TiddlyWiki\\n\\tremoveWarningBanner();\\n\\tdocument.location.hash = \\\"#\\\";\\n\\t$tw.boot.boot();\\n}\\n\\nfunction removeWarningBanner() {\\n\\twarningWrapper.parentNode.removeChild(warningWrapper);\\n\\tstylesWrapper.parentNode.removeChild(stylesWrapper);\\n}\\n\\n})();\\n\",\"type\":\"application/javascript\",\"module-type\":\"library\"},\"$:/plugins/tiddlywiki/share/rawmarkup\":{\"title\":\"$:/plugins/tiddlywiki/share/rawmarkup\",\"tags\":\"$:/tags/RawMarkupWikified\",\"text\":\"`<script>`\\n`var tiddlywikiSharePluginStartupWarningHtml = \\\"`<$view tiddler=\\\"$:/plugins/tiddlywiki/share/startup-warning.html\\\" format=\\\"jsencoded\\\"/>`\\\";`\\n`var tiddlywikiSharePluginStartupWarningCss = \\\"`<$view tiddler=\\\"$:/plugins/tiddlywiki/share/startup-warning.css\\\" format=\\\"jsencoded\\\"/>`\\\";`\\n{{$:/plugins/tiddlywiki/share/rawmarkup.js}}\\n`</script>`\\n\"},\"$:/plugins/tiddlywiki/share/readme\":{\"title\":\"$:/plugins/tiddlywiki/share/readme\",\"text\":\"<div class=\\\"tc-message-box\\\">Do not install this plugin unless you understand exactly what it does</div>\\n\\nThis experimental plugin provides tools to share tiddlers via URLs, comprising:\\n\\n* The ability to load a group of tiddlers from the browser location hash at startup\\n* Wizard and templates to create URLs from group of tiddlers\\n\\n\"},\"$:/plugins/tiddlywiki/share/settings\":{\"title\":\"$:/plugins/tiddlywiki/share/settings\",\"text\":\"!! Base sharing URL\\n\\n//Defaults to the current location//\\n\\n<$edit-text tiddler=\\\"$:/config/plugins/share/base-url\\\" tag=\\\"input\\\" class=\\\"tc-sharing-wizard-editor\\\"/>\\n\"},\"$:/plugins/tiddlywiki/share/startup-warning.css\":{\"title\":\"$:/plugins/tiddlywiki/share/startup-warning.css\",\"text\":\"\\n.startup-warning-wrapper {\\n\\tfont-family: sans-serif;\\n\\tline-height: 1.4;\\n\\twidth: 50%;\\n\\tmargin: 1em auto 0 auto;\\n\\tpadding: 0 1em;\\n\\tborder: 6px solid transparent;\\n\\tborder-radius: 8px;\\n\\tbackground: linear-gradient(white, white) padding-box, repeating-linear-gradient(-45deg, red 0, red 25%, transparent 0, transparent 50%) 0 / .6em .6em;\\n\\tanimation: marching-ants 20s linear infinite;\\n}\\n\\n@media (max-width: 600px) {\\n\\t.startup-warning-wrapper {\\n\\t\\twidth: 85%;\\n\\t}\\n}\\n\\n#startup-warning-preview {\\n list-style-type: none;\\n padding-left: 0;\\n}\\n\\n#startup-warning-preview .tiddler-title {\\n font-weight: bold;\\n font-size: 1.2em;\\n}\\n\\n#startup-warning-preview table {\\n\\tmargin-left: 1em;\\n}\\n\\n#startup-warning-preview th {\\n\\tvertical-align: top;\\n\\tfont-weight: normal;\\n}\\n\\n#startup-warning-preview td {\\n\\tfont-family: monospace;\\n white-space: pre-wrap;\\n background: #f8f8f8;\\n}\\n\\n.startup-warning-wrapper button {\\n padding: 0.3em;\\n border-radius: 4px;\\n font-size: 1.5em;\\n}\\n\\n#startup-warning-cancel {\\n\\tbackground: #DB2828;\\n\\tcolor: #fff;\\n}\\n\\n#startup-warning-cancel:hover {\\n\\tbackground: #E75C60;\\n\\tcolor: #fff;\\n}\\n\\n#startup-warning-cancel:active {\\n\\tbackground: #ec8d8d;\\n\\tcolor: #fff;\\n}\\n\\n#startup-warning-proceed {\\n\\tbackground: #24BA4C;\\n\\tcolor: #fff;\\n}\\n\\n#startup-warning-proceed:hover {\\n\\tbackground: #59e27e;\\n\\tcolor: #fff;\\n}\\n\\n#startup-warning-proceed:active {\\n\\tbackground: #ABF5BD;\\n\\tcolor: #fff;\\n}\\n\\n.startup-warning-wrapper h1,\\n.startup-warning-wrapper h2 {\\n\\tfont-weight: bold;\\n}\\n \\n@keyframes marching-ants { to { background-position: 100% 100% } }\\n\\n\",\"type\":\"text/css\"},\"$:/plugins/tiddlywiki/share/startup-warning.html\":{\"title\":\"$:/plugins/tiddlywiki/share/startup-warning.html\",\"text\":\"<div class=\\\"startup-warning-wrapper\\\">\\n<h1>\\nWarning: This site is designed to share untrusted content\\n</h1>\\n<h2>\\nPlease do not proceed unless you are certain you understand the warnings below\\n</h2>\\n<p>\\nThis is a special site that allows users to share content for <a href=\\\"https://tiddlywiki.com/\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\">TiddlyWiki</a> without needing conventional hosting. Instead, the content is encoded in the URL used to access the site. This means that there are no controls or protections on the content that is shared, and as such it may contain malicious links or any kind of content.\\n</p>\\n<p>\\nViewing links to this site in the browser is generally safe because web pages are designed to run in a sandbox that prevents them from accessing or harming your data. However, please exercise caution before downloading content to your own computer, or importing content into your own TiddlyWiki.\\n</p>\\n\\n<details>\\n<summary>\\nClick here to see the tiddlers that are being shared\\n</summary>\\n<ul id=\\\"startup-warning-preview\\\">\\n</ul>\\n</details>\\n\\n<p>\\n<strong><em>Only continue if you understand the risks</em></strong>\\n</p>\\n\\n<p>\\n<button id=\\\"startup-warning-proceed\\\">\\nProceed\\n</button>\\n<button id=\\\"startup-warning-cancel\\\">\\nCancel\\n</button>\\n</p>\\n\\n<h2>\\nTechnical details\\n</h2>\\n\\n<p>\\nThis web page is a <a href=\\\"https://tiddlywiki.com/\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\">TiddlyWiki</a> loaded with the <a href=\\\"https://github.com/Jermolene/TiddlyWiki5/tree/master/plugins/tiddlywiki/share\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\">Share plugin</a>. It has the special capability that at startup it can load raw tiddlers from a block of JSON encoded into the location hash part of the URL (ie the part after the # character).\\n</p>\\n<p>\\nThis is useful because it enables people to share working examples of TiddlyWikis without needing to arrange special hosting. The only restriction is that browsers and other Internet infrastructure frequently limit the length of URLs to a few tens of kilobytes.\\n</p>\\n\\n</div>\\n\",\"type\":\"text/html\"},\"$:/plugins/tiddlywiki/share/styles\":{\"title\":\"$:/plugins/tiddlywiki/share/styles\",\"tags\":\"[[$:/tags/Stylesheet]]\",\"text\":\"\\\\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline\\n\\n.tc-sharing-wizard-wrapper {\\n\\twidth: 100%;\\n\\tpadding: 1em 1em;\\n\\tmargin-bottom: 1em;\\n border-radius: 4px;\\n background: <<colour background>>;\\n\\t<<box-shadow \\\"inset 0px 2px 3px 2px rgba(0,0,0,0.4)\\\">>\\n}\\n\\ninput.tc-sharing-wizard-editor {\\n\\twidth: 100%;\\n}\"},\"$:/plugins/tiddlywiki/share/wizard\":{\"title\":\"$:/plugins/tiddlywiki/share/wizard\",\"text\":\"\\\\define generate-json()\\n<$text text=<<jsontiddlers filter:\\\"\\\"\\\"$(share-filter)$\\\"\\\"\\\" spaces:\\\"\\\">>/>\\n\\\\end\\n\\n\\\\define inner-share-actions()\\n<$wikify name=\\\"json\\\" text=<<generate-json>>>\\n<$action-sendmessage $message=\\\"tm-copy-to-clipboard\\\" $param={{{ [<json>encodeuricomponent[]addprefix[##]addprefix<base-url>] }}}/>\\n</$wikify>\\n\\\\end\\n\\n\\\\define share-actions()\\n<$set name=\\\"base-url\\\" value={{$:/config/plugins/share/base-url}} emptyValue={{$:/info/url/full}}>\\n<$set name=\\\"share-filter\\\" value={{$:/config/plugins/share/filter}}>\\n<<inner-share-actions>>\\n</$set>\\n</$set>\\n\\\\end\\n\\n<div class=\\\"tc-sharing-wizard-wrapper\\\">\\n\\n! Welcome to the sharing edition of ~TiddlyWiki\\n\\nThis edition of ~TiddlyWiki allows users to create links to wikis with the special capability of containing embedded tiddlers that are loaded into the target wiki at startup. Most browsers allow tens of kilobytes of data to be loaded in this way, making it possible to conveniently share groups of tiddlers as a fully functional wiki. See the [[readme|$:/plugins/tiddlywiki/share]] for more details.\\n\\n!! 1 - Import or create the tiddlers that are to be shared\\n\\nThe first step to create a sharing URL is to import or otherwise create the tiddlers that are to be shared.\\n\\n!! 2 - Check that the sharing filter is correct\\n\\nThe tiddlers that are included in the sharing URL are determined by the combination of two filters.\\n\\nThe sharing filter specifies the tiddlers to be shared:\\n\\n<$edit-text tiddler=\\\"$:/config/plugins/share/filter\\\" tag=\\\"input\\\" class=\\\"tc-sharing-wizard-editor\\\"/>\\n\\nThe exclusion subfilter is used to exclude the system tiddlers comprising this wiki:\\n\\n<$edit-text tiddler=\\\"$:/config/plugins/share/exclusions\\\" tag=\\\"input\\\" class=\\\"tc-sharing-wizard-editor\\\"/>\\n\\n!! 3 - Review the tiddlers to be shared\\n\\nTiddlers to be shared (<$count filter={{$:/config/plugins/share/filter}}/>):\\n\\n<ul>\\n<$list filter={{$:/config/plugins/share/filter}}>\\n<li>\\n<$link>\\n<$view field=\\\"title\\\"/>\\n</$link>\\n</li>\\n</$list>\\n</ul>\\n\\n!! 3 - Generate the sharing link\\n\\n<$button>\\n<<share-actions>>\\nGenerate sharing link\\n</$button> (the link will be copied to the clipboard)\\n\\n!! 5 - Export the shared tiddlers\\n\\n<$button>\\n<$action-sendmessage $message=\\\"tm-download-file\\\" $param=\\\"$:/core/templates/exporters/JsonFile\\\" exportFilter={{$:/config/plugins/share/filter}} filename=\\\"tiddlers.json\\\"/>\\nExport as JSON\\n</$button>\\n\\n</div>\"}}}"});