kinsite 0.3.0 → 0.5.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 +238 -1
- package/build.mjs +29 -8
- package/lib/build.mjs +26 -4
- package/lib/config.mjs +6 -1
- package/lib/css.mjs +21 -2
- package/lib/diff.mjs +266 -0
- package/lib/gedcom.mjs +66 -12
- package/lib/hourglass.mjs +4 -2
- package/lib/kin.mjs +2 -1
- package/lib/living.mjs +15 -5
- package/lib/media.mjs +74 -0
- package/lib/news.mjs +175 -0
- package/lib/render.mjs +111 -20
- package/package.json +2 -1
- package/scripts/dev.mjs +56 -0
- package/scripts/serve.mjs +56 -0
- package/scripts/who.mjs +595 -0
package/README.md
CHANGED
|
@@ -14,6 +14,10 @@ Needs Node 22 or later; no dependencies. Live demo: https://chrismo.github.io/ki
|
|
|
14
14
|
node build.mjs sample/kinsite.config.json # build the fictional sample tree into site/
|
|
15
15
|
open site/index.html
|
|
16
16
|
npm run dev # preview the sample at http://localhost:4000 (PORT=... to change); rebuilds and reloads on edits
|
|
17
|
+
npm run dev -- my/kinsite.config.json # the same for your own tree; /who places people in photos (see "Photos")
|
|
18
|
+
npx kinsite dev my/kinsite.config.json # the same, with kinsite installed from npm
|
|
19
|
+
node build.mjs diff sample/kinsite.config.json old.ged # what changed on the site since old.ged (see "What changed")
|
|
20
|
+
node build.mjs news stamp kinsite.config.json old.ged # record a deploy's changes for the What's new page (see "What's new")
|
|
17
21
|
npm test
|
|
18
22
|
```
|
|
19
23
|
|
|
@@ -39,9 +43,12 @@ For your own tree, write a `kinsite.config.json` next to your GEDCOM:
|
|
|
39
43
|
| `anonymizeLiving` | Show living people only as "Private", for a public site (see Goals) | `false` |
|
|
40
44
|
| `citations` | Show source citations on person pages; event notes follow `notes` | `true` |
|
|
41
45
|
| `notes` | Show person and event notes; a citation's own notes go with the citation | `true` |
|
|
46
|
+
| `news` | Directory of What's new entries and stamped changes (see "What's new") | unset: no page |
|
|
47
|
+
| `who` | Directory for identify-mode sessions (see "Photos") | `who` |
|
|
42
48
|
|
|
43
49
|
Relative paths resolve against the config file's directory. `FOCUS=I3` or `OUT=dir` in
|
|
44
|
-
the environment override the config for one run.
|
|
50
|
+
the environment override the config for one run. `SINCE=old.ged` previews unpublished
|
|
51
|
+
changes on the What's new page; it is never a config key (see "What's new"). The build log says what was
|
|
45
52
|
published, e.g. `published : citations shown, notes hidden, living anonymized`.
|
|
46
53
|
|
|
47
54
|
### A research site or a public site
|
|
@@ -95,6 +102,232 @@ quoted text of the record. Citations on the person record or on the name shown a
|
|
|
95
102
|
listed under Sources at the foot of the page. Marriages don't show notes or citations
|
|
96
103
|
yet.
|
|
97
104
|
|
|
105
|
+
## Parent families
|
|
106
|
+
|
|
107
|
+
A person listed as a child in more than one family (several `FAMC`) gets one main
|
|
108
|
+
parent family: the first `FAMC` in file order that points at a family in the file and isn't marked
|
|
109
|
+
`STAT DISPROVEN`. `PROVEN`
|
|
110
|
+
is shown as a label but doesn't reorder anything. Parents, Siblings, the chart and the
|
|
111
|
+
"Path to" breadcrumb all use the main family. The other families are listed under
|
|
112
|
+
Parents as "Also listed as a child of …", labeled with their `PEDI` (adopted, foster,
|
|
113
|
+
birth, or the `PHRASE` of `PEDI OTHER`) and `STAT`; the main family gets a label too
|
|
114
|
+
when it has a `PEDI` other than `BIRTH`, or a `STAT`. On those other parents' pages the
|
|
115
|
+
child is listed with a pointer to the main parents.
|
|
116
|
+
|
|
117
|
+
With `anonymizeLiving`, `DISPROVEN` families are left out, and a living person appears
|
|
118
|
+
only in their main family, with no `PEDI` or `STAT`.
|
|
119
|
+
|
|
120
|
+
The build warns about links recorded on one side only, such as a `FAMC` with no
|
|
121
|
+
matching `CHIL`, a `CHIL` with no `FAMC`, or the same for `FAMS` and `HUSB`/`WIFE`:
|
|
122
|
+
`warning: F2 CHIL @I7@ has no matching FAMC in I7`. A child link recorded on one side
|
|
123
|
+
still shows on both, labeled with the side that recorded it ("on the family record only"
|
|
124
|
+
or "on the child's record only"), so the child stays in the chart and the "Path to"
|
|
125
|
+
line. A child's own `FAMC` comes before a link found only on a family's `CHIL` when
|
|
126
|
+
choosing the main family. Add the missing line to the file to clear the label and the
|
|
127
|
+
warning.
|
|
128
|
+
|
|
129
|
+
## Photos
|
|
130
|
+
|
|
131
|
+
A person's page shows each image linked by an `OBJE` pointer, captioned by the `OBJE`
|
|
132
|
+
record's `TITL`, and lists other files as documents. Files are copied into the site as
|
|
133
|
+
they are.
|
|
134
|
+
|
|
135
|
+
**One person in a group photo.** A `CROP` under the person's `OBJE` link marks their
|
|
136
|
+
part of a shared image. A `TITL` there adds a line under the photo's title for that
|
|
137
|
+
person, and the image's alt text names them, as in "Corwin Quill in The harvest show":
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
0 @I3@ INDI
|
|
141
|
+
1 OBJE @O2@
|
|
142
|
+
2 CROP
|
|
143
|
+
3 TOP 100
|
|
144
|
+
3 LEFT 100
|
|
145
|
+
3 HEIGHT 180
|
|
146
|
+
3 WIDTH 140
|
|
147
|
+
2 TITL Corwin, far left
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The page shows just that region, at most 260px tall. Values
|
|
151
|
+
are pixels of the photo as it's shown, upright: for a JPEG that a phone saved sideways
|
|
152
|
+
with an Exif orientation, measure the turned picture, the way browsers and photo apps
|
|
153
|
+
display it. Sizes are read from JPEG, PNG, GIF and WebP files. A missing `LEFT` or `TOP` is 0, and a missing `WIDTH`
|
|
154
|
+
or `HEIGHT` runs to the edge. A crop that runs past the edge is cut off there. If the
|
|
155
|
+
size can't be read from the file, or no part of the crop is inside it, the page shows the
|
|
156
|
+
whole image. Placing or moving a crop isn't listed on What's new.
|
|
157
|
+
|
|
158
|
+
**A page for each shared photo.** An image that two or more people link to, or that
|
|
159
|
+
anyone has a `CROP` of, gets a page of its own, and each of those people's thumbnails
|
|
160
|
+
links to it. The page shows the whole image with a faint numbered outline on each
|
|
161
|
+
cropped person; hovering or focusing an outline shows their name and the link's `TITL`,
|
|
162
|
+
so a caption like "(unconfirmed)" says how sure the placement is. Below it, "In this
|
|
163
|
+
photo" lists the outlined people by number, left to right, and "Also in this photo (not
|
|
164
|
+
yet placed)" lists the people linked without a crop, so readers can see who still needs
|
|
165
|
+
a place. With `anonymizeLiving`, a photo shared with a living person is withheld from
|
|
166
|
+
everyone, so it has no page.
|
|
167
|
+
|
|
168
|
+
**Placing people in a photo.** While `npm run dev` (or `kinsite dev`) runs, http://localhost:4000/who lists
|
|
169
|
+
every image `OBJE` in the GEDCOM, linked to anyone or not, with how many people are
|
|
170
|
+
placed and how many are still to place. Open one to identify who's in it:
|
|
171
|
+
|
|
172
|
+
- Drag on the photo to draw a box around someone. Drag a box to move it, or its
|
|
173
|
+
corner to resize it.
|
|
174
|
+
- Pick a box to see a close-up of it, and search for who it is. The search lists the
|
|
175
|
+
people linked to the photo first, then the people alive in the year it was taken.
|
|
176
|
+
That year comes from the first four-digit number in the `OBJE` title, and you can
|
|
177
|
+
change it on the page.
|
|
178
|
+
- An answer can also be "Someone not in the tree" or "Not sure". "This is a guess"
|
|
179
|
+
marks a name you aren't sure of. Each box has a caption, which becomes the link's
|
|
180
|
+
`TITL`, and notes.
|
|
181
|
+
- The lists below the photo sort the boxes into placed, guessed, unknown and to place.
|
|
182
|
+
People linked to the photo who have no box yet count as to place.
|
|
183
|
+
- "For your GEDCOM" gives the `OBJE` link lines, with `CROP` and `TITL`, for each placed
|
|
184
|
+
person whose link is new or differs from the GEDCOM. Copy them into your genealogy
|
|
185
|
+
app, or under that person's record in the file.
|
|
186
|
+
|
|
187
|
+
kinsite never writes the GEDCOM. A photo's boxes, answers and notes save as you go to
|
|
188
|
+
`<OBJE id>.json` in the config's `who` folder, such as `who/O2.json`. Guesses, unknowns
|
|
189
|
+
and notes stay only in that file, and committing it is up to you.
|
|
190
|
+
|
|
191
|
+
A new session starts from the crops already in the GEDCOM. The session also remembers
|
|
192
|
+
the GEDCOM's crops as it last saw them. If you then move or add a crop in your
|
|
193
|
+
genealogy app, the next visit takes the new crop for that person's box and says so.
|
|
194
|
+
Boxes you've changed and not yet pasted are kept. The session also records the
|
|
195
|
+
photo's file. If the `OBJE` with that ID now names a different file, as happens when
|
|
196
|
+
an app renumbers IDs on export, the page warns you and saves nothing until you
|
|
197
|
+
either move that session aside or say its boxes are for this photo.
|
|
198
|
+
The page shows the whole tree, living people included, so it answers only on your
|
|
199
|
+
own machine, at `localhost`.
|
|
200
|
+
|
|
201
|
+
## What changed
|
|
202
|
+
|
|
203
|
+
Before deploying, `kinsite diff kinsite.config.json old.ged` compares an older GEDCOM
|
|
204
|
+
with the config's current one and prints one sentence per change, grouped by person.
|
|
205
|
+
It builds nothing and never touches git: getting `old.ged`, from a tag, a backup or
|
|
206
|
+
anywhere else, is up to you.
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
Ada Fenwick (I1)
|
|
210
|
+
Changed birth date from 1859 to about 1858
|
|
211
|
+
Added: residence 1880, Marrowby
|
|
212
|
+
Now listed as a child of Tobias Fenwick and Mara Quill
|
|
213
|
+
Removed: Jonas Pell (I9) and his marriage to Ada Fenwick
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
It reports what changed on the site, not in the GEDCOM: people and marriages added or
|
|
217
|
+
removed, the name shown, events, notes, citations, photos and documents (by `FILE`),
|
|
218
|
+
marriage date and place, and parent families with their `PEDI` and `STAT`. A child whose
|
|
219
|
+
main parent family changes gets one "Now listed as a child of …" line. Tags the site
|
|
220
|
+
doesn't show never appear, and neither do marriage notes and citations.
|
|
221
|
+
|
|
222
|
+
GEDCOM facts have no IDs, so versions of one event on one person (and one `TYPE`, for
|
|
223
|
+
`EVEN`) are matched like this: identical versions are unchanged; the rest are paired in
|
|
224
|
+
file order when they share a date or a place, and read as changed; anything left over
|
|
225
|
+
was added or removed. A fact whose date and place both changed reads as one removal and
|
|
226
|
+
one addition. Notes are matched by text, and citations by source and page, so
|
|
227
|
+
retitling a `SOUR` record changes nothing.
|
|
228
|
+
|
|
229
|
+
The list follows the config's privacy settings, so the same two files can be checked
|
|
230
|
+
against a research site and a public site. With `anonymizeLiving`, nothing is said
|
|
231
|
+
about a Private person, including links to them, or about media of theirs or media
|
|
232
|
+
shared with them; a removed person is named only if they would not be Private; and
|
|
233
|
+
removals name only what kind of thing went ("Removed a burial record"), not what it
|
|
234
|
+
said. With `notes` or `citations` off, there are no note or citation lines. Versions
|
|
235
|
+
marked `RESN PRIVACY` or `CONFIDENTIAL` never appear, and all text is redacted as on
|
|
236
|
+
the site.
|
|
237
|
+
|
|
238
|
+
Most of this rests on xrefs staying the same, as stable URLs already do. If more than
|
|
239
|
+
half of `old.ged`'s people are missing from the new file, the command stops with
|
|
240
|
+
`error: xrefs look renumbered` rather than reporting the whole tree as removed and
|
|
241
|
+
re-added.
|
|
242
|
+
|
|
243
|
+
## What's new
|
|
244
|
+
|
|
245
|
+
Set `"news": "news"` in the config to publish a `whats-new.html` page that relatives
|
|
246
|
+
can read: what you worked on, in your own words, then what changed on the site, with
|
|
247
|
+
links to the people. The index links to it. With `news` unset, nothing changes.
|
|
248
|
+
|
|
249
|
+
**Entries.** Each `.md` file in the directory is one entry, written while doing the
|
|
250
|
+
research. Mention people by xref:
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
# The two Ada Fenwicks
|
|
254
|
+
|
|
255
|
+
Sorted out the two Adas in Marrowby. @I1@ is the one who married
|
|
256
|
+
@I9@; the *other* Ada was her cousin. See https://example.org/marrowby-1880.
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Entries use a small subset of Markdown: an optional `# Title` first line, paragraphs
|
|
260
|
+
separated by a blank line, `*emphasis*`, `**strong**`, `[text](https://…)` links and
|
|
261
|
+
bare http(s) URLs, and `@I12@` mentions. Anything else, raw HTML included, shows as
|
|
262
|
+
plain text, and only http(s) links become links. All text is redacted as on the site.
|
|
263
|
+
A mention links to the person, or reads "Private" with no link when they are Private
|
|
264
|
+
in this build; a mention of an xref that isn't in the tree is left as written, and the
|
|
265
|
+
build warns. An entry is free text, though: like a note, it can still name a living
|
|
266
|
+
person in words, and nothing hides that.
|
|
267
|
+
|
|
268
|
+
**Stamping a deploy.** `kinsite news stamp kinsite.config.json old.ged` runs the "What
|
|
269
|
+
changed" diff between `old.ged` and the config's GEDCOM and writes one file per deploy,
|
|
270
|
+
such as `news/2026-11-14.changes.json` (`-2`, `-3`, … for later deploys that day):
|
|
271
|
+
|
|
272
|
+
```json
|
|
273
|
+
{ "date": "2026-11-14", "entries": ["pell-family", "two-adas"], "changes": [ … ] }
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Every entry not yet listed in a changes file is included, so entries written during one
|
|
277
|
+
round of research share one change list. A deploy with changes but no entry still gets a
|
|
278
|
+
file, and shows on the page with only its date. With no changes and no new entries, the
|
|
279
|
+
command writes nothing. Entries are never edited; whether one is waiting is decided by
|
|
280
|
+
the changes files. To drop a line, delete its record from `changes`; to reword
|
|
281
|
+
something, say it in an entry.
|
|
282
|
+
|
|
283
|
+
**The page.** Deploys are listed newest first: the date, the entries in file-name order,
|
|
284
|
+
then the change list. The sentences are written at each build from the stored records,
|
|
285
|
+
under that build's privacy settings, as `kinsite diff` would, so one `news/` directory
|
|
286
|
+
can feed a research site and a public site. A person later found to be living, or a fact
|
|
287
|
+
later marked `RESN PRIVACY` or `CONFIDENTIAL`, drops out of past deploys on the next
|
|
288
|
+
rebuild, and a deploy left with nothing to show is left off. Entries not yet stamped
|
|
289
|
+
aren't shown. The build log says, for example,
|
|
290
|
+
`news : 4 deploys, 2 entries not yet stamped`.
|
|
291
|
+
|
|
292
|
+
**Previewing the next deploy.** To read the next entry as it will appear, build with
|
|
293
|
+
`SINCE` set to the GEDCOM that's live now:
|
|
294
|
+
|
|
295
|
+
```sh
|
|
296
|
+
SINCE=old.ged node build.mjs kinsite.config.json
|
|
297
|
+
SINCE=old.ged npm run dev -- kinsite.config.json # rebuilds as the GEDCOM and the entries change
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
`whats-new.html` then starts with a "Not yet published" section: every entry not yet
|
|
301
|
+
stamped, followed by a fresh "What changed" diff between `old.ged` and the config's
|
|
302
|
+
GEDCOM, under the same privacy settings as the rest of the page. The build log says
|
|
303
|
+
`news : previewing changes since old.ged`. `SINCE` is only ever an environment
|
|
304
|
+
variable, never a config key, so a deploy can't publish the preview by accident; and
|
|
305
|
+
with the recipe below (stamp, then build) nothing is pending at deploy anyway.
|
|
306
|
+
|
|
307
|
+
**Updated notes.** A person page shows "Updated 14 Nov 2026" under the name, linking to
|
|
308
|
+
that deploy on the page (`whats-new.html#2026-11-14`). The date is the latest deploy that,
|
|
309
|
+
under this build's rules, lists a change under the person or has an entry mentioning
|
|
310
|
+
them, so a line that isn't shown can't date-stamp a page. Private people never get the
|
|
311
|
+
note, entries not yet stamped don't count, and the note doesn't age out. When building
|
|
312
|
+
with `SINCE`, a person changed or mentioned in the preview also gets a "Changed since
|
|
313
|
+
last deploy" link to the "Not yet published" section.
|
|
314
|
+
|
|
315
|
+
**Sharing one deploy.** Each dated heading on What's new has a faint `#` link to
|
|
316
|
+
itself, in the left margin (beside the date on a phone), so a reader can copy the link
|
|
317
|
+
to one deploy's news and send it to a relative. "Not yet published" has none.
|
|
318
|
+
|
|
319
|
+
**A deploy recipe.** kinsite never touches git; this is one way to run it:
|
|
320
|
+
|
|
321
|
+
1. Get the GEDCOM that's live now, as `old.ged`.
|
|
322
|
+
2. `kinsite news stamp kinsite.config.json old.ged`
|
|
323
|
+
3. Build.
|
|
324
|
+
4. Commit `news/`.
|
|
325
|
+
5. Deploy.
|
|
326
|
+
6. Record the GEDCOM you just deployed as the new live version.
|
|
327
|
+
|
|
328
|
+
Links to individual facts aren't possible: a fact has no ID that survives a rebuild.
|
|
329
|
+
Marriage notes and citations aren't covered, as in "What changed".
|
|
330
|
+
|
|
98
331
|
## Goals
|
|
99
332
|
|
|
100
333
|
- **Static output only.** No server, no database. JavaScript in the browser is fine,
|
|
@@ -116,6 +349,10 @@ yet.
|
|
|
116
349
|
whole tree shrunk until the text is useless.
|
|
117
350
|
- **Works on a phone.**
|
|
118
351
|
- **Stable URLs.** A person keeps the same page address across rebuilds.
|
|
352
|
+
- **Show the file as recorded.** kinsite never adds a relationship or fact the GEDCOM
|
|
353
|
+
doesn't state. When the file contradicts itself or is ambiguous, it shows what each
|
|
354
|
+
record says, labeled where GEDCOM provides labels, and the build log warns. Fixing
|
|
355
|
+
the data is the owner's call, not the generator's.
|
|
119
356
|
|
|
120
357
|
## Contributing
|
|
121
358
|
|
package/build.mjs
CHANGED
|
@@ -5,17 +5,38 @@
|
|
|
5
5
|
// node build.mjs path/to/kinsite.config.json
|
|
6
6
|
// FOCUS=I3 node build.mjs kinsite.config.json # re-center on another person
|
|
7
7
|
// OUT=/tmp/site node build.mjs kinsite.config.json
|
|
8
|
+
// SINCE=old.ged node build.mjs kinsite.config.json # preview unstamped news on What's new
|
|
9
|
+
// node build.mjs diff kinsite.config.json old.ged # what changed on the site since old.ged
|
|
10
|
+
// node build.mjs news stamp kinsite.config.json old.ged # record this deploy's changes for What's new
|
|
11
|
+
// node build.mjs dev kinsite.config.json # preview at localhost, rebuilt on change; /who places people in photos
|
|
8
12
|
import { loadConfig } from './lib/config.mjs'
|
|
9
13
|
import { buildSite } from './lib/build.mjs'
|
|
14
|
+
import { changeReport } from './lib/diff.mjs'
|
|
15
|
+
import { stampNews } from './lib/news.mjs'
|
|
10
16
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
const USAGE = `usage: kinsite path/to/kinsite.config.json
|
|
18
|
+
kinsite diff path/to/kinsite.config.json old.ged
|
|
19
|
+
kinsite news stamp path/to/kinsite.config.json old.ged
|
|
20
|
+
kinsite dev path/to/kinsite.config.json`
|
|
21
|
+
const [first, ...rest] = process.argv.slice(2)
|
|
22
|
+
const [cmd, file, old] = first === 'diff' ? [first, ...rest]
|
|
23
|
+
: first === 'dev' ? [first, rest[0]]
|
|
24
|
+
: first === 'news' ? (rest[0] === 'stamp' ? ['stamp', ...rest.slice(1)] : [])
|
|
25
|
+
: ['build', first]
|
|
26
|
+
if (!file || (cmd !== 'build' && cmd !== 'dev' && !old)) {
|
|
27
|
+
console.error(USAGE)
|
|
14
28
|
process.exit(2)
|
|
15
29
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
if (cmd === 'dev') {
|
|
31
|
+
process.argv = [...process.argv.slice(0, 2), file]
|
|
32
|
+
await import('./scripts/dev.mjs')
|
|
33
|
+
} else {
|
|
34
|
+
try {
|
|
35
|
+
if (cmd === 'diff') console.log(changeReport(loadConfig(file), old))
|
|
36
|
+
else if (cmd === 'stamp') stampNews(loadConfig(file), old)
|
|
37
|
+
else buildSite(loadConfig(file, { focus: process.env.FOCUS, out: process.env.OUT }), { since: process.env.SINCE })
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.error(`error: ${e.message}`)
|
|
40
|
+
process.exit(1)
|
|
41
|
+
}
|
|
21
42
|
}
|
package/lib/build.mjs
CHANGED
|
@@ -5,16 +5,24 @@ import { Kin } from './kin.mjs'
|
|
|
5
5
|
import { Renderer } from './render.mjs'
|
|
6
6
|
import { CSS } from './css.mjs'
|
|
7
7
|
import { anonymize } from './living.mjs'
|
|
8
|
+
import { readNews, newsSections, lastUpdated, whatsNewPage, count } from './news.mjs'
|
|
9
|
+
import { diffTrees, readGedcom } from './diff.mjs'
|
|
10
|
+
import { imageSize } from './media.mjs'
|
|
8
11
|
|
|
9
|
-
export
|
|
12
|
+
export const mediaSource = (f, mediaRoot) => (path.isAbsolute(f) && fs.existsSync(f) ? f : path.join(mediaRoot, f))
|
|
13
|
+
|
|
14
|
+
// since: an older GEDCOM to preview What's new against (the SINCE environment variable, never a config key).
|
|
15
|
+
export function buildSite(config, { log = console.log, since } = {}) {
|
|
10
16
|
const { gedcom, out, mediaRoot, title, focus, anonymizeLiving, citations = true, notes = true } = config
|
|
11
17
|
if (!fs.statSync(gedcom, { throwIfNoEntry: false })?.isFile()) throw new Error(`GEDCOM not found: ${gedcom}`)
|
|
18
|
+
if (since && !config.news) throw new Error('SINCE previews the What\'s new page, so the config needs "news" set')
|
|
19
|
+
const old = since && readGedcom(since)
|
|
12
20
|
const mediaOut = path.join(out, 'media')
|
|
13
21
|
const inside = (dir, f) => {
|
|
14
22
|
const rel = path.relative(dir, f)
|
|
15
23
|
return !path.isAbsolute(rel) && rel.split(path.sep)[0] !== '..'
|
|
16
24
|
}
|
|
17
|
-
for (const keep of [gedcom, mediaRoot]) {
|
|
25
|
+
for (const keep of [gedcom, mediaRoot, config.who].filter(Boolean)) {
|
|
18
26
|
if (inside(out, keep)) throw new Error(`refusing to delete ${out}: it contains ${keep}`)
|
|
19
27
|
}
|
|
20
28
|
|
|
@@ -24,6 +32,7 @@ export function buildSite(config, { log = console.log } = {}) {
|
|
|
24
32
|
fs.mkdirSync(mediaOut, { recursive: true })
|
|
25
33
|
|
|
26
34
|
const parsed = parseGedcom(fs.readFileSync(gedcom, 'utf8'))
|
|
35
|
+
for (const w of parsed.warnings) log(` warning: ${w}`)
|
|
27
36
|
const { indi, fam } = anonymizeLiving ? anonymize(parsed.indi, parsed.fam) : parsed
|
|
28
37
|
|
|
29
38
|
const copied = new Map()
|
|
@@ -32,7 +41,7 @@ export function buildSite(config, { log = console.log } = {}) {
|
|
|
32
41
|
for (const md of p.media) {
|
|
33
42
|
const f = md.file
|
|
34
43
|
if (!f || copied.has(f)) continue
|
|
35
|
-
const src =
|
|
44
|
+
const src = mediaSource(f, mediaRoot)
|
|
36
45
|
if (!isFile(src)) continue
|
|
37
46
|
const base = path.basename(f)
|
|
38
47
|
let dst = path.join(mediaOut, base)
|
|
@@ -46,18 +55,29 @@ export function buildSite(config, { log = console.log } = {}) {
|
|
|
46
55
|
copied.set(f, 'media/' + path.basename(dst))
|
|
47
56
|
}
|
|
48
57
|
}
|
|
58
|
+
const sizes = new Map()
|
|
59
|
+
for (const md of [...indi.values()].flatMap(p => p.media)) {
|
|
60
|
+
if (md.crop && copied.has(md.file) && !sizes.has(md.file)) {
|
|
61
|
+
sizes.set(md.file, imageSize(fs.readFileSync(path.join(out, copied.get(md.file)))))
|
|
62
|
+
}
|
|
63
|
+
}
|
|
49
64
|
|
|
50
65
|
fs.writeFileSync(path.join(out, 'style.css'), CSS)
|
|
51
66
|
|
|
52
67
|
const kin = new Kin(indi, fam, focus)
|
|
53
|
-
const
|
|
68
|
+
const news = config.news && readNews(config.news)
|
|
69
|
+
if (old) news.preview = { entries: news.pending, changes: diffTrees(old, parsed) }
|
|
70
|
+
const sections = news ? newsSections(news, indi, parsed, config, w => log(` warning: ${w}`)) : []
|
|
71
|
+
const r = new Renderer({ indi, fam, kin, copied, sizes, title, source: path.basename(gedcom), citations, notes, news: !!news, updated: lastUpdated(sections) })
|
|
54
72
|
let withPhoto = 0
|
|
55
73
|
for (const pid of indi.keys()) {
|
|
56
74
|
const page = r.personPage(pid)
|
|
57
75
|
if (page.withPhoto) withPhoto++
|
|
58
76
|
fs.writeFileSync(path.join(out, `${pid}.html`), page.html)
|
|
59
77
|
}
|
|
78
|
+
for (const oid of r.photos.keys()) fs.writeFileSync(path.join(out, `${oid}.html`), r.photoPage(oid))
|
|
60
79
|
fs.writeFileSync(path.join(out, 'index.html'), r.indexPage())
|
|
80
|
+
if (news) fs.writeFileSync(path.join(out, 'whats-new.html'), whatsNewPage(sections, r))
|
|
61
81
|
|
|
62
82
|
const stats = {
|
|
63
83
|
individuals: indi.size, families: fam.size, withPhoto, media: copied.size,
|
|
@@ -69,6 +89,8 @@ export function buildSite(config, { log = console.log } = {}) {
|
|
|
69
89
|
log(` media copied: ${stats.media}`)
|
|
70
90
|
const shown = on => (on ? 'shown' : 'hidden')
|
|
71
91
|
log(` published : citations ${shown(citations)}, notes ${shown(notes)}, living ${anonymizeLiving ? 'anonymized' : 'shown'}`)
|
|
92
|
+
if (news) log(` news : ${count(news.deploys.length, 'deploy')}, ${count(news.pending.length, 'entry', 'entries')} not yet stamped`)
|
|
93
|
+
if (old) log(` news : previewing changes since ${since}`)
|
|
72
94
|
log(`Wrote ${stats.pages} HTML pages.`)
|
|
73
95
|
log(`Open it: open "${path.join(out, 'index.html')}"`)
|
|
74
96
|
return stats
|
package/lib/config.mjs
CHANGED
|
@@ -11,8 +11,10 @@ export const DEFAULTS = {
|
|
|
11
11
|
anonymizeLiving: false,
|
|
12
12
|
citations: true,
|
|
13
13
|
notes: true,
|
|
14
|
+
news: null,
|
|
15
|
+
who: 'who',
|
|
14
16
|
}
|
|
15
|
-
const PATHS = ['gedcom', 'out', 'mediaRoot']
|
|
17
|
+
const PATHS = ['gedcom', 'out', 'mediaRoot', 'who']
|
|
16
18
|
const FLAGS = ['anonymizeLiving', 'citations', 'notes']
|
|
17
19
|
|
|
18
20
|
export function loadConfig(file, overrides = {}) {
|
|
@@ -26,7 +28,10 @@ export function loadConfig(file, overrides = {}) {
|
|
|
26
28
|
for (const k of FLAGS) {
|
|
27
29
|
if (typeof c[k] !== 'boolean') throw new Error(`${k} must be true or false, not ${JSON.stringify(c[k])} (in ${file})`)
|
|
28
30
|
}
|
|
31
|
+
if (typeof c.who !== 'string') throw new Error(`who must be a directory path, not ${JSON.stringify(c.who)} (in ${file})`)
|
|
32
|
+
if (c.news !== null && typeof c.news !== 'string') throw new Error(`news must be a directory path, not ${JSON.stringify(c.news)} (in ${file})`)
|
|
29
33
|
const base = path.dirname(path.resolve(file))
|
|
30
34
|
for (const k of PATHS) c[k] = path.resolve(base, c[k])
|
|
35
|
+
if (c.news) c.news = path.resolve(base, c.news)
|
|
31
36
|
return c
|
|
32
37
|
}
|
package/lib/css.mjs
CHANGED
|
@@ -2,12 +2,13 @@ export const CSS = `
|
|
|
2
2
|
:root{--ink:#222;--mut:#777;--line:#e3e0d8;--bg:#faf8f4;--accent:#7a5c3e}
|
|
3
3
|
*{box-sizing:border-box}
|
|
4
4
|
body{font:16px/1.55 -apple-system,Segoe UI,Roboto,sans-serif;color:var(--ink);
|
|
5
|
-
background:var(--bg);margin:0}
|
|
5
|
+
background:var(--bg);margin:0;overflow-wrap:break-word}
|
|
6
6
|
.wrap{max-width:820px;margin:0 auto;padding:24px}
|
|
7
7
|
h1{font-family:Georgia,serif;font-weight:700;margin:.2em 0}
|
|
8
8
|
a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}
|
|
9
9
|
.sub{color:var(--mut);margin:0 0 1.2em}
|
|
10
10
|
.back{font-size:.9em}
|
|
11
|
+
.updated{font-size:.85em;margin:0 0 .3em}
|
|
11
12
|
.card{background:#fff;border:1px solid var(--line);border-radius:10px;
|
|
12
13
|
padding:18px 20px;margin:14px 0}
|
|
13
14
|
.evt{margin:.15em 0}.lbl{display:inline-block;min-width:64px;color:var(--mut);
|
|
@@ -15,12 +16,30 @@ a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}
|
|
|
15
16
|
.yr{color:var(--mut);font-size:.9em}
|
|
16
17
|
.unknown{color:var(--mut)}
|
|
17
18
|
h2{font-size:.95em;text-transform:uppercase;letter-spacing:.05em;color:var(--mut);
|
|
18
|
-
border-bottom:1px solid var(--line);padding-bottom:4px;margin:1.4em 0 .6em}
|
|
19
|
+
border-bottom:1px solid var(--line);padding-bottom:4px;margin:1.4em 0 .6em;position:relative}
|
|
20
|
+
h2 a.self{position:absolute;left:-1.2em;color:var(--mut);opacity:.35}
|
|
21
|
+
h2 a.self:hover,h2 a.self:focus{opacity:1;text-decoration:none}
|
|
22
|
+
@media(max-width:880px){h2 a.self{position:static;margin-left:.5em}}
|
|
19
23
|
ul.rel{list-style:none;padding:0;margin:0}ul.rel li{margin:.2em 0}
|
|
20
24
|
.photos{display:flex;flex-wrap:wrap;gap:12px;margin:.4em 0}
|
|
21
25
|
.photos figure{margin:0;width:200px}
|
|
22
26
|
.photos img{width:100%;border:1px solid var(--line);border-radius:6px;display:block}
|
|
27
|
+
.photos a.crop{display:block;position:relative;overflow:hidden;border:1px solid var(--line);border-radius:6px}
|
|
28
|
+
.photos a.crop img{position:absolute;max-width:none;border:0;border-radius:0}
|
|
23
29
|
.photos figcaption{font-size:.8em;color:var(--mut);margin-top:4px}
|
|
30
|
+
.photos figcaption .cn{display:block;font-style:italic}
|
|
31
|
+
.stage{position:relative;margin:.5em 0 1em}
|
|
32
|
+
.stage img{display:block;width:100%;height:auto;border:1px solid var(--line);border-radius:8px}
|
|
33
|
+
.stage a.who{position:absolute;border:2px solid rgba(255,255,255,.7);border-radius:4px;box-shadow:0 0 0 1px rgba(0,0,0,.35)}
|
|
34
|
+
.stage a.who::after{content:'';position:absolute;inset:min(0px,calc((100% - 44px)/2))}
|
|
35
|
+
.stage a.who b{position:absolute;left:0;top:0;min-width:1.5em;padding:0 .25em;font-size:12px;line-height:1.5em;
|
|
36
|
+
text-align:center;color:#fff;background:rgba(0,0,0,.55);border-radius:0 0 3px 0}
|
|
37
|
+
.stage a.who span{display:none;position:absolute;top:100%;left:-2px;margin-top:4px;padding:2px 8px;z-index:1;
|
|
38
|
+
width:max-content;max-width:min(18em,45vw);font-size:.8em;color:#fff;background:var(--ink);border-radius:4px}
|
|
39
|
+
.stage a.who.r span{left:auto;right:-2px}
|
|
40
|
+
.stage a.who:hover,.stage a.who:focus{border-color:#fff;box-shadow:0 0 0 2px var(--accent);text-decoration:none}
|
|
41
|
+
.stage a.who:hover span,.stage a.who:focus span{display:block}
|
|
42
|
+
ol.placed{margin:0;padding-left:1.6em}ol.placed li{margin:.2em 0}
|
|
24
43
|
.docs a{display:inline-block;margin:.2em .6em .2em 0}
|
|
25
44
|
#q{width:100%;padding:10px 12px;font-size:1em;border:1px solid var(--line);
|
|
26
45
|
border-radius:8px;margin:.6em 0 .4em}
|