Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ These are settled, in new media and old alike, and reopening one wastes a review

Treat that as a judgment about the archive, never as a precedent for a new post.

**Every archive redaction is data, never a hand edit.** [`checks/media-redactions.json`][redactions] names each file, its fills or crop, and why. [`scripts/redact-media.py`][redact] applies it after the metadata normalizer, and records the hash each file starts from and lands on. So a run is deterministic, and a second run changes nothing. [`checks/check-media-redactions.py`][redactions-check] fails the build on a declared file that is not at its redacted result. To change an entry, restore the file's original from history, run the metadata normalizer on it, edit the entry, and run `uv run --no-project --with-requirements scripts/requirements.txt scripts/redact-media.py --record`. A restored file that any committed revision of the manifest records as a result is refused, since it already carries an earlier round's fills. An unchanged entry can also stop reproducing, after a Pillow bump that moves the output. Re-record it the same way, deleting its `declared` digest rather than editing the entry.
**Every archive redaction is data, never a hand edit.** [`checks/media-redactions.json`][redactions] names each file, its fills or crop, and why. [`scripts/redact-media.py`][redact] applies it after the metadata normalizer, and records the hash each file starts from and lands on. So a run is deterministic, and a second run changes nothing. [`checks/check-media-redactions.py`][redactions-check] fails the build on a declared file that is not at its redacted result. To change an entry, restore the file's original from history, run the metadata normalizer on it, edit the entry, and run `uv run --no-project --with-requirements scripts/requirements.txt scripts/redact-media.py --record`. A restored file that any committed revision of the manifest records as a result is refused, since it already carries an earlier round's fills. So is one other than the original the entry's `source` hash records, and deleting that hash takes a deliberately different original. An unchanged entry can also stop reproducing, after a Pillow bump that moves the output. Re-record it the same way, deleting its `declared` digest rather than editing the entry.

**The archive's text follows the same model.** [`scripts/normalize-text.py`][normalize-text] replaces typographic characters with ASCII outside fenced code, blockquotes, front matter, and lines holding a protected product name. It then applies the corrections listed one by one in [`scripts/text-corrections.json`][text-corrections]: doubled words, grammar slips, a title's HTML entity, and two links that located the home. Nothing else in an old post is restyled, its punctuation included.

Expand Down
9 changes: 8 additions & 1 deletion scripts/redact-media.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
with `scripts/normalize-media.py --apply`, edit its entry, and run with `--record`.
A restored file whose hash any committed revision of the manifest records as a result
is refused, since it already carries an earlier round's fills.
A restored file other than the one the entry's `source` hash records is refused too.
Delete the entry's `source` hash as well to take a deliberately different original.
Dependabot moves the pin in `scripts/requirements.txt`. The unit tests redact fixed
synthetic images against committed result hashes, so a bump that moves their output fails.
A file already at its result is left alone, so a bump changes no committed file.
Expand Down Expand Up @@ -237,7 +239,7 @@ def main() -> int:
parser.add_argument(
"--record",
action="store_true",
help="for each entry whose declared digest is missing or stale, take the file, which must be its original, as the source and record the result",
help="for each entry whose declared digest is missing or stale, take the file, which must be the original its source hash records where the entry has one, as the source and record the result",
)
args = parser.parse_args()
apply = args.apply or args.record
Expand Down Expand Up @@ -300,6 +302,11 @@ def main() -> int:
f"{name}: not normalized ({', '.join(sorted(unclean))}), run scripts/normalize-media.py --apply"
)
continue
if changed and entry.get("source") not in (None, current):
errors.append(
f"{name}: not the original its source hash records, restore that one, or delete the entry's source hash to take this file instead"
)
continue
if not changed and current != entry.get("source"):
errors.append(f"{name}: matches neither its source nor its result hash")
continue
Expand Down
45 changes: 45 additions & 0 deletions scripts/tests/test_redact_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,51 @@ def test_source_holding_earlier_fills_is_refused(self) -> None:
code, out = self.run_script("--record")
self.assertEqual(code, 0, out)

def test_uncommitted_round_counts_as_history(self) -> None:
path = self.add("a.jpg", jpeg(), {"fill": [[8, 8, 24, 24]]})
self.assertEqual(self.run_script("--record")[0], 0)
redacted = path.read_bytes()
copy = self.add("b.jpg", redacted, {"fill": [[32, 8, 48, 24]]})
before = self.manifest_path.read_bytes()
code, out = self.run_script("--record")
self.assertEqual(code, 1)
self.assertIn("static/b.jpg: already carries an earlier round's fills", out)
self.assertEqual(self.manifest_path.read_bytes(), before)
self.assertEqual(copy.read_bytes(), redacted)

def test_stale_digest_on_a_redacted_file_is_refused(self) -> None:
path = self.add("a.jpg", jpeg(), {"fill": [[8, 8, 24, 24]]})
self.assertEqual(self.run_script("--record")[0], 0)
redacted = path.read_bytes()
entry = self.manifest()["files"]["static/a.jpg"]
self.add("a.jpg", redacted, entry | {"declared": None})
before = self.manifest_path.read_bytes()
code, out = self.run_script("--record")
self.assertEqual(code, 1)
self.assertIn("restore its original first", out)
self.assertEqual(self.manifest_path.read_bytes(), before)
self.assertEqual(path.read_bytes(), redacted)

