Browse Source

Search and miscelanea

imwald
Nuša Pukšič 10 months ago
parent
commit
2929d4ab15
  1. 3
      config/packages/security.yaml
  2. 9
      src/Controller/NzineController.php
  3. 2
      src/Service/NostrClient.php
  4. 20
      src/Twig/Components/IndexTabs.php
  5. 4
      templates/components/SearchComponent.html.twig
  6. 29
      templates/components/UserMenu.html.twig
  7. 4
      templates/home.html.twig
  8. 2
      templates/pages/author.html.twig
  9. 3
      templates/pages/nzine.html.twig
  10. 4
      templates/pages/search.html.twig
  11. 1
      translations/messages.en.yaml

3
config/packages/security.yaml

@ -26,5 +26,6 @@ security: @@ -26,5 +26,6 @@ security:
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/admin, roles: ROLE_USER }
- { path: ^/nzine, roles: ROLE_USER }
- { path: ^/search, roles: ROLE_USER }
# - { path: ^/nzine, roles: ROLE_USER }
# - { path: ^/profile, roles: ROLE_USER }

9
src/Controller/NzineController.php

@ -154,7 +154,12 @@ class NzineController extends AbstractController @@ -154,7 +154,12 @@ class NzineController extends AbstractController
// add the new and updated indices to the main index
foreach ($catIndices as $idx) {
$mainIndex->addTag(['e' => $idx->getId() ]);
//remove e tags and add new
// $tags = array_splice($mainIndex->getTags(), -3);
// $mainIndex->setTags($tags);
// TODO add relay hints
$mainIndex->addTag(['a' => KindsEnum::PUBLICATION_INDEX->value .':'. $idx->getPublicKey() .':'. $idx->getSlug()]);
// $mainIndex->addTag(['e' => $idx->getId() ]);
}
// re-sign main index and save to relays
@ -204,6 +209,8 @@ class NzineController extends AbstractController @@ -204,6 +209,8 @@ class NzineController extends AbstractController
return $index->getSlug() == $nzine->getSlug();
});
dump($indices);die();
$mainIndex = array_pop($mainIndexCandidates);
return $this->render('pages/nzine.html.twig', [

2
src/Service/NostrClient.php

@ -176,7 +176,7 @@ class NostrClient @@ -176,7 +176,7 @@ class NostrClient
$filter = new Filter();
$filter->setKinds([KindsEnum::LONGFORM]);
// TODO make filters configurable
$filter->setSince(strtotime('-8 weeks')); //
$filter->setSince(strtotime('-1 week')); //
$requestMessage = new RequestMessage($subscriptionId, [$filter]);
// if user is logged in, use their settings

20
src/Twig/Components/IndexTabs.php

@ -20,7 +20,7 @@ class IndexTabs @@ -20,7 +20,7 @@ class IndexTabs
public int $activeTab = 1; // Default active tab
#[LiveProp]
/** ['id' => 1, 'label' => 'Tab 1'] */
/** ['id' => 1, 'label' => 'Tab 1', 'i' => <index> ] */
public array $tabs = [];
#[LiveAction]
@ -39,24 +39,26 @@ class IndexTabs @@ -39,24 +39,26 @@ class IndexTabs
// TODO extract categories from index and feed into tabs
foreach ($index->getTags() as $tag) {
if (array_key_first($tag) === 'a') {
$ref = $tag['a'];
$ref = $tag[1];
$relayHint = $tag[2] ?? null;
list($kind,$npub,$slug) = explode(':',$ref);
$cat = $this->entityManager->getRepository(EventEntity::class)->findOneBy(['slug' => $slug]);
} elseif (array_key_first($tag) === 'e') {
$cat = $this->entityManager->getRepository(EventEntity::class)->findOneBy(['id' => $tag['e']]);
$next = count($this->tabs) + 1;
$this->tabs[] = ['id' => $next, 'label' => $cat->getTitle()];
$this->tabs[] = ['id' => $next, 'label' => $cat->getTitle(), 'i' => $cat];
} elseif (array_key_first($tag) === 'e') {
// ignore 'e's, we want 'a's
//$cat = $this->entityManager->getRepository(EventEntity::class)->findOneBy(['id' => $tag[1]]);
//$next = count($this->tabs) + 1;
//$this->tabs[] = ['id' => $next, 'label' => $cat->getTitle()];
}
}
}
public function getTabContent(): string|array
{
// return current index
return match ($this->activeTab) {
1 => [
'30023:c1e6505c02da8d1b0a5b3d6db6e19b2eb22dcd54f0e86306ec8a213902b3157e:809797',
'30032:c1e6505c02da8d1b0a5b3d6db6e19b2eb22dcd54f0e86306ec8a213902b3157e:012025-7zsaxt'
],
1 => 'This will eventually be content.',
2 => 'This is content for Tab 2. No AJAX needed!',
default => 'No content available.',
};

4
templates/components/SearchComponent.html.twig

@ -8,7 +8,9 @@ @@ -8,7 +8,9 @@
</label>
<!-- Loading Indicator -->
<span data-loading>{{ 'text.searching'|trans }}</span>
<div style="text-align: center">
<span data-loading>{{ 'text.searching'|trans }}</span>
</div>
<!-- Results -->
{% if this.results is not empty %}

29
templates/components/UserMenu.html.twig

@ -2,22 +2,28 @@ @@ -2,22 +2,28 @@
{% if app.user %}
<p>Hello, {{ app.user.displayName }}</p>
{% if is_granted('ROLE_ADMIN') %}
<ul>
<li>
<a href="{{ path('admin_roles') }}">{{ 'heading.roles'|trans }}</a>
</li>
</ul>
{# <ul>#}
{# <li>#}
{# <a href="{{ path('admin_roles') }}">{{ 'heading.roles'|trans }}</a>#}
{# </li>#}
{# </ul>#}
{% endif %}
<ul>
<li>
<a href="{{ path('author-profile', {npub: app.user.npub }) }}">Profile</a>
</li>
{# <li>#}
{# <a href="{{ path('editor-create') }}">Write an article</a>#}
{# </li>#}
{# <li>#}
{# <a href="{{ path('nzine_index') }}">{{ 'heading.createNzine'|trans }}</a>#}
{# </li>#}
<li>
<a href="{{ path('editor-create') }}">Write an article</a>
</li>
<li>
<a href="{{ path('nzine_index') }}">{{ 'heading.createNzine'|trans }}</a>
<a href="{{ path('app_search_index') }}">{{ 'heading.search'|trans }}</a>
</li>
{# <li>#}
{# <a href="{{ path('app_index_index') }}">{{ 'heading.index'|trans }}</a>#}
{# </li>#}
<li>
<a href="/logout" data-action="live#$render">{{ 'heading.logout'|trans }}</a>
</li>
@ -25,9 +31,4 @@ @@ -25,9 +31,4 @@
{% else %}
<twig:Atoms:Button {{ ...stimulus_action('login', 'loginAct') }}>{{ 'heading.logIn'|trans }}</twig:Atoms:Button>
{% endif %}
<ul>
<li>
<a href="{{ path('app_search_index') }}">{{ 'heading.search'|trans }}</a>
</li>
</ul>
</div>

4
templates/home.html.twig

@ -9,6 +9,6 @@ @@ -9,6 +9,6 @@
{% endblock %}
{% block aside %}
<h6>Magazines</h6>
<twig:Organisms:ZineList />
{# <h6>Magazines</h6>#}
{# <twig:Organisms:ZineList />#}
{% endblock %}

2
templates/pages/author.html.twig

@ -26,5 +26,5 @@ @@ -26,5 +26,5 @@
{% endblock %}
{% block aside %}
<twig:Organisms:ZineList :nzines="nzines" />
{# <twig:Organisms:ZineList :nzines="nzines" />#}
{% endblock %}

3
templates/pages/nzine.html.twig

@ -8,10 +8,9 @@ @@ -8,10 +8,9 @@
<twig:IndexTabs :index="index" />
</div>
{% endblock %}
{% block aside %}
<p>TODO search</p>
{# <p>TODO search & add to index</p> #}
{% endblock %}

4
templates/pages/search.html.twig

@ -8,6 +8,6 @@ @@ -8,6 +8,6 @@
{% endblock %}
{% block aside %}
<h6>Magazines</h6>
<twig:Organisms:ZineList />
{# <h6>Magazines</h6>#}
{# <twig:Organisms:ZineList />#}
{% endblock %}

1
translations/messages.en.yaml

@ -10,3 +10,4 @@ heading: @@ -10,3 +10,4 @@ heading:
createNzine: 'Create an N-Zine'
editNzine: 'Edit your N-Zine'
search: 'Search'
index: 'Index'

Loading…
Cancel
Save