Browse Source

bug-fixes

imwald
Silberengel 1 month ago
parent
commit
eb7cf4a9c6
  1. 1
      src/Controller/DefaultController.php
  2. 31
      src/Service/MagazineContentService.php
  3. 4
      src/Service/MagazineRefresher.php
  4. 11
      templates/components/Organisms/HomeMagazineArticleStrip.html.twig
  5. 1
      templates/home.html.twig

1
src/Controller/DefaultController.php

@ -28,7 +28,6 @@ class DefaultController extends AbstractController @@ -28,7 +28,6 @@ class DefaultController extends AbstractController
$magazineStrip = $this->magazineContent->buildHomeMagazineRootHeadlineStripData();
return $this->render('home.html.twig', [
'home_magazine_strip_heading' => $magazineStrip['heading'],
'home_magazine_strip_tiles' => $magazineStrip['tiles'],
'home_featured_tiles' => $this->magazineContent->buildHomeMixedFeaturedWallTiles($categoryATags),
'home_sidebar_category_recent' => $this->magazineContent->buildHomeSidebarCategorizedRecent($categoryATags),

31
src/Service/MagazineContentService.php

@ -31,8 +31,9 @@ final class MagazineContentService @@ -31,8 +31,9 @@ final class MagazineContentService
}
/**
* Category `a` tags from the persisted root only (no relay). The store is filled by
* `app:prewarm` / cron ({@see MagazineRefresher::refreshFromRelays}), not from HTTP.
* Kind **30040** child-index `a` tags from the persisted magazine root only (no relay). Long-form
* `a` tags on the same root event are excluded so they are not shown as header categories.
* The store is filled by `app:prewarm` / cron ({@see MagazineRefresher::refreshFromRelays}), not from HTTP.
*
* @return list<array<int, string>>
*/
@ -85,7 +86,15 @@ final class MagazineContentService @@ -85,7 +86,15 @@ final class MagazineContentService
if ($seq === null || !isset($seq[1]) || (string) $seq[1] === '') {
continue;
}
$cats[] = ['a', (string) $seq[1]];
$coord = (string) $seq[1];
$parts = explode(':', $coord, 3);
if (\count($parts) < 3) {
continue;
}
if ((int) ($parts[0] ?? 0) !== KindsEnum::PUBLICATION_INDEX->value) {
continue;
}
$cats[] = ['a', $coord];
}
return $cats;
@ -711,9 +720,9 @@ final class MagazineContentService @@ -711,9 +720,9 @@ final class MagazineContentService
/**
* Home headline strip: kind **30040** magazine root (`npub` + `d_tag`), walking `a` tags **top to bottom**.
* Only kind **30023** / **30024** addresses become tiles; nested **30040** category `a` tags are skipped.
* Section heading comes from the root index `title` tag when present.
* No strip-level heading — each article’s own title in the template is enough.
*
* @return array{heading: string, tiles: list<array{article: FeaturedArticleCard, body_html: string}>}
* @return array{tiles: list<array{article: FeaturedArticleCard, body_html: string}>}
*/
public function buildHomeMagazineRootHeadlineStripData(): array
{
@ -725,10 +734,9 @@ final class MagazineContentService @@ -725,10 +734,9 @@ final class MagazineContentService
$mag = $this->store->getRoot($npub, $dTag);
}
if ($mag === null) {
return ['heading' => '', 'tiles' => []];
return ['tiles' => []];
}
$heading = '';
$orderedCoords = [];
$seenAddr = [];
foreach ($mag->getTags() as $tagRow) {
@ -737,9 +745,6 @@ final class MagazineContentService @@ -737,9 +745,6 @@ final class MagazineContentService
continue;
}
$name = strtolower((string) ($seq[0] ?? ''));
if ($name === 'title' && isset($seq[1]) && trim((string) $seq[1]) !== '') {
$heading = trim((string) $seq[1]);
}
if ($name !== 'a' || !isset($seq[1]) || (string) $seq[1] === '') {
continue;
}
@ -766,7 +771,7 @@ final class MagazineContentService @@ -766,7 +771,7 @@ final class MagazineContentService
}
if ($orderedCoords === []) {
return ['heading' => $heading, 'tiles' => []];
return ['tiles' => []];
}
$pairsArg = [];
@ -804,10 +809,10 @@ final class MagazineContentService @@ -804,10 +809,10 @@ final class MagazineContentService
}
if ($tiles === []) {
return ['heading' => $heading, 'tiles' => []];
return ['tiles' => []];
}
return ['heading' => $heading, 'tiles' => $tiles];
return ['tiles' => $tiles];
}
/**

4
src/Service/MagazineRefresher.php

@ -5,6 +5,7 @@ declare(strict_types=1); @@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Service;
use App\Entity\Event;
use App\Enum\KindsEnum;
use App\Util\NostrEventTags;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Cache\InvalidArgumentException;
@ -202,6 +203,9 @@ final class MagazineRefresher @@ -202,6 +203,9 @@ final class MagazineRefresher
if (\count($parts) < 3) {
continue;
}
if ((int) ($parts[0] ?? 0) !== KindsEnum::PUBLICATION_INDEX->value) {
continue;
}
$s = trim((string) $parts[2]);
if ($s !== '' && !\in_array($s, $slugs, true)) {
$slugs[] = $s;

11
templates/components/Organisms/HomeMagazineArticleStrip.html.twig

@ -1,19 +1,12 @@ @@ -1,19 +1,12 @@
{#
Home: magazine root kind 30040 — long-form `a` tags in index order (top to bottom). Section title from
root `title` tag. Same layout as before: illustration, headline, full article body (Markdown + highlights).
Home: magazine root kind 30040 — long-form `a` tags in index order. No strip-level heading; each
article uses its own title (h3). Same layout: illustration, headline, full body.
#}
{% if tiles is not empty %}
<section
class="home-curation-landmark"
{% if section_title|default('') != '' %}
aria-labelledby="home-magazine-strip-heading"
{% else %}
aria-label="{{ (website_name ~ ' — featured articles')|e('html_attr') }}"
{% endif %}
>
{% if section_title|default('') != '' %}
<h2 id="home-magazine-strip-heading" class="home-curation-landmark__title">{{ section_title|e }}</h2>
{% endif %}
<div class="home-curation-landmark__articles">
{% for tile in tiles %}
{% set item = tile.article %}

1
templates/home.html.twig

@ -43,7 +43,6 @@ @@ -43,7 +43,6 @@
{% if home_magazine_strip_tiles|default([]) is not empty %}
{% include 'components/Organisms/HomeMagazineArticleStrip.html.twig' with {
tiles: home_magazine_strip_tiles,
section_title: home_magazine_strip_heading|default(''),
} only %}
{% endif %}
{% include 'components/Organisms/FeaturedWall.html.twig' with { tiles: home_featured_tiles|default([]) } only %}

Loading…
Cancel
Save