def test_re_record_needs_the_recorded_source(self) -> None:
path = self.add("a.jpg", jpeg(), {"fill": [[8, 8, 24, 24]]})
self.assertEqual(self.run_script("--record")[0], 0)
entry = self.manifest()["files"]["static/a.jpg"] | {"declared": None}
other = jpeg((1, 2, 3))
self.add("a.jpg", other, entry)
before = self.manifest_path.read_bytes()
code, out = self.run_script("--record")
self.assertEqual(code, 1)
self.assertIn("not the original its source hash records", out)
self.assertEqual(self.manifest_path.read_bytes(), before)
self.assertEqual(path.read_bytes(), other)
del entry["source"]
self.add("a.jpg", other, entry)
code, out = self.run_script("--record")
self.assertEqual(code, 0, out)
recorded = self.manifest()["files"]["static/a.jpg"]
self.assertEqual(recorded["source"], sha256(other))
self.assertEqual(sha256(path.read_bytes()), recorded["result"])

def test_unreadable_history_is_an_error(self) -> None:
path = self.add("a.jpg", jpeg(), {"fill": [[8, 8, 24, 24]]})
before = path.read_bytes()
Expand Down
6 changes: 3 additions & 3 deletions themes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ diff -r --exclude=.git /tmp/papermod themes/PaperMod

Some customizations fill extension points the theme documents for the purpose. They live outside the vendored tree. Hugo resolves a project's `layouts/` file ahead of the theme's at the same path. The head partial bundles a project's `assets/css/extended/` stylesheet beside the theme's. The customization table below lists every one of them:

| Customization | At | Replaces the theme's |
| Customization | At | Theme hook |
| --- | --- | --- |
| Lexend body font, and the `gallery` and `gallery-cols-*` rules the gallery shortcode needs | [`assets/css/extended/custom.css`](../assets/css/extended/custom.css) | `assets/css/extended/blank.css`, an empty slot the theme's head partial globs for |
| Lexend body font, and the `gallery` and `gallery-cols-*` rules the gallery shortcode needs | [`assets/css/extended/custom.css`](../assets/css/extended/custom.css) | `assets/css/extended/blank.css`, a comment-only stylesheet the theme's head partial bundles beside this one |
| Google Fonts preconnect and stylesheet links for Lexend | [`layouts/_partials/extend_head.html`](../layouts/_partials/extend_head.html) | `layouts/_partials/extend_head.html`, an empty partial the theme's head partial calls |
| GitHub Discussions link for a post that sets a `discussions` URL in its front matter | [`layouts/_partials/extend_post_content.html`](../layouts/_partials/extend_post_content.html) | `layouts/_partials/extend_post_content.html`, an empty partial the theme's single-page template calls after the post body |

Expand Down Expand Up @@ -75,7 +75,7 @@ The content width is unchanged from the theme default, deliberately. 720px at th

Nothing is carried, so an update is a replace. Delete `PaperMod/`, drop the new upstream tree in its place, and update the upstream table at the top of the PaperMod section. Then confirm the site still builds under `--panicOnWarning`, which is the gate the theme has failed before. Run the `diff -r` above afterwards, so the next reader inherits the same guarantee.

Re-check the customization table before the replace, while the upstream table still names the old commit. Each file it overrides is a comment-only hook upstream today. If upstream adds content to one, the local override hides it without any build failure. The exception is `blank.css`, which the head partial bundles beside `custom.css` rather than shadowing. Added rules there still ship, so a diff only means checking for duplication. Use the clone from the `diff -r` check above, or make a fresh one. Diff the file each row replaces between the recorded commit and the new commit. A comment-only diff needs no action. Added markup or rules mean porting them into the override, or deciding they are unwanted.
Re-check the customization table before the replace, while the upstream table still names the old commit. Each theme hook it names is a comment-only file upstream today. If upstream adds content to one, the local override hides it without any build failure. The exception is `blank.css`, which the head partial bundles beside `custom.css` rather than shadowing. Added rules there still ship, so a diff only means checking for duplication. Use the clone from the `diff -r` check above, or make a fresh one. Diff each row's theme hook between the recorded commit and the new commit. A comment-only diff needs no action. Added markup or rules mean porting them into the override, or deciding they are unwanted.

Check the root override table at the same moment, before the replace. The `diff` below covers it too. Any change there is upstream editing a template an override hides. Port it into the override, and keep the change the table records. A row whose only change is a deprecated call becomes removable once upstream makes the same swap. Once upstream makes the same swap, a row with other changes stays, and its last column drops the swap clause. The `--diff-filter=A` listing names templates upstream added, with `--no-renames` so a moved template shows too. A new template more specific than an overridden one outranks the root override with no diff and no build failure. It takes only the kinds it matches, so the old template keeps rendering the rest. A `home.rss.xml` beside `rss.xml` takes the home feed, while `rss.xml` still renders every section, taxonomy, and term feed. Compare the new template with the overridden one at the new commit, using the command after the block below. Port that difference into a copy of the override at the new path, as a new row. Keep the old row while the old path still renders anything. When upstream deletes or renames an overridden template, compare the old template at the recorded commit with its successor at the new commit. The `diff` shows a rename as a whole-file delete, so edits made in the rename surface only in that comparison. Port that difference into a copy of the override at the successor's path, as a new row. Upstream no longer ships the old path, so retire the old row. With no successor, retire the row the same way. Keep a retired row's root file while it still renders anything, since deleting it drops its site behavior, such as the GUID handling in `rss.xml`. Retire a row by removing its paths from the table, the `diff` command, and the `grep`. A `grep` left on an old name matches nothing, which reads as upstream no longer calling the partial. Also compare each added name against the root `layouts/` tree, reading a root `shortcodes/` file as `_shortcodes/`. A match is a new whole-template override, so it joins the root override table.

Expand Down
Loading