diff --git a/blocks/topic-hero/render.php b/blocks/topic-hero/render.php index c510f50..031063e 100644 --- a/blocks/topic-hero/render.php +++ b/blocks/topic-hero/render.php @@ -24,7 +24,7 @@ $chrnx_label = $chrnx_term instanceof WP_Term ? $chrnx_term->name : ucfirst( $
- <?php echo esc_attr( $chrnx_label ); ?> + diff --git a/patterns/about.php b/patterns/about.php new file mode 100644 index 0000000..45b6623 --- /dev/null +++ b/patterns/about.php @@ -0,0 +1,22 @@ + + +
+

+

+

+

.

+

+

+
+ diff --git a/patterns/home-intro.php b/patterns/home-intro.php new file mode 100644 index 0000000..8728918 --- /dev/null +++ b/patterns/home-intro.php @@ -0,0 +1,17 @@ + + +
+

+

+
+ diff --git a/patterns/home-music.php b/patterns/home-music.php new file mode 100644 index 0000000..ece2336 --- /dev/null +++ b/patterns/home-music.php @@ -0,0 +1,28 @@ + + +
+ +
+
+

+

+

+
+
+ <?php echo esc_attr__( 'The No Names musician portrait', 'chrnx' ); ?> +
+
+ +
+ diff --git a/patterns/home-projects.php b/patterns/home-projects.php new file mode 100644 index 0000000..31c7fc9 --- /dev/null +++ b/patterns/home-projects.php @@ -0,0 +1,23 @@ + + +
+

+ +
+

+

+

+
+ +
+ diff --git a/patterns/music-landing.php b/patterns/music-landing.php new file mode 100644 index 0000000..ad22d1e --- /dev/null +++ b/patterns/music-landing.php @@ -0,0 +1,29 @@ + + +
+

+

+

+

+ <?php echo esc_attr__( 'The No Names collage', 'chrnx' ); ?> +

+ +
+

+

+

+
+ +
+ diff --git a/patterns/music-release.php b/patterns/music-release.php new file mode 100644 index 0000000..4668cae --- /dev/null +++ b/patterns/music-release.php @@ -0,0 +1,20 @@ + + +
+

+

+
+
+
+
+ diff --git a/patterns/podcast-episode.php b/patterns/podcast-episode.php new file mode 100644 index 0000000..ed0c090 --- /dev/null +++ b/patterns/podcast-episode.php @@ -0,0 +1,23 @@ + + +
+ +
+
+
+
+
+
+
+
+ diff --git a/patterns/podcast-landing.php b/patterns/podcast-landing.php new file mode 100644 index 0000000..4d7df87 --- /dev/null +++ b/patterns/podcast-landing.php @@ -0,0 +1,21 @@ + + +
+

+ +
+
+
+
+ diff --git a/patterns/podcast-show.php b/patterns/podcast-show.php new file mode 100644 index 0000000..f659f9a --- /dev/null +++ b/patterns/podcast-show.php @@ -0,0 +1,22 @@ + + +
+ +
+
+
+
+
+
+
+ diff --git a/patterns/project-detail.php b/patterns/project-detail.php new file mode 100644 index 0000000..bf3a558 --- /dev/null +++ b/patterns/project-detail.php @@ -0,0 +1,22 @@ + + +
+ +

+
+
+
+
+
+
+ diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..a1f326e --- /dev/null +++ b/templates/404.html @@ -0,0 +1,14 @@ + + + +
+

Page not found

+

This address does not lead to a published page. Search the site or return to a known starting point.

+ + + + +
+ + + diff --git a/templates/archive.html b/templates/archive.html new file mode 100644 index 0000000..33f06df --- /dev/null +++ b/templates/archive.html @@ -0,0 +1,12 @@ + + + +
+ + + + +
+ + + diff --git a/templates/home.html b/templates/home.html new file mode 100644 index 0000000..4b8a382 --- /dev/null +++ b/templates/home.html @@ -0,0 +1,21 @@ + + + +
+ + + + + + + +
+

About

+

Independent research, software, music, games, and the human life around the work.

+
+ + +
+ + + diff --git a/templates/page.html b/templates/page.html new file mode 100644 index 0000000..504ed79 --- /dev/null +++ b/templates/page.html @@ -0,0 +1,10 @@ + + + +
+ + +
+ + + diff --git a/templates/search.html b/templates/search.html new file mode 100644 index 0000000..91f1c97 --- /dev/null +++ b/templates/search.html @@ -0,0 +1,14 @@ + + + +
+ + + + + + +
+ + + diff --git a/templates/single.html b/templates/single.html new file mode 100644 index 0000000..04a06f9 --- /dev/null +++ b/templates/single.html @@ -0,0 +1,21 @@ + + + +
+ + + + + + + + + +
+ + + diff --git a/tests/php/BlockRenderingTest.php b/tests/php/BlockRenderingTest.php index e8bc7d2..5eb0f8b 100644 --- a/tests/php/BlockRenderingTest.php +++ b/tests/php/BlockRenderingTest.php @@ -201,8 +201,8 @@ class BlockRenderingTest extends WP_UnitTestCase { $this->assertStringNotContainsString( ' 'chrnx/topic-hero', @@ -218,7 +218,12 @@ class BlockRenderingTest extends WP_UnitTestCase { $this->assertStringContainsString( 'assertStringContainsString( 'Research', $output ); $this->assertStringContainsString( 'aria-hidden="true"', $output ); - $this->assertStringNotContainsString( 'assertStringContainsString( 'assertStringContainsString( 'alt=""', $output ); + $this->assertStringContainsString( 'width="1122"', $output ); + $this->assertStringContainsString( 'height="1402"', $output ); + $this->assertStringContainsString( 'loading="lazy"', $output ); + $this->assertStringContainsString( 'decoding="async"', $output ); $unsafe = render_block( array( diff --git a/tests/php/PatternsTest.php b/tests/php/PatternsTest.php new file mode 100644 index 0000000..008cf39 --- /dev/null +++ b/tests/php/PatternsTest.php @@ -0,0 +1,129 @@ +assertFileExists( $path, $name ); + $source = file_get_contents( $path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local test fixture. + $this->assertMatchesRegularExpression( '/^\s*<\?php\s*\/\*\*.*?\*\sTitle:\s*.+$/ms', $source, $name ); + $this->assertMatchesRegularExpression( '/^\s*\*\sSlug:\s*chrnx\/' . preg_quote( $name, '/' ) . '\s*$/m', $source, $name ); + $this->assertMatchesRegularExpression( '/^\s*\*\sCategories:\s*\S.+$/m', $source, $name ); + $this->assertMatchesRegularExpression( '/^\s*\*\sDescription:\s*\S.+$/m', $source, $name ); + $this->assertMatchesRegularExpression( '/^\s*\*\sInserter:\s*(?:yes|no)\s*$/m', $source, $name ); + if ( preg_match( '/(?:__|_e)\s*\(/', $source ) ) { + $this->assertStringContainsString( "'chrnx'", $source, $name ); + } + + $content = $this->render_pattern( $path ); + $blocks = parse_blocks( $content ); + $this->assertNotEmpty( $blocks, $name ); + $this->assertSame( trim( $content ), trim( serialize_blocks( $blocks ) ), $name ); + foreach ( $blocks as $parsed_block ) { + if ( null === $parsed_block['blockName'] ) { + $this->assertSame( '', trim( $parsed_block['innerHTML'] ), $name . ' has non-block content' ); + } + } + $this->assertStringContainsString( '/gs)) { + const [, closing, blockName, selfClosing] = match; + if (selfClosing) continue; + if (!closing) { + stack.push(blockName); + continue; + } + assert.equal(stack.pop(), blockName, `${name} must close ${blockName} in order`); + } + assert.deepEqual(stack, [], `${name} must close every WordPress block`); +} + +for (const name of templates) { + test(`${name}.html is a complete portable page template`, async () => { + const markup = await readTemplate(name); + + assertBalancedBlockMarkup(markup, name); + assert.equal((markup.match(/wp:template-part \{"slug":"header","tagName":"header"\}/g) ?? []).length, 1); + assert.equal((markup.match(/wp:template-part \{"slug":"footer","tagName":"footer"\}/g) ?? []).length, 1); + assert.equal((markup.match(//g) ?? []).length, 1); + assert.match(markup, /]*\bid="chrnx-main"[^>]*>/); + assert.doesNotMatch(markup, /wp:(?:legacy-widget|widget-group)| { + const markup = await readTemplate('home'); + const orderedMarkers = [ + '"slug":"header"', + 'wp:pattern {"slug":"chrnx/home-intro"}', + 'wp:chrnx/featured-stories', + 'wp:chrnx/journal-stream', + 'wp:pattern {"slug":"chrnx/home-projects"}', + 'wp:pattern {"slug":"chrnx/home-music"}', + 'wp:chrnx/latest-podcast', + 'chrnx-home-about-preview', + 'wp:chrnx/subscribe-cta', + '"slug":"footer"', + ]; + let previous = -1; + for (const marker of orderedMarkers) { + const index = markup.indexOf(marker); + assert.ok(index > previous, `${marker} must appear in the approved home order`); + previous = index; + } +}); + +test('single provides readable content, neutral metadata, and post-only components', async () => { + const markup = await readTemplate('single'); + assert.match(markup, /chrnx-entry--single/); + assert.match(markup, /wp:post-title/); + assert.match(markup, /wp:post-terms \{"term":"chrnx_topic"/); + assert.match(markup, /wp:post-terms \{"term":"chrnx_language"/); + assert.match(markup, /wp:post-date/); + assert.match(markup, /wp:post-featured-image/); + assert.match(markup, /wp:post-content/); + assert.match(markup, /wp:chrnx\/podcast-meta/); + assert.match(markup, /wp:chrnx\/related-posts/); + assert.match(markup, /wp:chrnx\/subscribe-cta/); +}); + +test('page remains a readable title and content shell without post metadata', async () => { + const markup = await readTemplate('page'); + assert.match(markup, /chrnx-entry--page/); + assert.match(markup, /wp:post-title/); + assert.match(markup, /wp:post-content/); + assert.doesNotMatch(markup, /wp:post-(?:date|terms|featured-image)|wp:chrnx\/(?:podcast-meta|related-posts)/); +}); + +test('archive offers context, safe filters, stream, and a useful empty state', async () => { + const markup = await readTemplate('archive'); + assert.match(markup, /wp:query-title/); + assert.match(markup, /wp:term-description/); + assert.match(markup, /wp:chrnx\/topic-hero/); + assert.match(markup, /wp:chrnx\/journal-stream/); +}); + +test('search offers search context, filters, and a Journal recovery path', async () => { + const markup = await readTemplate('search'); + assert.match(markup, /wp:query-title \{"type":"search"/); + assert.match(markup, /wp:search/); + assert.match(markup, /wp:chrnx\/journal-stream/); + assert.match(markup, /wp:home-link/); + assert.doesNotMatch(markup, /"url":"\//); +}); + +test('404 offers concise recovery with search, Journal, and home links', async () => { + const markup = await readTemplate('404'); + assert.match(markup, /Page not found/); + assert.match(markup, /wp:search/); + assert.match(markup, /wp:home-link/); + assert.doesNotMatch(markup, /"url":"\//); +});