@tideworthy/tidysites 0.1.5 → 0.1.7

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 CHANGED
@@ -22,7 +22,7 @@ nothing else; it lives in `.tidysites/key`, which is kept out of git.
22
22
  | `tidysites status` | what changed here since the pull |
23
23
  | `tidysites validate` | every file against the content model, with the file and the field in each message |
24
24
  | `tidysites push [--prune] [--force] [--dry] [--only pages]` | validate, then write the created and updated entries back (with `--prune`, delete the entries whose files are gone), then pull |
25
- | `tidysites shot <path or url> [--mobile] [--tablet] [--desktop] [--wide] [--all] [--first-screen] [--live]` | a screenshot of a page of the preview site, the live site, or any address, saved under `.tidysites/shots/`; none of the width flags means desktop and mobile; a port compares all four |
25
+ | `tidysites shot <path or url> [--mobile] [--tablet] [--desktop] [--wide] [--all] [--first-screen] [--live]` | a screenshot of a page of the preview site, the live site, or any address, saved under `.tidysites/shots/`; none of the width flags means desktop and mobile; a port compares all four. A page taller than 2400px comes in 1600px bands (`<name>-band-01.jpg`, …), top to bottom, that an image reader can take in one at a time |
26
26
  | `tidysites pages` | every address the website renders |
27
27
  | `tidysites page <path> [--html]` | the rendered page, section by section, with the key each section carries |
28
28
  | `tidysites schema [type or collection]` | the section types and layouts, or one type's or collection's fields |
@@ -62,6 +62,10 @@ Images: an image field, a hero's image or a Columns image slot takes
62
62
  push fetches the file into the website's library. An image already in the
63
63
  library keeps the value the pull gave it.
64
64
 
65
+ A picture in custom HTML is written as a plain `<img src="{{ s.image.url }}" alt="{{ s.image.alt }}">`: a stored picture gets its resized variants (`srcset`, and a `sizes` hint when none is written) on the way out, so a phone downloads a phone-sized file; write your own `sizes` when the picture is narrower than half the screen on a laptop, and your own `srcset` to take over entirely. Pictures in the first section load at once and the first of them asks to go first; pictures below load when they are needed, unless the markup says `loading="eager"`.
66
+
67
+ Every form carries a hidden trap field a scraper fills and a person never sees. A Forms record or a Request form section can add Cloudflare Turnstile through its **Spam protection** field; it is off unless chosen, and when chosen its script loads only as the form comes into view or is touched.
68
+
65
69
  References: a record names another by its id (what the pull shows), or by
66
70
  `"$ref:<slug>"` for one created in the same push.
67
71
 
package/bin/tidysites.mjs CHANGED
@@ -7,7 +7,7 @@
7
7
  * status what changed here since the pull
8
8
  * validate check the files against the content model
9
9
  * push [--prune] [--force] [--dry] write the changes back, then pull
10
- * shot <path|url> [--mobile] [--tablet] [--desktop] [--wide] [--all] [--first-screen] screenshot to .tidysites/shots (none = desktop and mobile)
10
+ * shot <path|url> [--mobile] [--tablet] [--desktop] [--wide] [--all] [--first-screen] screenshot to .tidysites/shots (none = desktop and mobile); a tall page comes in 1600px bands
11
11
  * pages every address the website renders
12
12
  * page <path> [--html] the rendered page, section by section
13
13
  * schema [name] section types and layouts, or one type's or collection's fields
@@ -368,9 +368,12 @@ async function shot(ctx, target = positional[0] ?? '/', opts = {}) {
368
368
  const stamp = new Date().toISOString().replace(/[-:.]/g, '').slice(4, 18);
369
369
  const base = (opts.name ?? (isUrl ? new URL(target).hostname + new URL(target).pathname : target)).replace(/[^a-z0-9]+/gi, '-').replace(/^-|-$/g, '') || 'home';
370
370
  const named = Array.isArray(json?.captures) ? json.captures : [];
371
+ // The pictures come in the order of the captures: a tall page as its bands (top to bottom), a short one whole.
372
+ const slots = named.filter((c) => !c.error).flatMap((c) => (Array.isArray(c.bands) && c.bands.length ? c.bands.map((b) => ({ view: c.view, band: b.index })) : [{ view: c.view, band: 0 }]));
371
373
  images.forEach((img, i) => {
372
- const v = named[i]?.view ?? (view === 'both' ? ['desktop', 'mobile'][i] : view === 'all' ? ['desktop', 'mobile', 'tablet', 'wide'][i] : view.split(',')[i] ?? view);
373
- const p = join(outDir, `${base}-${v}-${stamp}.${img.mimeType.includes('png') ? 'png' : 'jpg'}`);
374
+ const v = slots[i]?.view ?? (view === 'both' ? ['desktop', 'mobile'][i] : view === 'all' ? ['desktop', 'mobile', 'tablet', 'wide'][i] : view.split(',')[i] ?? view);
375
+ const band = slots[i]?.band ? `-band-${String(slots[i].band).padStart(2, '0')}` : '';
376
+ const p = join(outDir, `${base}-${v}-${stamp}${band}.${img.mimeType.includes('png') ? 'png' : 'jpg'}`);
374
377
  writeFileSync(p, Buffer.from(img.base64, 'base64'));
375
378
  say(relative(process.cwd(), p));
376
379
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tideworthy/tidysites",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Pull a Tidysites website to files, edit, validate against its content model, push it back, screenshot the result.",
5
5
  "type": "module",
6
6
  "bin": {