wiki-plugin-rcnmap 0.0.0-stage → 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 +61 -2
- package/client/rcnmap.js +545 -0
- package/factory.json +1 -0
- package/index.js +2 -0
- package/package.json +10 -4
- package/pages/about-rcnmap-plugin +355 -0
package/README.md
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
-
#
|
|
1
|
+
# wiki-plugin-rcnmap
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A small RCN map on a Federated Wiki page that draws points **and the ties between them**. Each point is coloured by its kind, each tie by its kind of link, and clicking a point opens that point's page in the lineup beside this one.
|
|
4
|
+
|
|
5
|
+
FedWiki's own Map plugin draws points only. The full RCN Map is a full-screen tool that lives in a site's assets. This plugin sits between them: the item carries its own subject — a few KB in the RCN Map issue-file shape — and draws it in the page column.
|
|
6
|
+
|
|
7
|
+
Install on a wiki server:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install -g wiki-plugin-rcnmap
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
and restart the wiki. The Factory then offers **RCN Map**.
|
|
14
|
+
|
|
15
|
+
## The item
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"type": "rcnmap",
|
|
20
|
+
"text": "Caption on the first line\nthen the points and ties in words",
|
|
21
|
+
"map": {
|
|
22
|
+
"types": { "worker": {"label": "Worker co-op", "color": "#c0392b"} },
|
|
23
|
+
"linkKinds": { "trade": {"label": "Trade — supplies goods", "color": "#1a7a4a", "weight": 3.5, "dash": "8 4"} },
|
|
24
|
+
"parcels": [ {"id": "tyl", "label": "Cooperativa Tierra y Libertad", "wikiTitle": "Cooperativa Tierra y Libertad", "type": "worker", "latLng": [48.8769, -122.4344]} ],
|
|
25
|
+
"links": [ {"from": "tyl", "to": "cfc", "kind": "trade", "label": "Supplies produce"} ],
|
|
26
|
+
"view": {"lat": 48.8, "lng": -122.4, "zoom": 10}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- `map` is the RCN Map issue-file format (`types`, `linkKinds`, `parcels`, `links`), so the full RCN Map can draw the same data. `view` is optional; without it the map fits its points.
|
|
32
|
+
- A point opens the page named by `wikiTitle`, or by `label` when there is none.
|
|
33
|
+
- `text`: the first line is the caption. The rest lists the points and ties in plain words, so FedWiki search finds them and a wiki without this plugin still shows something readable.
|
|
34
|
+
- An item with no `map` — a fresh one from the Factory — is drawn from its text: every `lat, lon label` line is a point, as in the native Map plugin. Ties need `map`.
|
|
35
|
+
|
|
36
|
+
Double-click the item to edit its text. Editing the text changes the caption; the points and ties live in `map`, which the full RCN Map will edit in a later version.
|
|
37
|
+
|
|
38
|
+
## Lineup merging
|
|
39
|
+
|
|
40
|
+
Like FedWiki's own Map plugin, this one combines maps across the lineup.
|
|
41
|
+
|
|
42
|
+
- **Every RCN map offers its data** to items to its right, two ways: the native way (class `marker-source`, `markerData()` — so a native Map item with `LINEUP` collects RCN points), and a richer RCN way (class `rcnmap-source`, `rcnMapData()` — points, ties, kinds and link kinds).
|
|
43
|
+
- **An RCN map whose text has a `LINEUP` line** collects from every item to its left — earlier pages, and earlier items on its own page: full data from RCN maps, points from native maps. Points merge when they name the same page (`wikiTitle`, else label); ties are remapped onto the merged points, so a tie whose ends come from different pages joins them. Kinds merge by key; two sources giving one key different colours keep both.
|
|
44
|
+
- **❄** freezes what is collected into the item (`item.frozen`, saved as an ordinary edit), so it stays when the lineup changes; shift-click ❄ unfreezes. **↻** collects again — the native plugin reads the lineup only when it draws.
|
|
45
|
+
- Browser-side only: it sees pages open in this window, to its left.
|
|
46
|
+
|
|
47
|
+
## Walks
|
|
48
|
+
|
|
49
|
+
A map can carry walks, written in the RCN Map (🚶 Walk, then ✎ Edit) and copied into the item: `item.map.walks = [{name, steps:[{say, points:[ids], ties:['from>to'], view?:{center:[lat,lng], zoom}, all?, ask?}]}]`. A lit tie lights its two ends.
|
|
50
|
+
|
|
51
|
+
- **▶ Walk** under the map plays it: each step flies the map to what it lights (or to its own `view`), draws the lit ties heavier, names the lit points when there are eight or fewer, fades the rest (points and ties already visited stay half lit) and reads the words aloud, shown as a caption too. An `ask` step stops for the group.
|
|
52
|
+
- Space plays or pauses, ← → step, Esc or ■ Stop ends it and puts the map back.
|
|
53
|
+
- Same bar, keys and voice settings (localStorage `rcnWalkPrefs` / `rcnWalkVoice`) as the rcngraph and rcntimeline walks, and one walk speaks at a time on the page.
|
|
54
|
+
- A `LINEUP` or frozen map plays none: its ids are gathered from other pages, not the ones the walk names.
|
|
55
|
+
|
|
56
|
+
## Status
|
|
57
|
+
|
|
58
|
+
Version 0.3: draws points, ties and a legend; a point opens its page; lineup merging with ties, ❄ freeze, ↻ refresh; walks play. Planned next, in `docs/rcn-map-plugin-plan.md`: "Open in RCN Map" with save-back, and shared layers.
|
|
59
|
+
|
|
60
|
+
Part of the [RCN toolset](https://github.com/marpie1/rcn), MIT.
|
|
61
|
+
|
|
62
|
+
Marc Pierson and Claude Opus 5.5 · October 2026
|
package/client/rcnmap.js
ADDED
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
|
|
3
|
+
// RCN Map — a small map on a wiki page that draws points AND the ties between
|
|
4
|
+
// them. FedWiki's own Map plugin draws points only; the full RCN Map is a
|
|
5
|
+
// full-screen tool in the site's assets. This sits between the two: the item
|
|
6
|
+
// holds its own subject (a few KB in the RCN Map issue-file shape) and draws
|
|
7
|
+
// it in the page column.
|
|
8
|
+
//
|
|
9
|
+
// item.map = { types, linkKinds, parcels:[{id,label,wikiTitle,type,latLng}],
|
|
10
|
+
// links:[{from,to,kind,label}], view? }
|
|
11
|
+
// item.text = first line is the caption; the rest is a plain-words list of
|
|
12
|
+
// the points and ties, so FedWiki search finds them and a wiki
|
|
13
|
+
// without this plugin still shows something readable.
|
|
14
|
+
//
|
|
15
|
+
// An item with no `map` (a fresh one from the Factory) is drawn from its text
|
|
16
|
+
// instead: every "lat, lon label" line is a point, the way the native Map
|
|
17
|
+
// plugin reads it. Ties need `map`.
|
|
18
|
+
//
|
|
19
|
+
// Plan and later steps (lineup merging, popup round trip): docs/rcn-map-plugin-plan.md
|
|
20
|
+
//
|
|
21
|
+
// item.map.walks, written in the RCN Map, play here: see "Walk playback".
|
|
22
|
+
|
|
23
|
+
// Same Leaflet the native Map plugin loads, so the two share one copy on a
|
|
24
|
+
// page instead of fighting over window.L.
|
|
25
|
+
const LEAFLET_JS = 'https://unpkg.com/leaflet@1.7.1/dist/leaflet.js'
|
|
26
|
+
const LEAFLET_CSS = 'https://unpkg.com/leaflet@1.7.1/dist/leaflet.css'
|
|
27
|
+
// Esri's light-grey canvas, the RCN Map's "Light" basemap: no key, and no
|
|
28
|
+
// referrer requirement (tile.openstreetmap.org refuses referrer-less requests).
|
|
29
|
+
const ESRI = 'https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/'
|
|
30
|
+
const DEFAULT_COLOR = '#64748b'
|
|
31
|
+
|
|
32
|
+
const esc = s => String(s == null ? '' : s)
|
|
33
|
+
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
|
|
34
|
+
|
|
35
|
+
// A "lat, lon label" line, as the native Map plugin reads it.
|
|
36
|
+
const POINT = /^(-?\d{1,3}\.?\d*)[, ] *(-?\d{1,3}\.?\d*)\s*(.*)$/
|
|
37
|
+
|
|
38
|
+
function caption (item) {
|
|
39
|
+
return String(item.text || '').split('\n')[0]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// The data to draw: item.map, or points read from the text.
|
|
43
|
+
function model (item) {
|
|
44
|
+
if (item.map && Array.isArray(item.map.parcels)) return item.map
|
|
45
|
+
const parcels = []
|
|
46
|
+
String(item.text || '').split('\n').forEach((line, i) => {
|
|
47
|
+
const m = POINT.exec(line.trim())
|
|
48
|
+
if (!m) return
|
|
49
|
+
const label = m[3].replace(/\[\[(.*?)\]\]/g, '$1').trim()
|
|
50
|
+
parcels.push({ id: 'p' + i, label: label || (m[1] + ', ' + m[2]), latLng: [+m[1], +m[2]] })
|
|
51
|
+
})
|
|
52
|
+
return { types: {}, linkKinds: {}, parcels, links: [] }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ── Lineup merging ────────────────────────────────────────────────────
|
|
56
|
+
// FedWiki's own Map plugin: each map item adds class `marker-source` and a
|
|
57
|
+
// markerData() of its points; a map whose text has a LINEUP line collects
|
|
58
|
+
// them from every item to its left and draws them with its own; ❄ freezes
|
|
59
|
+
// the collection into the page. This plugin takes part both ways — it is a
|
|
60
|
+
// native marker source, so a native LINEUP map collects RCN points — and it
|
|
61
|
+
// adds a richer offer, `rcnmap-source` / rcnMapData(), so an RCN map
|
|
62
|
+
// collecting from RCN maps merges the TIES as well as the points: a tie whose
|
|
63
|
+
// ends come from different pages joins them into one network.
|
|
64
|
+
const lineupOn = item => /^LINEUP\s*$/m.test(String(item.text || ''))
|
|
65
|
+
const keyOf = p => String(p.wikiTitle || p.label || '').replace(/\s+/g, ' ').trim().toLowerCase()
|
|
66
|
+
|
|
67
|
+
// Merge maps. A point is the same point when it names the same page (else the
|
|
68
|
+
// same label); the first copy wins. Kinds and link kinds merge by key; if two
|
|
69
|
+
// sources give one key different colours, the later one is renamed so each
|
|
70
|
+
// keeps its own. Ties are remapped onto the merged points and deduplicated.
|
|
71
|
+
function merge (parts) {
|
|
72
|
+
const out = { types: {}, linkKinds: {}, parcels: [], links: [] }
|
|
73
|
+
const byKey = new Map(), seenL = new Set()
|
|
74
|
+
const same = (a, b) => a && b && a.color === b.color && a.label === b.label
|
|
75
|
+
parts.forEach((part, pi) => {
|
|
76
|
+
const tmap = {}, kmap = {}, idmap = {}
|
|
77
|
+
Object.entries(part.types || {}).forEach(([k, t]) => {
|
|
78
|
+
let kk = k; if (out.types[kk] && !same(out.types[kk], t)) kk = k + '@' + pi
|
|
79
|
+
out.types[kk] = out.types[kk] || t; tmap[k] = kk
|
|
80
|
+
})
|
|
81
|
+
Object.entries(part.linkKinds || {}).forEach(([k, t]) => {
|
|
82
|
+
let kk = k; if (out.linkKinds[kk] && !same(out.linkKinds[kk], t)) kk = k + '@' + pi
|
|
83
|
+
out.linkKinds[kk] = out.linkKinds[kk] || t; kmap[k] = kk
|
|
84
|
+
})
|
|
85
|
+
;(part.parcels || []).forEach(p => {
|
|
86
|
+
const key = keyOf(p)
|
|
87
|
+
if (!byKey.has(key)) {
|
|
88
|
+
const id = 'p' + out.parcels.length
|
|
89
|
+
byKey.set(key, id)
|
|
90
|
+
out.parcels.push(Object.assign({}, p, { id, type: p.type != null ? (tmap[p.type] || p.type) : p.type }))
|
|
91
|
+
}
|
|
92
|
+
idmap[p.id] = byKey.get(key)
|
|
93
|
+
})
|
|
94
|
+
;(part.links || []).forEach(l => {
|
|
95
|
+
const a = idmap[l.from], b = idmap[l.to]
|
|
96
|
+
if (!a || !b) return
|
|
97
|
+
const kind = kmap[l.kind] || l.kind, k = a + '|' + b + '|' + kind
|
|
98
|
+
if (!seenL.has(k)) { seenL.add(k); out.links.push(Object.assign({}, l, { from: a, to: b, kind })) }
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
return out
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Every map to the left of this item: full data from RCN maps, points only
|
|
105
|
+
// from native Map items.
|
|
106
|
+
function collect ($item) {
|
|
107
|
+
const all = $('.item'), here = all.index($item), out = []
|
|
108
|
+
all.slice(0, here).each(function () {
|
|
109
|
+
if (this.rcnMapData) out.push(this.rcnMapData())
|
|
110
|
+
else if ($(this).hasClass('marker-source') && this.markerData) {
|
|
111
|
+
out.push({ parcels: this.markerData().map((mk, i) => ({
|
|
112
|
+
id: 'm' + i, label: String(mk.label || '').replace(/<[^>]*>/g, '').replace(/\[\[(.*?)\]\]/g, '$1').trim() || (mk.lat + ', ' + mk.lon),
|
|
113
|
+
latLng: [mk.lat, mk.lon] })) })
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
return out
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// What this item draws: its own, then (frozen ? the frozen collection :
|
|
120
|
+
// LINEUP ? what the maps to its left offer now : nothing).
|
|
121
|
+
function effective ($item, item) {
|
|
122
|
+
const own = model(item)
|
|
123
|
+
if (item.frozen) return merge([own, item.frozen])
|
|
124
|
+
if (lineupOn(item) && $item) return merge([own, ...collect($item)])
|
|
125
|
+
return own
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ── Walk playback ──────────────────────────────────────────────────────
|
|
129
|
+
// A walk, written in the RCN Map, is a list of steps: words to say and the
|
|
130
|
+
// points and ties each step is about (item.map.walks = [{name, steps:[{say,
|
|
131
|
+
// points:[ids], ties:['from>to'], view?:{center,zoom}, all?, ask?}]}]).
|
|
132
|
+
// Playing it here flies this small map to what a step lights (or to the
|
|
133
|
+
// step's own view), names the lit points, fades the rest (ones already
|
|
134
|
+
// visited stay half lit) and speaks the words with the browser's own voice,
|
|
135
|
+
// shown as a caption too. Same controls, keys and voice settings as the
|
|
136
|
+
// drawing and timeline plugins, and one walk speaks at a time on the page.
|
|
137
|
+
// Walk ids are this item's own, so a LINEUP or frozen map plays none.
|
|
138
|
+
const WALK_GHOST = 0.13, WALK_SEEN = 0.42, WALK_LABELS_MAX = 8
|
|
139
|
+
|
|
140
|
+
function walkList (item) {
|
|
141
|
+
if (lineupOn(item) || item.frozen) return []
|
|
142
|
+
const ws = item.map && item.map.walks
|
|
143
|
+
return Array.isArray(ws) ? ws.filter(w => w && Array.isArray(w.steps) && w.steps.length) : []
|
|
144
|
+
}
|
|
145
|
+
// null = everything lit. A lit tie lights its two ends.
|
|
146
|
+
function stepLit (st) {
|
|
147
|
+
if (!st || st.all) return null
|
|
148
|
+
const P = new Set((st.points || []).map(String)), T = new Set((st.ties || []).map(String))
|
|
149
|
+
T.forEach(k => k.split('>').forEach(id => P.add(id)))
|
|
150
|
+
return { P, T }
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Voice and speed are the listener's: kept in this browser, the same keys the Graph Tool uses.
|
|
154
|
+
function walkPrefs () {
|
|
155
|
+
let p = {}
|
|
156
|
+
try { p = JSON.parse(localStorage.getItem('rcnWalkPrefs') || '{}') } catch (e) {}
|
|
157
|
+
let on = true
|
|
158
|
+
try { on = localStorage.getItem('rcnWalkVoice') !== 'off' } catch (e) {}
|
|
159
|
+
return { voice: p.voice || '', rate: (+p.rate >= 0.6 && +p.rate <= 1.4) ? +p.rate : 0.95, on }
|
|
160
|
+
}
|
|
161
|
+
function walkVoice (name) {
|
|
162
|
+
const vs = window.speechSynthesis ? speechSynthesis.getVoices().filter(v => /^en/i.test(v.lang)) : []
|
|
163
|
+
return vs.find(v => v.name === name) || vs.find(v => /Enhanced|Premium|Natural|Neural/i.test(v.name)) ||
|
|
164
|
+
['Samantha', 'Daniel', 'Karen', 'Moira', 'Google UK English Female', 'Google US English', 'Microsoft Aria']
|
|
165
|
+
.map(p => vs.find(v => v.name.indexOf(p) === 0)).find(Boolean) || vs[0] || null
|
|
166
|
+
}
|
|
167
|
+
const stopVoice = () => { try { if (window.speechSynthesis) speechSynthesis.cancel() } catch (e) {} }
|
|
168
|
+
// Say the words; done() runs once when they have been said. One utterance per
|
|
169
|
+
// sentence, because Chrome stops a long one after about fifteen seconds.
|
|
170
|
+
function walkSay (text, isCurrent, done) {
|
|
171
|
+
const prefs = walkPrefs(), words = (text || '').split(/\s+/).length
|
|
172
|
+
let fired = false
|
|
173
|
+
const after = () => { if (fired || !isCurrent()) return; fired = true; done() }
|
|
174
|
+
setTimeout(after, words * (prefs.on ? 650 : 420) + (prefs.on ? 6000 : 2500)) // if the voice never says it finished
|
|
175
|
+
stopVoice()
|
|
176
|
+
if (!prefs.on || !window.speechSynthesis || !text) { setTimeout(after, text ? words * 400 + 2000 : 1200); return }
|
|
177
|
+
const v = walkVoice(prefs.voice)
|
|
178
|
+
const parts = text.match(/[^.!?]+[.!?]+["'”’)]*\s*|[^.!?]+$/g) || [text]
|
|
179
|
+
parts.forEach((s, k) => {
|
|
180
|
+
const u = new SpeechSynthesisUtterance(s.trim())
|
|
181
|
+
if (v) { u.voice = v; u.lang = v.lang }
|
|
182
|
+
u.rate = prefs.rate
|
|
183
|
+
if (k === parts.length - 1) u.onend = after
|
|
184
|
+
speechSynthesis.speak(u)
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function walkBar (item) {
|
|
189
|
+
const ws = walkList(item)
|
|
190
|
+
if (!ws.length) return ''
|
|
191
|
+
const b = 'cursor:pointer;font-size:12px;padding:2px 8px;'
|
|
192
|
+
const pick = ws.length > 1
|
|
193
|
+
? `<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>`
|
|
194
|
+
: `<span style="font-size:12px;color:#475569">${esc(ws[0].name || 'Walk')}</span>`
|
|
195
|
+
return `<div class="walk-bar" tabindex="0" title="Hear and see this map explained one part at a time. Space plays or pauses, ← → step, Esc stops." style="padding:8px 0 0;outline:none;">
|
|
196
|
+
<div style="display:flex;gap:6px;align-items:center;justify-content:center;flex-wrap:wrap">
|
|
197
|
+
<button class="walk-start" style="${b}font-weight:600">▶ Walk</button>
|
|
198
|
+
${pick}
|
|
199
|
+
<button class="walk-prev" style="${b}display:none" title="Back a step (←)">◀</button>
|
|
200
|
+
<button class="walk-play" style="${b}display:none" title="Play or pause (Space)">❚❚</button>
|
|
201
|
+
<button class="walk-next" style="${b}display:none" title="Next step (→)">▶</button>
|
|
202
|
+
<span class="walk-count" style="display:none;font-size:12px;color:#64748b;min-width:70px;text-align:center"></span>
|
|
203
|
+
<button class="walk-voice" style="${b}display:none" title="Read the words aloud, or show them only"></button>
|
|
204
|
+
<button class="walk-close" style="${b}display:none" title="Stop the walk (Esc)">■ Stop</button>
|
|
205
|
+
</div>
|
|
206
|
+
<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>
|
|
207
|
+
<div class="walk-note" style="font-size:11px;color:#64748b;text-align:center;margin-top:3px"></div>
|
|
208
|
+
</div>`
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Restyle the drawn map for the open step, or put it back (no walk open).
|
|
212
|
+
// el.rcnmDrawn is what draw() made: {map, markers:{id}, ties:[{key,layer,weight}], home()}.
|
|
213
|
+
function walkPaint (el, item) {
|
|
214
|
+
const d = el.rcnmDrawn, wk = el.rcnmWalk
|
|
215
|
+
if (!d) return
|
|
216
|
+
const L = window.L, walk = wk && wk.w !== null ? walkList(item)[wk.w] : null
|
|
217
|
+
const st = walk && walk.steps[wk.i], lit = st ? stepLit(st) : null
|
|
218
|
+
const seenP = new Set(), seenT = new Set()
|
|
219
|
+
if (walk) walk.steps.slice(0, wk.i).forEach(s => { const x = stepLit(s); if (x) { x.P.forEach(v => seenP.add(v)); x.T.forEach(v => seenT.add(v)) } })
|
|
220
|
+
const op = (set, seen, k) => !walk || !lit || set.has(k) ? 1 : seen.has(k) ? WALK_SEEN : WALK_GHOST
|
|
221
|
+
// A tie the step is about is drawn heavier, so a short or dotted one still reads.
|
|
222
|
+
d.ties.forEach(t => {
|
|
223
|
+
const on = lit && lit.T.has(t.key)
|
|
224
|
+
t.layer.setStyle({ opacity: on ? 1 : 0.85 * op(lit ? lit.T : null, seenT, t.key), weight: on ? Math.max(5, t.weight * 2) : t.weight })
|
|
225
|
+
if (on) t.layer.bringToFront()
|
|
226
|
+
})
|
|
227
|
+
Object.keys(d.markers).forEach(id => {
|
|
228
|
+
const f = op(lit ? lit.P : null, seenP, id)
|
|
229
|
+
d.markers[id].setStyle({ opacity: f, fillOpacity: 0.95 * f })
|
|
230
|
+
if (f === 1) d.markers[id].bringToFront()
|
|
231
|
+
})
|
|
232
|
+
const tiles = d.map.getPane('tilePane')
|
|
233
|
+
if (tiles) tiles.style.opacity = walk ? '0.55' : ''
|
|
234
|
+
// Name the points a step is about, unless so many are lit the names would pile up.
|
|
235
|
+
if (d.labels) { d.map.removeLayer(d.labels); d.labels = null }
|
|
236
|
+
if (lit && lit.P.size <= WALK_LABELS_MAX) {
|
|
237
|
+
const byId = {}
|
|
238
|
+
model(item).parcels.forEach(p => { byId[p.id] = p })
|
|
239
|
+
d.labels = L.layerGroup([...lit.P].filter(id => d.markers[id] && byId[id]).map(id =>
|
|
240
|
+
L.marker(d.markers[id].getLatLng(), { interactive: false, keyboard: false,
|
|
241
|
+
icon: L.divIcon({ className: 'rcnm-label', iconSize: [0, 0], html: `<span>${esc(byId[id].label)}</span>` }) }))).addTo(d.map)
|
|
242
|
+
walkDeclutter(d)
|
|
243
|
+
}
|
|
244
|
+
if (!walk) { d.home(); return }
|
|
245
|
+
if (st.view && Array.isArray(st.view.center)) { d.map.flyTo(st.view.center, st.view.zoom || 12, { duration: 1.1 }); return }
|
|
246
|
+
const pts = lit ? [...lit.P].map(id => d.markers[id] && d.markers[id].getLatLng()).filter(Boolean) : []
|
|
247
|
+
if (!pts.length) d.home()
|
|
248
|
+
else if (pts.length === 1) d.map.flyTo(pts[0], Math.max(d.map.getZoom(), 13), { duration: 1.1 })
|
|
249
|
+
else d.map.flyToBounds(L.latLngBounds(pts), { padding: [30, 30], maxZoom: 14, duration: 1.1 })
|
|
250
|
+
}
|
|
251
|
+
// Downtown, lit points sit within a block of each other: try each name right
|
|
252
|
+
// of its dot, then left, above and below, and keep the first place that
|
|
253
|
+
// covers no name already placed. Runs again whenever the map settles.
|
|
254
|
+
const LABEL_SPOTS = ['translate(9px,-50%)', 'translate(calc(-100% - 9px),-50%)', 'translate(9px,-125%)', 'translate(9px,25%)',
|
|
255
|
+
'translate(calc(-100% - 9px),-125%)', 'translate(calc(-100% - 9px),25%)']
|
|
256
|
+
function walkDeclutter (d) {
|
|
257
|
+
if (!d.labels) return
|
|
258
|
+
const placed = [], hit = (a, b) => a.left < b.right + 2 && b.left < a.right + 2 && a.top < b.bottom + 2 && b.top < a.bottom + 2
|
|
259
|
+
d.labels.eachLayer(mk => {
|
|
260
|
+
const sp = mk.getElement() && mk.getElement().querySelector('span')
|
|
261
|
+
if (!sp) return
|
|
262
|
+
let best = LABEL_SPOTS[0]
|
|
263
|
+
for (const t of LABEL_SPOTS) {
|
|
264
|
+
sp.style.transform = t
|
|
265
|
+
const r = sp.getBoundingClientRect()
|
|
266
|
+
if (!placed.some(q => hit(r, q))) { best = t; break }
|
|
267
|
+
}
|
|
268
|
+
sp.style.transform = best
|
|
269
|
+
placed.push(sp.getBoundingClientRect())
|
|
270
|
+
})
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Playback for one item. w === null: no walk open. token guards every voice
|
|
274
|
+
// callback, so a step that was skipped or stopped can never move the walk on.
|
|
275
|
+
function bindWalk ($item, item) {
|
|
276
|
+
const el = $item.get(0)
|
|
277
|
+
const wk = el.rcnmWalk = el.rcnmWalk || { w: null, i: 0, playing: false, token: 0, heard: null }
|
|
278
|
+
const cur = () => wk.w !== null ? walkList(item)[wk.w] : null
|
|
279
|
+
const ui = note => {
|
|
280
|
+
const walk = cur(), open = !!walk
|
|
281
|
+
const $bar = $item.find('.walk-bar')
|
|
282
|
+
$bar.find('.walk-prev, .walk-next, .walk-play, .walk-count, .walk-voice, .walk-close').toggle(open)
|
|
283
|
+
$bar.find('.walk-start, .walk-pick').toggle(!open)
|
|
284
|
+
$bar.find('.walk-say').toggle(open)
|
|
285
|
+
$bar.find('.walk-play').text(wk.playing ? '❚❚' : '▶')
|
|
286
|
+
$bar.find('.walk-voice').text(walkPrefs().on ? '🔈 Voice on' : '🔇 Voice off')
|
|
287
|
+
$bar.find('.walk-count').text(open ? 'Step ' + (wk.i + 1) + ' of ' + walk.steps.length : '')
|
|
288
|
+
$bar.find('.walk-note').text(note || (open && !wk.playing ? 'Space plays · ← → step · Esc stops' : ''))
|
|
289
|
+
}
|
|
290
|
+
const speak = () => {
|
|
291
|
+
const tok = ++wk.token, walk = cur(), st = walk && walk.steps[wk.i]
|
|
292
|
+
if (!st) return
|
|
293
|
+
wk.heard = wk.i
|
|
294
|
+
walkSay(st.say, () => tok === wk.token && window.rcnActiveWalk === wk, () => {
|
|
295
|
+
const last = wk.i >= walk.steps.length - 1
|
|
296
|
+
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 }
|
|
297
|
+
setTimeout(() => { if (tok === wk.token && wk.playing) show(wk.i + 1) }, 1300) // time for the map to land
|
|
298
|
+
})
|
|
299
|
+
}
|
|
300
|
+
const show = i => {
|
|
301
|
+
const walk = cur()
|
|
302
|
+
if (!walk) return
|
|
303
|
+
wk.i = Math.max(0, Math.min(walk.steps.length - 1, i))
|
|
304
|
+
wk.token++; stopVoice()
|
|
305
|
+
walkPaint(el, item)
|
|
306
|
+
const st = walk.steps[wk.i]
|
|
307
|
+
$item.find('.walk-say').text(st.say || '').css({ color: st.ask ? '#7c2d12' : '#1e1b4b', fontStyle: st.ask ? 'italic' : 'normal' })
|
|
308
|
+
ui()
|
|
309
|
+
if (wk.playing) speak()
|
|
310
|
+
}
|
|
311
|
+
const pause = () => { wk.playing = false; wk.token++; stopVoice(); ui() }
|
|
312
|
+
const toggle = () => {
|
|
313
|
+
if (!cur()) return
|
|
314
|
+
if (wk.playing) { pause(); return }
|
|
315
|
+
const other = window.rcnActiveWalk
|
|
316
|
+
if (other && other !== wk && other.end) other.end()
|
|
317
|
+
window.rcnActiveWalk = wk
|
|
318
|
+
wk.playing = true
|
|
319
|
+
// Space after a step has been heard moves on; otherwise it says the step.
|
|
320
|
+
if (wk.heard === wk.i && wk.i < cur().steps.length - 1) { show(wk.i + 1); return }
|
|
321
|
+
ui(); speak()
|
|
322
|
+
}
|
|
323
|
+
const end = () => {
|
|
324
|
+
wk.playing = false; wk.token++; wk.w = null; wk.heard = null
|
|
325
|
+
if (window.rcnActiveWalk === wk) { stopVoice(); window.rcnActiveWalk = null }
|
|
326
|
+
walkPaint(el, item)
|
|
327
|
+
ui()
|
|
328
|
+
}
|
|
329
|
+
wk.end = end
|
|
330
|
+
$item.off('.rcnmwalk')
|
|
331
|
+
$item.on('click.rcnmwalk', '.walk-start', e => {
|
|
332
|
+
e.stopPropagation()
|
|
333
|
+
wk.w = +($item.find('.walk-pick').val() || 0)
|
|
334
|
+
wk.heard = null
|
|
335
|
+
show(0)
|
|
336
|
+
toggle() // a click is a user gesture, so the browser will speak
|
|
337
|
+
$item.find('.walk-bar').trigger('focus')
|
|
338
|
+
})
|
|
339
|
+
$item.on('click.rcnmwalk', '.walk-play', e => { e.stopPropagation(); toggle() })
|
|
340
|
+
$item.on('click.rcnmwalk', '.walk-prev', e => { e.stopPropagation(); show(wk.i - 1) })
|
|
341
|
+
$item.on('click.rcnmwalk', '.walk-next', e => { e.stopPropagation(); show(wk.i + 1) })
|
|
342
|
+
$item.on('click.rcnmwalk', '.walk-close', e => { e.stopPropagation(); end() })
|
|
343
|
+
$item.on('click.rcnmwalk', '.walk-voice', e => {
|
|
344
|
+
e.stopPropagation()
|
|
345
|
+
const on = !walkPrefs().on
|
|
346
|
+
try { localStorage.setItem('rcnWalkVoice', on ? 'on' : 'off') } catch (err) {}
|
|
347
|
+
if (!on) stopVoice()
|
|
348
|
+
if (wk.playing) speak()
|
|
349
|
+
ui()
|
|
350
|
+
})
|
|
351
|
+
$item.on('keydown.rcnmwalk', '.walk-bar', e => {
|
|
352
|
+
if (wk.w === null || $(e.target).is('select')) return
|
|
353
|
+
if (e.key === ' ') { e.preventDefault(); e.stopPropagation(); toggle() }
|
|
354
|
+
else if (e.key === 'ArrowRight') { e.preventDefault(); e.stopPropagation(); show(wk.i + 1) }
|
|
355
|
+
else if (e.key === 'ArrowLeft') { e.preventDefault(); e.stopPropagation(); show(wk.i - 1) }
|
|
356
|
+
else if (e.key === 'Escape') { e.preventDefault(); end() }
|
|
357
|
+
})
|
|
358
|
+
// A save or ↻ redraws the item; a walk left open would point at a stale map.
|
|
359
|
+
if (wk.w !== null) end()
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function loadLeaflet (done) {
|
|
363
|
+
if (!document.querySelector(`link[href='${LEAFLET_CSS}']`)) {
|
|
364
|
+
$(`<link rel="stylesheet" href="${LEAFLET_CSS}">`).appendTo('head')
|
|
365
|
+
}
|
|
366
|
+
if (window.L && window.L.map) return done()
|
|
367
|
+
wiki.getScript(LEAFLET_JS, done)
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function legendHTML (m) {
|
|
371
|
+
const usedTypes = new Set(m.parcels.map(p => p.type))
|
|
372
|
+
const usedKinds = new Set((m.links || []).map(l => l.kind))
|
|
373
|
+
const rows = []
|
|
374
|
+
Object.keys(m.types || {}).filter(k => usedTypes.has(k)).forEach(k => {
|
|
375
|
+
const t = m.types[k]
|
|
376
|
+
rows.push(`<span class="rcnm-key"><span class="rcnm-dot" style="background:${esc(t.color)}"></span>${esc(t.label)}</span>`)
|
|
377
|
+
})
|
|
378
|
+
Object.keys(m.linkKinds || {}).filter(k => usedKinds.has(k)).forEach(k => {
|
|
379
|
+
const lk = m.linkKinds[k]
|
|
380
|
+
rows.push(`<span class="rcnm-key"><svg width="20" height="8"><line x1="0" y1="4" x2="20" y2="4" stroke="${esc(lk.color)}" stroke-width="${Math.min(3, lk.weight || 2)}" stroke-dasharray="${esc(lk.dash || '')}"/></svg>${esc(lk.label)}</span>`)
|
|
381
|
+
})
|
|
382
|
+
return rows.join('')
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function emit ($item, item) {
|
|
386
|
+
$item.empty()
|
|
387
|
+
// Offer this map to any LINEUP map to its right — the native way (points)
|
|
388
|
+
// and the RCN way (points and ties). Set before drawing.
|
|
389
|
+
const el = $item.get(0), slug = $item.parents('.page:first').attr('id') || ''
|
|
390
|
+
const offered = () => item.frozen ? merge([model(item), item.frozen]) : model(item)
|
|
391
|
+
$item.addClass('marker-source rcnmap-source')
|
|
392
|
+
el.markerData = () => offered().parcels.map(p => ({ lat: p.latLng[0], lon: p.latLng[1], label: p.wikiTitle ? '[[' + p.wikiTitle + ']]' : p.label }))
|
|
393
|
+
el.markerGeo = () => ({ type: 'FeatureCollection', features: offered().parcels.map(p => ({
|
|
394
|
+
type: 'Feature', geometry: { type: 'Point', coordinates: [p.latLng[1], p.latLng[0]] }, properties: { label: p.label } })) })
|
|
395
|
+
el.rcnMapData = () => Object.assign({ source: slug }, offered())
|
|
396
|
+
const m = effective($item, item)
|
|
397
|
+
const lineup = lineupOn(item)
|
|
398
|
+
const controls = lineup
|
|
399
|
+
? `<div style="padding:6px 0 0;text-align:center;font-size:11px;color:#64748b;">`
|
|
400
|
+
+ (item.frozen ? `Frozen: ${m.parcels.length} points and ${m.links.length} ties kept in this page. `
|
|
401
|
+
: `Collected from ${collect($item).length} map(s) to the left. `)
|
|
402
|
+
+ `<button class="rcnm-freeze" title="${item.frozen ? 'Frozen: shift-click to unfreeze' : 'Freeze what the lineup shows into this page'}" style="cursor:pointer;${item.frozen ? 'color:#2563eb;' : ''}">❄︎</button> `
|
|
403
|
+
+ `<button class="rcnm-refresh" title="Collect again from the maps to the left" style="cursor:pointer;"${item.frozen ? ' disabled' : ''}>↻</button></div>`
|
|
404
|
+
: ''
|
|
405
|
+
const id = 'rcnmap-' + Math.floor(Math.random() * 1e9)
|
|
406
|
+
$item.append(`
|
|
407
|
+
<div style="background:#f5f5f5;padding:8px;">
|
|
408
|
+
<div id="${id}" style="height:320px;border:1px solid #ddd;background:#e5e7eb;"></div>
|
|
409
|
+
<div class="rcnm-legend" style="font-size:11px;color:#475569;padding:6px 2px 0;line-height:1.7;">${legendHTML(m)}</div>
|
|
410
|
+
<p class="caption" style="margin:4px 0 0;">${wiki.resolveLinks ? wiki.resolveLinks(esc(caption(item))) : esc(caption(item))}</p>
|
|
411
|
+
${controls}
|
|
412
|
+
${walkBar(item)}
|
|
413
|
+
</div>
|
|
414
|
+
<style>
|
|
415
|
+
.rcnm-label{background:none;border:0}
|
|
416
|
+
.rcnm-label span{display:inline-block;transform:translate(9px,-50%);white-space:nowrap;font:600 11px system-ui,sans-serif;color:#1e1b4b;background:rgba(255,255,255,.88);border-radius:4px;padding:1px 4px;box-shadow:0 1px 3px rgba(0,0,0,.2);pointer-events:none}
|
|
417
|
+
.rcnm-key{display:inline-flex;align-items:center;gap:4px;margin-right:10px;white-space:nowrap}
|
|
418
|
+
.rcnm-dot{display:inline-block;width:9px;height:9px;border-radius:50%;border:1px solid #fff;box-shadow:0 0 0 1px #cbd5e1}
|
|
419
|
+
</style>`)
|
|
420
|
+
if (!m.parcels.length) {
|
|
421
|
+
$item.find('#' + id).html(lineup
|
|
422
|
+
? '<p style="padding:12px;color:#64748b">Nothing to collect yet. Open co-op pages to the left of this one, then press ↻.</p>'
|
|
423
|
+
: '<p style="padding:12px;color:#64748b">No points yet. Double-click to add lines of the form <code>48.75, -122.48 Name</code>.</p>')
|
|
424
|
+
return
|
|
425
|
+
}
|
|
426
|
+
loadLeaflet(() => draw($item, item, m, id))
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function draw ($item, item, m, id) {
|
|
430
|
+
const L = window.L
|
|
431
|
+
const map = L.map(id, { scrollWheelZoom: false, zoomControl: true, attributionControl: true })
|
|
432
|
+
L.tileLayer(ESRI + 'World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}', {
|
|
433
|
+
maxNativeZoom: 16, maxZoom: 19,
|
|
434
|
+
attribution: 'Tiles © Esri — Esri, HERE, Garmin, © OpenStreetMap contributors'
|
|
435
|
+
}).addTo(map)
|
|
436
|
+
L.tileLayer(ESRI + 'World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}', {
|
|
437
|
+
maxNativeZoom: 16, maxZoom: 19
|
|
438
|
+
}).addTo(map)
|
|
439
|
+
|
|
440
|
+
const byId = {}
|
|
441
|
+
m.parcels.forEach(p => { byId[p.id] = p })
|
|
442
|
+
const drawn = { map, markers: {}, ties: [], labels: null }
|
|
443
|
+
|
|
444
|
+
// Ties first, so the points sit on top and stay clickable.
|
|
445
|
+
;(m.links || []).forEach(l => {
|
|
446
|
+
const a = byId[l.from], b = byId[l.to]
|
|
447
|
+
if (!a || !b) return
|
|
448
|
+
const k = (m.linkKinds || {})[l.kind] || {}
|
|
449
|
+
const line = L.polyline([a.latLng, b.latLng], {
|
|
450
|
+
color: k.color || DEFAULT_COLOR, weight: k.weight || 2.5,
|
|
451
|
+
dashArray: k.dash || null, opacity: 0.85
|
|
452
|
+
}).bindTooltip(esc(l.label || k.label || ''), { sticky: true }).addTo(map)
|
|
453
|
+
drawn.ties.push({ key: l.from + '>' + l.to, layer: line, weight: k.weight || 2.5 })
|
|
454
|
+
})
|
|
455
|
+
|
|
456
|
+
const $page = $item.parents('.page:first')
|
|
457
|
+
m.parcels.forEach(p => {
|
|
458
|
+
const t = (m.types || {})[p.type] || {}
|
|
459
|
+
const c = p.contact || {}
|
|
460
|
+
const tip = `<b>${esc(p.label)}</b>` + (t.label ? `<br>${esc(t.label)}` : '')
|
|
461
|
+
+ (c.website ? `<br>${esc(c.website.replace(/^https?:\/\/(www\.)?/, '').replace(/\/$/, ''))}` : '')
|
|
462
|
+
+ (c.phone ? `<br>${esc(c.phone)}` : '')
|
|
463
|
+
+ '<br><i style="color:#64748b">click to open its page</i>'
|
|
464
|
+
drawn.markers[p.id] = L.circleMarker(p.latLng, {
|
|
465
|
+
radius: 7, fillColor: t.color || DEFAULT_COLOR, color: '#fff', weight: 1.5, fillOpacity: 0.95
|
|
466
|
+
}).bindTooltip(tip, { direction: 'top', offset: [0, -6] })
|
|
467
|
+
.on('click', () => wiki.doInternalLink(p.wikiTitle || p.label, $page))
|
|
468
|
+
.addTo(map)
|
|
469
|
+
})
|
|
470
|
+
|
|
471
|
+
// The item's own view: where the map opens, and where a walk's overview steps return to.
|
|
472
|
+
const v = m.view
|
|
473
|
+
drawn.home = () => {
|
|
474
|
+
if (v && v.lat != null) map.setView([v.lat, v.lng], v.zoom || 11)
|
|
475
|
+
else if (m.parcels.length === 1) map.setView(m.parcels[0].latLng, 13)
|
|
476
|
+
else map.fitBounds(L.latLngBounds(m.parcels.map(p => p.latLng)), { padding: [24, 24], maxZoom: 15 })
|
|
477
|
+
}
|
|
478
|
+
drawn.home()
|
|
479
|
+
const el = $item.get(0)
|
|
480
|
+
el.rcnmDrawn = drawn
|
|
481
|
+
map.on('zoomend moveend', () => walkDeclutter(drawn))
|
|
482
|
+
|
|
483
|
+
// Dragging the map must not drag the item, and a double-click on the map
|
|
484
|
+
// should open the editor, as it does anywhere else on the item.
|
|
485
|
+
L.DomEvent.disableClickPropagation(document.getElementById(id))
|
|
486
|
+
map.doubleClickZoom.disable()
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function save ($item, item) {
|
|
490
|
+
wiki.pageHandler.put($item.parents('.page:first'), { type: 'edit', id: item.id, item })
|
|
491
|
+
emit($item, item)
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
// ⓘ — this plugin's About page in one click. FedWiki opens it with Cmd/Ctrl-I,
|
|
496
|
+
// but only from the item's text editor, which people seldom open when the real
|
|
497
|
+
// work happens elsewhere. Redraws empty the item, so the mark puts itself back.
|
|
498
|
+
function aboutMark ($item, type) {
|
|
499
|
+
const el = $item.get(0)
|
|
500
|
+
if (!el || el.__aboutMark) return
|
|
501
|
+
el.__aboutMark = true
|
|
502
|
+
if (getComputedStyle(el).position === 'static') el.style.position = 'relative'
|
|
503
|
+
const add = () => {
|
|
504
|
+
if (el.querySelector(':scope > .rcn-about')) return
|
|
505
|
+
const a = document.createElement('a')
|
|
506
|
+
a.className = 'rcn-about'
|
|
507
|
+
a.href = '/view/about-' + type + '-plugin'
|
|
508
|
+
a.title = 'About this plugin'
|
|
509
|
+
a.textContent = 'ⓘ'
|
|
510
|
+
a.style.cssText = 'position:absolute;top:0;right:-18px;z-index:1000;font:15px/1 system-ui,sans-serif;color:#64748b;text-decoration:none;cursor:pointer;background:rgba(255,255,255,.75);border-radius:50%;padding:1px 2px'
|
|
511
|
+
a.addEventListener('click', e => {
|
|
512
|
+
e.preventDefault()
|
|
513
|
+
e.stopPropagation()
|
|
514
|
+
wiki.doInternalLink('about ' + type + ' plugin', $item.parents('.page:first'))
|
|
515
|
+
})
|
|
516
|
+
a.addEventListener('dblclick', e => e.stopPropagation())
|
|
517
|
+
el.appendChild(a)
|
|
518
|
+
}
|
|
519
|
+
add()
|
|
520
|
+
new MutationObserver(add).observe(el, { childList: true })
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function bind ($item, item) {
|
|
524
|
+
aboutMark($item, 'rcnmap')
|
|
525
|
+
bindWalk($item, item)
|
|
526
|
+
$item.dblclick(e => { if (!$(e.target).closest('button, .walk-bar').length) wiki.textEditor($item, item) })
|
|
527
|
+
$item.on('click', '.rcnm-refresh', e => { e.stopPropagation(); emit($item, item) })
|
|
528
|
+
$item.on('click', '.rcnm-freeze', e => {
|
|
529
|
+
e.stopPropagation()
|
|
530
|
+
if (e.shiftKey) { if (item.frozen) { delete item.frozen; save($item, item) } return }
|
|
531
|
+
const got = merge(collect($item))
|
|
532
|
+
if (!got.parcels.length) return
|
|
533
|
+
item.frozen = item.frozen ? merge([item.frozen, got]) : got
|
|
534
|
+
save($item, item)
|
|
535
|
+
})
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (typeof window !== 'undefined') {
|
|
539
|
+
window.plugins.rcnmap = { emit, bind }
|
|
540
|
+
}
|
|
541
|
+
if (typeof module !== 'undefined') {
|
|
542
|
+
module.exports = { model, caption, merge, lineupOn, walkList, stepLit }
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
})()
|
package/factory.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"Rcnmap","title":"RCN Map","category":"visualization"}
|
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-plugin-rcnmap",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Federated Wiki plugin: a small RCN map on a page that draws points and the ties between them; each point opens its page",
|
|
5
|
+
"keywords": ["wiki", "federated wiki", "plugin", "rcn", "map"],
|
|
6
|
+
"author": "RCN Network <rcn@relocalizecreativity.net>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"files": ["client/rcnmap.js", "factory.json", "index.js", "pages", "README.md"],
|
|
10
|
+
"repository": {"type": "git", "url": "git+https://github.com/marpie1/rcn.git"},
|
|
11
|
+
"homepage": "https://github.com/marpie1/rcn/tree/master/wiki-plugin-rcnmap"
|
|
12
|
+
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "About Rcnmap Plugin",
|
|
3
|
+
"story": [
|
|
4
|
+
{
|
|
5
|
+
"type": "paragraph",
|
|
6
|
+
"text": "The RCN Map plugin puts a small map on a wiki page that draws points and the ties between them. Each point is coloured by its kind and each tie by its kind of link, with a legend under the map. Hover a point for its name and kind; click it and that page opens in the lineup beside this one.",
|
|
7
|
+
"id": "746273db7898005b"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"type": "paragraph",
|
|
11
|
+
"id": "a4ef6e3499d86014",
|
|
12
|
+
"text": "See [https://github.com/marpie1/rcn/tree/master/wiki-plugin-rcnmap GitHub] for plugin source."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"type": "paragraph",
|
|
16
|
+
"text": "FedWiki\u2019s own Map plugin draws points only. The full RCN Map is a full-screen tool that lives in a site\u2019s assets. This plugin sits between them: the item carries its own subject, a few KB in the RCN Map issue-file shape, and draws it in the page column.",
|
|
17
|
+
"id": "8dcaffbd1fad8a51"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
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 points and ties in plain words, so wiki search finds them. The points and ties themselves live in the item\u2019s map field. A new item from the Factory has no map field yet: type lines of the form 48.75, -122.48 Name and each becomes a point, as in the native Map plugin.",
|
|
22
|
+
"id": "9f943464d295f7ea"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "paragraph",
|
|
26
|
+
"text": "Below: Community to Community and the co-ops it is tied to, from the Co-ops of Whatcom County pages.",
|
|
27
|
+
"id": "5c2d5213900ae62a"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"type": "rcnmap",
|
|
31
|
+
"id": "f0ab1e2536632919",
|
|
32
|
+
"text": "Community to Community C2C and the 2 co-ops it is tied to. Click a point for its page.\nCommunity to Community C2C \u2014 Co-op development support\nCommunity Food Co-op \u2014 Consumer co-op / credit union\nCooperativa Tierra y Libertad \u2014 Worker co-op\nCommunity Food Co-op \u2192 Community to Community C2C: Farm Fund grant \u2014 co-op development for farmworkers\nCommunity to Community C2C \u2192 Cooperativa Tierra y Libertad: Organised and incubated the co-op; led the land fundraising\nCooperativa Tierra y Libertad \u2192 Community Food Co-op: Supplies produce",
|
|
33
|
+
"map": {
|
|
34
|
+
"types": {
|
|
35
|
+
"worker": {
|
|
36
|
+
"label": "Worker co-op",
|
|
37
|
+
"color": "#c0392b"
|
|
38
|
+
},
|
|
39
|
+
"consumer": {
|
|
40
|
+
"label": "Consumer co-op / credit union",
|
|
41
|
+
"color": "#2563eb"
|
|
42
|
+
},
|
|
43
|
+
"support": {
|
|
44
|
+
"label": "Co-op development support",
|
|
45
|
+
"color": "#1a7a4a"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"linkKinds": {
|
|
49
|
+
"money": {
|
|
50
|
+
"label": "Money \u2014 grant or loan fund",
|
|
51
|
+
"color": "#d4a017",
|
|
52
|
+
"weight": 3.5
|
|
53
|
+
},
|
|
54
|
+
"trade": {
|
|
55
|
+
"label": "Trade \u2014 supplies goods",
|
|
56
|
+
"color": "#1a7a4a",
|
|
57
|
+
"weight": 3.5
|
|
58
|
+
},
|
|
59
|
+
"develop": {
|
|
60
|
+
"label": "Built or helped build the co-op",
|
|
61
|
+
"color": "#8e5cc4",
|
|
62
|
+
"weight": 3.5,
|
|
63
|
+
"dash": "8 4"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"parcels": [
|
|
67
|
+
{
|
|
68
|
+
"id": "c2c",
|
|
69
|
+
"label": "Community to Community (C2C)",
|
|
70
|
+
"wikiTitle": "Community to Community C2C",
|
|
71
|
+
"type": "support",
|
|
72
|
+
"latLng": [
|
|
73
|
+
48.7505,
|
|
74
|
+
-122.4787
|
|
75
|
+
],
|
|
76
|
+
"contact": {
|
|
77
|
+
"website": "https://foodjustice.org",
|
|
78
|
+
"phone": "(360) 899-5641"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"id": "cfc",
|
|
83
|
+
"label": "Community Food Co-op",
|
|
84
|
+
"wikiTitle": "Community Food Co-op",
|
|
85
|
+
"type": "consumer",
|
|
86
|
+
"latLng": [
|
|
87
|
+
48.747,
|
|
88
|
+
-122.4765
|
|
89
|
+
],
|
|
90
|
+
"contact": {
|
|
91
|
+
"website": "https://communityfood.coop",
|
|
92
|
+
"phone": "(360) 734-8158"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "tyl",
|
|
97
|
+
"label": "Cooperativa Tierra y Libertad",
|
|
98
|
+
"wikiTitle": "Cooperativa Tierra y Libertad",
|
|
99
|
+
"type": "worker",
|
|
100
|
+
"latLng": [
|
|
101
|
+
48.8769,
|
|
102
|
+
-122.4344
|
|
103
|
+
],
|
|
104
|
+
"contact": {
|
|
105
|
+
"website": "https://www.instagram.com/tierraylibertad_coop/"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"links": [
|
|
110
|
+
{
|
|
111
|
+
"from": "cfc",
|
|
112
|
+
"to": "c2c",
|
|
113
|
+
"kind": "money",
|
|
114
|
+
"label": "Farm Fund grant \u2014 co-op development for farmworkers"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"from": "c2c",
|
|
118
|
+
"to": "tyl",
|
|
119
|
+
"kind": "develop",
|
|
120
|
+
"label": "Organised and incubated the co-op; led the land fundraising"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"from": "tyl",
|
|
124
|
+
"to": "cfc",
|
|
125
|
+
"kind": "trade",
|
|
126
|
+
"label": "Supplies produce"
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"type": "paragraph",
|
|
133
|
+
"text": "Walks. A map made from an RCN Map issue can carry walks: a reading of the map, one step at a time. Press \u25b6 Walk under the map. Each step flies the map to the points and ties it is about, names those points, fades the rest (the ones already visited stay half lit) and reads one or two sentences aloud, shown as a caption too. Space plays or pauses, \u2190 and \u2192 step, Esc stops. Voice on or off and the choice of voice are kept in this browser and shared with the Graph Tool and Timeline walks. Walks are written in the RCN Map (\ud83d\udeb6 Walk, then \u270e Edit) and copied into the item's map; a LINEUP or frozen map plays none, because its points are gathered from other pages.",
|
|
134
|
+
"id": "acad2aaf540683fe"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"type": "paragraph",
|
|
138
|
+
"id": "22dca488818d034f",
|
|
139
|
+
"text": "Coming next: an Open in RCN Map button that saves back into the item, and shared layers referenced by address. Plan: docs/rcn-map-plugin-plan.md in the rcn repository."
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"type": "markdown",
|
|
143
|
+
"id": "c78d043e4730c15f",
|
|
144
|
+
"text": "*Marc Pierson and Claude Opus 5.5 \u00b7 October 2026*",
|
|
145
|
+
"attribution": true
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"journal": [
|
|
149
|
+
{
|
|
150
|
+
"type": "create",
|
|
151
|
+
"item": {
|
|
152
|
+
"title": "About Rcnmap Plugin",
|
|
153
|
+
"story": []
|
|
154
|
+
},
|
|
155
|
+
"date": 1790643282153,
|
|
156
|
+
"author": "Marc Pierson with Claude Opus 5.5"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"type": "add",
|
|
160
|
+
"id": "746273db7898005b",
|
|
161
|
+
"item": {
|
|
162
|
+
"type": "paragraph",
|
|
163
|
+
"text": "The RCN Map plugin puts a small map on a wiki page that draws points and the ties between them. Each point is coloured by its kind and each tie by its kind of link, with a legend under the map. Hover a point for its name and kind; click it and that page opens in the lineup beside this one.",
|
|
164
|
+
"id": "746273db7898005b"
|
|
165
|
+
},
|
|
166
|
+
"date": 1790643282154
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"type": "add",
|
|
170
|
+
"id": "8dcaffbd1fad8a51",
|
|
171
|
+
"item": {
|
|
172
|
+
"type": "paragraph",
|
|
173
|
+
"text": "FedWiki\u2019s own Map plugin draws points only. The full RCN Map is a full-screen tool that lives in a site\u2019s assets. This plugin sits between them: the item carries its own subject, a few KB in the RCN Map issue-file shape, and draws it in the page column.",
|
|
174
|
+
"id": "8dcaffbd1fad8a51"
|
|
175
|
+
},
|
|
176
|
+
"date": 1790643282155,
|
|
177
|
+
"after": "746273db7898005b"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"type": "add",
|
|
181
|
+
"id": "9f943464d295f7ea",
|
|
182
|
+
"item": {
|
|
183
|
+
"type": "paragraph",
|
|
184
|
+
"text": "Editing the item. Double-click to open the text editor. The first line of the text is the caption; the rest lists the points and ties in plain words, so wiki search finds them. The points and ties themselves live in the item\u2019s map field. A new item from the Factory has no map field yet: type lines of the form 48.75, -122.48 Name and each becomes a point, as in the native Map plugin.",
|
|
185
|
+
"id": "9f943464d295f7ea"
|
|
186
|
+
},
|
|
187
|
+
"date": 1790643282156,
|
|
188
|
+
"after": "8dcaffbd1fad8a51"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"type": "add",
|
|
192
|
+
"id": "5c2d5213900ae62a",
|
|
193
|
+
"item": {
|
|
194
|
+
"type": "paragraph",
|
|
195
|
+
"text": "Below: Community to Community and the co-ops it is tied to, from the Co-ops of Whatcom County pages.",
|
|
196
|
+
"id": "5c2d5213900ae62a"
|
|
197
|
+
},
|
|
198
|
+
"date": 1790643282157,
|
|
199
|
+
"after": "9f943464d295f7ea"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"type": "add",
|
|
203
|
+
"id": "f0ab1e2536632919",
|
|
204
|
+
"item": {
|
|
205
|
+
"type": "rcnmap",
|
|
206
|
+
"id": "f0ab1e2536632919",
|
|
207
|
+
"text": "Community to Community C2C and the 2 co-ops it is tied to. Click a point for its page.\nCommunity to Community C2C \u2014 Co-op development support\nCommunity Food Co-op \u2014 Consumer co-op / credit union\nCooperativa Tierra y Libertad \u2014 Worker co-op\nCommunity Food Co-op \u2192 Community to Community C2C: Farm Fund grant \u2014 co-op development for farmworkers\nCommunity to Community C2C \u2192 Cooperativa Tierra y Libertad: Organised and incubated the co-op; led the land fundraising\nCooperativa Tierra y Libertad \u2192 Community Food Co-op: Supplies produce",
|
|
208
|
+
"map": {
|
|
209
|
+
"types": {
|
|
210
|
+
"worker": {
|
|
211
|
+
"label": "Worker co-op",
|
|
212
|
+
"color": "#c0392b"
|
|
213
|
+
},
|
|
214
|
+
"consumer": {
|
|
215
|
+
"label": "Consumer co-op / credit union",
|
|
216
|
+
"color": "#2563eb"
|
|
217
|
+
},
|
|
218
|
+
"support": {
|
|
219
|
+
"label": "Co-op development support",
|
|
220
|
+
"color": "#1a7a4a"
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
"linkKinds": {
|
|
224
|
+
"money": {
|
|
225
|
+
"label": "Money \u2014 grant or loan fund",
|
|
226
|
+
"color": "#d4a017",
|
|
227
|
+
"weight": 3.5
|
|
228
|
+
},
|
|
229
|
+
"trade": {
|
|
230
|
+
"label": "Trade \u2014 supplies goods",
|
|
231
|
+
"color": "#1a7a4a",
|
|
232
|
+
"weight": 3.5
|
|
233
|
+
},
|
|
234
|
+
"develop": {
|
|
235
|
+
"label": "Built or helped build the co-op",
|
|
236
|
+
"color": "#8e5cc4",
|
|
237
|
+
"weight": 3.5,
|
|
238
|
+
"dash": "8 4"
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
"parcels": [
|
|
242
|
+
{
|
|
243
|
+
"id": "c2c",
|
|
244
|
+
"label": "Community to Community (C2C)",
|
|
245
|
+
"wikiTitle": "Community to Community C2C",
|
|
246
|
+
"type": "support",
|
|
247
|
+
"latLng": [
|
|
248
|
+
48.7505,
|
|
249
|
+
-122.4787
|
|
250
|
+
],
|
|
251
|
+
"contact": {
|
|
252
|
+
"website": "https://foodjustice.org",
|
|
253
|
+
"phone": "(360) 899-5641"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"id": "cfc",
|
|
258
|
+
"label": "Community Food Co-op",
|
|
259
|
+
"wikiTitle": "Community Food Co-op",
|
|
260
|
+
"type": "consumer",
|
|
261
|
+
"latLng": [
|
|
262
|
+
48.747,
|
|
263
|
+
-122.4765
|
|
264
|
+
],
|
|
265
|
+
"contact": {
|
|
266
|
+
"website": "https://communityfood.coop",
|
|
267
|
+
"phone": "(360) 734-8158"
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"id": "tyl",
|
|
272
|
+
"label": "Cooperativa Tierra y Libertad",
|
|
273
|
+
"wikiTitle": "Cooperativa Tierra y Libertad",
|
|
274
|
+
"type": "worker",
|
|
275
|
+
"latLng": [
|
|
276
|
+
48.8769,
|
|
277
|
+
-122.4344
|
|
278
|
+
],
|
|
279
|
+
"contact": {
|
|
280
|
+
"website": "https://www.instagram.com/tierraylibertad_coop/"
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
],
|
|
284
|
+
"links": [
|
|
285
|
+
{
|
|
286
|
+
"from": "cfc",
|
|
287
|
+
"to": "c2c",
|
|
288
|
+
"kind": "money",
|
|
289
|
+
"label": "Farm Fund grant \u2014 co-op development for farmworkers"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"from": "c2c",
|
|
293
|
+
"to": "tyl",
|
|
294
|
+
"kind": "develop",
|
|
295
|
+
"label": "Organised and incubated the co-op; led the land fundraising"
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"from": "tyl",
|
|
299
|
+
"to": "cfc",
|
|
300
|
+
"kind": "trade",
|
|
301
|
+
"label": "Supplies produce"
|
|
302
|
+
}
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
"date": 1790643282158,
|
|
307
|
+
"after": "5c2d5213900ae62a"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"type": "add",
|
|
311
|
+
"id": "acad2aaf540683fe",
|
|
312
|
+
"item": {
|
|
313
|
+
"type": "paragraph",
|
|
314
|
+
"text": "Walks. A map made from an RCN Map issue can carry walks: a reading of the map, one step at a time. Press \u25b6 Walk under the map. Each step flies the map to the points and ties it is about, names those points, fades the rest (the ones already visited stay half lit) and reads one or two sentences aloud, shown as a caption too. Space plays or pauses, \u2190 and \u2192 step, Esc stops. Voice on or off and the choice of voice are kept in this browser and shared with the Graph Tool and Timeline walks. Walks are written in the RCN Map (\ud83d\udeb6 Walk, then \u270e Edit) and copied into the item's map; a LINEUP or frozen map plays none, because its points are gathered from other pages.",
|
|
315
|
+
"id": "acad2aaf540683fe"
|
|
316
|
+
},
|
|
317
|
+
"date": 1790643282159,
|
|
318
|
+
"after": "f0ab1e2536632919"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"type": "add",
|
|
322
|
+
"id": "c78d043e4730c15f",
|
|
323
|
+
"item": {
|
|
324
|
+
"type": "markdown",
|
|
325
|
+
"id": "c78d043e4730c15f",
|
|
326
|
+
"text": "*Marc Pierson and Claude Opus 5.5 \u00b7 October 2026*",
|
|
327
|
+
"attribution": true
|
|
328
|
+
},
|
|
329
|
+
"date": 1790643282317,
|
|
330
|
+
"after": "acad2aaf540683fe"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"type": "add",
|
|
334
|
+
"id": "a4ef6e3499d86014",
|
|
335
|
+
"item": {
|
|
336
|
+
"type": "paragraph",
|
|
337
|
+
"id": "a4ef6e3499d86014",
|
|
338
|
+
"text": "See [https://github.com/marpie1/rcn/tree/master/wiki-plugin-rcnmap GitHub] for plugin source."
|
|
339
|
+
},
|
|
340
|
+
"after": "746273db7898005b",
|
|
341
|
+
"date": 1791164815533
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"type": "add",
|
|
345
|
+
"id": "22dca488818d034f",
|
|
346
|
+
"item": {
|
|
347
|
+
"type": "paragraph",
|
|
348
|
+
"id": "22dca488818d034f",
|
|
349
|
+
"text": "Coming next: an Open in RCN Map button that saves back into the item, and shared layers referenced by address. Plan: docs/rcn-map-plugin-plan.md in the rcn repository."
|
|
350
|
+
},
|
|
351
|
+
"after": "acad2aaf540683fe",
|
|
352
|
+
"date": 1792642784633
|
|
353
|
+
}
|
|
354
|
+
]
|
|
355
|
+
}
|