diff --git a/.gitignore b/.gitignore index a7679bb..8442cab 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules/ vendor/ .phpunit.result.cache +.pytest_cache/ dist/ .wp-env.override.json test-results/ diff --git a/assets/css/base.css b/assets/css/base.css index 0cfb5d5..c94b189 100644 --- a/assets/css/base.css +++ b/assets/css/base.css @@ -18,6 +18,7 @@ body { margin: 0; background: var(--wp--preset--color--night); color: var(--wp--preset--color--text); + overflow-wrap: break-word; } img, diff --git a/inc/setup.php b/inc/setup.php index de97e35..77c7500 100644 --- a/inc/setup.php +++ b/inc/setup.php @@ -13,9 +13,69 @@ function chrnx_setup() { add_theme_support( 'post-thumbnails' ); add_theme_support( 'responsive-embeds' ); add_theme_support( 'editor-styles' ); - add_editor_style( array( 'assets/css/base.css', 'assets/css/layout.css' ) ); + add_editor_style( array( 'assets/css/base.css', 'assets/css/layout.css', 'assets/css/components.css' ) ); remove_action( 'wp_footer', 'the_block_template_skip_link' ); add_image_size( 'chrnx-card', 720, 480, true ); + + register_nav_menus( + array( + 'chrnx-primary' => __( 'Primary navigation', 'chrnx' ), + 'chrnx-footer' => __( 'Footer navigation', 'chrnx' ), + ) + ); + + // No template renders a comment thread, so nothing is collected silently. + remove_post_type_support( 'post', 'comments' ); + remove_post_type_support( 'page', 'comments' ); } add_action( 'after_setup_theme', 'chrnx_setup' ); +add_filter( 'comments_open', '__return_false' ); + +/** + * Print Open Graph and Twitter card tags for the current request. + * + * ponytail: hand-rolled because the theme needs four tags, not an SEO plugin. + */ +function chrnx_print_social_meta() { + if ( is_singular() ) { + $title = get_the_title(); + $url = get_permalink(); + $description = wp_strip_all_tags( get_the_excerpt() ); + $type = 'article'; + $image_id = get_post_thumbnail_id(); + } else { + $title = get_bloginfo( 'name' ); + $url = home_url( '/' ); + $description = get_bloginfo( 'description' ); + $type = 'website'; + $image_id = 0; + } + + // Generated derivative, not the design master: masters are not shipped. + $image = $image_id + ? wp_get_attachment_image_url( $image_id, 'full' ) + : get_theme_file_uri( 'assets/images/generated/about-grunge-1536.webp' ); + + $tags = array( + 'og:site_name' => get_bloginfo( 'name' ), + 'og:type' => $type, + 'og:title' => $title, + 'og:description' => $description, + 'og:url' => $url, + 'og:image' => $image, + ); + + foreach ( $tags as $property => $content ) { + if ( '' === $content ) { + continue; + } + printf( + '' . "\n", + esc_attr( $property ), + esc_attr( $content ) + ); + } + echo '' . "\n"; +} +add_action( 'wp_head', 'chrnx_print_social_meta' ); diff --git a/patterns/about.php b/patterns/about.php index b5e43cf..2e6920f 100644 --- a/patterns/about.php +++ b/patterns/about.php @@ -10,11 +10,11 @@ */ $chrnx_research_url = esc_url( 'https://arxiv.org/abs/2603.05352' ); ?> - +
- +

@@ -28,11 +28,5 @@ $chrnx_research_url = esc_url( 'https://arxiv.org/abs/2603.05352' );
- -
- - -
-
diff --git a/templates/404.html b/templates/404.html index 7606439..b880879 100644 --- a/templates/404.html +++ b/templates/404.html @@ -1,6 +1,6 @@ - +

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/index.html b/templates/index.html index 3ff77b2..4287ace 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,25 +1,9 @@ - -
- -
- - -
- - -
- - - - - - - - -
- + +
+ +
diff --git a/templates/page.html b/templates/page.html index 504ed79..b598a43 100644 --- a/templates/page.html +++ b/templates/page.html @@ -1,6 +1,6 @@ - +
diff --git a/templates/single.html b/templates/single.html index 6f9ce19..97ded73 100644 --- a/templates/single.html +++ b/templates/single.html @@ -1,6 +1,6 @@ - +
@@ -14,6 +14,7 @@ +
diff --git a/tests/e2e/visual-states.spec.mjs b/tests/e2e/visual-states.spec.mjs index 5912ea0..2f33df4 100644 --- a/tests/e2e/visual-states.spec.mjs +++ b/tests/e2e/visual-states.spec.mjs @@ -237,7 +237,7 @@ test( 'lower home sections keep the layered Music stage contained in both themes const result = await page.locator( '.chrnx-home' ).evaluate( ( home, order ) => { const selectors = [ - '.chrnx-home-projects', + '.chrnx-home-projects > .chrnx-character-stage', '.chrnx-home-music > .chrnx-character-stage', '.chrnx-latest-podcast', '.chrnx-home-about-preview', @@ -372,7 +372,7 @@ test( 'lower home sections keep the layered Music stage contained in both themes } ), ] ); expect( result.collageLazy ).toBe( 'lazy' ); - expect( result.collageFallback ).toContain( 'the-no-names-collage.jpeg' ); + expect( result.collageFallback ).toContain( 'the-no-names-collage-768.webp' ); expect( result.collageContained ).toBeTruthy(); expect( result.collageTreated ).toBeTruthy(); expect( result.copyPosition ).not.toBe( 'static' ); @@ -540,7 +540,7 @@ test( 'explicit themes use an atmospheric canvas and a compact home introduction for ( const theme of [ 'Dark', 'Light' ] ) { await page.setViewportSize( { width: 1440, height: 900 } ); await page.goto( '/' ); - await page.getByRole( 'radio', { name: theme, exact: true } ).check(); + await page.getByRole( 'button', { name: theme, exact: true } ).click(); await expect( page.locator( 'html' ) ).toHaveAttribute( 'data-theme', theme.toLowerCase() ); const desktop = await page.evaluate( () => { @@ -649,9 +649,9 @@ test( 'topic, music, podcast, and about surfaces use real content and approved a page, } ) => { for ( const [ path, heading, asset ] of [ - [ '/topic/code/', 'Code', 'alter-ego-code.png' ], - [ '/topic/research/', 'Research', 'alter-ego-research.png' ], - [ '/topic/gaming/', 'Gaming', 'alter-ego-gaming-half-body.png' ], + [ '/topic/code/', 'Code', 'alter-ego-code-768.webp' ], + [ '/topic/research/', 'Research', 'alter-ego-research-768.webp' ], + [ '/topic/gaming/', 'Gaming', 'alter-ego-gaming-half-body-768.webp' ], ] ) { await page.goto( path ); await expect( page.getByRole( 'heading', { level: 1, name: heading } ) ).toBeVisible(); @@ -705,12 +705,12 @@ test( 'topic, music, podcast, and about surfaces use real content and approved a await expect( page.getByRole( 'heading', { level: 1, name: 'Music' } ) ).toBeVisible(); await expect( page.getByText( 'Grunge mexicano para cerebros que no se callan.' ) ).toBeVisible(); await expect( - page.locator( 'picture img[src*="the-no-names-musician-cutout.png"]' ), + page.locator( 'picture img[src*="the-no-names-musician-cutout-768.webp"]' ), ).toBeVisible(); await page.goto( '/podcasts/' ); await expect( page.getByRole( 'heading', { level: 1, name: 'Podcasts' } ) ).toBeVisible(); - await expect( page.locator( 'picture img[src*="alter-ego-podcasts.png"]' ) ).toBeVisible(); + await expect( page.locator( 'picture img[src*="alter-ego-podcasts-768.webp"]' ) ).toBeVisible(); await expect( page.locator( 'iframe, audio' ) ).toHaveCount( 0 ); await page.goto( '/about/' ); @@ -722,8 +722,8 @@ test( 'topic, music, podcast, and about surfaces use real content and approved a await expect( page.locator( '.chrnx-about .chrnx-character-stage__art > picture' ) ).toHaveCount( 1, ); - await expect( page.locator( '.chrnx-about__portraits > picture' ) ).toHaveCount( 2 ); - await expect( page.locator( '.chrnx-about picture' ) ).toHaveCount( 3 ); + // One backdrop in the atmosphere layer plus the portrait in the art layer. + await expect( page.locator( '.chrnx-about picture' ) ).toHaveCount( 2 ); } ); test( 'long, incomplete, empty, and missing states stay usable', async ( { page } ) => { @@ -888,7 +888,7 @@ test( 'reduced motion removes card transitions while theme preference remains us ); expect( duration ).toBeLessThanOrEqual( 0.001 ); await expect( page.locator( '.chrnx-home-music h2' ) ).toHaveCSS( 'color', 'rgb(230, 237, 243)' ); - await page.getByRole( 'radio', { name: 'Dark', exact: true } ).check(); + await page.getByRole( 'button', { name: 'Dark', exact: true } ).click(); await expect( page.locator( 'html' ) ).toHaveAttribute( 'data-theme', 'dark' ); } ); @@ -970,8 +970,10 @@ test( 'character stage geometry, layering, effects, loading, and inspection capt } expect( geometry.contentArtIntersect ).toBeFalsy(); expect( geometry.followingIntersections ).toBe( 0 ); + // 'about' is absent: its stage is now the last thing on the page, so + // there is no following surface left to check for overlap. if ( - [ 'home-projects', 'home-music', 'projects', 'music', 'podcasts', 'about' ].includes( + [ 'home-projects', 'home-music', 'projects', 'music', 'podcasts' ].includes( surface.name, ) ) { @@ -991,7 +993,8 @@ test( 'character stage geometry, layering, effects, loading, and inspection capt const sourceName = new URL( image.src ).pathname .split( '/' ) .pop() - .replace( /\.png$/, '' ); + // The src is a generated derivative now: strip -.. + .replace( /-\d+\.(?:png|jpe?g|webp|avif)$/, '' ); const [ naturalWidth, naturalHeight, x0, y0, x1, y1 ] = boundsByAsset[ sourceName ]; const imageRect = image.getBoundingClientRect(); const stageRect = element.getBoundingClientRect(); @@ -1057,10 +1060,6 @@ test( 'character stage geometry, layering, effects, loading, and inspection capt expect( collageContract.hiddenAncestor ).toBeFalsy(); expect( collageContract.alt ).toBe( 'The No Names collage' ); } - if ( surface.name === 'about' ) { - expect( geometry.facetsOpacity ).toBeLessThan( 1 ); - expect( geometry.facetsZ ).toBeLessThan( geometry.pictureZ ); - } await expectNoHorizontalOverflow( page ); if ( initial.top >= viewport.height ) { @@ -1310,8 +1309,8 @@ const musicPodcastLandingCases = [ path: '/music/', root: '.chrnx-music-landing', copy: 'The No Names es una banda activa', - atmosphere: 'img[src*="the-no-names-collage.jpeg"]', - art: 'img[src*="the-no-names-musician-cutout.png"]', + atmosphere: 'img[src*="the-no-names-collage-768.webp"]', + art: 'img[src*="the-no-names-musician-cutout-768.webp"]', latestMedia: null, supporting: 'text=El proceso usa generative AI', }, @@ -1320,8 +1319,8 @@ const musicPodcastLandingCases = [ path: '/podcasts/', root: '.chrnx-podcast-landing', copy: 'Conversations about the work behind software, research, music, and games.', - atmosphere: 'img[src*="podcast-frequency-grunge.png"]', - art: 'img[src*="alter-ego-podcasts.png"]', + atmosphere: 'img[src*="podcast-frequency-grunge-1536.webp"]', + art: 'img[src*="alter-ego-podcasts-768.webp"]', latestMedia: '.chrnx-latest-podcast .chrnx-podcast-card__image, .chrnx-latest-podcast .chrnx-podcast-card__fallback', supporting: '.chrnx-latest-podcast', diff --git a/tests/php/PatternsTest.php b/tests/php/PatternsTest.php index 75efeda..c6dc526 100644 --- a/tests/php/PatternsTest.php +++ b/tests/php/PatternsTest.php @@ -68,12 +68,12 @@ class PatternsTest extends WP_UnitTestCase { $this->assertMatchesRegularExpression( '/]*\bloading="lazy"[^>]*\bdecoding="async"/i', $content, $name ); } $music = $this->render_pattern( get_theme_file_path( 'patterns/music-landing.php' ) ); - $this->assertStringContainsString( 'the-no-names-collage.jpeg', $music ); - $this->assertStringContainsString( 'the-no-names-musician-cutout.png', $music ); + $this->assertStringContainsString( 'the-no-names-collage-768.webp', $music ); + $this->assertStringContainsString( 'the-no-names-musician-cutout-768.webp', $music ); $this->assertSame( 2, substr_count( $music, 'render_pattern( get_theme_file_path( 'patterns/podcast-show.php' ) ); - $this->assertStringContainsString( 'alter-ego-podcasts.png', $show ); + $this->assertStringContainsString( 'alter-ego-podcasts-768.webp', $show ); $this->assertStringContainsString( 'alt=""', $show ); $this->assertStringContainsString( 'aria-hidden="true"', $show ); } @@ -89,9 +89,9 @@ class PatternsTest extends WP_UnitTestCase { $this->assertStringContainsString( 'the-no-names-collage-768.webp 768w', $content ); $this->assertStringContainsString( 'sizes="(max-width: 599px) 100vw, 720px"', $content ); $this->assertMatchesRegularExpression( '/class="chrnx-character-stage__collage"[^>]*loading="lazy"[^>]*alt=""/', $content ); - $this->assertStringContainsString( 'the-no-names-musician-cutout.png', $content ); + $this->assertStringContainsString( 'the-no-names-musician-cutout-768.webp', $content ); $this->assertLessThan( - strpos( $content, 'the-no-names-musician-cutout.png' ), + strpos( $content, 'the-no-names-musician-cutout-768.webp' ), strpos( $content, 'the-no-names-collage-384.avif' ) ); } @@ -103,18 +103,22 @@ class PatternsTest extends WP_UnitTestCase { 'Grunge mexicano para cerebros que no se callan.', 'grunge en español mexicano desde Sinaloa', 'estudio crudo, cero live', - 'El Hermoso Caos que habita en mi cabeza', - '13-track debut album', - 'Ando Bien Arriba', - 'six-track bright mirrored EP', - 'Aquí se Rompió una Jerga', - 'six-track dark mirrored EP', - 'draft/in production', 'generative AI', 'Chrnx', ) as $copy ) { $this->assertStringContainsString( $copy, wp_strip_all_tags( $content ), $copy ); } + + // Release names moved out of the pattern into the chrnx_release vocabulary. + $releases = chrnx_get_editorial_taxonomies()['chrnx_release']['terms']; + foreach ( array( + 'El Hermoso Caos que habita en mi cabeza', + 'Ando Bien Arriba', + 'Aquí se Rompió una Jerga', + ) as $release ) { + $this->assertContains( $release, $releases, $release ); + } + $this->assertStringContainsString( 'chrnx/release-list', file_get_contents( get_theme_file_path( 'patterns/music-landing.php' ) ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local test fixture. $this->assertDoesNotMatchRegularExpression( '/concert|rehearsal|coming live|tour/i', $content ); } @@ -202,22 +206,23 @@ class PatternsTest extends WP_UnitTestCase { $contracts = array( 'home-projects' => array( 'heading' => 'Selected work', - 'order' => array( 'Selected work', 'Expressive Tea', 'Ailed', 'Published research' ), - 'art' => 'alter-ego-code.png', + // The project names come from chrnx/selected-work now, not the pattern. + 'order' => array( 'Selected work' ), + 'art' => 'alter-ego-code-768.webp', 'art_alt' => '', 'atmosphere' => 'chrnx-character-stage__secondary-art', ), 'home-music' => array( 'heading' => 'The No Names', 'order' => array( 'The No Names', 'Grunge mexicano para cerebros que no se callan.', 'Un proyecto de banda activo hecho en Sinaloa: estudio crudo, cero live.' ), - 'art' => 'the-no-names-musician-cutout.png', + 'art' => 'the-no-names-musician-cutout-768.webp', 'art_alt' => 'The No Names musician portrait', 'atmosphere' => 'chrnx-character-stage__collage', ), 'music-landing' => array( 'heading' => 'The No Names', 'order' => array( 'The No Names', 'Grunge mexicano para cerebros que no se callan.', 'The No Names es una banda activa' ), - 'art' => 'the-no-names-musician-cutout.png', + 'art' => 'the-no-names-musician-cutout-768.webp', 'art_alt' => 'The No Names musician portrait', 'atmosphere' => 'chrnx-character-stage__collage', 'atmos_alt' => 'The No Names collage', @@ -226,16 +231,15 @@ class PatternsTest extends WP_UnitTestCase { 'podcast-landing' => array( 'heading' => 'Podcasts', 'order' => array( 'Podcasts', 'Conversations about the work behind software, research, music, and games.' ), - 'art' => 'alter-ego-podcasts.png', + 'art' => 'alter-ego-podcasts-768.webp', 'art_alt' => '', 'atmosphere' => 'chrnx-character-stage__frequency', ), 'about' => array( 'heading' => 'About', 'order' => array( 'About', 'I work as Lead Developer @Expressive Tea', 'I am a published researcher.', 'I am an autistic Level 1 software developer and researcher.', 'Beyond the work', 'I am the father of three wonderful children' ), - 'art' => 'alter-ego-life.png', + 'art' => 'alter-ego-life-768.webp', 'art_alt' => '', - 'facets' => array( 'alter-ego-literature.png', 'alter-ego-gaming-half-body.png' ), ), ); @@ -343,8 +347,9 @@ class PatternsTest extends WP_UnitTestCase { $music_root = $music_xpath->query( '//*[@id="chrnx-test-root"]/*[1]' )->item( 0 ); $this->assertInstanceOf( DOMElement::class, $music_stage ); - $this->assertSame( 1, substr_count( $music, 'the-no-names-collage.jpeg' ) ); - $this->assertSame( 1, substr_count( $music, 'the-no-names-musician-cutout.png' ) ); + // Twice: once in the WebP srcset, once as the fallback src. + $this->assertSame( 2, substr_count( $music, 'the-no-names-collage-768.webp' ) ); + $this->assertSame( 2, substr_count( $music, 'the-no-names-musician-cutout-768.webp' ) ); $this->assertSame( 1, $music_xpath->query( './*[1]//img[@alt="The No Names collage"]', $music_stage )->length ); $this->assertSame( 0, $music_xpath->query( './*[2]//img[contains(@class,"chrnx-character-stage__collage")]', $music_stage )->length ); $this->assertSame( 1, $music_xpath->query( './*[3]//img[@alt="The No Names musician portrait"]', $music_stage )->length ); @@ -355,20 +360,21 @@ class PatternsTest extends WP_UnitTestCase { $this->assertInstanceOf( DOMElement::class, $releases ); $this->assertSame( $music_stage, $process->previousElementSibling ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- DOM API property. $this->assertSame( $process, $releases->previousElementSibling ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- DOM API property. - $this->assertSame( array( 2, 3, 4, 4, 4 ), $this->heading_levels( $music_dom ) ); + // The h4 release headings are rendered by chrnx/release-list now. + $this->assertSame( array( 2, 3 ), $this->heading_levels( $music_dom ) ); $podcast = $this->render_pattern( get_theme_file_path( 'patterns/podcast-landing.php' ) ); $podcast_dom = $this->load_html_fragment( $podcast ); $podcast_xpath = new DOMXPath( $podcast_dom ); $podcast_stage = $podcast_xpath->query( '//*[contains(concat(" ", normalize-space(@class), " "), " chrnx-character-stage ")]' )->item( 0 ); $this->assertInstanceOf( DOMElement::class, $podcast_stage ); - $this->assertSame( 1, substr_count( $podcast, 'podcast-frequency-grunge.png' ) ); + $this->assertSame( 2, substr_count( $podcast, 'podcast-frequency-grunge-1536.webp' ) ); $podcast_atmosphere = $podcast_dom->saveHTML( $podcast_xpath->query( './*[1]', $podcast_stage )->item( 0 ) ); $this->assertStringContainsString( '