From 2532d635d6592f5920057679b890d92ff8f3ba1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C5=A1a=20Puk=C5=A1i=C4=8D?= Date: Wed, 15 Oct 2025 20:34:41 +0200 Subject: [PATCH] Lists, reorganizing again --- assets/styles/02-layout/layout.css | 10 ++++ assets/styles/05-utilities/utilities.css | 7 +++ src/Controller/AuthorController.php | 54 +++++++++++++++++-- src/Controller/ReadingListController.php | 3 ++ .../Organisms/ReadingListList.html.twig | 9 ++-- .../components/Organisms/ZineList.html.twig | 3 +- templates/components/UserMenu.html.twig | 12 +++-- templates/layout.html.twig | 7 +-- templates/pages/lists.html.twig | 2 +- templates/pages/newsstand.html.twig | 2 +- templates/profile/author-lists.html.twig | 16 ++++++ .../{pages => profile}/author-media.html.twig | 1 + templates/{pages => profile}/author.html.twig | 1 + 13 files changed, 105 insertions(+), 22 deletions(-) create mode 100644 templates/profile/author-lists.html.twig rename templates/{pages => profile}/author-media.html.twig (98%) rename templates/{pages => profile}/author.html.twig (89%) diff --git a/assets/styles/02-layout/layout.css b/assets/styles/02-layout/layout.css index 70128ed..01b7047 100644 --- a/assets/styles/02-layout/layout.css +++ b/assets/styles/02-layout/layout.css @@ -148,6 +148,16 @@ aside header { display: none; } +/* Responsive adjustments */ +@media (max-width: 1200px) { + .layout { + grid-template-columns: 240px auto; + } + aside { + display: none; /* Hide the sidebars on small screens */ + } +} + /* Responsive adjustments */ @media (max-width: 768px) { .layout { diff --git a/assets/styles/05-utilities/utilities.css b/assets/styles/05-utilities/utilities.css index 9c0ecfc..f550f07 100644 --- a/assets/styles/05-utilities/utilities.css +++ b/assets/styles/05-utilities/utilities.css @@ -14,6 +14,13 @@ .mx-0{margin-left:0!important;margin-right:0!important}.mx-1{margin-left:.25rem!important;margin-right:.25rem!important}.mx-2{margin-left:.5rem!important;margin-right:.5rem!important}.mx-3{margin-left:1rem!important;margin-right:1rem!important}.mx-4{margin-left:1.5rem!important;margin-right:1.5rem!important}.mx-5{margin-left:3rem!important;margin-right:3rem!important} .my-0{margin-top:0!important;margin-bottom:0!important}.my-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-5{margin-top:3rem!important;margin-bottom:3rem!important} .mx-auto{margin-left:auto!important;margin-right:auto!important} +.p-0{padding:0!important;}.p-1{padding:.25rem!important}.p-2{padding:.5rem!important}.p-3{padding:1rem!important}.p-4{padding:1.5rem!important}.p-5{padding:3rem!important} +.pt-0{padding-top:0!important}.pt-1{padding-top:.25rem!important}.pt-2{padding-top:.5rem!important}.pt-3{padding-top:1rem!important}.pt-4{padding-top:1.5rem!important}.pt-5{padding-top:3rem!important} +.pb-0{padding-bottom:0!important}.pb-1{padding-bottom:.25rem!important}.pb-2{padding-bottom:.5rem!important}.pb-3{padding-bottom:1rem!important}.pb-4{padding-bottom:1.5rem!important}.pb-5{padding-bottom:3rem!important} +.ps-0{padding-left:0!important}.ps-1{padding-left:.25rem!important}.ps-2{padding-left:.5rem!important}.ps-3{padding-left:1rem!important}.ps-4{padding-left:1.5rem!important}.ps-5{padding-left:3rem!important} +.pe-0{padding-right:0!important}.pe-1{padding-right:.25rem!important}.pe-2{padding-right:.5rem!important}.pe-3{padding-right:1rem!important}.pe-4{padding-right:1.5rem!important}.pe-5{padding-right:3rem!important} +.px-0{padding-left:0!important;padding-right:0!important}.px-1{padding-left:.25rem!important;padding-right:.25rem!important}.px-2{padding-left:.5rem!important;padding-right:.5rem!important}.px-3{padding-left:1rem!important;padding-right:1rem!important}.px-4{padding-left:1.5rem!important;padding-right:1.5rem!important}.px-5{padding-left:3rem!important;padding-right:3rem!important} +.py-0{padding-top:0!important;padding-bottom:0!important}.py-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-5{padding-top:3rem!important;padding-bottom:3rem!important} /* Display & layout */ .d-flex{display:flex!important;flex-direction:column} diff --git a/src/Controller/AuthorController.php b/src/Controller/AuthorController.php index 109ed48..a43c5c2 100644 --- a/src/Controller/AuthorController.php +++ b/src/Controller/AuthorController.php @@ -33,7 +33,55 @@ class AuthorController extends AbstractController { /** - * Lists + * Reading List Index + */ + #[Route('/p/{npub}/lists', name: 'author-reading-lists')] + public function readingLists($npub, + EntityManagerInterface $em, + NostrKeyUtil $keyUtil, + LoggerInterface $logger): Response + { + // Convert npub to hex pubkey + $pubkey = $keyUtil->npubToHex($npub); + $logger->info(sprintf('Reading list: pubkey=%s', $pubkey)); + // Find reading lists by pubkey, kind 30040 directly from database + $repo = $em->getRepository(Event::class); + $lists = $repo->findBy(['pubkey' => $pubkey, 'kind' => KindsEnum::PUBLICATION_INDEX], ['created_at' => 'DESC']); + // Filter to ensure they have a 'type:reading-list' tag + $filteredLists = []; + $seenSlugs = []; + foreach ($lists as $ev) { + if (!$ev instanceof Event) continue; + $tags = $ev->getTags(); + $isReadingList = false; + $title = null; $slug = null; $summary = null; + foreach ($tags as $t) { + if (is_array($t)) { + if (($t[0] ?? null) === 'type' && ($t[1] ?? null) === 'reading-list') { $isReadingList = true; } + if (($t[0] ?? null) === 'title') { $title = (string)$t[1]; } + if (($t[0] ?? null) === 'summary') { $summary = (string)$t[1]; } + if (($t[0] ?? null) === 'd') { $slug = (string)$t[1]; } + } + } + if ($isReadingList) { + // Collapse by slug: keep only newest per slug + $keySlug = $slug ?: ('__no_slug__:' . $ev->getId()); + if (isset($seenSlugs[$slug ?? $keySlug])) { + continue; + } + $seenSlugs[$slug ?? $keySlug] = true; + $filteredLists[] = $ev; + } + } + + return $this->render('profile/author-lists.html.twig', [ + 'lists' => $filteredLists, + 'npub' => $npub, + ]); + } + + /** + * List * @throws Exception */ #[Route('/p/{npub}/list/{slug}', name: 'reading-list')] @@ -128,7 +176,7 @@ class AuthorController extends AbstractController $event->noteId = $nip19->encodeNote($event->id); } - return $this->render('pages/author-media.html.twig', [ + return $this->render('profile/author-media.html.twig', [ 'author' => $author, 'npub' => $npub, 'pictureEvents' => $mediaEvents, @@ -210,7 +258,7 @@ class AuthorController extends AbstractController } - return $this->render('pages/author.html.twig', [ + return $this->render('profile/author.html.twig', [ 'author' => $author, 'npub' => $npub, 'pubkey' => $pubkey, diff --git a/src/Controller/ReadingListController.php b/src/Controller/ReadingListController.php index a13644f..4ddea2b 100644 --- a/src/Controller/ReadingListController.php +++ b/src/Controller/ReadingListController.php @@ -18,6 +18,9 @@ use Symfony\Component\Routing\Attribute\Route; class ReadingListController extends AbstractController { + /** + * Display the user's reading lists. + */ #[Route('/reading-list', name: 'reading_list_index')] public function index(EntityManagerInterface $em): Response { diff --git a/templates/components/Organisms/ReadingListList.html.twig b/templates/components/Organisms/ReadingListList.html.twig index 6197c35..c8cd3a7 100644 --- a/templates/components/Organisms/ReadingListList.html.twig +++ b/templates/components/Organisms/ReadingListList.html.twig @@ -2,14 +2,13 @@ {% set items = this.lists %} {% if items is not empty %} {% for item in items %} -
-

{{ item.title }}

-

by

- {{ item.createdAt|date('Y-m-d') }} +
+

{{ item.title }}

{% if item.summary is defined and item.summary %}

{{ item.summary }}

{% endif %} -
+

by

+ {% endfor %} {% else %}

No reading lists yet.

diff --git a/templates/components/Organisms/ZineList.html.twig b/templates/components/Organisms/ZineList.html.twig index 191201b..d448d8d 100644 --- a/templates/components/Organisms/ZineList.html.twig +++ b/templates/components/Organisms/ZineList.html.twig @@ -1,7 +1,7 @@
{% if nzines is not empty %} {% for item in nzines %} -
+ -
{% endfor %} {% else %}

No magazines yet.

diff --git a/templates/components/UserMenu.html.twig b/templates/components/UserMenu.html.twig index 25ac226..28cdf13 100644 --- a/templates/components/UserMenu.html.twig +++ b/templates/components/UserMenu.html.twig @@ -11,10 +11,14 @@ {% endif %}
    - -{#
  • #} -{# Compose List#} -{#
  • #} + {% if is_granted('ROLE_ADMIN') %} +
  • + My NZines +
  • + {% endif %} +
  • + Compose List +
  • {% if is_granted('ROLE_ADMIN') %}
  • Create Magazine diff --git a/templates/layout.html.twig b/templates/layout.html.twig index e71162f..2b695d4 100644 --- a/templates/layout.html.twig +++ b/templates/layout.html.twig @@ -21,13 +21,8 @@ Multimedia
  • - Lists + Lists
  • - {% if is_granted('ROLE_ADMIN') %} -
  • - My NZines -
  • - {% endif %}
  • {{ 'heading.search'|trans }}
  • diff --git a/templates/pages/lists.html.twig b/templates/pages/lists.html.twig index 40b6687..3595934 100644 --- a/templates/pages/lists.html.twig +++ b/templates/pages/lists.html.twig @@ -1,7 +1,7 @@ {% extends 'layout.html.twig' %} {% block body %} -
    +

    Reading Lists

    for collections, curations, courses and more

    diff --git a/templates/pages/newsstand.html.twig b/templates/pages/newsstand.html.twig index 8be9c0e..7de38bc 100644 --- a/templates/pages/newsstand.html.twig +++ b/templates/pages/newsstand.html.twig @@ -11,7 +11,7 @@
    -
    +

    More magazines soon

    this is only the beginning

    diff --git a/templates/profile/author-lists.html.twig b/templates/profile/author-lists.html.twig new file mode 100644 index 0000000..8e10874 --- /dev/null +++ b/templates/profile/author-lists.html.twig @@ -0,0 +1,16 @@ +{% extends 'layout.html.twig' %} + +{% block body %} + + {% include 'partial/_author-section.html.twig' with {author: author, npub: npub} %} + +
    + + + + +
    diff --git a/templates/pages/author-media.html.twig b/templates/profile/author-media.html.twig similarity index 98% rename from templates/pages/author-media.html.twig rename to templates/profile/author-media.html.twig index 876b15c..fa7b1ad 100644 --- a/templates/pages/author-media.html.twig +++ b/templates/profile/author-media.html.twig @@ -7,6 +7,7 @@
    diff --git a/templates/pages/author.html.twig b/templates/profile/author.html.twig similarity index 89% rename from templates/pages/author.html.twig rename to templates/profile/author.html.twig index 44d094d..799d596 100644 --- a/templates/pages/author.html.twig +++ b/templates/profile/author.html.twig @@ -7,6 +7,7 @@