A snippet sequence · after the eighteen steps

The Grafted Folder

A snippet sequence in four steps: whole HTML files, deployed in a folder, served by the CMS at addresses of your choosing — with their companions beside them.

The wish: a folder to drop HTML files into — files with their own images and stylesheets in the same folder — which the CMS will serve when the writer gives them an address. This is a third kind of page: not grown in the editor, not pasted into the datastore, but pointed at.

A snippet sequence obeys the three rules of the original, plus three of its own. It must attach at points in the existing structure you can name — if it has to be smeared across the system, it belongs to a different sequence. It must leave a live datastore untouched, or touch it only by addition — existing entities never learn that anything happened. And it must be the least of all sufficient changes: where the organism already has an organ for the job, the graft uses that organ rather than growing its own.

Step A1

The folder answers

Every file in the folder is alive at its own address, before any name is minted for it.

A folder, filepages/, deployed with the application. At the very end of the serving pathway — after the datastore has been asked, after the old names have been checked for redirects, just before the 404 — the folder gets to answer. A file at filepages/sample/hello.html is served at /sample/hello.html; its stylesheet beside it is served beside it. Because the address space mirrors the folder, relative references between companions work exactly as they do on disk.

Two things make this the right first step. It is end-to-end immediately: drop a file, request it, see it. And the point of attachment is the least invasive one in the whole program — the fall-through position means every request that could be answered before the graft is still answered the same way after it. Note also whose organ does the work: Flask's send_from_directory already guards path traversal and already speaks ETag and Last-Modified — the graft inherits step seventeen's virtue without writing a line of caching code.

# main.py, at the end of the not-found branch of view_page:
        # after entities, after redirects, before the 404 --
        # the folder gets to answer.
        try:
            return send_from_directory(FILEPAGES, path, max_age=300)
        except Exception:
            abort(404)

The graft attaches where nothing existing can feel it.

Step A2

The third kind

A page may be a pointer: its body names a file, and the datastore never learns a new field existed.

At step five of the original sequence, pages forked into two kinds. Now a third: kind = "file". And here is the decision this snippet turns on — the file's name is stored in the page's existing body field. No new property, no schema change, no migration; a live datastore full of pages does not notice. This is not a trick. The body has always meant where the content is: for a managed page, the fragment itself; for a raw page, the whole document; for a file page, the pointer. The meaning was already wide enough.

Because a mount is just a page, everything a page has ever earned applies to it unasked: draft and published, titles and descriptions, a place in navigation, old addresses that redirect forever when the mount moves.

    if page.kind == "file":                 # snippet A, step 2
        # A mount: the entity's body names a file in the folder.
        try:
            return send_from_directory(FILEPAGES, page.body, max_age=300)
        except Exception:
            abort(404)

One branch beside the raw branch of step five.

Step A3

The surface takes the third shape

The tool fits the kind of page it edits — and a graft tests the health of the tissue it joins.

The editor gains a third choice at creation, and a third surface: for a file page, one small field naming the file. The submit handler routes whichever surface was used into the single body that travels.

The graft also forced a small repair, worth confessing because it is the interesting kind: the old template poured the page's body into both surfaces regardless of kind. With two kinds this was invisible — one surface was always hidden. With three it became visibly wrong, and the fix (each surface receives the body only when the body is its kind) made step fifteen more true than it was before. A good graft does that: it finds the places where the old tissue was healthy only by accident.

form.addEventListener("submit", function () {
  var k = currentKind();
  bodyField.value = k === "raw" ? rawBody.value
                  : k === "file" ? fileBody.value.trim()
                  : canvas.innerHTML;
});

Three surfaces, still one field.

Step A4

The organism accepts the graft

A structure-preserving change is recognized by everything it did not have to do.

The last step writes no feature; it verifies membership. A published file page appears on the home page, in the navigation if asked, in the sitemap — with no code written for any of it, because a mount is a page and those organs eat pages. Its responses carry validators and cache headers because the framework's file-serving organ already speaks them. Drafts hide it; renames redirect from its old address; the admin table lists its kind in the column that has always listed kinds.

This is what structure-preserving means operationally: the measure of the graft is the length of the list of things that worked without being touched.

$ curl -s /sitemap.xml | grep folder-page
<url><loc>https://site/essays/folder-page</loc>...</url>

$ curl -sD- /sample/hello.html | grep -iE "etag|cache"
Cache-Control: public, max-age=300
ETag: "1783380822.811-426-798299281"

Membership, unasked: the transcript of the verification.

What it cost, and what it proved

What the graft cost, stated honestly: files in the folder are deployed with the application, so — like everything under /static — they are inherently public the moment they are deployed. A draft mount hides the chosen address, not the file itself. That is the nature of the tissue this graft joins (a deployment is public), not a defect of the graft; but a sequence that does not state its costs is an advertisement.

And what it proved: the fall-through was placed at the very end of the serving pathway, so entities shadow files, redirects keep their promises, and nothing that existed before the graft behaves differently after it. Total change: one constant, two branches, one template surface, and zero model fields.