wiki-plugin-rcntimeline 0.2.1 → 0.3.0
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 +3 -1
- package/client/rcntimeline.js +232 -21
- package/package.json +1 -1
- package/pages/about-rcntimeline-plugin +24 -8
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
|
|
|
@@ -47,3 +47,5 @@ Version 0.2: draws intervals, fuzz, links and an axis; bars open their pages; Op
|
|
|
47
47
|
Part of the [RCN toolset](https://github.com/marpie1/rcn), MIT.
|
|
48
48
|
|
|
49
49
|
Marc Pierson and Claude Opus 5.5 · September 2026
|
|
50
|
+
|
|
51
|
+
**Walks** (0.3.0). A timeline made in the full tool can carry `walks`: readings that play one step at a time. **▶ Walk** under the timeline redraws each step's years, fades the other bars, and reads the words aloud with a caption; Space, ← →, Esc. Open in RCN Timeline and Save to wiki carry the walks both ways.
|
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)
|
|
@@ -172,11 +181,14 @@
|
|
|
172
181
|
return s.slice(0, lo).trimEnd() + '…'
|
|
173
182
|
}
|
|
174
183
|
|
|
175
|
-
|
|
184
|
+
// range: {lo, hi} in years, to draw just that stretch (a walk step); else the whole timeline.
|
|
185
|
+
function draw ($item, item, m, range) {
|
|
176
186
|
const W = Math.max(280, ($item.width() || 420) - 18)
|
|
177
187
|
const H = AXIS_H + m.lanes * ROW_H + PAD
|
|
178
188
|
let lo = Math.min(...m.intervals.map(v => v.s - v.sf)), hi = Math.max(...m.intervals.map(v => v.e + v.ef))
|
|
179
189
|
const pad = Math.max((hi - lo) * 0.03, 0.25); lo -= pad; hi += pad
|
|
190
|
+
if (range) { lo = range.lo; hi = range.hi }
|
|
191
|
+
const offStage = v => range && (v.e + v.ef < lo || v.s - v.sf > hi)
|
|
180
192
|
const x = t => PAD + (t - lo) / (hi - lo) * (W - 2 * PAD)
|
|
181
193
|
const yMid = lane => AXIS_H + lane * ROW_H + ROW_H / 2
|
|
182
194
|
const byId = {}; m.intervals.forEach(v => { byId[v.id] = v })
|
|
@@ -200,7 +212,7 @@
|
|
|
200
212
|
(v.sf || v.ef) ? 'uncertain by ' + [v.sf ? v.sf + ' yr before' : '', v.ef ? v.ef + ' yr after' : ''].filter(Boolean).join(', ') : '',
|
|
201
213
|
v.who ? 'Source: ' + v.who : '', v.conf != null ? 'Confidence ' + Math.round(v.conf * 100) + '%' : '',
|
|
202
214
|
v.note || '', v.page ? '— click to open ' + v.page : ''].filter(Boolean).join('\n')
|
|
203
|
-
parts.push(`<g class="rcnt-bar" data-page="${esc(v.page || '')}" style="cursor:${v.page ? 'pointer' : 'default'}"><title>${esc(tip)}</title>`
|
|
215
|
+
parts.push(`<g class="rcnt-bar" data-iv="${esc(v.id)}" data-page="${esc(v.page || '')}" style="cursor:${v.page ? 'pointer' : 'default'}"><title>${esc(tip)}</title>`
|
|
204
216
|
+ (v.sf ? `<rect x="${x(v.s - v.sf)}" y="${y}" width="${xs - x(v.s - v.sf)}" height="${BAR_H}" fill="url(#${gid}L)"/>` : '')
|
|
205
217
|
+ (v.ef ? `<rect x="${xe}" y="${y}" width="${x(v.e + v.ef) - xe}" height="${BAR_H}" fill="url(#${gid}R)"/>` : '')
|
|
206
218
|
+ `<rect x="${xs}" y="${y}" width="${xe - xs}" height="${BAR_H}" rx="3" fill="${esc(v.color)}" fill-opacity=".85"/></g>`)
|
|
@@ -214,7 +226,7 @@
|
|
|
214
226
|
const x1 = rel === 'during' ? x((a.s + a.e) / 2) : x(a.e), y1 = yMid(a.lane)
|
|
215
227
|
const x2 = rel === 'during' ? x((a.s + a.e) / 2) : x(b.s), y2 = yMid(b.lane)
|
|
216
228
|
const dy = Math.max(12, Math.abs(y2 - y1) / 2)
|
|
217
|
-
parts.push(`<path d="M${x1},${y1} C${x1},${y1 + (y2 > y1 ? dy : -dy)} ${x2},${y2 - (y2 > y1 ? dy : -dy)} ${x2},${y2}" fill="none" stroke="${LINK_COLOR}" stroke-width="1.2" stroke-opacity=".7"${Array.isArray(l.rel) ? ' stroke-dasharray="3 3"' : ''}><title>${esc(a.label + ' ' + relWords(l.rel) + ' ' + b.label + (l.who ? '\nSource: ' + l.who : '') + (l.note ? '\n' + l.note : ''))}</title></path>`)
|
|
229
|
+
parts.push(`<path data-from="${esc(l.from)}" data-to="${esc(l.to)}" d="M${x1},${y1} C${x1},${y1 + (y2 > y1 ? dy : -dy)} ${x2},${y2 - (y2 > y1 ? dy : -dy)} ${x2},${y2}" fill="none" stroke="${LINK_COLOR}" stroke-width="1.2" stroke-opacity=".7"${Array.isArray(l.rel) ? ' stroke-dasharray="3 3"' : ''}><title>${esc(a.label + ' ' + relWords(l.rel) + ' ' + b.label + (l.who ? '\nSource: ' + l.who : '') + (l.note ? '\n' + l.note : ''))}</title></path>`)
|
|
218
230
|
})
|
|
219
231
|
|
|
220
232
|
// labels last, on a white halo. At the bar's start when it fits there,
|
|
@@ -227,6 +239,7 @@
|
|
|
227
239
|
// a later one begins — a firm's label gives way to the co-op it became.
|
|
228
240
|
const limit = {}
|
|
229
241
|
m.intervals.slice().sort((a, b) => a.lane - b.lane || b.s - a.s).forEach(v => {
|
|
242
|
+
if (offStage(v)) return // zoomed in on a walk step: no label for a bar out of view
|
|
230
243
|
let lx = Math.max(x(v.s) + 4, 4)
|
|
231
244
|
const next = m.intervals.filter(o => o !== v && o.lane === v.lane && o.s > v.s).reduce((a, o) => Math.min(a, o.s), Infinity)
|
|
232
245
|
const stop = Math.min(next < Infinity ? x(next) : W, limit[v.lane] != null ? limit[v.lane] : W)
|
|
@@ -241,12 +254,195 @@
|
|
|
241
254
|
}
|
|
242
255
|
const t = fitText(v.label, room)
|
|
243
256
|
if (t) limit[v.lane] = Math.min(limit[v.lane] != null ? limit[v.lane] : W, lx - 6)
|
|
244
|
-
if (t) parts.push(`<text x="${lx}" y="${yMid(v.lane) + 4}" font-size="11" font-weight="600" fill="#1e293b" paint-order="stroke" stroke="#fff" stroke-width="3" stroke-linejoin="round" pointer-events="none">${esc(t)}</text>`)
|
|
257
|
+
if (t) parts.push(`<text data-iv="${esc(v.id)}" x="${lx}" y="${yMid(v.lane) + 4}" font-size="11" font-weight="600" fill="#1e293b" paint-order="stroke" stroke="#fff" stroke-width="3" stroke-linejoin="round" pointer-events="none">${esc(t)}</text>`)
|
|
245
258
|
})
|
|
246
259
|
|
|
247
260
|
return `<svg xmlns="${NS}" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}" style="display:block;font-family:system-ui,-apple-system,sans-serif"><defs>${defs.join('')}</defs>${parts.join('')}</svg>`
|
|
248
261
|
}
|
|
249
262
|
|
|
263
|
+
// ── Walk playback ──────────────────────────────────────────────────────
|
|
264
|
+
// A walk, written in the RCN Timeline tool, is a list of steps: words to say
|
|
265
|
+
// and the bars each step is about (item.timeline.walks = [{name, steps:[{say,
|
|
266
|
+
// intervals:[ids], all?, ask?}]}]). Playing it here redraws the timeline over
|
|
267
|
+
// just the years a step is about, fades the other bars (ones already visited
|
|
268
|
+
// stay half lit), and speaks the words with the browser's own voice, shown as
|
|
269
|
+
// a caption too. Same controls, keys and voice settings as the drawing plugin.
|
|
270
|
+
const WALK_GHOST = 0.13, WALK_SEEN = 0.42
|
|
271
|
+
|
|
272
|
+
function walkList (item) {
|
|
273
|
+
const ws = item.timeline && item.timeline.walks
|
|
274
|
+
return Array.isArray(ws) ? ws.filter(w => w && Array.isArray(w.steps) && w.steps.length) : []
|
|
275
|
+
}
|
|
276
|
+
const stepLit = st => (!st || st.all) ? null : new Set((st.intervals || []).map(String))
|
|
277
|
+
|
|
278
|
+
// The years a step is about, with room either side; null = the whole timeline.
|
|
279
|
+
function stepRange (m, st) {
|
|
280
|
+
const lit = stepLit(st)
|
|
281
|
+
const ivs = lit ? m.intervals.filter(v => lit.has(String(v.id))) : []
|
|
282
|
+
if (!ivs.length) return null
|
|
283
|
+
let lo = Math.min(...ivs.map(v => v.s - v.sf)), hi = Math.max(...ivs.map(v => v.e + v.ef))
|
|
284
|
+
const span = Math.max(hi - lo, 3), mid = (lo + hi) / 2
|
|
285
|
+
return { lo: mid - span * 0.62, hi: mid + span * 0.62 }
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function walkFade ($item, m, walk, i) {
|
|
289
|
+
const lit = stepLit(walk.steps[i])
|
|
290
|
+
if (!lit) return
|
|
291
|
+
const seen = new Set()
|
|
292
|
+
walk.steps.slice(0, i).forEach(st => { const L = stepLit(st); if (L) L.forEach(id => seen.add(id)) })
|
|
293
|
+
const op = id => lit.has(id) ? 1 : seen.has(id) ? WALK_SEEN : WALK_GHOST
|
|
294
|
+
$item.find('.rcnt-canvas [data-iv]').each(function () { this.style.opacity = op(this.getAttribute('data-iv')) })
|
|
295
|
+
$item.find('.rcnt-canvas [data-from]').each(function () {
|
|
296
|
+
this.style.opacity = Math.min(op(this.getAttribute('data-from')), op(this.getAttribute('data-to')))
|
|
297
|
+
})
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Voice and speed are the listener's: kept in this browser, the same keys the Graph Tool uses.
|
|
301
|
+
function walkPrefs () {
|
|
302
|
+
let p = {}
|
|
303
|
+
try { p = JSON.parse(localStorage.getItem('rcnWalkPrefs') || '{}') } catch (e) {}
|
|
304
|
+
let on = true
|
|
305
|
+
try { on = localStorage.getItem('rcnWalkVoice') !== 'off' } catch (e) {}
|
|
306
|
+
return { voice: p.voice || '', rate: (+p.rate >= 0.6 && +p.rate <= 1.4) ? +p.rate : 0.95, on }
|
|
307
|
+
}
|
|
308
|
+
function walkVoice (name) {
|
|
309
|
+
const vs = window.speechSynthesis ? speechSynthesis.getVoices().filter(v => /^en/i.test(v.lang)) : []
|
|
310
|
+
return vs.find(v => v.name === name) || vs.find(v => /Enhanced|Premium|Natural|Neural/i.test(v.name)) ||
|
|
311
|
+
['Samantha', 'Daniel', 'Karen', 'Moira', 'Google UK English Female', 'Google US English', 'Microsoft Aria']
|
|
312
|
+
.map(p => vs.find(v => v.name.indexOf(p) === 0)).find(Boolean) || vs[0] || null
|
|
313
|
+
}
|
|
314
|
+
const stopVoice = () => { try { if (window.speechSynthesis) speechSynthesis.cancel() } catch (e) {} }
|
|
315
|
+
// Say the words; done() runs once when they have been said. One utterance per
|
|
316
|
+
// sentence, because Chrome stops a long one after about fifteen seconds.
|
|
317
|
+
function walkSay (text, isCurrent, done) {
|
|
318
|
+
const prefs = walkPrefs(), words = (text || '').split(/\s+/).length
|
|
319
|
+
let fired = false
|
|
320
|
+
const after = () => { if (fired || !isCurrent()) return; fired = true; done() }
|
|
321
|
+
setTimeout(after, words * (prefs.on ? 650 : 420) + (prefs.on ? 6000 : 2500)) // if the voice never says it finished
|
|
322
|
+
stopVoice()
|
|
323
|
+
if (!prefs.on || !window.speechSynthesis || !text) { setTimeout(after, text ? words * 400 + 2000 : 1200); return }
|
|
324
|
+
const v = walkVoice(prefs.voice)
|
|
325
|
+
const parts = text.match(/[^.!?]+[.!?]+["'”’)]*\s*|[^.!?]+$/g) || [text]
|
|
326
|
+
parts.forEach((s, k) => {
|
|
327
|
+
const u = new SpeechSynthesisUtterance(s.trim())
|
|
328
|
+
if (v) { u.voice = v; u.lang = v.lang }
|
|
329
|
+
u.rate = prefs.rate
|
|
330
|
+
if (k === parts.length - 1) u.onend = after
|
|
331
|
+
speechSynthesis.speak(u)
|
|
332
|
+
})
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function walkBar (item) {
|
|
336
|
+
const ws = walkList(item)
|
|
337
|
+
if (!ws.length) return ''
|
|
338
|
+
const b = 'cursor:pointer;font-size:12px;padding:2px 8px;'
|
|
339
|
+
const pick = ws.length > 1
|
|
340
|
+
? `<select class="walk-pick" style="max-width:220px;font-size:12px" title="Which walk">${ws.map((w, i) => `<option value="${i}">${esc(w.name || 'Walk ' + (i + 1))} (${w.steps.length} steps)</option>`).join('')}</select>`
|
|
341
|
+
: `<span style="font-size:12px;color:#475569">${esc(ws[0].name || 'Walk')}</span>`
|
|
342
|
+
return `<div class="walk-bar" tabindex="0" title="Hear and see this timeline explained one part at a time. Space plays or pauses, ← → step, Esc stops." style="padding:8px 0 0;outline:none;">
|
|
343
|
+
<div style="display:flex;gap:6px;align-items:center;justify-content:center;flex-wrap:wrap">
|
|
344
|
+
<button class="walk-start" style="${b}font-weight:600">▶ Walk</button>
|
|
345
|
+
${pick}
|
|
346
|
+
<button class="walk-prev" style="${b}display:none" title="Back a step (←)">◀</button>
|
|
347
|
+
<button class="walk-play" style="${b}display:none" title="Play or pause (Space)">❚❚</button>
|
|
348
|
+
<button class="walk-next" style="${b}display:none" title="Next step (→)">▶</button>
|
|
349
|
+
<span class="walk-count" style="display:none;font-size:12px;color:#64748b;min-width:70px;text-align:center"></span>
|
|
350
|
+
<button class="walk-voice" style="${b}display:none" title="Read the words aloud, or show them only"></button>
|
|
351
|
+
<button class="walk-close" style="${b}display:none" title="Stop the walk (Esc)">■ Stop</button>
|
|
352
|
+
</div>
|
|
353
|
+
<div class="walk-say" aria-live="polite" style="display:none;margin:8px 4px 0;padding:10px 12px;background:#fff;border:1px solid #c7d2fe;border-radius:8px;font-size:17px;line-height:1.45;color:#1e1b4b"></div>
|
|
354
|
+
<div class="walk-note" style="font-size:11px;color:#64748b;text-align:center;margin-top:3px"></div>
|
|
355
|
+
</div>`
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Playback for one item. w === null: no walk open. token guards every voice
|
|
359
|
+
// callback, so a step that was skipped or stopped can never move the walk on.
|
|
360
|
+
// One walk speaks at a time on the whole lineup, the drawing plugin's included.
|
|
361
|
+
function bindWalk ($item, item) {
|
|
362
|
+
const el = $item.get(0)
|
|
363
|
+
const wk = el.rcntWalk = el.rcntWalk || { w: null, i: 0, playing: false, token: 0, heard: null }
|
|
364
|
+
const cur = () => wk.w !== null ? walkList(item)[wk.w] : null
|
|
365
|
+
const ui = note => {
|
|
366
|
+
const walk = cur(), open = !!walk
|
|
367
|
+
const $bar = $item.find('.walk-bar')
|
|
368
|
+
$bar.find('.walk-prev, .walk-next, .walk-play, .walk-count, .walk-voice, .walk-close').toggle(open)
|
|
369
|
+
$bar.find('.walk-start, .walk-pick').toggle(!open)
|
|
370
|
+
$bar.find('.walk-say').toggle(open)
|
|
371
|
+
$bar.find('.walk-play').text(wk.playing ? '❚❚' : '▶')
|
|
372
|
+
$bar.find('.walk-voice').text(walkPrefs().on ? '🔈 Voice on' : '🔇 Voice off')
|
|
373
|
+
$bar.find('.walk-count').text(open ? 'Step ' + (wk.i + 1) + ' of ' + walk.steps.length : '')
|
|
374
|
+
$bar.find('.walk-note').text(note || (open && !wk.playing ? 'Space plays · ← → step · Esc stops' : ''))
|
|
375
|
+
}
|
|
376
|
+
const speak = () => {
|
|
377
|
+
const tok = ++wk.token, walk = cur(), st = walk && walk.steps[wk.i]
|
|
378
|
+
if (!st) return
|
|
379
|
+
wk.heard = wk.i
|
|
380
|
+
walkSay(st.say, () => tok === wk.token && window.rcnActiveWalk === wk, () => {
|
|
381
|
+
const last = wk.i >= walk.steps.length - 1
|
|
382
|
+
if (st.ask || last) { wk.playing = false; ui(last && !st.ask ? 'End of the walk. ← to go back, Esc to stop.' : 'Over to you. Press Space or ▶ to go on.'); return }
|
|
383
|
+
setTimeout(() => { if (tok === wk.token && wk.playing) show(wk.i + 1) }, 800)
|
|
384
|
+
})
|
|
385
|
+
}
|
|
386
|
+
const show = i => {
|
|
387
|
+
const walk = cur()
|
|
388
|
+
if (!walk) return
|
|
389
|
+
wk.i = Math.max(0, Math.min(walk.steps.length - 1, i))
|
|
390
|
+
wk.token++; stopVoice()
|
|
391
|
+
if (el.rcntPaint) el.rcntPaint()
|
|
392
|
+
const st = walk.steps[wk.i]
|
|
393
|
+
$item.find('.walk-say').text(st.say || '').css({ color: st.ask ? '#7c2d12' : '#1e1b4b', fontStyle: st.ask ? 'italic' : 'normal' })
|
|
394
|
+
ui()
|
|
395
|
+
if (wk.playing) speak()
|
|
396
|
+
}
|
|
397
|
+
const pause = () => { wk.playing = false; wk.token++; stopVoice(); ui() }
|
|
398
|
+
const toggle = () => {
|
|
399
|
+
if (!cur()) return
|
|
400
|
+
if (wk.playing) { pause(); return }
|
|
401
|
+
const other = window.rcnActiveWalk
|
|
402
|
+
if (other && other !== wk && other.end) other.end()
|
|
403
|
+
window.rcnActiveWalk = wk
|
|
404
|
+
wk.playing = true
|
|
405
|
+
// Space after a step has been heard moves on; otherwise it says the step.
|
|
406
|
+
if (wk.heard === wk.i && wk.i < cur().steps.length - 1) { show(wk.i + 1); return }
|
|
407
|
+
ui(); speak()
|
|
408
|
+
}
|
|
409
|
+
const end = () => {
|
|
410
|
+
wk.playing = false; wk.token++; wk.w = null; wk.heard = null
|
|
411
|
+
if (window.rcnActiveWalk === wk) { stopVoice(); window.rcnActiveWalk = null }
|
|
412
|
+
if (el.rcntPaint) el.rcntPaint()
|
|
413
|
+
ui()
|
|
414
|
+
}
|
|
415
|
+
wk.end = end
|
|
416
|
+
$item.off('.rcntwalk')
|
|
417
|
+
$item.on('click.rcntwalk', '.walk-start', () => {
|
|
418
|
+
wk.w = +($item.find('.walk-pick').val() || 0)
|
|
419
|
+
wk.heard = null
|
|
420
|
+
show(0)
|
|
421
|
+
toggle() // a click is a user gesture, so the browser will speak
|
|
422
|
+
$item.find('.walk-bar').trigger('focus')
|
|
423
|
+
})
|
|
424
|
+
$item.on('click.rcntwalk', '.walk-play', () => toggle())
|
|
425
|
+
$item.on('click.rcntwalk', '.walk-prev', () => show(wk.i - 1))
|
|
426
|
+
$item.on('click.rcntwalk', '.walk-next', () => show(wk.i + 1))
|
|
427
|
+
$item.on('click.rcntwalk', '.walk-close', () => end())
|
|
428
|
+
$item.on('click.rcntwalk', '.walk-voice', () => {
|
|
429
|
+
const on = !walkPrefs().on
|
|
430
|
+
try { localStorage.setItem('rcnWalkVoice', on ? 'on' : 'off') } catch (e) {}
|
|
431
|
+
if (!on) stopVoice()
|
|
432
|
+
if (wk.playing) speak()
|
|
433
|
+
ui()
|
|
434
|
+
})
|
|
435
|
+
$item.on('keydown.rcntwalk', '.walk-bar', e => {
|
|
436
|
+
if (wk.w === null || $(e.target).is('select')) return
|
|
437
|
+
if (e.key === ' ') { e.preventDefault(); e.stopPropagation(); toggle() }
|
|
438
|
+
else if (e.key === 'ArrowRight') { e.preventDefault(); e.stopPropagation(); show(wk.i + 1) }
|
|
439
|
+
else if (e.key === 'ArrowLeft') { e.preventDefault(); e.stopPropagation(); show(wk.i - 1) }
|
|
440
|
+
else if (e.key === 'Escape') { e.preventDefault(); end() }
|
|
441
|
+
})
|
|
442
|
+
// A save redraws the item; a walk left open would point at a stale step.
|
|
443
|
+
if (wk.w !== null) end()
|
|
444
|
+
}
|
|
445
|
+
|
|
250
446
|
function emit ($item, item) {
|
|
251
447
|
$item.empty()
|
|
252
448
|
// Offer this item's timeline (its own, plus anything frozen into it) to any
|
|
@@ -277,10 +473,19 @@
|
|
|
277
473
|
: 'Collected from ' + collect($item).length + ' timeline(s) to the left.'}</p>` : ''
|
|
278
474
|
$item.append(`<div style="background:#f5f5f5;padding:8px;">
|
|
279
475
|
<div class="rcnt-canvas" style="background:#fff;border:1px solid #ddd;overflow-x:auto"></div>
|
|
476
|
+
${walkBar(item)}
|
|
280
477
|
<p class="caption" style="margin:4px 0 0;">${cap}</p>${note}
|
|
281
478
|
<div style="padding:6px 0 0;text-align:center;">${controls}<button class="rcnt-open" style="cursor:pointer;">Open in RCN Timeline ↗</button></div></div>`)
|
|
282
|
-
// Width is known only once the item is in the page.
|
|
283
|
-
|
|
479
|
+
// Width is known only once the item is in the page. A walk step draws just
|
|
480
|
+
// the years it is about and fades what it is not about.
|
|
481
|
+
const el = $item.get(0)
|
|
482
|
+
el.rcntModel = m
|
|
483
|
+
const paint = el.rcntPaint = () => {
|
|
484
|
+
const wk = el.rcntWalk, walk = wk && wk.w !== null ? walkList(item)[wk.w] : null
|
|
485
|
+
const st = walk && walk.steps[wk.i]
|
|
486
|
+
$item.find('.rcnt-canvas').html(draw($item, item, m, st ? stepRange(m, st) : null))
|
|
487
|
+
if (st) walkFade($item, m, walk, wk.i)
|
|
488
|
+
}
|
|
284
489
|
paint()
|
|
285
490
|
setTimeout(paint, 0)
|
|
286
491
|
}
|
|
@@ -295,11 +500,15 @@
|
|
|
295
500
|
intervals: raw.intervals.map(v => Object.assign({}, v, v.start == null ? { start: fmt(toYear(v.s)), end: fmt(toYear(v.e)) } : {})),
|
|
296
501
|
links: raw.links
|
|
297
502
|
}
|
|
298
|
-
const doc = Object.assign({ name: caption(item) || 'Timeline' }, tl)
|
|
299
|
-
const
|
|
300
|
-
|
|
503
|
+
const doc = Object.assign({ name: caption(item) || 'Timeline' }, tl, walkList(item).length ? { walks: item.timeline.walks } : {})
|
|
504
|
+
const hash = '#tl=' + b64(JSON.stringify(doc))
|
|
505
|
+
// Open the window now, while the click still counts, and point it at the
|
|
506
|
+
// tool once we know which copy to use; otherwise popup blockers stop it.
|
|
507
|
+
const win = window.open('', 'rcntimeline')
|
|
301
508
|
pending = { item, $item, win }
|
|
302
|
-
|
|
509
|
+
toolUrl(item).then(url => {
|
|
510
|
+
if (win) { win.location.href = url + hash; win.focus() } else window.open(url + hash, 'rcntimeline')
|
|
511
|
+
})
|
|
303
512
|
}
|
|
304
513
|
|
|
305
514
|
// The text an item carries beside its timeline: caption, then the intervals
|
|
@@ -326,7 +535,7 @@
|
|
|
326
535
|
if (event.data.action !== 'saveTimeline' || !event.data.timeline) return
|
|
327
536
|
const { item, $item } = pending
|
|
328
537
|
const tl = event.data.timeline
|
|
329
|
-
item.timeline = { intervals: tl.intervals || [], links: tl.links || [] }
|
|
538
|
+
item.timeline = Object.assign({ intervals: tl.intervals || [], links: tl.links || [] }, Array.isArray(tl.walks) && tl.walks.length ? { walks: tl.walks } : {})
|
|
330
539
|
delete item.frozen // what was frozen is now in the item's own timeline
|
|
331
540
|
item.text = words(item, item.timeline)
|
|
332
541
|
save($item, item)
|
|
@@ -364,7 +573,9 @@
|
|
|
364
573
|
|
|
365
574
|
function bind ($item, item) {
|
|
366
575
|
aboutMark($item, 'rcntimeline')
|
|
367
|
-
|
|
576
|
+
// Stepping a walk is quick clicking — never let it open the editor.
|
|
577
|
+
$item.dblclick(e => { if (!$(e.target).closest('button, .walk-bar').length) wiki.textEditor($item, item) })
|
|
578
|
+
bindWalk($item, item)
|
|
368
579
|
$item.on('click', '.rcnt-open', e => { e.stopPropagation(); openTool($item, item) })
|
|
369
580
|
$item.on('click', '.rcnt-refresh', e => { e.stopPropagation(); emit($item, item) })
|
|
370
581
|
$item.on('click', '.rcnt-freeze', e => {
|
|
@@ -391,7 +602,7 @@
|
|
|
391
602
|
}
|
|
392
603
|
}
|
|
393
604
|
if (typeof module !== 'undefined') {
|
|
394
|
-
module.exports = { model, rawOf, merge, normalize, lineupOn, toYear, fmt, ticks, relWords, caption }
|
|
605
|
+
module.exports = { model, rawOf, merge, normalize, lineupOn, toYear, fmt, ticks, relWords, caption, toolUrl, walkList, stepRange }
|
|
395
606
|
}
|
|
396
607
|
|
|
397
608
|
})()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-plugin-rcntimeline",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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>",
|
|
@@ -18,18 +18,23 @@
|
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"type": "paragraph",
|
|
21
|
-
"text": "Editing the item. Double-click to open the text editor. The first line of the text is the caption; the rest lists the intervals and links in words, so wiki search finds them. The intervals themselves live in the item
|
|
21
|
+
"text": "Editing the item. Double-click to open the text editor. The first line of the text is the caption; the rest lists the intervals and links in words, so wiki search finds them. The intervals themselves live in the item’s timeline field, in the tool’s own export format. A new item from the Factory has no timeline field yet: type lines such as Pilot = Jan 2020 .. Jun 2021 and each becomes a bar.",
|
|
22
22
|
"id": "84d2ec6a4ab43717"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
"type": "paragraph",
|
|
26
|
-
"
|
|
26
|
+
"id": "1caf7fe1c5cc610a",
|
|
27
|
+
"text": "Walks. A timeline can carry walks, made in the full RCN Timeline tool: readings that explain it one stretch at a time. Press ▶ Walk under the timeline. Each step redraws the years it is about, fades the other bars, and says its words aloud with a caption. Space plays or pauses, the arrow keys step, Esc stops, and a walk stops at its questions so a group can talk. Voice on or off and the choice of voice are kept in the browser, shared with the drawing plugin's walks. Walks added October 2026 with Claude Opus 5.5."
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"type": "paragraph",
|
|
31
|
+
"text": "Below: the Northwest Agriculture Business Center, from the Co-ops of Whatcom County pages. Its help to the meat co-op sits inside the co-op’s organising years, and the food hub it ran became a farmer-owned co-op.",
|
|
27
32
|
"id": "8bd7dff26d7d8c1e"
|
|
28
33
|
},
|
|
29
34
|
{
|
|
30
35
|
"type": "rcntimeline",
|
|
31
36
|
"id": "11dd477f3b62535a",
|
|
32
|
-
"text": "Northwest Agriculture Business Center over time. Click a shared bar for the other co-op
|
|
37
|
+
"text": "Northwest Agriculture Business Center over time. Click a shared bar for the other co-op’s page.\nNABC co-op development help (USDA grant): Jul 1 2015 – Jul 1 2016\nPuget Sound Food Hub, run by NABC: Jul 1 2010 – Jul 1 2016\nNW Agriculture Business Center: Jul 1 2006 – Sep 28 2026\nNABC co-op development help (USDA grant) during NW Agriculture Business Center\nPuget Sound Food Hub, run by NABC during NW Agriculture Business Center",
|
|
33
38
|
"timeline": {
|
|
34
39
|
"intervals": [
|
|
35
40
|
{
|
|
@@ -112,7 +117,7 @@
|
|
|
112
117
|
{
|
|
113
118
|
"type": "markdown",
|
|
114
119
|
"id": "a5673a5be44d674a",
|
|
115
|
-
"text": "*Marc Pierson and Claude Opus 5.5
|
|
120
|
+
"text": "*Marc Pierson and Claude Opus 5.5 · September 2026*",
|
|
116
121
|
"attribution": true
|
|
117
122
|
}
|
|
118
123
|
],
|
|
@@ -152,7 +157,7 @@
|
|
|
152
157
|
"id": "84d2ec6a4ab43717",
|
|
153
158
|
"item": {
|
|
154
159
|
"type": "paragraph",
|
|
155
|
-
"text": "Editing the item. Double-click to open the text editor. The first line of the text is the caption; the rest lists the intervals and links in words, so wiki search finds them. The intervals themselves live in the item
|
|
160
|
+
"text": "Editing the item. Double-click to open the text editor. The first line of the text is the caption; the rest lists the intervals and links in words, so wiki search finds them. The intervals themselves live in the item’s timeline field, in the tool’s own export format. A new item from the Factory has no timeline field yet: type lines such as Pilot = Jan 2020 .. Jun 2021 and each becomes a bar.",
|
|
156
161
|
"id": "84d2ec6a4ab43717"
|
|
157
162
|
},
|
|
158
163
|
"date": 1790644321806,
|
|
@@ -163,7 +168,7 @@
|
|
|
163
168
|
"id": "8bd7dff26d7d8c1e",
|
|
164
169
|
"item": {
|
|
165
170
|
"type": "paragraph",
|
|
166
|
-
"text": "Below: the Northwest Agriculture Business Center, from the Co-ops of Whatcom County pages. Its help to the meat co-op sits inside the co-op
|
|
171
|
+
"text": "Below: the Northwest Agriculture Business Center, from the Co-ops of Whatcom County pages. Its help to the meat co-op sits inside the co-op’s organising years, and the food hub it ran became a farmer-owned co-op.",
|
|
167
172
|
"id": "8bd7dff26d7d8c1e"
|
|
168
173
|
},
|
|
169
174
|
"date": 1790644321807,
|
|
@@ -175,7 +180,7 @@
|
|
|
175
180
|
"item": {
|
|
176
181
|
"type": "rcntimeline",
|
|
177
182
|
"id": "11dd477f3b62535a",
|
|
178
|
-
"text": "Northwest Agriculture Business Center over time. Click a shared bar for the other co-op
|
|
183
|
+
"text": "Northwest Agriculture Business Center over time. Click a shared bar for the other co-op’s page.\nNABC co-op development help (USDA grant): Jul 1 2015 – Jul 1 2016\nPuget Sound Food Hub, run by NABC: Jul 1 2010 – Jul 1 2016\nNW Agriculture Business Center: Jul 1 2006 – Sep 28 2026\nNABC co-op development help (USDA grant) during NW Agriculture Business Center\nPuget Sound Food Hub, run by NABC during NW Agriculture Business Center",
|
|
179
184
|
"timeline": {
|
|
180
185
|
"intervals": [
|
|
181
186
|
{
|
|
@@ -270,7 +275,7 @@
|
|
|
270
275
|
"item": {
|
|
271
276
|
"type": "markdown",
|
|
272
277
|
"id": "a5673a5be44d674a",
|
|
273
|
-
"text": "*Marc Pierson and Claude Opus 5.5
|
|
278
|
+
"text": "*Marc Pierson and Claude Opus 5.5 · September 2026*",
|
|
274
279
|
"attribution": true
|
|
275
280
|
},
|
|
276
281
|
"date": 1790644321962,
|
|
@@ -286,6 +291,17 @@
|
|
|
286
291
|
},
|
|
287
292
|
"after": "f0a9a8322aafc9ab",
|
|
288
293
|
"date": 1791164815533
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"type": "add",
|
|
297
|
+
"id": "1caf7fe1c5cc610a",
|
|
298
|
+
"item": {
|
|
299
|
+
"type": "paragraph",
|
|
300
|
+
"id": "1caf7fe1c5cc610a",
|
|
301
|
+
"text": "Walks. A timeline can carry walks, made in the full RCN Timeline tool: readings that explain it one stretch at a time. Press ▶ Walk under the timeline. Each step redraws the years it is about, fades the other bars, and says its words aloud with a caption. Space plays or pauses, the arrow keys step, Esc stops, and a walk stops at its questions so a group can talk. Voice on or off and the choice of voice are kept in the browser, shared with the drawing plugin's walks. Walks added October 2026 with Claude Opus 5.5."
|
|
302
|
+
},
|
|
303
|
+
"after": "84d2ec6a4ab43717",
|
|
304
|
+
"date": 1792629734413
|
|
289
305
|
}
|
|
290
306
|
]
|
|
291
307
|
}
|