Browse Source

Lists, reorganizing again

imwald
Nuša Pukšič 3 months ago
parent
commit
2532d635d6
  1. 10
      assets/styles/02-layout/layout.css
  2. 7
      assets/styles/05-utilities/utilities.css
  3. 54
      src/Controller/AuthorController.php
  4. 3
      src/Controller/ReadingListController.php
  5. 9
      templates/components/Organisms/ReadingListList.html.twig
  6. 3
      templates/components/Organisms/ZineList.html.twig
  7. 12
      templates/components/UserMenu.html.twig
  8. 7
      templates/layout.html.twig
  9. 2
      templates/pages/lists.html.twig
  10. 2
      templates/pages/newsstand.html.twig
  11. 16
      templates/profile/author-lists.html.twig
  12. 1
      templates/profile/author-media.html.twig
  13. 1
      templates/profile/author.html.twig

10
assets/styles/02-layout/layout.css

@ -148,6 +148,16 @@ aside header { @@ -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 {

7
assets/styles/05-utilities/utilities.css

@ -14,6 +14,13 @@ @@ -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}

54
src/Controller/AuthorController.php

@ -33,7 +33,55 @@ class AuthorController extends AbstractController @@ -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 @@ -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 @@ -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,

3
src/Controller/ReadingListController.php

@ -18,6 +18,9 @@ use Symfony\Component\Routing\Attribute\Route; @@ -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
{

9
templates/components/Organisms/ReadingListList.html.twig

@ -2,14 +2,13 @@ @@ -2,14 +2,13 @@
{% set items = this.lists %}
{% if items is not empty %}
{% for item in items %}
<section class="d-flex gap-3 center">
<h1><a href="{{ path('reading-list', { slug: item.slug, pubkey: item.pubkey }) }}">{{ item.title }}</a></h1>
<p>by <twig:Molecules:UserFromNpub :ident="item.pubkey" /></p>
<small class="text-muted">{{ item.createdAt|date('Y-m-d') }}</small>
<div class="card d-flex gap-3 center ln-section--reader">
<h1><a href="{{ path('reading-list', { slug: item.slug, npub: item.pubkey|toNpub }) }}">{{ item.title }}</a></h1>
{% if item.summary is defined and item.summary %}
<p class="eyebrow">{{ item.summary }}</p>
{% endif %}
</section>
<p>by <twig:Molecules:UserFromNpub :ident="item.pubkey" /></p>
</div>
{% endfor %}
{% else %}
<p><small>No reading lists yet.</small></p>

3
templates/components/Organisms/ZineList.html.twig

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<div {{ attributes }}>
{% if nzines is not empty %}
{% for item in nzines %}
<div class="card">
<div class="card p-3 ln-section--reader">
<div class="card-body text-center">
<h2 class="card-title">
<a href="{{ path('magazine-index', {mag: item.slug}) }}">
@ -35,7 +35,6 @@ @@ -35,7 +35,6 @@
{% endif %}
</div>
</div>
<br>
{% endfor %}
{% else %}
<p><small>No magazines yet.</small></p>

12
templates/components/UserMenu.html.twig

@ -11,10 +11,14 @@ @@ -11,10 +11,14 @@
</ul>
{% endif %}
<ul class="user-nav">
{# <li>#}
{# <a href="{{ path('reading_list_index') }}">Compose List</a>#}
{# </li>#}
{% if is_granted('ROLE_ADMIN') %}
<li>
<a href="{{ path('nzine_list') }}">My NZines</a>
</li>
{% endif %}
<li>
<a href="{{ path('reading_list_index') }}">Compose List</a>
</li>
{% if is_granted('ROLE_ADMIN') %}
<li>
<a href="{{ path('mag_wizard_setup') }}">Create Magazine</a>

7
templates/layout.html.twig

@ -21,13 +21,8 @@ @@ -21,13 +21,8 @@
<a href="{{ path('media-discovery') }}">Multimedia</a>
</li>
<li>
<a href="{{ path('reading_list_index') }}">Lists</a>
<a href="{{ path('lists') }}">Lists</a>
</li>
{% if is_granted('ROLE_ADMIN') %}
<li>
<a href="{{ path('nzine_list') }}">My NZines</a>
</li>
{% endif %}
<li>
<a href="{{ path('app_search_index') }}">{{ 'heading.search'|trans }}</a>
</li>

2
templates/pages/lists.html.twig

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
{% extends 'layout.html.twig' %}
{% block body %}
<section class="d-flex gap-3 center ln-section--newsstand mb-3">
<section class="d-flex gap-3 center ln-section--newsstand">
<div class="container mt-5 mb-5">
<h1>Reading Lists</h1>
<p class="eyebrow">for collections, curations, courses and more</p>

2
templates/pages/newsstand.html.twig

@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
<twig:Organisms:ZineList />
</section>
<section class="d-flex gap-3 center ln-section--newsroom">
<section class="d-flex gap-3 center ln-section--newsstand">
<div class="container mt-5 mb-5">
<h1>More magazines soon</h1>
<p class="eyebrow">this is only the beginning</p>

16
templates/profile/author-lists.html.twig

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
{% extends 'layout.html.twig' %}
{% block body %}
{% include 'partial/_author-section.html.twig' with {author: author, npub: npub} %}
<section>
<div class="profile-tabs">
<a href="{{ path('author-profile', {'npub': npub}) }}" class="tab-link">Articles</a>
<a href="{{ path('author-reading-lists', {'npub': npub}) }}" class="tab-link">Reading Lists</a>
<a href="{{ path('author-media', {'npub': npub}) }}" class="tab-link active">Media</a>
</div>
</section>

1
templates/pages/author-media.html.twig → templates/profile/author-media.html.twig

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
<section>
<div class="profile-tabs">
<a href="{{ path('author-profile', {'npub': npub}) }}" class="tab-link">Articles</a>
<a href="{{ path('author-reading-lists', {'npub': npub}) }}" class="tab-link">Reading Lists</a>
<a href="{{ path('author-media', {'npub': npub}) }}" class="tab-link active">Media</a>
</div>

1
templates/pages/author.html.twig → templates/profile/author.html.twig

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
<section>
<div class="profile-tabs">
<a href="{{ path('author-profile', {'npub': npub}) }}" class="tab-link active">Articles</a>
<a href="{{ path('author-reading-lists', {'npub': npub}) }}" class="tab-link">Reading Lists</a>
<a href="{{ path('author-media', {'npub': npub}) }}" class="tab-link">Media</a>
</div>
Loading…
Cancel
Save