mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2025-12-05 18:20:38 -08:00
Purge deprecated plugins and editions (#9350)
This commit is contained in:
parent
0b38ced43a
commit
276fdc8634
64 changed files with 0 additions and 2404 deletions
|
|
@ -73,10 +73,8 @@ rm $TW5_BUILD_OUTPUT/dev/static/*
|
|||
|
||||
echo "<a href='./plugins/tiddlywiki/tw2parser/index.html'>Moved to http://tiddlywiki.com/plugins/tiddlywiki/tw2parser/index.html</a>" > $TW5_BUILD_OUTPUT/classicparserdemo.html
|
||||
echo "<a href='./plugins/tiddlywiki/codemirror/index.html'>Moved to http://tiddlywiki.com/plugins/tiddlywiki/codemirror/index.html</a>" > $TW5_BUILD_OUTPUT/codemirrordemo.html
|
||||
echo "<a href='./plugins/tiddlywiki/d3/index.html'>Moved to http://tiddlywiki.com/plugins/tiddlywiki/d3/index.html</a>" > $TW5_BUILD_OUTPUT/d3demo.html
|
||||
echo "<a href='./plugins/tiddlywiki/highlight/index.html'>Moved to http://tiddlywiki.com/plugins/tiddlywiki/highlight/index.html</a>" > $TW5_BUILD_OUTPUT/highlightdemo.html
|
||||
echo "<a href='./plugins/tiddlywiki/markdown/index.html'>Moved to http://tiddlywiki.com/plugins/tiddlywiki/markdown/index.html</a>" > $TW5_BUILD_OUTPUT/markdowndemo.html
|
||||
echo "<a href='./plugins/tiddlywiki/tahoelafs/index.html'>Moved to http://tiddlywiki.com/plugins/tiddlywiki/tahoelafs/index.html</a>" > $TW5_BUILD_OUTPUT/tahoelafs.html
|
||||
|
||||
# Put the build details into a .tid file so that it can be included in each build (deleted at the end of this script)
|
||||
|
||||
|
|
@ -301,26 +299,6 @@ node $TW5_BUILD_TIDDLYWIKI \
|
|||
--rendertiddler $:/core/save/empty plugins/tiddlywiki/katex/empty.html text/plain \
|
||||
|| exit 1
|
||||
|
||||
# /plugins/tiddlywiki/tahoelafs/index.html Demo wiki with Tahoe-LAFS plugin
|
||||
# /plugins/tiddlywiki/tahoelafs/empty.html Empty wiki with Tahoe-LAFS plugin
|
||||
node $TW5_BUILD_TIDDLYWIKI \
|
||||
./editions/tahoelafs \
|
||||
--load $TW5_BUILD_OUTPUT/build.tid \
|
||||
--output $TW5_BUILD_OUTPUT \
|
||||
--rendertiddler $:/core/save/all plugins/tiddlywiki/tahoelafs/index.html text/plain \
|
||||
--rendertiddler $:/core/save/empty plugins/tiddlywiki/tahoelafs/empty.html text/plain \
|
||||
|| exit 1
|
||||
|
||||
# /plugins/tiddlywiki/d3/index.html Demo wiki with D3 plugin
|
||||
# /plugins/tiddlywiki/d3/empty.html Empty wiki with D3 plugin
|
||||
node $TW5_BUILD_TIDDLYWIKI \
|
||||
./editions/d3demo \
|
||||
--load $TW5_BUILD_OUTPUT/build.tid \
|
||||
--output $TW5_BUILD_OUTPUT \
|
||||
--rendertiddler $:/core/save/all plugins/tiddlywiki/d3/index.html text/plain \
|
||||
--rendertiddler $:/core/save/empty plugins/tiddlywiki/d3/empty.html text/plain \
|
||||
|| exit 1
|
||||
|
||||
# /plugins/tiddlywiki/codemirror/index.html Demo wiki with codemirror plugin
|
||||
# /plugins/tiddlywiki/codemirror/empty.html Empty wiki with codemirror plugin
|
||||
node $TW5_BUILD_TIDDLYWIKI \
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
title: CloudData
|
||||
type: application/json
|
||||
|
||||
[
|
||||
{"text": "Tokyo/Yokohama", "size": 33.200},
|
||||
{"text": "New York Metro", "size": 17.800},
|
||||
{"text": "Sao Paulo", "size": 17.700},
|
||||
{"text": "Seoul/Incheon", "size": 17.500},
|
||||
{"text": "Mexico City", "size": 17.400},
|
||||
{"text": "Osaka/Kobe/Kyoto", "size": 16.425},
|
||||
{"text": "Manila", "size": 14.750},
|
||||
{"text": "Mumbai", "size": 14.350},
|
||||
{"text": "Delhi", "size": 14.300},
|
||||
{"text": "Jakarta", "size": 14.250},
|
||||
{"text": "Lagos", "size": 13.400},
|
||||
{"text": "Kolkata", "size": 12.700},
|
||||
{"text": "Cairo", "size": 12.200},
|
||||
{"text": "Los Angeles", "size": 11.789},
|
||||
{"text": "Buenos Aires", "size": 11.200},
|
||||
{"text": "Rio de Janeiro", "size": 10.800},
|
||||
{"text": "Moscow", "size": 10.500},
|
||||
{"text": "Shanghai", "size": 10.000},
|
||||
{"text": "Karachi", "size": 9.800},
|
||||
{"text": "Paris", "size": 9.645},
|
||||
{"text": "Istanbul", "size": 9.000},
|
||||
{"text": "Nagoya", "size": 9.000},
|
||||
{"text": "Beijing", "size": 8.614},
|
||||
{"text": "Chicago", "size": 8.308},
|
||||
{"text": "London", "size": 8.278},
|
||||
{"text": "Shenzhen", "size": 8.000},
|
||||
{"text": "Essen/Dusseldorf", "size": 7.350},
|
||||
{"text": "Tehran", "size": 7.250},
|
||||
{"text": "Bogota", "size": 7.000},
|
||||
{"text": "Lima", "size": 7.000},
|
||||
{"text": "Bangkok", "size": 6.500},
|
||||
{"text": "Johannesburg/East Rand", "size": 6.000},
|
||||
{"text": "Chennai", "size": 5.950},
|
||||
{"text": "Taipei", "size": 5.700},
|
||||
{"text": "Baghdad", "size": 5.500},
|
||||
{"text": "Santiago", "size": 5.425},
|
||||
{"text": "Bangalore", "size": 5.400},
|
||||
{"text": "Hyderabad", "size": 5.300},
|
||||
{"text": "St Petersburg", "size": 5.300}
|
||||
]
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
title: $:/DefaultTiddlers
|
||||
|
||||
[[HelloThere]]
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,17 +0,0 @@
|
|||
title: HelloThere
|
||||
|
||||
This is a demo of TiddlyWiki5 incorporating a plugin for the [[D3.js]] visualisation library.
|
||||
|
||||
! Word Cloud
|
||||
|
||||
<$d3cloud data="CloudData" spiral={{$:/spiral}}/>
|
||||
|
||||
|
||||
//[[Raw data|CloudData]]//
|
||||
|
||||
! Bar Chart
|
||||
|
||||
<$d3bar grouped={{$:/grouped}} data="GraphData"/>
|
||||
<$button set="$:/grouped" setTo="yes">grouped</$button> <$button set="$:/grouped" setTo="no">stacked</$button>
|
||||
|
||||
//[[Raw data|GraphData]]//
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
title: $:/SiteSubtitle
|
||||
|
||||
a demo of the D3.js plugin for TiddlyWiki5
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
title: $:/SiteTitle
|
||||
|
||||
d3demo
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
title: $:/grouped
|
||||
|
||||
yes
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
title: $:/spiral
|
||||
|
||||
archimedean
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"description": "Demo of the D3 plugin",
|
||||
"plugins": [
|
||||
"tiddlywiki/d3"
|
||||
],
|
||||
"themes": [
|
||||
"tiddlywiki/vanilla",
|
||||
"tiddlywiki/snowwhite"
|
||||
],
|
||||
"includeWikis": [
|
||||
],
|
||||
"build": {
|
||||
"index": [
|
||||
"--rendertiddler","$:/core/save/all","d3demo.html","text/plain"]
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
title: $:/DefaultTiddlers
|
||||
|
||||
HelloThere
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
title: HelloThere
|
||||
|
||||
This is an experimental edition of TiddlyWiki5 for use with [[Tahoe-LAFS|https://tahoe-lafs.org/]]. At this point it is largely for experimentation by @zooko. Click the ''save changes'' button to PUT the updated TiddlyWiki HTML file back to the server.
|
||||
|
||||
<$button message="tm-new-tiddler">New Tiddler</$button>
|
||||
<$button message="tm-save-wiki">Save Changes</$button>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
title: $:/SiteSubtitle
|
||||
|
||||
Tahoe-LAFS edition
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
title: $:/SiteTitle
|
||||
|
||||
TiddlyWiki5
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"description": "Demo of TahoeLAFS plugin",
|
||||
"plugins": [
|
||||
"tiddlywiki/tahoelafs"
|
||||
],
|
||||
"themes": [
|
||||
"tiddlywiki/vanilla",
|
||||
"tiddlywiki/snowwhite"
|
||||
],
|
||||
"build": {
|
||||
"index": [
|
||||
"--rendertiddler","$:/core/save/all","tahoelafs.html","text/plain"]
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/blog/docs
|
||||
|
||||
Until there's more documentation, see an example of the use of this plugin here:
|
||||
|
||||
* Blog: http://jermolene-blog.github.io/
|
||||
* Repository: https://github.com/Jermolene-blog/blog
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"title": "$:/plugins/tiddlywiki/blog",
|
||||
"name": "Blog",
|
||||
"description": "Blog publishing tools",
|
||||
"list": "readme docs",
|
||||
"stability": "STABILITY_0_DEPRECATED"
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/blog/readme
|
||||
|
||||
This plugin contains tools to help publish blogs:
|
||||
|
||||
* Templates and tools for building static HTML pages and posts
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/blog/templates/html-page/page
|
||||
|
||||
\define tv-wikilink-template() posts/$uri_doubleencoded$.html
|
||||
\define tv-config-toolbar-icons() no
|
||||
\define tv-config-toolbar-text() no
|
||||
\define tv-config-toolbar-class() tc-btn-invisible
|
||||
`<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="generator" content="TiddlyWiki" />
|
||||
<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">
|
||||
<link id="faviconLink" rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" href="static.css">
|
||||
<title>`<$transclude field="caption"><$view field="title"/></$transclude>: {{$:/core/wiki/title}}`</title>
|
||||
</head>
|
||||
<body class="tc-body">
|
||||
`{{$:/StaticBanner||$:/core/templates/html-tiddler}}`
|
||||
<section class="tc-story-river">
|
||||
`<$importvariables filter={{$:/core/config/GlobalImportFilter}}>
|
||||
<$view tiddler="$:/plugins/tiddlywiki/blog/templates/tiddler" format="htmlwikified"/>
|
||||
</$importvariables>`
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/blog/templates/html-page/post
|
||||
|
||||
\define tv-wikilink-template() /$uri_doubleencoded$.html
|
||||
\define tv-config-toolbar-icons() no
|
||||
\define tv-config-toolbar-text() no
|
||||
\define tv-config-toolbar-class() tc-btn-invisible
|
||||
`<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="generator" content="TiddlyWiki" />
|
||||
<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">
|
||||
<link id="faviconLink" rel="shortcut icon" href="../favicon.ico">
|
||||
<link rel="stylesheet" href="../static.css">
|
||||
<title>`<$transclude field="caption"><$view field="title"/></$transclude>: {{$:/core/wiki/title}}`</title>
|
||||
</head>
|
||||
<body class="tc-body">
|
||||
`{{$:/StaticBanner||$:/core/templates/html-tiddler}}`
|
||||
<section class="tc-story-river">
|
||||
`<$importvariables filter={{$:/core/config/GlobalImportFilter}}>
|
||||
<$view tiddler="$:/plugins/tiddlywiki/blog/templates/tiddler" format="htmlwikified"/>
|
||||
<$view tiddler="$:/plugins/tiddlywiki/blog/templates/menu" format="htmlwikified"/>
|
||||
</$importvariables>`
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/blog/templates/menu
|
||||
|
||||
<div class="tc-blog-menu">
|
||||
|
||||
<div class="tc-blog-menu-item">
|
||||
|
||||
<a href="../index.html">
|
||||
|
||||
{{$:/core/images/home-button}}
|
||||
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/blog/templates/tiddler
|
||||
|
||||
<div class="tc-tiddler-frame tc-tiddler-view-frame tc-clearfix">
|
||||
|
||||
<div class="tc-tiddler-title tc-clearfix">
|
||||
|
||||
<div class="tc-titlebar">
|
||||
|
||||
<h2 class="tc-title">
|
||||
|
||||
<$transclude field="caption" mode="inline">
|
||||
|
||||
<$view field="title"/>
|
||||
|
||||
</$transclude>
|
||||
|
||||
</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tc-subtitle">
|
||||
|
||||
<$view field="modified" format="date" template="DDth MMM YYYY"/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tc-tiddler-body">
|
||||
|
||||
<$transclude/>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/*\
|
||||
title: $:/plugins/tiddlywiki/cecily/cecily.js
|
||||
type: application/javascript
|
||||
module-type: storyview
|
||||
|
||||
Positions tiddlers on a 2D map
|
||||
|
||||
\*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var CecilyStoryView = function(listWidget) {
|
||||
var self = this;
|
||||
this.listWidget = listWidget;
|
||||
// Load the map
|
||||
this.loadMap();
|
||||
// Position the existing tiddlers
|
||||
$tw.utils.each(this.listWidget.children,function(itemWidget,index) {
|
||||
var domNode = itemWidget.findFirstDomNode();
|
||||
domNode.style.position = "absolute";
|
||||
var title = itemWidget.parseTreeNode.itemTitle;
|
||||
self.positionTiddler(title,domNode);
|
||||
});
|
||||
};
|
||||
|
||||
CecilyStoryView.prototype.navigateTo = function(historyInfo) {
|
||||
var listElementIndex = this.listWidget.findListItem(0,historyInfo.title);
|
||||
if(listElementIndex === undefined) {
|
||||
return;
|
||||
}
|
||||
var listItemWidget = this.listWidget.children[listElementIndex],
|
||||
targetElement = listItemWidget.findFirstDomNode();
|
||||
// Scroll the node into view
|
||||
this.listWidget.dispatchEvent({type: "tm-scroll", target: targetElement});
|
||||
};
|
||||
|
||||
CecilyStoryView.prototype.insert = function(widget) {
|
||||
var domNode = widget.findFirstDomNode(),
|
||||
duration = $tw.utils.getAnimationDuration();
|
||||
// Make the newly inserted node position absolute
|
||||
$tw.utils.setStyle(domNode,[
|
||||
{position: "absolute"},
|
||||
{transition: ""},
|
||||
{opacity: "0.0"}
|
||||
]);
|
||||
// Position it
|
||||
var title = widget.parseTreeNode.itemTitle;
|
||||
this.positionTiddler(title,domNode);
|
||||
$tw.utils.forceLayout(domNode);
|
||||
// Animate it in
|
||||
$tw.utils.setStyle(domNode,[
|
||||
{transition: "opacity " + duration + "ms ease-out"},
|
||||
{opacity: "1.0"}
|
||||
]);
|
||||
};
|
||||
|
||||
CecilyStoryView.prototype.remove = function(widget) {
|
||||
var targetElement = widget.findFirstDomNode(),
|
||||
duration = $tw.utils.getAnimationDuration();
|
||||
// Remove the widget at the end of the transition
|
||||
setTimeout(function() {
|
||||
widget.removeChildDomNodes();
|
||||
},duration);
|
||||
// Animate the closure
|
||||
$tw.utils.setStyle(targetElement,[
|
||||
{transition: "none"},
|
||||
{opacity: "1.0"}
|
||||
]);
|
||||
$tw.utils.forceLayout(targetElement);
|
||||
$tw.utils.setStyle(targetElement,[
|
||||
{transition: $tw.utils.roundTripPropertyName("transform") + " " + duration + "ms ease-in-out, " +
|
||||
"opacity " + duration + "ms ease-in-out"},
|
||||
{transform: "scale(0.01)"},
|
||||
{opacity: "0.0"}
|
||||
]);
|
||||
};
|
||||
|
||||
/*
|
||||
Load the current map
|
||||
*/
|
||||
CecilyStoryView.prototype.loadMap = function() {
|
||||
this.map = this.listWidget.wiki.getTiddlerData(this.getMapTiddlerTitle(),{
|
||||
positions: {},
|
||||
newTiddlerPosition: {x: 0, y: 0},
|
||||
width: parseInt(this.listWidget.getAttribute("cecily-width","600"),10)
|
||||
});
|
||||
};
|
||||
|
||||
CecilyStoryView.prototype.getMapTiddlerTitle = function() {
|
||||
return this.listWidget.getAttribute("cecily-map","$:/TiddlerMap");
|
||||
};
|
||||
|
||||
/*
|
||||
Position a tiddler according to the map
|
||||
*/
|
||||
CecilyStoryView.prototype.positionTiddler = function(title,domNode) {
|
||||
var pos = this.lookupTiddlerInMap(title,domNode),
|
||||
scale = pos.w/domNode.offsetWidth;
|
||||
$tw.utils.setStyle(domNode,[
|
||||
{width: this.map.width + "px"},
|
||||
{transformOrigin: "0% 0%"},
|
||||
{transform: "translateX(" + pos.x + "px) translateY(" + pos.y + "px) scale(" + scale + ") translateX(-50%) rotate(" + (pos.r || 0) + "deg) translateX(50%)"}
|
||||
]);
|
||||
};
|
||||
|
||||
// Get the position of a particular tiddler
|
||||
CecilyStoryView.prototype.lookupTiddlerInMap = function(title,domNode) {
|
||||
// If this is a draft tiddler then look for the position of the original tiddler
|
||||
var tiddler = this.listWidget.wiki.getTiddler(title);
|
||||
if(tiddler) {
|
||||
var draftOf = tiddler.fields["draft.of"];
|
||||
if(draftOf && this.map.positions[draftOf]) {
|
||||
return this.map.positions[draftOf];
|
||||
}
|
||||
}
|
||||
// Try looking the target tiddler up in the map
|
||||
if(this.map.positions[title]) {
|
||||
return this.map.positions[title];
|
||||
}
|
||||
// If the tiddler wasn't in the map we'll have to compute it
|
||||
var newPosition;
|
||||
switch(this.map.positionNew) {
|
||||
default: // "right"
|
||||
newPosition = {
|
||||
x: this.map.newTiddlerPosition.x,
|
||||
y: this.map.newTiddlerPosition.y,
|
||||
w: 200,
|
||||
h: 200
|
||||
};
|
||||
this.map.newTiddlerPosition.x += newPosition.w * 1.1;
|
||||
break;
|
||||
}
|
||||
// A default position
|
||||
newPosition = newPosition || {x: 0,y: 0,w: 100,h: 100};
|
||||
// Save the position back to the map
|
||||
this.map.positions[title] = newPosition;
|
||||
return newPosition;
|
||||
};
|
||||
|
||||
exports.cecily = CecilyStoryView;
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"title": "$:/plugins/tiddlywiki/cecily",
|
||||
"name": "Cecily",
|
||||
"description": "Zoomable storyview (Cecily)",
|
||||
"list": "readme",
|
||||
"stability": "STABILITY_0_DEPRECATED"
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/cecily/readme
|
||||
|
||||
This experimental plugin provides a new story visualisation that displays individual tiddlers as resizable tiles on an infinite canvas.
|
||||
|
||||
Cecily is based on an earlier plugin for TiddlyWiki Classic: http://jermolene.com/cecily
|
||||
|
||||
Cecily is currently in the early stages of development with little functionality yet implemented.
|
||||
|
||||
[[Source code|https://github.com/TiddlyWiki/TiddlyWiki5/blob/master/plugins/tiddlywiki/cecily]]
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
title: $:/core/images/storyview-cecily
|
||||
tags: $:/tags/Image
|
||||
|
||||
<svg class="tc-image-storyview-cecily tc-image-button" width="22pt" height="22pt" viewBox="0 0 128 128">
|
||||
<g fill-rule="evenodd">
|
||||
<path d="M8.00697327,0 C3.58484404,0 0,3.59075293 0,8.00697327 L0,119.993027 C0,124.415156 3.59075293,128 8.00697327,128 L119.993027,128 C124.415156,128 128,124.409247 128,119.993027 L128,8.00697327 C128,3.58484404 124.409247,0 119.993027,0 L8.00697327,0 L8.00697327,0 Z M23.9949725,16 C19.5794711,16 16,19.5776607 16,23.9924054 L16,40.0075946 C16,44.4216782 19.5905136,48 23.9949725,48 L71.0050275,48 C75.4205289,48 79,44.4223393 79,40.0075946 L79,23.9924054 C79,19.5783218 75.4094864,16 71.0050275,16 L23.9949725,16 L23.9949725,16 Z M72.0070969,64 C67.5848994,64 64,67.5881712 64,72.0070969 L64,103.992903 C64,108.415101 67.5881712,112 72.0070969,112 L103.992903,112 C108.415101,112 112,108.411829 112,103.992903 L112,72.0070969 C112,67.5848994 108.411829,64 103.992903,64 L72.0070969,64 L72.0070969,64 Z M24.0034204,80 C19.5832534,80 16,83.5776607 16,87.9924054 L16,104.007595 C16,108.421678 19.5863782,112 24.0034204,112 L38.9965796,112 C43.4167466,112 47,108.422339 47,104.007595 L47,87.9924054 C47,83.5783218 43.4136218,80 38.9965796,80 L24.0034204,80 L24.0034204,80 Z M104,16 C99.581722,16 96,19.5776607 96,23.9924054 L96,40.0075946 C96,44.4216782 99.5907123,48 104,48 C108.418278,48 112,44.4223393 112,40.0075946 L112,23.9924054 C112,19.5783218 108.409288,16 104,16 L104,16 Z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
199
plugins/tiddlywiki/d3/barwidget.js
vendored
199
plugins/tiddlywiki/d3/barwidget.js
vendored
|
|
@ -1,199 +0,0 @@
|
|||
/*\
|
||||
title: $:/plugins/tiddlywiki/d3/barwidget.js
|
||||
type: application/javascript
|
||||
module-type: widget
|
||||
|
||||
A widget for displaying stacked or grouped bar charts. Derived from http://bl.ocks.org/mbostock/3943967
|
||||
|
||||
\*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var Widget = require("$:/core/modules/widgets/widget.js").widget,
|
||||
d3 = require("$:/plugins/tiddlywiki/d3/d3.js").d3;
|
||||
|
||||
var BarWidget = function(parseTreeNode,options) {
|
||||
this.initialise(parseTreeNode,options);
|
||||
};
|
||||
|
||||
/*
|
||||
Inherit from the base widget class
|
||||
*/
|
||||
BarWidget.prototype = new Widget();
|
||||
|
||||
/*
|
||||
Render this widget into the DOM
|
||||
*/
|
||||
BarWidget.prototype.render = function(parent,nextSibling) {
|
||||
// Save the parent dom node
|
||||
this.parentDomNode = parent;
|
||||
// Compute our attributes
|
||||
this.computeAttributes();
|
||||
// Execute our logic
|
||||
this.execute();
|
||||
// Create the chart
|
||||
var chart = this.createChart(parent,nextSibling);
|
||||
this.updateChart = chart.updateChart;
|
||||
if(this.updateChart) {
|
||||
this.updateChart();
|
||||
}
|
||||
// Insert the chart into the DOM and render any children
|
||||
parent.insertBefore(chart.domNode,nextSibling);
|
||||
this.domNodes.push(chart.domNode);
|
||||
};
|
||||
|
||||
BarWidget.prototype.createChart = function(parent,nextSibling) {
|
||||
// Get the data we're plotting
|
||||
var data = this.wiki.getTiddlerData(this.barData),
|
||||
n,m,stack,layers;
|
||||
if(data) {
|
||||
n = data.layers;
|
||||
m = data.samples;
|
||||
layers = data.data;
|
||||
} else { // Use randomly generated data if we don't have any
|
||||
n = 4; // number of layers
|
||||
m = 58; // number of samples per layer
|
||||
stack = d3.layout.stack();
|
||||
layers = stack(d3.range(n).map(function() { return bumpLayer(m, 0.1); }));
|
||||
}
|
||||
// Calculate the maximum data values
|
||||
var yGroupMax = d3.max(layers, function(layer) { return d3.max(layer, function(d) { return d.y; }); }),
|
||||
yStackMax = d3.max(layers, function(layer) { return d3.max(layer, function(d) { return d.y0 + d.y; }); });
|
||||
// Calculate margins and width and height
|
||||
var margin = {top: 40, right: 10, bottom: 20, left: 10},
|
||||
width = 960 - margin.left - margin.right,
|
||||
height = 500 - margin.top - margin.bottom;
|
||||
// x-scale
|
||||
var x = d3.scale.ordinal()
|
||||
.domain(d3.range(m))
|
||||
.rangeRoundBands([0, width], 0.08);
|
||||
// y-scale
|
||||
var y = d3.scale.linear()
|
||||
.domain([0, yStackMax])
|
||||
.range([height, 0]);
|
||||
// Array of colour values
|
||||
var color = d3.scale.linear()
|
||||
.domain([0, n - 1])
|
||||
.range(["#aad", "#556"]);
|
||||
// x-axis
|
||||
var xAxis = d3.svg.axis()
|
||||
.scale(x)
|
||||
.tickSize(0)
|
||||
.tickPadding(6)
|
||||
.orient("bottom");
|
||||
// Create SVG element
|
||||
var svgElement = d3.select(parent).insert("svg",function() {return nextSibling;})
|
||||
.attr("viewBox", "0 0 960 500")
|
||||
.attr("preserveAspectRatio", "xMinYMin meet")
|
||||
.attr("width", width + margin.left + margin.right)
|
||||
.attr("height", height + margin.top + margin.bottom);
|
||||
// Create main group
|
||||
var mainGroup = svgElement.append("g")
|
||||
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
||||
// Create the layers
|
||||
var layer = mainGroup.selectAll(".layer")
|
||||
.data(layers)
|
||||
.enter().append("g")
|
||||
.attr("class", "layer")
|
||||
.style("fill", function(d, i) { return color(i); });
|
||||
// Create the rectangles in each layer
|
||||
var rect = layer.selectAll("rect")
|
||||
.data(function(d) { return d; })
|
||||
.enter().append("rect")
|
||||
.attr("x", function(d) { return x(d.x); })
|
||||
.attr("y", height)
|
||||
.attr("width", x.rangeBand())
|
||||
.attr("height", 0);
|
||||
// Transition the rectangles to their final height
|
||||
rect.transition()
|
||||
.delay(function(d, i) { return i * 10; })
|
||||
.attr("y", function(d) { return y(d.y0 + d.y); })
|
||||
.attr("height", function(d) { return y(d.y0) - y(d.y0 + d.y); });
|
||||
// Add to the DOM
|
||||
mainGroup.append("g")
|
||||
.attr("class", "x axis")
|
||||
.attr("transform", "translate(0," + height + ")")
|
||||
.call(xAxis);
|
||||
var self = this;
|
||||
// Return the svg node
|
||||
return {
|
||||
domNode: svgElement[0][0],
|
||||
updateChart: function() {
|
||||
if(self.barGrouped !== "no") {
|
||||
transitionGrouped();
|
||||
} else {
|
||||
transitionStacked();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function transitionGrouped() {
|
||||
y.domain([0, yGroupMax]);
|
||||
rect.transition()
|
||||
.duration(500)
|
||||
.delay(function(d, i) { return i * 10; })
|
||||
.attr("x", function(d, i, j) { return x(d.x) + x.rangeBand() / n * j; })
|
||||
.attr("width", x.rangeBand() / n)
|
||||
.transition()
|
||||
.attr("y", function(d) { return y(d.y); })
|
||||
.attr("height", function(d) { return height - y(d.y); });
|
||||
}
|
||||
|
||||
function transitionStacked() {
|
||||
y.domain([0, yStackMax]);
|
||||
rect.transition()
|
||||
.duration(500)
|
||||
.delay(function(d, i) { return i * 10; })
|
||||
.attr("y", function(d) { return y(d.y0 + d.y); })
|
||||
.attr("height", function(d) { return y(d.y0) - y(d.y0 + d.y); })
|
||||
.transition()
|
||||
.attr("x", function(d) { return x(d.x); })
|
||||
.attr("width", x.rangeBand());
|
||||
}
|
||||
|
||||
// Inspired by Lee Byron's test data generator.
|
||||
function bumpLayer(n, o) {
|
||||
function bump(a) {
|
||||
var x = 1 / (0.1 + Math.random()),
|
||||
y = 2 * Math.random() - 0.5,
|
||||
z = 10 / (0.1 + Math.random());
|
||||
for(var i = 0; i < n; i++) {
|
||||
var w = (i / n - y) * z;
|
||||
a[i] += x * Math.exp(-w * w);
|
||||
}
|
||||
}
|
||||
var a = [], i;
|
||||
for(i = 0; i < n; ++i) a[i] = o + o * Math.random();
|
||||
for(i = 0; i < 5; ++i) bump(a);
|
||||
return a.map(function(d, i) { return {x: i, y: Math.max(0, d)}; });
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Compute the internal state of the widget
|
||||
*/
|
||||
BarWidget.prototype.execute = function() {
|
||||
// Get the parameters from the attributes
|
||||
this.barData = this.getAttribute("data");
|
||||
this.barGrouped = this.getAttribute("grouped","no");
|
||||
};
|
||||
|
||||
/*
|
||||
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
||||
*/
|
||||
BarWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
if(changedAttributes.data || changedTiddlers[this.barData]) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else if(changedAttributes.grouped) {
|
||||
this.execute();
|
||||
if(this.updateChart) {
|
||||
this.updateChart();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.d3bar = BarWidget;
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/d3/base.tid
|
||||
tags: [[$:/tags/Stylesheet]]
|
||||
|
||||
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline
|
||||
|
||||
.tc-barwidget {
|
||||
}
|
||||
|
||||
.tc-barwidget text {
|
||||
font: 8px sans-serif;
|
||||
}
|
||||
|
||||
.tc-barwidget .axis path,
|
||||
.tc-barwidget .axis line {
|
||||
fill: none;
|
||||
stroke: #000;
|
||||
shape-rendering: crispEdges;
|
||||
}
|
||||
128
plugins/tiddlywiki/d3/cloudwidget.js
vendored
128
plugins/tiddlywiki/d3/cloudwidget.js
vendored
|
|
@ -1,128 +0,0 @@
|
|||
/*\
|
||||
title: $:/plugins/tiddlywiki/d3/cloudwidget.js
|
||||
type: application/javascript
|
||||
module-type: widget
|
||||
|
||||
A widget for displaying word clouds. Derived from https://github.com/jasondavies/d3-cloud
|
||||
|
||||
\*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var Widget = require("$:/core/modules/widgets/widget.js").widget,
|
||||
d3 = require("$:/plugins/tiddlywiki/d3/d3.js").d3;
|
||||
|
||||
if($tw.browser) {
|
||||
// Frightful hack to give the cloud plugin the global d3 variable it needs
|
||||
window.d3 = d3;
|
||||
d3.layout.cloud = require("$:/plugins/tiddlywiki/d3/d3.layout.cloud.js").cloud;
|
||||
}
|
||||
|
||||
var CloudWidget = function(parseTreeNode,options) {
|
||||
this.initialise(parseTreeNode,options);
|
||||
};
|
||||
|
||||
/*
|
||||
Inherit from the base widget class
|
||||
*/
|
||||
CloudWidget.prototype = new Widget();
|
||||
|
||||
/*
|
||||
Render this widget into the DOM
|
||||
*/
|
||||
CloudWidget.prototype.render = function(parent,nextSibling) {
|
||||
// Save the parent dom node
|
||||
this.parentDomNode = parent;
|
||||
// Compute our attributes
|
||||
this.computeAttributes();
|
||||
// Execute our logic
|
||||
this.execute();
|
||||
// Create the chart
|
||||
var chart = this.createChart(parent,nextSibling);
|
||||
this.updateChart = chart.updateChart;
|
||||
if(this.updateChart) {
|
||||
this.updateChart();
|
||||
}
|
||||
// Insert the chart into the DOM and render any children
|
||||
parent.insertBefore(chart.domNode,nextSibling);
|
||||
this.domNodes.push(chart.domNode);
|
||||
};
|
||||
|
||||
CloudWidget.prototype.createChart = function(parent,nextSibling) {
|
||||
var self = this,
|
||||
fill = d3.scale.category20(),
|
||||
data = this.wiki.getTiddlerData(this.cloudData);
|
||||
// Use dummy data if none provided
|
||||
if(!data) {
|
||||
data = "This word cloud does not have any data in it".split(" ").map(function(d) {
|
||||
return {text: d, size: 10 + Math.random() * 90};
|
||||
});
|
||||
}
|
||||
// Create the svg element
|
||||
var svgElement = d3.select(parent).insert("svg",function() {return nextSibling;})
|
||||
.attr("width", 600)
|
||||
.attr("height", 400);
|
||||
// Create the main group
|
||||
var mainGroup = svgElement
|
||||
.append("g")
|
||||
.attr("transform", "translate(300,200)");
|
||||
// Create the layout
|
||||
var layout = d3.layout.cloud().size([600, 400])
|
||||
.words(data)
|
||||
.padding(5)
|
||||
.rotate(function() { return ~~(Math.random() * 5) * 30 - 60; })
|
||||
.font("Impact")
|
||||
.fontSize(function(d) { return d.size*2; })
|
||||
.on("end", draw)
|
||||
.start();
|
||||
// Function to draw all the words
|
||||
function draw(words) {
|
||||
mainGroup.selectAll("text")
|
||||
.data(words)
|
||||
.enter().append("text")
|
||||
.style("font-size", function(d) { return d.size + "px"; })
|
||||
.style("font-family", "Impact")
|
||||
.style("fill", function(d, i) { return fill(i); })
|
||||
.attr("text-anchor", "middle")
|
||||
.attr("transform", function(d) {
|
||||
return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")";
|
||||
})
|
||||
.text(function(d) { return d.text; });
|
||||
}
|
||||
function updateChart() {
|
||||
layout.spiral(self.spiral);
|
||||
}
|
||||
return {
|
||||
domNode: svgElement[0][0],
|
||||
updateChart: updateChart
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
Compute the internal state of the widget
|
||||
*/
|
||||
CloudWidget.prototype.execute = function() {
|
||||
// Get the parameters from the attributes
|
||||
this.cloudData = this.getAttribute("data");
|
||||
this.cloudSpiral = this.getAttribute("spiral","archimedean");
|
||||
};
|
||||
|
||||
/*
|
||||
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
||||
*/
|
||||
CloudWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
if(changedAttributes.data || changedTiddlers[this.cloudData]) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else if(changedAttributes.spiral) {
|
||||
this.execute();
|
||||
if(this.updateChart) {
|
||||
this.updateChart();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.d3cloud = CloudWidget;
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
Copyright (c) 2013, Michael Bostock
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* The name Michael Bostock may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
Copyright (c) 2013, Jason Davies.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* The name Jason Davies may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL JASON DAVIES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
@ -1,401 +0,0 @@
|
|||
// Word cloud layout by Jason Davies, http://www.jasondavies.com/word-cloud/
|
||||
// Algorithm due to Jonathan Feinberg, http://static.mrfeinberg.com/bv_ch03.pdf
|
||||
(function(exports) {
|
||||
function cloud() {
|
||||
var size = [256, 256],
|
||||
text = cloudText,
|
||||
font = cloudFont,
|
||||
fontSize = cloudFontSize,
|
||||
fontStyle = cloudFontNormal,
|
||||
fontWeight = cloudFontNormal,
|
||||
rotate = cloudRotate,
|
||||
padding = cloudPadding,
|
||||
spiral = archimedeanSpiral,
|
||||
words = [],
|
||||
timeInterval = Infinity,
|
||||
event = d3.dispatch("word", "end"),
|
||||
timer = null,
|
||||
cloud = {};
|
||||
|
||||
cloud.start = function() {
|
||||
var board = zeroArray((size[0] >> 5) * size[1]),
|
||||
bounds = null,
|
||||
n = words.length,
|
||||
i = -1,
|
||||
tags = [],
|
||||
data = words.map(function(d, i) {
|
||||
d.text = text.call(this, d, i);
|
||||
d.font = font.call(this, d, i);
|
||||
d.style = fontStyle.call(this, d, i);
|
||||
d.weight = fontWeight.call(this, d, i);
|
||||
d.rotate = rotate.call(this, d, i);
|
||||
d.size = ~~fontSize.call(this, d, i);
|
||||
d.padding = padding.call(this, d, i);
|
||||
return d;
|
||||
}).sort(function(a, b) { return b.size - a.size; });
|
||||
|
||||
if (timer) clearInterval(timer);
|
||||
timer = setInterval(step, 0);
|
||||
step();
|
||||
|
||||
return cloud;
|
||||
|
||||
function step() {
|
||||
var start = +new Date,
|
||||
d;
|
||||
while (+new Date - start < timeInterval && ++i < n && timer) {
|
||||
d = data[i];
|
||||
d.x = (size[0] * (Math.random() + .5)) >> 1;
|
||||
d.y = (size[1] * (Math.random() + .5)) >> 1;
|
||||
cloudSprite(d, data, i);
|
||||
if (d.hasText && place(board, d, bounds)) {
|
||||
tags.push(d);
|
||||
event.word(d);
|
||||
if (bounds) cloudBounds(bounds, d);
|
||||
else bounds = [{x: d.x + d.x0, y: d.y + d.y0}, {x: d.x + d.x1, y: d.y + d.y1}];
|
||||
// Temporary hack
|
||||
d.x -= size[0] >> 1;
|
||||
d.y -= size[1] >> 1;
|
||||
}
|
||||
}
|
||||
if (i >= n) {
|
||||
cloud.stop();
|
||||
event.end(tags, bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cloud.stop = function() {
|
||||
if (timer) {
|
||||
clearInterval(timer);
|
||||
timer = null;
|
||||
}
|
||||
return cloud;
|
||||
};
|
||||
|
||||
cloud.timeInterval = function(x) {
|
||||
if (!arguments.length) return timeInterval;
|
||||
timeInterval = x == null ? Infinity : x;
|
||||
return cloud;
|
||||
};
|
||||
|
||||
function place(board, tag, bounds) {
|
||||
var perimeter = [{x: 0, y: 0}, {x: size[0], y: size[1]}],
|
||||
startX = tag.x,
|
||||
startY = tag.y,
|
||||
maxDelta = Math.sqrt(size[0] * size[0] + size[1] * size[1]),
|
||||
s = spiral(size),
|
||||
dt = Math.random() < .5 ? 1 : -1,
|
||||
t = -dt,
|
||||
dxdy,
|
||||
dx,
|
||||
dy;
|
||||
|
||||
while (dxdy = s(t += dt)) {
|
||||
dx = ~~dxdy[0];
|
||||
dy = ~~dxdy[1];
|
||||
|
||||
if (Math.min(dx, dy) > maxDelta) break;
|
||||
|
||||
tag.x = startX + dx;
|
||||
tag.y = startY + dy;
|
||||
|
||||
if (tag.x + tag.x0 < 0 || tag.y + tag.y0 < 0 ||
|
||||
tag.x + tag.x1 > size[0] || tag.y + tag.y1 > size[1]) continue;
|
||||
// TODO only check for collisions within current bounds.
|
||||
if (!bounds || !cloudCollide(tag, board, size[0])) {
|
||||
if (!bounds || collideRects(tag, bounds)) {
|
||||
var sprite = tag.sprite,
|
||||
w = tag.width >> 5,
|
||||
sw = size[0] >> 5,
|
||||
lx = tag.x - (w << 4),
|
||||
sx = lx & 0x7f,
|
||||
msx = 32 - sx,
|
||||
h = tag.y1 - tag.y0,
|
||||
x = (tag.y + tag.y0) * sw + (lx >> 5),
|
||||
last;
|
||||
for (var j = 0; j < h; j++) {
|
||||
last = 0;
|
||||
for (var i = 0; i <= w; i++) {
|
||||
board[x + i] |= (last << msx) | (i < w ? (last = sprite[j * w + i]) >>> sx : 0);
|
||||
}
|
||||
x += sw;
|
||||
}
|
||||
delete tag.sprite;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
cloud.words = function(x) {
|
||||
if (!arguments.length) return words;
|
||||
words = x;
|
||||
return cloud;
|
||||
};
|
||||
|
||||
cloud.size = function(x) {
|
||||
if (!arguments.length) return size;
|
||||
size = [+x[0], +x[1]];
|
||||
return cloud;
|
||||
};
|
||||
|
||||
cloud.font = function(x) {
|
||||
if (!arguments.length) return font;
|
||||
font = d3.functor(x);
|
||||
return cloud;
|
||||
};
|
||||
|
||||
cloud.fontStyle = function(x) {
|
||||
if (!arguments.length) return fontStyle;
|
||||
fontStyle = d3.functor(x);
|
||||
return cloud;
|
||||
};
|
||||
|
||||
cloud.fontWeight = function(x) {
|
||||
if (!arguments.length) return fontWeight;
|
||||
fontWeight = d3.functor(x);
|
||||
return cloud;
|
||||
};
|
||||
|
||||
cloud.rotate = function(x) {
|
||||
if (!arguments.length) return rotate;
|
||||
rotate = d3.functor(x);
|
||||
return cloud;
|
||||
};
|
||||
|
||||
cloud.text = function(x) {
|
||||
if (!arguments.length) return text;
|
||||
text = d3.functor(x);
|
||||
return cloud;
|
||||
};
|
||||
|
||||
cloud.spiral = function(x) {
|
||||
if (!arguments.length) return spiral;
|
||||
spiral = spirals[x + ""] || x;
|
||||
return cloud;
|
||||
};
|
||||
|
||||
cloud.fontSize = function(x) {
|
||||
if (!arguments.length) return fontSize;
|
||||
fontSize = d3.functor(x);
|
||||
return cloud;
|
||||
};
|
||||
|
||||
cloud.padding = function(x) {
|
||||
if (!arguments.length) return padding;
|
||||
padding = d3.functor(x);
|
||||
return cloud;
|
||||
};
|
||||
|
||||
return d3.rebind(cloud, event, "on");
|
||||
}
|
||||
|
||||
function cloudText(d) {
|
||||
return d.text;
|
||||
}
|
||||
|
||||
function cloudFont() {
|
||||
return "serif";
|
||||
}
|
||||
|
||||
function cloudFontNormal() {
|
||||
return "normal";
|
||||
}
|
||||
|
||||
function cloudFontSize(d) {
|
||||
return Math.sqrt(d.value);
|
||||
}
|
||||
|
||||
function cloudRotate() {
|
||||
return (~~(Math.random() * 6) - 3) * 30;
|
||||
}
|
||||
|
||||
function cloudPadding() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Fetches a monochrome sprite bitmap for the specified text.
|
||||
// Load in batches for speed.
|
||||
function cloudSprite(d, data, di) {
|
||||
if (d.sprite) return;
|
||||
c.clearRect(0, 0, (cw << 5) / ratio, ch / ratio);
|
||||
var x = 0,
|
||||
y = 0,
|
||||
maxh = 0,
|
||||
n = data.length;
|
||||
--di;
|
||||
while (++di < n) {
|
||||
d = data[di];
|
||||
c.save();
|
||||
c.font = d.style + " " + d.weight + " " + ~~((d.size + 1) / ratio) + "px " + d.font;
|
||||
var w = c.measureText(d.text + "m").width * ratio,
|
||||
h = d.size << 1;
|
||||
if (d.rotate) {
|
||||
var sr = Math.sin(d.rotate * cloudRadians),
|
||||
cr = Math.cos(d.rotate * cloudRadians),
|
||||
wcr = w * cr,
|
||||
wsr = w * sr,
|
||||
hcr = h * cr,
|
||||
hsr = h * sr;
|
||||
w = (Math.max(Math.abs(wcr + hsr), Math.abs(wcr - hsr)) + 0x1f) >> 5 << 5;
|
||||
h = ~~Math.max(Math.abs(wsr + hcr), Math.abs(wsr - hcr));
|
||||
} else {
|
||||
w = (w + 0x1f) >> 5 << 5;
|
||||
}
|
||||
if (h > maxh) maxh = h;
|
||||
if (x + w >= (cw << 5)) {
|
||||
x = 0;
|
||||
y += maxh;
|
||||
maxh = 0;
|
||||
}
|
||||
if (y + h >= ch) break;
|
||||
c.translate((x + (w >> 1)) / ratio, (y + (h >> 1)) / ratio);
|
||||
if (d.rotate) c.rotate(d.rotate * cloudRadians);
|
||||
c.fillText(d.text, 0, 0);
|
||||
if (d.padding) c.lineWidth = 2 * d.padding, c.strokeText(d.text, 0, 0);
|
||||
c.restore();
|
||||
d.width = w;
|
||||
d.height = h;
|
||||
d.xoff = x;
|
||||
d.yoff = y;
|
||||
d.x1 = w >> 1;
|
||||
d.y1 = h >> 1;
|
||||
d.x0 = -d.x1;
|
||||
d.y0 = -d.y1;
|
||||
d.hasText = true;
|
||||
x += w;
|
||||
}
|
||||
var pixels = c.getImageData(0, 0, (cw << 5) / ratio, ch / ratio).data,
|
||||
sprite = [];
|
||||
while (--di >= 0) {
|
||||
d = data[di];
|
||||
if (!d.hasText) continue;
|
||||
var w = d.width,
|
||||
w32 = w >> 5,
|
||||
h = d.y1 - d.y0;
|
||||
// Zero the buffer
|
||||
for (var i = 0; i < h * w32; i++) sprite[i] = 0;
|
||||
x = d.xoff;
|
||||
if (x == null) return;
|
||||
y = d.yoff;
|
||||
var seen = 0,
|
||||
seenRow = -1;
|
||||
for (var j = 0; j < h; j++) {
|
||||
for (var i = 0; i < w; i++) {
|
||||
var k = w32 * j + (i >> 5),
|
||||
m = pixels[((y + j) * (cw << 5) + (x + i)) << 2] ? 1 << (31 - (i % 32)) : 0;
|
||||
sprite[k] |= m;
|
||||
seen |= m;
|
||||
}
|
||||
if (seen) seenRow = j;
|
||||
else {
|
||||
d.y0++;
|
||||
h--;
|
||||
j--;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
d.y1 = d.y0 + seenRow;
|
||||
d.sprite = sprite.slice(0, (d.y1 - d.y0) * w32);
|
||||
}
|
||||
}
|
||||
|
||||
// Use mask-based collision detection.
|
||||
function cloudCollide(tag, board, sw) {
|
||||
sw >>= 5;
|
||||
var sprite = tag.sprite,
|
||||
w = tag.width >> 5,
|
||||
lx = tag.x - (w << 4),
|
||||
sx = lx & 0x7f,
|
||||
msx = 32 - sx,
|
||||
h = tag.y1 - tag.y0,
|
||||
x = (tag.y + tag.y0) * sw + (lx >> 5),
|
||||
last;
|
||||
for (var j = 0; j < h; j++) {
|
||||
last = 0;
|
||||
for (var i = 0; i <= w; i++) {
|
||||
if (((last << msx) | (i < w ? (last = sprite[j * w + i]) >>> sx : 0))
|
||||
& board[x + i]) return true;
|
||||
}
|
||||
x += sw;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function cloudBounds(bounds, d) {
|
||||
var b0 = bounds[0],
|
||||
b1 = bounds[1];
|
||||
if (d.x + d.x0 < b0.x) b0.x = d.x + d.x0;
|
||||
if (d.y + d.y0 < b0.y) b0.y = d.y + d.y0;
|
||||
if (d.x + d.x1 > b1.x) b1.x = d.x + d.x1;
|
||||
if (d.y + d.y1 > b1.y) b1.y = d.y + d.y1;
|
||||
}
|
||||
|
||||
function collideRects(a, b) {
|
||||
return a.x + a.x1 > b[0].x && a.x + a.x0 < b[1].x && a.y + a.y1 > b[0].y && a.y + a.y0 < b[1].y;
|
||||
}
|
||||
|
||||
function archimedeanSpiral(size) {
|
||||
var e = size[0] / size[1];
|
||||
return function(t) {
|
||||
return [e * (t *= .1) * Math.cos(t), t * Math.sin(t)];
|
||||
};
|
||||
}
|
||||
|
||||
function rectangularSpiral(size) {
|
||||
var dy = 4,
|
||||
dx = dy * size[0] / size[1],
|
||||
x = 0,
|
||||
y = 0;
|
||||
return function(t) {
|
||||
var sign = t < 0 ? -1 : 1;
|
||||
// See triangular numbers: T_n = n * (n + 1) / 2.
|
||||
switch ((Math.sqrt(1 + 4 * sign * t) - sign) & 3) {
|
||||
case 0: x += dx; break;
|
||||
case 1: y += dy; break;
|
||||
case 2: x -= dx; break;
|
||||
default: y -= dy; break;
|
||||
}
|
||||
return [x, y];
|
||||
};
|
||||
}
|
||||
|
||||
// TODO reuse arrays?
|
||||
function zeroArray(n) {
|
||||
var a = [],
|
||||
i = -1;
|
||||
while (++i < n) a[i] = 0;
|
||||
return a;
|
||||
}
|
||||
|
||||
var cloudRadians = Math.PI / 180,
|
||||
cw = 1 << 11 >> 5,
|
||||
ch = 1 << 11,
|
||||
canvas,
|
||||
ratio = 1;
|
||||
|
||||
if (typeof document !== "undefined") {
|
||||
canvas = document.createElement("canvas");
|
||||
canvas.width = 1;
|
||||
canvas.height = 1;
|
||||
ratio = Math.sqrt(canvas.getContext("2d").getImageData(0, 0, 1, 1).data.length >> 2);
|
||||
canvas.width = (cw << 5) / ratio;
|
||||
canvas.height = ch / ratio;
|
||||
} else {
|
||||
// node-canvas support
|
||||
var Canvas = require("canvas");
|
||||
canvas = new Canvas(cw << 5, ch);
|
||||
}
|
||||
|
||||
var c = canvas.getContext("2d"),
|
||||
spirals = {
|
||||
archimedean: archimedeanSpiral,
|
||||
rectangular: rectangularSpiral
|
||||
};
|
||||
c.fillStyle = c.strokeStyle = "red";
|
||||
c.textAlign = "center";
|
||||
|
||||
exports.cloud = cloud;
|
||||
})(typeof exports === "undefined" ? d3.layout || (d3.layout = {}) : exports);
|
||||
5
plugins/tiddlywiki/d3/files/d3.min.js
vendored
5
plugins/tiddlywiki/d3/files/d3.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"tiddlers": [
|
||||
{
|
||||
"file": "d3.min.js",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": "$:/plugins/tiddlywiki/d3/d3.js",
|
||||
"module-type": "library"
|
||||
},
|
||||
"prefix": "var d3;if($tw.browser){\n",
|
||||
"suffix": "}\nexports.d3 = d3;\n"
|
||||
},
|
||||
{
|
||||
"file": "cloud/d3.layout.cloud.js",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": "$:/plugins/tiddlywiki/d3/d3.layout.cloud.js",
|
||||
"module-type": "library"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"title": "$:/plugins/tiddlywiki/d3",
|
||||
"name": "D3",
|
||||
"description": "D3 data visualisation demo",
|
||||
"list": "readme",
|
||||
"stability": "STABILITY_0_DEPRECATED"
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/d3/readme
|
||||
|
||||
The D3 plugin is a proof-of-concept demo of integration with the D3.js data visualisation framework (http://d3js.org).
|
||||
|
||||
It is not currently in a state where it can be used for anything useful.
|
||||
|
||||
[[Source code|https://github.com/TiddlyWiki/TiddlyWiki5/blob/master/plugins/tiddlywiki/d3]]
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 2011-2017 by Jorik Tangelder (Eight Media)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"tiddlers": [
|
||||
{
|
||||
"file": "hammer.min.v2.0.8.js",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": "$:/plugins/tiddlywiki/hammerjs/hammer.js",
|
||||
"module-type": "library"
|
||||
},
|
||||
"prefix": "",
|
||||
"suffix": ""
|
||||
},{
|
||||
"file": "LICENSE.markdown",
|
||||
"fields": {
|
||||
"type": "text/plain",
|
||||
"title": "$:/plugins/tiddlywiki/hammerjs/license"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"title": "$:/plugins/tiddlywiki/hammerjs",
|
||||
"name": "HammerJS",
|
||||
"description": "HammerJS touch gesture library",
|
||||
"author": "Jorik Tangelder (Eight Media)",
|
||||
"list": "readme license",
|
||||
"stability": "STABILITY_0_DEPRECATED"
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/hammerjs/readme
|
||||
|
||||
This plugin packages [[HammerJS|https://hammerjs.github.io]] for use by other plugins. It does not provide any end-user visible features.
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
title: $:/config/HighlightPlugin/TypeMappings/
|
||||
|
||||
application/javascript: javascript
|
||||
application/json: json
|
||||
text/css: css
|
||||
text/html: html
|
||||
image/svg+xml: xml
|
||||
text/x-markdown: markdown
|
||||
text/markdown: markdown
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
|
||||
Original highlight.js style (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
|
||||
|
||||
*/
|
||||
|
||||
.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
background: #F0F0F0;
|
||||
}
|
||||
|
||||
|
||||
/* Base color: saturation 0; */
|
||||
|
||||
.hljs,
|
||||
.hljs-subst {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.hljs-comment {
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
.hljs-keyword,
|
||||
.hljs-attribute,
|
||||
.hljs-selector-tag,
|
||||
.hljs-meta-keyword,
|
||||
.hljs-doctag,
|
||||
.hljs-name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
/* User color: hue: 0 */
|
||||
|
||||
.hljs-type,
|
||||
.hljs-string,
|
||||
.hljs-number,
|
||||
.hljs-selector-id,
|
||||
.hljs-selector-class,
|
||||
.hljs-quote,
|
||||
.hljs-template-tag,
|
||||
.hljs-deletion {
|
||||
color: #880000;
|
||||
}
|
||||
|
||||
.hljs-title,
|
||||
.hljs-section {
|
||||
color: #880000;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-regexp,
|
||||
.hljs-symbol,
|
||||
.hljs-variable,
|
||||
.hljs-template-variable,
|
||||
.hljs-link,
|
||||
.hljs-selector-attr,
|
||||
.hljs-selector-pseudo {
|
||||
color: #BC6060;
|
||||
}
|
||||
|
||||
|
||||
/* Language color: hue: 90; */
|
||||
|
||||
.hljs-literal {
|
||||
color: #78A960;
|
||||
}
|
||||
|
||||
.hljs-built_in,
|
||||
.hljs-bullet,
|
||||
.hljs-code,
|
||||
.hljs-addition {
|
||||
color: #397300;
|
||||
}
|
||||
|
||||
|
||||
/* Meta color: hue: 200 */
|
||||
|
||||
.hljs-meta {
|
||||
color: #1f7199;
|
||||
}
|
||||
|
||||
.hljs-meta-string {
|
||||
color: #4d99bf;
|
||||
}
|
||||
|
||||
|
||||
/* Misc effects */
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"tiddlers": [
|
||||
{
|
||||
"file": "highlight.pack.js",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": "$:/plugins/tiddlywiki/highlight-legacy/highlight.js",
|
||||
"module-type": "library"
|
||||
},
|
||||
"prefix": "var hljs = require(\"$:/plugins/tiddlywiki/highlight-legacy/highlight.js\");\n",
|
||||
"suffix": "\nexports.hljs = hljs;\n"
|
||||
},
|
||||
{
|
||||
"file": "default.css",
|
||||
"fields": {
|
||||
"type": "text/css",
|
||||
"title": "$:/plugins/tiddlywiki/highlight-legacy/highlight.css",
|
||||
"tags": "[[$:/tags/Stylesheet]]"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/*\
|
||||
title: $:/plugins/tiddlywiki/highlight-legacy/highlightblock.js
|
||||
type: application/javascript
|
||||
module-type: widget
|
||||
|
||||
Wraps up the fenced code blocks parser for highlight and use in TiddlyWiki5
|
||||
|
||||
\*/
|
||||
"use strict";
|
||||
var TYPE_MAPPINGS_BASE = "$:/config/HighlightPlugin/TypeMappings/";
|
||||
|
||||
var CodeBlockWidget = require("$:/core/modules/widgets/codeblock.js").codeblock;
|
||||
|
||||
var hljs = require("$:/plugins/tiddlywiki/highlight-legacy/highlight.js");
|
||||
|
||||
hljs.configure({tabReplace: " "});
|
||||
|
||||
CodeBlockWidget.prototype.postRender = function() {
|
||||
var domNode = this.domNodes[0],
|
||||
language = this.language,
|
||||
tiddler = this.wiki.getTiddler(TYPE_MAPPINGS_BASE + language);
|
||||
if(tiddler) {
|
||||
language = tiddler.fields.text || "";
|
||||
}
|
||||
if(language && hljs.getLanguage(language)) {
|
||||
domNode.className = language.toLowerCase() + " hljs";
|
||||
if($tw.browser && !domNode.isTiddlyWikiFakeDom) {
|
||||
hljs.highlightBlock(domNode);
|
||||
} else {
|
||||
var text = domNode.textContent;
|
||||
domNode.children[0].innerHTML = hljs.fixMarkup(hljs.highlight(language,text).value);
|
||||
// If we're using the fakedom then specially save the original raw text
|
||||
if(domNode.isTiddlyWikiFakeDom) {
|
||||
domNode.children[0].textInnerHTML = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/highlight-legacy/license
|
||||
type: text/plain
|
||||
|
||||
Copyright (c) 2006, Ivan Sagalaev
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of highlight.js nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"title": "$:/plugins/tiddlywiki/highlight-legacy",
|
||||
"name": "Highlight (Legacy)",
|
||||
"description": "Highlight.js syntax highlighting for legacy browsers",
|
||||
"author": "Joao Bolila",
|
||||
"list": "readme usage license",
|
||||
"stability": "STABILITY_3_LEGACY"
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/highlight-legacy/readme
|
||||
|
||||
This plugin provides syntax highlighting of code blocks using v9.18.1 of [[highlight.js|https://github.com/isagalaev/highlight.js]] from Ivan Sagalaev. This legacy version should be installed in place of the regular Highlight plugin when you require your wiki to be opened in browsers that do not fully support <$text text="JavaScript"/> ES6 (2015). Here's a [[ES6 compatibility table|https://caniuse.com/?search=es6]].
|
||||
|
||||
! Built-in Language Brushes
|
||||
|
||||
The plugin includes support for the following languages (referred to as "brushes" by highlight.js):
|
||||
|
||||
* apache
|
||||
* arduino
|
||||
* arm assembly
|
||||
* asciidoc
|
||||
* autohotkey
|
||||
* awk
|
||||
* bash
|
||||
* cmake
|
||||
* coffeescript
|
||||
* cpp
|
||||
* cs
|
||||
* css
|
||||
* diff
|
||||
* dockerfile
|
||||
* erlang
|
||||
* elixir
|
||||
* fortran
|
||||
* go
|
||||
* gradle
|
||||
* haskell
|
||||
* html
|
||||
* http
|
||||
* ini
|
||||
* intel x86 assembly
|
||||
* java
|
||||
* javascript
|
||||
* json
|
||||
* kotlin
|
||||
* less
|
||||
* lua
|
||||
* makefile
|
||||
* markdown
|
||||
* mathematica
|
||||
* matlab
|
||||
* nginx
|
||||
* objectivec
|
||||
* perl
|
||||
* php
|
||||
* plaintext
|
||||
* powershell
|
||||
* properties
|
||||
* python
|
||||
* R
|
||||
* ruby
|
||||
* rust
|
||||
* scss
|
||||
* shell session
|
||||
* sql
|
||||
* swift
|
||||
* toml
|
||||
* typescript
|
||||
* vala
|
||||
* vim script
|
||||
* xml
|
||||
* yaml
|
||||
|
||||
The mapping between a MIME type and a highlight.js language specifier is accomplished via mapping tiddlers whose titles start with `$:/config/HighlightPlugin/TypeMappings/`.
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/highlight-legacy/styles
|
||||
tags: [[$:/tags/Stylesheet]]
|
||||
|
||||
.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
background: <<colour tiddler-editor-background>>;
|
||||
color: <<colour foreground>>;
|
||||
-webkit-text-size-adjust:none
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-quote {
|
||||
color: #93a1a1;
|
||||
}
|
||||
|
||||
/* Solarized Green */
|
||||
.hljs-keyword,
|
||||
.hljs-selector-tag,
|
||||
.hljs-addition {
|
||||
color: #859900;
|
||||
}
|
||||
|
||||
/* Solarized Cyan */
|
||||
.hljs-number,
|
||||
.hljs-string,
|
||||
.hljs-meta .hljs-meta-string,
|
||||
.hljs-literal,
|
||||
.hljs-doctag,
|
||||
.hljs-regexp {
|
||||
color: #2aa198;
|
||||
}
|
||||
|
||||
/* Solarized Blue */
|
||||
.hljs-title,
|
||||
.hljs-section,
|
||||
.hljs-name,
|
||||
.hljs-selector-id,
|
||||
.hljs-selector-class {
|
||||
color: #268bd2;
|
||||
}
|
||||
|
||||
/* Solarized Yellow */
|
||||
.hljs-attribute,
|
||||
.hljs-attr,
|
||||
.hljs-variable,
|
||||
.hljs-template-variable,
|
||||
.hljs-class .hljs-title,
|
||||
.hljs-type {
|
||||
color: #b58900;
|
||||
}
|
||||
|
||||
/* Solarized Orange */
|
||||
.hljs-symbol,
|
||||
.hljs-bullet,
|
||||
.hljs-subst,
|
||||
.hljs-meta,
|
||||
.hljs-meta .hljs-keyword,
|
||||
.hljs-selector-attr,
|
||||
.hljs-selector-pseudo,
|
||||
.hljs-link {
|
||||
color: #cb4b16;
|
||||
}
|
||||
|
||||
/* Solarized Red */
|
||||
.hljs-built_in,
|
||||
.hljs-deletion {
|
||||
color: #dc322f;
|
||||
}
|
||||
|
||||
.hljs-formula {
|
||||
background: #eee8d5;
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/highlight-legacy/usage
|
||||
|
||||
! Usage
|
||||
|
||||
Syntax highlighting is triggered when you add language information to code blocks defined with triple backticks or with the `<$codeblock>` widget. For fenced code blocks, specify the code's language immediately after the first set of backticks:
|
||||
|
||||
```
|
||||
```js
|
||||
var a = b + c; // Highlighted as JavaScript
|
||||
```
|
||||
```
|
||||
|
||||
! Adding Themes
|
||||
|
||||
You can add themes from highlight.js by copying the CSS to a new tiddler and tagging it with [[$:/tags/Stylesheet]]. The available themes can be found on GitHub:
|
||||
|
||||
https://github.com/isagalaev/highlight.js/tree/master/src/styles
|
||||
|
||||
! Supporting Additional Languages
|
||||
|
||||
The [[highlight.js|https://github.com/highlightjs/highlight.js]] project supports many languages. Only a subset of these languages are supported by the plugin. It is possible for users to change the set of languages supported by the plugin by following these steps:
|
||||
|
||||
(Requires ~TiddlyWiki on Node.js)
|
||||
|
||||
# Go to the highlight.js project [[download page|https://highlightjs.org/download/]], select the language definitions to include, and press the Download button to download a zip archive containing customised support files for a highlight.js syntax highlighting server.
|
||||
# Locate the `highlight.pack.js` file in the highlight plugin -- on a stock Debian 8 system running Tiddlywiki5 under node-js, it is in `/usr/local/lib/node_modules/tiddlywiki/plugins/tiddlywiki/highlight/files/`.
|
||||
# Replace the plugin `highlight.pack.js` file located in step 2 with the one from the downloaded archive obtained in step 1.
|
||||
# Restart the ~TiddlyWiki server.
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
Copyright (c) 2013 Tim Ruffles
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -1,477 +0,0 @@
|
|||
(function(doc) {
|
||||
|
||||
function _exposeIosHtml5DragDropShim(config) {
|
||||
log = noop; // noOp, remove this line to enable debugging
|
||||
|
||||
var coordinateSystemForElementFromPoint;
|
||||
|
||||
var DRAG_OVER_EMIT_FREQ = 50;
|
||||
|
||||
function main() {
|
||||
config = config || {};
|
||||
if (!config.hasOwnProperty("simulateAnchorClick")) config.simulateAnchorClick = true;
|
||||
|
||||
coordinateSystemForElementFromPoint = navigator.userAgent.match(/OS [1-4](?:_\d+)+ like Mac/) ? "page" : "client";
|
||||
|
||||
var div = doc.createElement('div');
|
||||
var dragDiv = 'draggable' in div;
|
||||
var evts = 'ondragstart' in div && 'ondrop' in div;
|
||||
|
||||
var needsPatch = !(dragDiv || evts) || /iPad|iPhone|iPod|Android/.test(navigator.userAgent);
|
||||
log((needsPatch ? "" : "not ") + "patching html5 drag drop");
|
||||
|
||||
if(!needsPatch) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!config.enableEnterLeave) {
|
||||
DragDrop.prototype.synthesizeEnterLeave = noop;
|
||||
}
|
||||
|
||||
if(config.holdToDrag){
|
||||
doc.addEventListener("touchstart", touchstartDelay(config.holdToDrag), {passive:false});
|
||||
}
|
||||
else {
|
||||
doc.addEventListener("touchstart", touchstart, {passive:false});
|
||||
}
|
||||
}
|
||||
|
||||
function DragDrop(event, el) {
|
||||
|
||||
this.dragData = {};
|
||||
this.dragDataTypes = [];
|
||||
this.dragImage = null;
|
||||
this.dragImageTransform = null;
|
||||
this.dragImageWebKitTransform = null;
|
||||
this.customDragImage = null;
|
||||
this.customDragImageX = null;
|
||||
this.customDragImageY = null;
|
||||
this.el = el || event.target;
|
||||
this.dragOverTimer = null;
|
||||
this.lastMoveEvent = null;
|
||||
|
||||
log("dragstart");
|
||||
|
||||
if (this.dispatchDragStart()) {
|
||||
this.createDragImage();
|
||||
this.listen();
|
||||
}
|
||||
}
|
||||
|
||||
DragDrop.prototype = {
|
||||
listen: function() {
|
||||
var move = onEvt(doc, "touchmove", this.move, this);
|
||||
var end = onEvt(doc, "touchend", ontouchend, this);
|
||||
var cancel = onEvt(doc, "touchcancel", cleanup, this);
|
||||
|
||||
function ontouchend(event) {
|
||||
this.dragend(event, event.target);
|
||||
cleanup.call(this);
|
||||
}
|
||||
function cleanup() {
|
||||
log("cleanup");
|
||||
this.dragDataTypes = [];
|
||||
if (this.dragImage !== null) {
|
||||
this.dragImage.parentNode.removeChild(this.dragImage);
|
||||
this.dragImage = null;
|
||||
this.dragImageTransform = null;
|
||||
this.dragImageWebKitTransform = null;
|
||||
}
|
||||
this.customDragImage = null;
|
||||
this.customDragImageX = null;
|
||||
this.customDragImageY = null;
|
||||
this.el = this.dragData = null;
|
||||
return [move, end, cancel].forEach(function(handler) {
|
||||
return handler.off();
|
||||
});
|
||||
}
|
||||
},
|
||||
move: function(event) {
|
||||
event.preventDefault();
|
||||
var pageXs = [], pageYs = [];
|
||||
[].forEach.call(event.changedTouches, function(touch) {
|
||||
pageXs.push(touch.pageX);
|
||||
pageYs.push(touch.pageY);
|
||||
});
|
||||
|
||||
var x = average(pageXs) - (this.customDragImageX || parseInt(this.dragImage.offsetWidth, 10) / 2);
|
||||
var y = average(pageYs) - (this.customDragImageY || parseInt(this.dragImage.offsetHeight, 10) / 2);
|
||||
this.translateDragImage(x, y);
|
||||
|
||||
this.synthesizeEnterLeave(event);
|
||||
this.synthesizeOver(event);
|
||||
},
|
||||
// We use translate instead of top/left because of sub-pixel rendering and for the hope of better performance
|
||||
// http://www.paulirish.com/2012/why-moving-elements-with-translate-is-better-than-posabs-topleft/
|
||||
translateDragImage: function(x, y) {
|
||||
var translate = "translate(" + x + "px," + y + "px) ";
|
||||
|
||||
if (this.dragImageWebKitTransform !== null) {
|
||||
this.dragImage.style["-webkit-transform"] = translate + this.dragImageWebKitTransform;
|
||||
}
|
||||
if (this.dragImageTransform !== null) {
|
||||
this.dragImage.style.transform = translate + this.dragImageTransform;
|
||||
}
|
||||
},
|
||||
synthesizeEnterLeave: function(event) {
|
||||
var target = elementFromTouchEvent(this.el,event)
|
||||
if (target != this.lastEnter) {
|
||||
if (this.lastEnter) {
|
||||
this.dispatchLeave(event);
|
||||
}
|
||||
this.lastEnter = target;
|
||||
if (this.lastEnter) {
|
||||
this.dispatchEnter(event);
|
||||
}
|
||||
}
|
||||
},
|
||||
synthesizeOver: function(event) {
|
||||
this.lastMoveEvent = event;
|
||||
if(this.lastEnter && !this.dragOverTimer) {
|
||||
this.dragOverTimer = setInterval(this.dispatchOver.bind(this), DRAG_OVER_EMIT_FREQ);
|
||||
}
|
||||
},
|
||||
clearDragOverTimer: function() {
|
||||
if(this.dragOverTimer) {
|
||||
clearInterval(this.dragOverTimer);
|
||||
this.dragOverTimer = null;
|
||||
}
|
||||
},
|
||||
dragend: function(event) {
|
||||
|
||||
// we'll dispatch drop if there's a target, then dragEnd.
|
||||
// drop comes first http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#drag-and-drop-processing-model
|
||||
log("dragend");
|
||||
|
||||
if (this.lastEnter) {
|
||||
this.dispatchLeave(event);
|
||||
}
|
||||
|
||||
var target = elementFromTouchEvent(this.el,event)
|
||||
if (target) {
|
||||
log("found drop target " + target.tagName);
|
||||
this.dispatchDrop(target, event);
|
||||
} else {
|
||||
log("no drop target");
|
||||
}
|
||||
|
||||
var dragendEvt = doc.createEvent("Event");
|
||||
dragendEvt.initEvent("dragend", true, true);
|
||||
this.el.dispatchEvent(dragendEvt);
|
||||
this.clearDragOverTimer();
|
||||
},
|
||||
dispatchDrop: function(target, event) {
|
||||
var dropEvt = doc.createEvent("Event");
|
||||
dropEvt.initEvent("drop", true, true);
|
||||
|
||||
var touch = event.changedTouches[0];
|
||||
var x = touch[coordinateSystemForElementFromPoint + 'X'];
|
||||
var y = touch[coordinateSystemForElementFromPoint + 'Y'];
|
||||
|
||||
var targetOffset = getOffset(target);
|
||||
|
||||
dropEvt.offsetX = x - targetOffset.x;
|
||||
dropEvt.offsetY = y - targetOffset.y;
|
||||
|
||||
dropEvt.dataTransfer = {
|
||||
types: this.dragDataTypes,
|
||||
getData: function(type) {
|
||||
return this.dragData[type];
|
||||
}.bind(this),
|
||||
dropEffect: "move"
|
||||
};
|
||||
dropEvt.preventDefault = function() {
|
||||
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=14638 - if we don't cancel it, we'll snap back
|
||||
}.bind(this);
|
||||
|
||||
once(doc, "drop", function() {
|
||||
log("drop event not canceled");
|
||||
},this);
|
||||
|
||||
target.dispatchEvent(dropEvt);
|
||||
},
|
||||
dispatchEnter: function(event) {
|
||||
|
||||
var enterEvt = doc.createEvent("Event");
|
||||
enterEvt.initEvent("dragenter", true, true);
|
||||
enterEvt.dataTransfer = {
|
||||
types: this.dragDataTypes,
|
||||
getData: function(type) {
|
||||
return this.dragData[type];
|
||||
}.bind(this)
|
||||
};
|
||||
|
||||
var touch = event.changedTouches[0];
|
||||
enterEvt.pageX = touch.pageX;
|
||||
enterEvt.pageY = touch.pageY;
|
||||
enterEvt.clientX = touch.clientX;
|
||||
enterEvt.clientY = touch.clientY;
|
||||
|
||||
this.lastEnter.dispatchEvent(enterEvt);
|
||||
},
|
||||
dispatchOver: function() {
|
||||
|
||||
var overEvt = doc.createEvent("Event");
|
||||
overEvt.initEvent("dragover", true, true);
|
||||
overEvt.dataTransfer = {
|
||||
types: this.dragDataTypes,
|
||||
getData: function(type) {
|
||||
return this.dragData[type];
|
||||
}.bind(this)
|
||||
};
|
||||
|
||||
var touch = this.lastMoveEvent.changedTouches[0];
|
||||
overEvt.pageX = touch.pageX;
|
||||
overEvt.pageY = touch.pageY;
|
||||
overEvt.clientX = touch.clientX;
|
||||
overEvt.clientY = touch.clientY;
|
||||
|
||||
this.lastEnter.dispatchEvent(overEvt);
|
||||
},
|
||||
dispatchLeave: function(event) {
|
||||
|
||||
var leaveEvt = doc.createEvent("Event");
|
||||
leaveEvt.initEvent("dragleave", true, true);
|
||||
leaveEvt.dataTransfer = {
|
||||
types: this.dragDataTypes,
|
||||
getData: function(type) {
|
||||
return this.dragData[type];
|
||||
}.bind(this)
|
||||
};
|
||||
|
||||
var touch = event.changedTouches[0];
|
||||
leaveEvt.pageX = touch.pageX;
|
||||
leaveEvt.pageY = touch.pageY;
|
||||
leaveEvt.clientX = touch.clientX;
|
||||
leaveEvt.clientY = touch.clientY;
|
||||
|
||||
this.lastEnter.dispatchEvent(leaveEvt);
|
||||
this.lastEnter = null;
|
||||
this.clearDragOverTimer();
|
||||
},
|
||||
dispatchDragStart: function() {
|
||||
var evt = doc.createEvent("Event");
|
||||
evt.initEvent("dragstart", true, true);
|
||||
evt.dataTransfer = {
|
||||
setData: function(type, val) {
|
||||
this.dragData[type] = val;
|
||||
if (this.dragDataTypes.indexOf(type) == -1) {
|
||||
this.dragDataTypes[this.dragDataTypes.length] = type;
|
||||
}
|
||||
return val;
|
||||
}.bind(this),
|
||||
setDragImage: function(el, x, y){
|
||||
this.customDragImage = el;
|
||||
this.customDragImageX = x
|
||||
this.customDragImageY = y
|
||||
}.bind(this),
|
||||
dropEffect: "move"
|
||||
};
|
||||
return this.el.dispatchEvent(evt);
|
||||
},
|
||||
createDragImage: function() {
|
||||
if (this.customDragImage) {
|
||||
this.dragImage = this.customDragImage.cloneNode(true);
|
||||
duplicateStyle(this.customDragImage, this.dragImage);
|
||||
} else {
|
||||
this.dragImage = this.el.cloneNode(true);
|
||||
duplicateStyle(this.el, this.dragImage);
|
||||
}
|
||||
this.dragImage.style.opacity = "0.5";
|
||||
this.dragImage.style.position = "absolute";
|
||||
this.dragImage.style.left = "0px";
|
||||
this.dragImage.style.top = "0px";
|
||||
this.dragImage.style.zIndex = "999999";
|
||||
|
||||
var transform = this.dragImage.style.transform;
|
||||
if (typeof transform !== "undefined") {
|
||||
this.dragImageTransform = "";
|
||||
if (transform != "none") {
|
||||
this.dragImageTransform = transform.replace(/translate\(\D*\d+[^,]*,\D*\d+[^,]*\)\s*/g, '');
|
||||
}
|
||||
}
|
||||
|
||||
var webkitTransform = this.dragImage.style["-webkit-transform"];
|
||||
if (typeof webkitTransform !== "undefined") {
|
||||
this.dragImageWebKitTransform = "";
|
||||
if (webkitTransform != "none") {
|
||||
this.dragImageWebKitTransform = webkitTransform.replace(/translate\(\D*\d+[^,]*,\D*\d+[^,]*\)\s*/g, '');
|
||||
}
|
||||
}
|
||||
|
||||
this.translateDragImage(-9999, -9999);
|
||||
|
||||
doc.body.appendChild(this.dragImage);
|
||||
}
|
||||
};
|
||||
|
||||
// delayed touch start event
|
||||
function touchstartDelay(delay) {
|
||||
return function(evt){
|
||||
var el = evt.target;
|
||||
|
||||
do {
|
||||
if (elementIsDraggable(el)) {
|
||||
var heldItem = function() {
|
||||
end.off();
|
||||
cancel.off();
|
||||
scroll.off();
|
||||
touchstart(evt);
|
||||
};
|
||||
|
||||
var onReleasedItem = function() {
|
||||
end.off();
|
||||
cancel.off();
|
||||
scroll.off();
|
||||
clearTimeout(timer);
|
||||
};
|
||||
|
||||
var timer = setTimeout(heldItem, delay);
|
||||
|
||||
var end = onEvt(el, 'touchend', onReleasedItem, this);
|
||||
var cancel = onEvt(el, 'touchcancel', onReleasedItem, this);
|
||||
var scroll = onEvt(window, 'scroll', onReleasedItem, this);
|
||||
break;
|
||||
}
|
||||
} while ((el = el.parentNode) && el !== doc.body);
|
||||
};
|
||||
};
|
||||
|
||||
// event listeners
|
||||
function touchstart(evt) {
|
||||
var el = evt.target;
|
||||
do {
|
||||
if (elementIsDraggable(el)) {
|
||||
handleTouchStartOnAnchor(evt, el);
|
||||
|
||||
evt.preventDefault();
|
||||
new DragDrop(evt,el);
|
||||
break;
|
||||
}
|
||||
} while((el = el.parentNode) && el !== doc.body);
|
||||
}
|
||||
|
||||
function elementIsDraggable(el){
|
||||
// if an element is not draggable either explicitly or implicitly we can exit immediately
|
||||
if(!el.draggable) return false;
|
||||
|
||||
// if an element has been explicitly set to be draggable we're good to go
|
||||
if(el.hasAttribute("draggable")) return true;
|
||||
|
||||
// otherwise we investigate the implicit option
|
||||
return (!config.requireExplicitDraggable);
|
||||
}
|
||||
|
||||
function elementIsAnchor(el){
|
||||
return el.tagName.toLowerCase() == "a";
|
||||
}
|
||||
|
||||
function handleTouchStartOnAnchor(evt, el){
|
||||
// If draggable isn't explicitly set for anchors, then simulate a click event.
|
||||
// Otherwise plain old vanilla links will stop working.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Touch_events#Handling_clicks
|
||||
if (!el.hasAttribute("draggable") && elementIsAnchor(el) && config.simulateAnchorClick) {
|
||||
var clickEvt = document.createEvent("MouseEvents");
|
||||
clickEvt.initMouseEvent("click", true, true, el.ownerDocument.defaultView, 1,
|
||||
evt.screenX, evt.screenY, evt.clientX, evt.clientY,
|
||||
evt.ctrlKey, evt.altKey, evt.shiftKey, evt.metaKey, 0, null);
|
||||
el.dispatchEvent(clickEvt);
|
||||
log("Simulating click to anchor");
|
||||
}
|
||||
}
|
||||
|
||||
// DOM helpers
|
||||
function elementFromTouchEvent(el,event) {
|
||||
var touch = event.changedTouches[0];
|
||||
var target = doc.elementFromPoint(
|
||||
touch[coordinateSystemForElementFromPoint + "X"],
|
||||
touch[coordinateSystemForElementFromPoint + "Y"]
|
||||
);
|
||||
return target;
|
||||
}
|
||||
|
||||
//calculate the offset position of an element (relative to the window, not the document)
|
||||
function getOffset(el) {
|
||||
var rect = el.getBoundingClientRect();
|
||||
return {
|
||||
"x": rect.left,
|
||||
"y": rect.top
|
||||
};
|
||||
}
|
||||
|
||||
function onEvt(el, event, handler, context) {
|
||||
if(context) {
|
||||
handler = handler.bind(context);
|
||||
}
|
||||
el.addEventListener(event, handler, {passive:false});
|
||||
return {
|
||||
off: function() {
|
||||
return el.removeEventListener(event, handler, {passive:false});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function once(el, event, handler, context) {
|
||||
if(context) {
|
||||
handler = handler.bind(context);
|
||||
}
|
||||
function listener(evt) {
|
||||
handler(evt);
|
||||
return el.removeEventListener(event,listener);
|
||||
}
|
||||
return el.addEventListener(event,listener);
|
||||
}
|
||||
|
||||
// duplicateStyle expects dstNode to be a clone of srcNode
|
||||
function duplicateStyle(srcNode, dstNode) {
|
||||
// Is this node an element?
|
||||
if (srcNode.nodeType == 1) {
|
||||
// Remove any potential conflict attributes
|
||||
dstNode.removeAttribute("id");
|
||||
dstNode.removeAttribute("class");
|
||||
dstNode.removeAttribute("style");
|
||||
dstNode.removeAttribute("draggable");
|
||||
|
||||
// Clone the style
|
||||
var cs = window.getComputedStyle(srcNode);
|
||||
for (var i = 0; i < cs.length; i++) {
|
||||
var csName = cs[i];
|
||||
dstNode.style.setProperty(csName, cs.getPropertyValue(csName), cs.getPropertyPriority(csName));
|
||||
}
|
||||
|
||||
// Pointer events as none makes the drag image transparent to document.elementFromPoint()
|
||||
dstNode.style.pointerEvents = "none";
|
||||
}
|
||||
|
||||
// Do the same for the children
|
||||
if (srcNode.hasChildNodes()) {
|
||||
for (var j = 0; j < srcNode.childNodes.length; j++) {
|
||||
duplicateStyle(srcNode.childNodes[j], dstNode.childNodes[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// general helpers
|
||||
function log(msg) {
|
||||
console.log(msg);
|
||||
}
|
||||
|
||||
function average(arr) {
|
||||
if (arr.length === 0) return 0;
|
||||
return arr.reduce((function(s, v) {
|
||||
return v + s;
|
||||
}), 0) / arr.length;
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
main();
|
||||
|
||||
};
|
||||
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
module.exports = _exposeIosHtml5DragDropShim;
|
||||
} else if (typeof window !== 'undefined') {
|
||||
_exposeIosHtml5DragDropShim(window.iosDragDropShim);
|
||||
}
|
||||
})(document);
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"tiddlers": [
|
||||
{
|
||||
"file": "ios-drag-drop.js",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": "$:/plugins/tiddlywiki/mobiledragdrop/ios-drag-drop.js"
|
||||
}
|
||||
},
|
||||
{
|
||||
"file": "LICENSE",
|
||||
"fields": {
|
||||
"type": "text/plain",
|
||||
"title": "$:/plugins/tiddlywiki/mobiledragdrop/license"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"title": "$:/plugins/tiddlywiki/mobiledragdrop",
|
||||
"name": "Mobile Drag Drop",
|
||||
"description": "Mobile drag and drop shim",
|
||||
"author": "Tim Ruffles",
|
||||
"list": "readme license",
|
||||
"stability": "STABILITY_0_DEPRECATED"
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/mobiledragdrop/rawmarkup
|
||||
tags: $:/tags/RawMarkupWikified
|
||||
|
||||
`<script>
|
||||
var iosDragDropShim = { enableEnterLeave: true, holdToDrag: 300 };`
|
||||
{{$:/plugins/tiddlywiki/mobiledragdrop/ios-drag-drop.js}}
|
||||
`</script>`
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/mobiledragdrop/readme
|
||||
|
||||
This plugin provides a "shim" that enables HTML 5 compatible drag and drop operations on mobile browsers, including iOS and Android. The shim was created by Tim Ruffles and is published at https://github.com/timruffles/ios-html5-drag-drop-shim.
|
||||
|
||||
After installing the plugin it is necessary to save the HTML file a second time before it will be fully enabled.
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
/*\
|
||||
title: $:/plugins/tiddlywiki/mobiledragdrop/startup.js
|
||||
type: application/javascript
|
||||
module-type: startup
|
||||
|
||||
Startup initialisation
|
||||
|
||||
\*/
|
||||
|
||||
"use strict";
|
||||
|
||||
// Export name and synchronous status
|
||||
exports.name = "mobiledragdrop";
|
||||
exports.platforms = ["browser"];
|
||||
exports.after = ["startup"];
|
||||
exports.synchronous = true;
|
||||
|
||||
exports.startup = function() {
|
||||
window.addEventListener("touchmove", function() {});
|
||||
};
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*\
|
||||
title: $:/core/modules/savers/nodewebkit.js
|
||||
type: application/javascript
|
||||
module-type: saver
|
||||
|
||||
Handles saving changes in the NW.js environment. Not required by TiddlyDesktop, which re-uses the TiddlyFox saver, but useful if you're embedding a single TiddlyWiki document into a NW.js app.
|
||||
|
||||
\*/
|
||||
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false, netscape: false, Components: false */
|
||||
"use strict";
|
||||
|
||||
var NodeWebKitSaver = function(wiki) {
|
||||
};
|
||||
|
||||
NodeWebKitSaver.prototype.save = function(text,method,callback) {
|
||||
// Bail out unless this is a save (rather than a download)
|
||||
if(method !== "save") {
|
||||
return false;
|
||||
}
|
||||
// Get the pathname of this document
|
||||
var pathname = document.location.pathname;
|
||||
// Test for a Windows path of the form /x:/blah/blah
|
||||
if(/^\/[A-Z]\:\//i.test(pathname)) {
|
||||
// Remove the leading slash
|
||||
pathname = pathname.substr(1);
|
||||
// Convert slashes to backslashes
|
||||
pathname = pathname.replace(/\//g,"\\");
|
||||
}
|
||||
// Try to save
|
||||
var fs = require("fs");
|
||||
fs.writeFile(pathname,text,callback);
|
||||
return true;
|
||||
};
|
||||
|
||||
/*
|
||||
Information about this saver
|
||||
*/
|
||||
NodeWebKitSaver.prototype.info = {
|
||||
name: "nodewebkit",
|
||||
priority: 1700
|
||||
};
|
||||
|
||||
/*
|
||||
Static method that returns true if this saver is capable of working
|
||||
*/
|
||||
exports.canSave = function(wiki) {
|
||||
// Check if we're running under node-webkit
|
||||
return (typeof process == "object");
|
||||
};
|
||||
|
||||
/*
|
||||
Create an instance of this saver
|
||||
*/
|
||||
exports.create = function(wiki) {
|
||||
return new NodeWebKitSaver(wiki);
|
||||
};
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"title": "$:/plugins/tiddlywiki/nodewebkitsaver",
|
||||
"name": "nw.js Saver",
|
||||
"description": "Saver for nw.js",
|
||||
"list": "readme",
|
||||
"stability": "STABILITY_0_DEPRECATED"
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/nodewebkitsaver/readme
|
||||
|
||||
This plugin provides a ''saver'' module for saving changes when using TiddlyWiki directly under NW.js (previously known as node-webkit).
|
||||
|
||||
[[Source code|https://github.com/TiddlyWiki/TiddlyWiki5/blob/master/plugins/tiddlywiki/nodewebkitsaver]]
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"title": "$:/plugins/tiddlywiki/tahoelafs",
|
||||
"name": "TahoeLAFS",
|
||||
"description": "Tahoe-LAFS saver",
|
||||
"list": "readme",
|
||||
"stability": "STABILITY_0_DEPRECATED"
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
title: $:/plugins/tiddlywiki/tahoelafs/readme
|
||||
|
||||
This plugin provides a ''saver'' module for saving changes under the [[Tahoe Least Authority File System|https://tahoe-lafs.org/]].
|
||||
|
||||
At this point it is largely for experimentation by @zooko.
|
||||
|
||||
[[Source code|https://github.com/TiddlyWiki/TiddlyWiki5/blob/master/plugins/tiddlywiki/tahoelafs]]
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/*\
|
||||
title: $:/plugins/tiddlywiki/tahoelafs/saver.js
|
||||
type: application/javascript
|
||||
module-type: saver
|
||||
|
||||
A bare bones saver for Tahoe-LAFS. It just PUTs the new HTML file back to the server at the same URL.
|
||||
|
||||
\*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Select the appropriate saver module and set it up
|
||||
*/
|
||||
var TahoeSaver = function(wiki) {
|
||||
this.wiki = wiki;
|
||||
};
|
||||
|
||||
TahoeSaver.prototype.save = function(text) {
|
||||
// Do the HTTP post
|
||||
var http = new XMLHttpRequest();
|
||||
http.open("PUT",document.location.toString(),true);
|
||||
http.onreadystatechange = function() {
|
||||
if(http.readyState == 4 && http.status == 200) {
|
||||
window.alert("Saved to Tahoe-LAFS: " + http.responseText);
|
||||
}
|
||||
};
|
||||
http.send(text);
|
||||
return true;
|
||||
};
|
||||
|
||||
/*
|
||||
Information about this saver
|
||||
*/
|
||||
TahoeSaver.prototype.info = {
|
||||
name: "tahoelafs",
|
||||
priority: 1000
|
||||
};
|
||||
|
||||
/*
|
||||
Static method that returns true if this saver is capable of working
|
||||
*/
|
||||
exports.canSave = function(wiki) {
|
||||
return true;
|
||||
};
|
||||
|
||||
/*
|
||||
Create an instance of this saver
|
||||
*/
|
||||
exports.create = function(wiki) {
|
||||
return new TahoeSaver(wiki);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue