wiki-plugin-rcntimeline 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/client/rcntimeline.js +25 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A small RCN timeline on a Federated Wiki page: intervals as bars with their fuzzy edges, the links between them, and a date axis. Hover a bar for its dates, source, confidence and note; click it to open its page in the lineup.
|
|
4
4
|
|
|
5
|
-
The full RCN Timeline (`tools/rcn-timeline.html` in the rcn repository) solves and edits. This plugin draws what the item holds — dates as stored, no solving — and its **Open in RCN Timeline ↗** button opens the item's timeline in the full tool, in its own tab. On a localhost wiki that is the working copy on port 8765; elsewhere the site's `/assets/rcn-timeline/rcn-timeline.html
|
|
5
|
+
The full RCN Timeline (`tools/rcn-timeline.html` in the rcn repository) solves and edits. This plugin draws what the item holds — dates as stored, no solving — and its **Open in RCN Timeline ↗** button opens the item's timeline in the full tool, in its own tab. On a localhost wiki that is the working copy on port 8765; elsewhere the site's own `/assets/rcn-timeline/rcn-timeline.html` if it has one, otherwise the shared copy at `https://marc.relocalizecreativity.net/assets/Drag/rcn-timeline.html`, beside the Graph Tool, so one upload serves every site; an item's `tool` field overrides all of them. A second Open reuses the same tab. Edits made there do not come back to the page yet.
|
|
6
6
|
|
|
7
7
|
Install on a wiki server:
|
|
8
8
|
|
package/client/rcntimeline.js
CHANGED
|
@@ -24,14 +24,23 @@
|
|
|
24
24
|
const LINK_COLOR = '#7c3aed'
|
|
25
25
|
const NS = 'http://www.w3.org/2000/svg'
|
|
26
26
|
|
|
27
|
-
// The full RCN Timeline. A local wiki opens the working copy served on :8765
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
// The full RCN Timeline. A local wiki opens the working copy served on :8765.
|
|
28
|
+
// Anywhere else: the site's own copy in its assets if it has one, otherwise
|
|
29
|
+
// the shared copy beside the Graph Tool on marc.relocalizecreativity.net, so
|
|
30
|
+
// one upload serves every site. An item may name its own with a `tool` field.
|
|
31
|
+
// The tool opens any timeline passed as #tl=<base64 JSON>, so opening needs
|
|
32
|
+
// nothing from the tool but that.
|
|
33
|
+
const HERE = typeof window !== 'undefined' ? window.location : { hostname: '', origin: '' }
|
|
34
|
+
const LOCAL = /(^|\.)localhost$/.test(HERE.hostname)
|
|
35
|
+
const LOCAL_URL = 'http://localhost:8765/tools/rcn-timeline.html'
|
|
36
|
+
const SITE_URL = HERE.origin + '/assets/rcn-timeline/rcn-timeline.html'
|
|
37
|
+
const SHARED_URL = 'https://marc.relocalizecreativity.net/assets/Drag/rcn-timeline.html'
|
|
38
|
+
function toolUrl (item) {
|
|
39
|
+
if (item.tool) return Promise.resolve(item.tool)
|
|
40
|
+
if (LOCAL) return Promise.resolve(LOCAL_URL)
|
|
41
|
+
return fetch(SITE_URL, { method: 'HEAD', cache: 'no-store' })
|
|
42
|
+
.then(r => (r.ok ? SITE_URL : SHARED_URL), () => SHARED_URL)
|
|
43
|
+
}
|
|
35
44
|
const b64 = str => btoa(unescape(encodeURIComponent(str)))
|
|
36
45
|
|
|
37
46
|
const esc = s => String(s == null ? '' : s)
|
|
@@ -296,10 +305,14 @@
|
|
|
296
305
|
links: raw.links
|
|
297
306
|
}
|
|
298
307
|
const doc = Object.assign({ name: caption(item) || 'Timeline' }, tl)
|
|
299
|
-
const
|
|
300
|
-
|
|
308
|
+
const hash = '#tl=' + b64(JSON.stringify(doc))
|
|
309
|
+
// Open the window now, while the click still counts, and point it at the
|
|
310
|
+
// tool once we know which copy to use; otherwise popup blockers stop it.
|
|
311
|
+
const win = window.open('', 'rcntimeline')
|
|
301
312
|
pending = { item, $item, win }
|
|
302
|
-
|
|
313
|
+
toolUrl(item).then(url => {
|
|
314
|
+
if (win) { win.location.href = url + hash; win.focus() } else window.open(url + hash, 'rcntimeline')
|
|
315
|
+
})
|
|
303
316
|
}
|
|
304
317
|
|
|
305
318
|
// The text an item carries beside its timeline: caption, then the intervals
|
|
@@ -391,7 +404,7 @@
|
|
|
391
404
|
}
|
|
392
405
|
}
|
|
393
406
|
if (typeof module !== 'undefined') {
|
|
394
|
-
module.exports = { model, rawOf, merge, normalize, lineupOn, toYear, fmt, ticks, relWords, caption }
|
|
407
|
+
module.exports = { model, rawOf, merge, normalize, lineupOn, toYear, fmt, ticks, relWords, caption, toolUrl }
|
|
395
408
|
}
|
|
396
409
|
|
|
397
410
|
})()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-plugin-rcntimeline",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Federated Wiki plugin: a small RCN timeline on a page — intervals with fuzzy edges, the links between them, a date axis; each bar opens its page",
|
|
5
5
|
"keywords": ["wiki", "federated wiki", "plugin", "rcn", "timeline"],
|
|
6
6
|
"author": "RCN Network <rcn@relocalizecreativity.net>",
|