1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-22 21:33:14 +00:00

First attempt at sharing plugin/edition

This commit is contained in:
Jeremy Ruston 2020-02-04 14:06:59 +00:00
parent 3df1f9c9d0
commit 005c584d85
16 changed files with 184 additions and 0 deletions

View File

@ -0,0 +1,14 @@
{
"description": "Sharing tiddlers via URLs",
"plugins": [
"tiddlywiki/share"
],
"themes": [
"tiddlywiki/vanilla",
"tiddlywiki/snowwhite"
],
"build": {
"share": [
"--rendertiddler","$:/core/save/all","share.html","text/plain"]
}
}

View File

@ -0,0 +1,3 @@
title: $:/DefaultTiddlers
[list[$:/StoryList]]

View File

@ -0,0 +1,3 @@
title: $:/SiteSubtitle
tools to share tiddlers via URLs

View File

@ -0,0 +1,3 @@
title: $:/SiteTitle
Share

View File

@ -0,0 +1,4 @@
title: $:/plugins/tiddlywiki/share/above-story
tags: $:/tags/AboveStory
<$transclude tiddler="$:/plugins/tiddlywiki/share/wizard" mode="block"/>

View File

@ -0,0 +1,2 @@
title: $:/config/plugins/share/base-url
text:

View File

@ -0,0 +1,2 @@
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/]]

View File

@ -0,0 +1,2 @@
title: $:/config/plugins/share/filter
text: [all[tiddlers]] -[subfilter{$:/config/plugins/share/exclusions}]

View File

@ -0,0 +1,6 @@
{
"title": "$:/plugins/tiddlywiki/share",
"name": "Share",
"description": "Sharing tiddlers via URLs",
"list": "readme wizard settings"
}

View File

@ -0,0 +1,3 @@
title: $:/core/ui/PageTemplate/pluginreloadwarning
<!-- Disable plugin reload warnings -->

View File

@ -0,0 +1,35 @@
/*\
title: $:/plugins/tiddlywiki/share/rawmarkup.js
type: application/javascript
module-type: library
Read tiddlers from the browser location hash
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
// Get the hash
var rawHash = document.location.hash.substring(1);
if(rawHash.charAt(0) === "#") {
var hash = decodeURIComponent(rawHash.substring(1));
// Try to parse the hash as JSON
var tiddlers;
try {
tiddlers= JSON.parse(hash);
} catch(ex) {
}
if(tiddlers) {
// Need to initialise these because we run before bootprefix.js and boot.js
window.$tw = window.$tw || {};
$tw.boot = $tw.boot || {};
$tw.preloadTiddlers = $tw.preloadTiddlers || [];
// Load our tiddlers
$tw.preloadTiddlers = $tw.preloadTiddlers.concat(tiddlers);
}
}
})();

View File

@ -0,0 +1,6 @@
title: $:/plugins/tiddlywiki/share/rawmarkup
tags: $:/tags/RawMarkupWikified
`<script>`
{{$:/plugins/tiddlywiki/share/rawmarkup.js}}
`</script>`

View File

@ -0,0 +1,6 @@
title: $:/plugins/tiddlywiki/share/readme
This plugin provides tools to share tiddlers via URLs, comprising:
* The ability to load a group of tiddlers from the browser location hash at startup
* Wizard and templates to create URLs from group of tiddlers

View File

@ -0,0 +1,7 @@
title: $:/plugins/tiddlywiki/share/settings
!! Base sharing URL
//Defaults to the current location//
<$edit-text tiddler="$:/config/plugins/share/base-url" tag="input" class="tc-sharing-wizard-editor"/>

View File

@ -0,0 +1,17 @@
title: $:/plugins/tiddlywiki/share/styles
tags: [[$:/tags/Stylesheet]]
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline
.tc-sharing-wizard-wrapper {
width: 100%;
padding: 1em 1em;
margin-bottom: 1em;
border-radius: 4px;
background: <<colour background>>;
<<box-shadow "inset 0px 2px 3px 2px rgba(0,0,0,0.4)">>
}
input.tc-sharing-wizard-editor {
width: 100%;
}

View File

@ -0,0 +1,71 @@
title: $:/plugins/tiddlywiki/share/wizard
\define generate-json()
<$text text=<<jsontiddlers filter:"""$(share-filter)$""" spaces:"">>/>
\end
\define inner-share-actions()
<$wikify name="json" text=<<generate-json>>>
<$action-sendmessage $message="tm-copy-to-clipboard" $param={{{ [<json>encodeuricomponent[]addprefix[##]addprefix<base-url>] }}}/>
</$wikify>
\end
\define share-actions()
<$set name="base-url" value={{$:/config/plugins/share/base-url}} emptyValue={{$:/info/url/full}}>
<$set name="share-filter" value={{$:/config/plugins/share/filter}}>
<<inner-share-actions>>
</$set>
</$set>
\end
<div class="tc-sharing-wizard-wrapper">
! Welcome to the sharing edition of ~TiddlyWiki
This 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.
!! 1 - Import or create the tiddlers that are to be shared
The first step to create a sharing URL is to import or otherwise create the tiddlers that are to be shared.
!! 2 - Check that the sharing filter is correct
The tiddlers that are included in the sharing URL are determined by the combination of two filters.
The sharing filter specifies the tiddlers to be shared:
<$edit-text tiddler="$:/config/plugins/share/filter" tag="input" class="tc-sharing-wizard-editor"/>
The exclusion subfilter is used to exclude the system tiddlers comprising this wiki:
<$edit-text tiddler="$:/config/plugins/share/exclusions" tag="input" class="tc-sharing-wizard-editor"/>
!! 3 - Review the tiddlers to be shared
Tiddlers to be shared (<$count filter={{$:/config/plugins/share/filter}}/>):
<ul>
<$list filter={{$:/config/plugins/share/filter}}>
<li>
<$link>
<$view field="title"/>
</$link>
</li>
</$list>
</ul>
!! 3 - Generate the sharing link
<$button>
<<share-actions>>
Generate sharing link
</$button> (the link will be copied to the clipboard)
!! 5 - Export the shared tiddlers
<$button>
<$action-sendmessage $message="tm-download-file" $param="$:/core/templates/exporters/JsonFile" exportFilter={{$:/config/plugins/share/filter}} filename="tiddlers.json"/>
Export as JSON
</$button>
</div>