From cf3d4e0729b142147812d97c3b6238c8bb3a2c57 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sat, 15 Aug 2026 14:15:20 -0500 Subject: [PATCH] docs: a project archive must filter the journal, not clone a tracklist Co-Authored-By: Claude Opus 5 (1M context) --- .../plans/2026-08-15-projects-as-entities.md | 114 ++++++++++++++++-- 1 file changed, 102 insertions(+), 12 deletions(-) diff --git a/docs/superpowers/plans/2026-08-15-projects-as-entities.md b/docs/superpowers/plans/2026-08-15-projects-as-entities.md index 70494ee..4e5ed7b 100644 --- a/docs/superpowers/plans/2026-08-15-projects-as-entities.md +++ b/docs/superpowers/plans/2026-08-15-projects-as-entities.md @@ -583,17 +583,26 @@ git commit -m "feat: list every project with its status and links" - Create: `blocks/project-detail/block.json`, `blocks/project-detail/render.php` - Modify: `inc/blocks.php:235` — add `'project-detail'` to the `$blocks` array, exactly as Task 4 added `'project-list'` +- Modify: `inc/blocks.php:32` — add `'chrnx_project'` to the `is_tax()` list +- Modify: `inc/queries.php` lines 377, 404, 434, 489, 529 — add `'chrnx_project'` to each taxonomy list - Test: `tests/php/ProjectBlocksTest.php` (extend) +**This block renders a HEADER ONLY. It does not list posts.** `blocks/release-detail/render.php` also renders a tracklist, and the first draft of this plan said to clone it line for line. That was wrong twice over: projects have no track numbers, and the posts belonging to a project are ordinary reverse-chronological editorial posts — which is exactly what `chrnx/journal-stream` already renders on an archive. + +The correct model is `chrnx_show`, not `chrnx_release`. Podcast programmes list their episodes through `journal-stream` on the archive, because `chrnx_show` appears in the taxonomy lists inside `inc/queries.php`. `chrnx_project` appears in none of them, so without those five edits a project archive would render the whole unfiltered journal — the wrong posts, with no error. + **Interfaces:** -- Consumes: `chrnx_get_project_links()`, `chrnx_get_topic_portrait_markup()`. +- Consumes: `chrnx_get_project_links()`, `chrnx_get_topic_portrait_markup()`, `chrnx_get_heading_level()`. - Produces: block `chrnx/project-detail`, consumed by `templates/taxonomy-chrnx_project.html`. -- [ ] **Step 1: Read the release equivalent** +- [ ] **Step 1: Add `chrnx_project` to every taxonomy list** -Run: `cat blocks/release-detail/render.php` -The project version renders the same shape: cover, status, description, links. Copy its structure exactly rather than inventing a new one. +Five in `inc/queries.php` and one in `inc/blocks.php`. Read each one before editing; two of them list only two taxonomies rather than three. + +```bash +grep -n "chrnx_topic', 'chrnx_language'" inc/queries.php inc/blocks.php +``` - [ ] **Step 2: Write the failing test** @@ -613,6 +622,7 @@ Append to `tests/php/ProjectBlocksTest.php`: ) ); update_term_meta( $term_id, 'chrnx_project_repo', 'https://github.com/example/ailed' ); + update_term_meta( $term_id, 'chrnx_project_status', 'Activo' ); $this->go_to( get_term_link( $term_id ) ); @@ -620,30 +630,108 @@ Append to `tests/php/ProjectBlocksTest.php`: $this->assertStringContainsString( 'A chess engine that feels.', $markup ); $this->assertStringContainsString( 'https://github.com/example/ailed', $markup ); + $this->assertStringContainsString( 'Activo', $markup ); + } + + /** + * Ensure the detail block renders nothing outside a project archive. + */ + public function test_project_detail_is_silent_off_its_archive() { + $this->go_to( home_url( '/' ) ); + + $this->assertSame( '', trim( do_blocks( '' ) ) ); + } + + /** + * Ensure a project archive filters the journal to that project. + */ + public function test_project_archive_filters_the_journal() { + $term_id = self::factory()->term->create( + array( + 'taxonomy' => 'chrnx_project', + 'slug' => 'filter-test', + ) + ); + $mine = self::factory()->post->create( array( 'post_title' => 'Belongs to the project' ) ); + self::factory()->post->create( array( 'post_title' => 'Unrelated post' ) ); + wp_set_object_terms( $mine, array( $term_id ), 'chrnx_project' ); + + $this->go_to( get_term_link( $term_id ) ); + + $markup = do_blocks( '' ); + + $this->assertStringContainsString( 'Belongs to the project', $markup ); + $this->assertStringNotContainsString( 'Unrelated post', $markup ); } ``` -- [ ] **Step 3: Run the test to verify it fails** +- [ ] **Step 3: Run the tests to verify they fail** Run: `npm run test:php` -Expected: FAIL, block not registered. +Expected: FAIL — the block is unregistered, and the archive filter test shows the unrelated post. - [ ] **Step 4: Create the block** -`blocks/project-detail/block.json` mirrors Task 4's JSON with `"name": "chrnx/project-detail"`, `"title": "Project Detail"`, `"description": "Cover, status and links for the queried project."`, and no `headingLevel` attribute. +`blocks/project-detail/block.json` mirrors Task 4's JSON with `"name": "chrnx/project-detail"`, `"title": "Project Detail"`, `"description": "Cover, status, description and links for the queried project."`, and a `headingLevel` attribute defaulting to 2. -`blocks/project-detail/render.php` follows `blocks/release-detail/render.php` line for line, substituting `chrnx_release` with `chrnx_project`, `chrnx_get_release_links` with `chrnx_get_project_links`, `chrnx_release_cover` with `chrnx_project_cover`, `chrnx_release_status` with `chrnx_project_status`, `placeholder-release` with `placeholder-project`, and the `chrnx-release-` class prefix with `chrnx-project-`. +`blocks/project-detail/render.php` follows the HEAD section of `blocks/release-detail/render.php` only — its guard, its art column, and its intro column. Stop before the tracklist; do not port it. -- [ ] **Step 5: Run the tests to verify they pass** +```php +taxonomy ) { + return; +} + +$chrnx_status = (string) get_term_meta( $chrnx_term->term_id, 'chrnx_project_status', true ); +$chrnx_cover = absint( get_term_meta( $chrnx_term->term_id, 'chrnx_project_cover', true ) ); +$chrnx_links = chrnx_get_project_links( $chrnx_term->term_id ); +// Without status, description or links there is no second column to fill. +$chrnx_has_intro = '' !== $chrnx_status || '' !== $chrnx_term->description || ! empty( $chrnx_links ); +$chrnx_head_class = 'chrnx-project-detail__head' . ( $chrnx_has_intro ? '' : ' is-bare' ); +?> +
'chrnx-project-detail' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> +
+
+ 0 ) : ?> + 'chrnx-project-detail__cover' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> + + + +
+
+ +

+ + description ) : ?> +

description ); ?>

+ + +
+
+
+``` + +- [ ] **Step 5: Register the block** + +Add `'project-detail'` to the `$blocks` array at `inc/blocks.php:235`. + +- [ ] **Step 6: Run the tests to verify they pass** Run: `npm run test:php && npm run phpcs` Expected: PASS. -- [ ] **Step 6: Commit** +- [ ] **Step 7: Commit** ```bash -git add blocks/project-detail tests/php/ProjectBlocksTest.php -git commit -m "feat: give each project its own page header" +git add blocks/project-detail inc/blocks.php inc/queries.php tests/php/ProjectBlocksTest.php +git commit -m "feat: give each project its own page header and post stream" ``` --- @@ -678,6 +766,8 @@ Expected: FAIL, both templates missing.
+ +