diff --git a/assets/styles/app.css b/assets/styles/app.css
index 76f618b..0b891c7 100644
--- a/assets/styles/app.css
+++ b/assets/styles/app.css
@@ -376,10 +376,10 @@ footer a {
transition: background-color 0.3s ease; /* Smooth hover effect */
}
-/* Hover effect for tags */
-.tag:hover {
- color: var(--color-text-contrast);
-}
+/*!* Hover effect for tags *!*/
+/*.tag:hover {*/
+/* color: var(--color-text-contrast);*/
+/*}*/
/* Optional: Responsive adjustments for smaller screens */
@media (max-width: 768px) {
diff --git a/src/Command/NostrEventFromYamlDefinitionCommand.php b/src/Command/NostrEventFromYamlDefinitionCommand.php
index b8b0734..ff56c1f 100644
--- a/src/Command/NostrEventFromYamlDefinitionCommand.php
+++ b/src/Command/NostrEventFromYamlDefinitionCommand.php
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace App\Command;
-use App\Entity\Article;
use App\Enum\IndexStatusEnum;
use App\Factory\ArticleFactory;
use App\Service\NostrClient;
@@ -103,31 +102,24 @@ class NostrEventFromYamlDefinitionCommand extends Command
// crawl relays for all the articles and save to db
$fresh = $this->client->getArticles($articleSlugsList);
+ $articles = [];
foreach ($fresh as $item) {
$article = $this->factory->createFromLongFormContentEvent($item);
+ $article->setIndexStatus(IndexStatusEnum::TO_BE_INDEXED);
$this->entityManager->persist($article);
- }
- $this->entityManager->flush();
-
- // look up all articles in the db and push to index whatever you find
- $articles = $this->entityManager->getRepository(Article::class)->createQueryBuilder('a')
- ->where('a.slug IN (:slugs)')
- ->setParameter('slugs', $articleSlugsList)
- ->getQuery()
- ->getResult();
-
- // mark all of those for indexing
- foreach ($articles as $article) {
- if ($article->getIndexStatus() === IndexStatusEnum::NOT_INDEXED) {
- $article->setIndexStatus(IndexStatusEnum::TO_BE_INDEXED);
- $this->entityManager->persist($article);
- }
+ $articles[] = $article;
}
$this->entityManager->flush();
// to elastic
if (count($articles) > 0 ) {
$this->itemPersister->insertMany($articles); // Insert or skip existing
+ // Set all articles as indexed
+ foreach ($articles as $article) {
+ $article->setIndexStatus(IndexStatusEnum::INDEXED);
+ $this->entityManager->persist($article);
+ }
+ $this->entityManager->flush();
$output->writeln('Added to index.');
}
diff --git a/src/Controller/AuthorController.php b/src/Controller/AuthorController.php
index 355405c..8b77307 100644
--- a/src/Controller/AuthorController.php
+++ b/src/Controller/AuthorController.php
@@ -45,7 +45,7 @@ class AuthorController extends AbstractController
}
}
- return $this->render('Pages/author.html.twig', [
+ return $this->render('pages/author.html.twig', [
'author' => $author,
'npub' => $npub,
'articles' => $articles
diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php
index 637df1e..eabcc80 100644
--- a/src/Controller/DefaultController.php
+++ b/src/Controller/DefaultController.php
@@ -4,15 +4,15 @@ declare(strict_types=1);
namespace App\Controller;
+use Elastica\Query;
use Elastica\Query\Terms;
+use Exception;
use FOS\ElasticaBundle\Finder\FinderInterface;
use Psr\Cache\InvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Contracts\Cache\CacheInterface;
-use App\Service\NostrClient;
-use App\Factory\ArticleFactory;
use Psr\Log\LoggerInterface;
class DefaultController extends AbstractController
@@ -23,7 +23,7 @@ class DefaultController extends AbstractController
}
/**
- * @throws \Exception
+ * @throws Exception
* @throws InvalidArgumentException
*/
#[Route('/', name: 'home')]
@@ -51,12 +51,10 @@ class DefaultController extends AbstractController
#[Route('/cat/{slug}', name: 'magazine-category')]
public function magCategory($slug, CacheInterface $redisCache,
FinderInterface $finder,
- NostrClient $nostrClient,
- ArticleFactory $articleFactory,
LoggerInterface $logger): Response
{
$catIndex = $redisCache->get('magazine-' . $slug, function (){
- throw new \Exception('Not found');
+ throw new Exception('Not found');
});
$list = [];
@@ -76,19 +74,21 @@ class DefaultController extends AbstractController
}
}
- // Limit to first 9 coordinates to avoid excessive processing
- $coordinates = array_slice($coordinates, 0, 9);
-
if (!empty($coordinates)) {
// Extract slugs for elasticsearch query
$slugs = array_map(function($coordinate) {
- $parts = explode(':', $coordinate);
- return count($parts) === 3 ? $parts[2] : '';
+ $parts = explode(':', $coordinate, 3);
+ return end($parts);
}, $coordinates);
$slugs = array_filter($slugs); // Remove empty values
- // Try to fetch articles from elasticsearch first
- $query = new Terms('slug', array_values($slugs));
+ // First filter to only include articles with the slugs we want
+ $termsQuery = new Terms('slug', array_values($slugs));
+
+ // Create a Query object to set the size parameter
+ $query = new Query($termsQuery);
+ $query->setSize(200); // Set size to exceed the number of articles we expect
+
$articles = $finder->find($query);
// Create a map of slug => item to remove duplicates
@@ -96,15 +96,24 @@ class DefaultController extends AbstractController
foreach ($articles as $item) {
$slug = $item->getSlug();
if ($slug !== '') {
- $slugMap[$slug] = $item;
+ // If the slugMap doesn't contain it yet, add it
+ if (!isset($slugMap[$slug])) {
+ $slugMap[$slug] = $item;
+ } else {
+ // If it already exists, compare created_at timestamps and save newest
+ $existingItem = $slugMap[$slug];
+ if ($item->getCreatedAt() > $existingItem->getCreatedAt()) {
+ $slugMap[$slug] = $item;
+ }
+ }
}
}
// Find missing coordinates
$missingCoordinates = [];
foreach ($coordinates as $coordinate) {
- $parts = explode(':', $coordinate);
- if (count($parts) === 3 && !isset($slugMap[$parts[2]])) {
+ $parts = explode(':', $coordinate, 3);
+ if (!isset($slugMap[end($parts)])) {
$missingCoordinates[] = $coordinate;
}
}
@@ -138,9 +147,9 @@ class DefaultController extends AbstractController
// Build ordered list based on original coordinates order
foreach ($coordinates as $coordinate) {
- $parts = explode(':', $coordinate);
- if (count($parts) === 3 && isset($slugMap[$parts[2]])) {
- $list[] = $slugMap[$parts[2]];
+ $parts = explode(':', $coordinate,3);
+ if (isset($slugMap[end($parts)])) {
+ $list[] = $slugMap[end($parts)];
}
}
}
diff --git a/src/Twig/Components/Organisms/FeaturedList.php b/src/Twig/Components/Organisms/FeaturedList.php
index 9b2f9af..01cd6a8 100644
--- a/src/Twig/Components/Organisms/FeaturedList.php
+++ b/src/Twig/Components/Organisms/FeaturedList.php
@@ -2,24 +2,18 @@
namespace App\Twig\Components\Organisms;
-use App\Entity\Article;
-use App\Factory\ArticleFactory;
-use App\Service\NostrClient;
-use Elastica\Query\MatchQuery;
+use Elastica\Query;
use Elastica\Query\Terms;
use FOS\ElasticaBundle\Finder\FinderInterface;
use Psr\Cache\InvalidArgumentException;
use swentel\nostr\Event\Event;
-use Symfony\Component\Serializer\Encoder\JsonEncoder;
-use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
-use Symfony\Component\Serializer\Serializer;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
#[AsTwigComponent]
final class FeaturedList
{
- public $category;
+ public string $category;
public string $title;
public array $list = [];
@@ -47,36 +41,40 @@ final class FeaturedList
$this->title = $tag[1];
}
if ($tag[0] === 'a') {
- $parts = explode(':', $tag[1]);
- if (count($parts) === 3) {
- $slugs[] = $parts[2];
+ $parts = explode(':', $tag[1], 3);
+ $slugs[] = end($parts);
+ if (count($slugs) >= 5) {
+ break; // Limit to 4 items
}
}
}
- $query = new Terms('slug', array_values($slugs));
- $res = $this->finder->find($query);
+ $termsQuery = new Terms('slug', array_values($slugs));
+ $query = new Query($termsQuery);
+ $query->setSize(200); // Set size to exceed the number of articles we expect
+ $articles = $this->finder->find($query);
- // Create a map of slug => item to remove duplicates
+ // Create a map of slug => item
$slugMap = [];
-
- foreach ($res as $item) {
- $slug = $item->getSlug();
-
- if ($slug !== '' && !isset($slugMap[$slug])) {
- $slugMap[$slug] = $item;
+ foreach ($articles as $article) {
+ $slug = $article->getSlug();
+ if ($slug !== '') {
+ if (!isset($slugMap[$slug])) {
+ $slugMap[$slug] = $article;
+ } elseif ($article->getCreatedAt() > $slugMap[$slug]->getCreatedAt()) {
+ $slugMap[$slug] = $article;
+ }
}
}
- if (!empty($res)) {
- foreach ($res as $result) {
- if (!isset($slugMap[$result->getSlug()])) {
- $slugMap[$result->getSlug()] = $result;
- }
+ // Build ordered list based on original slugs order
+ $orderedList = [];
+ foreach ($slugs as $slug) {
+ if (isset($slugMap[$slug])) {
+ $orderedList[] = $slugMap[$slug];
}
}
-
- $this->list = array_slice(array_values($slugMap), 0, 4);
+ $this->list = array_slice($orderedList, 0, 4);
}
}
diff --git a/src/Util/CommonMark/NostrSchemeExtension/NostrSchemeParser.php b/src/Util/CommonMark/NostrSchemeExtension/NostrSchemeParser.php
index 3e199f7..9fc6404 100644
--- a/src/Util/CommonMark/NostrSchemeExtension/NostrSchemeParser.php
+++ b/src/Util/CommonMark/NostrSchemeExtension/NostrSchemeParser.php
@@ -41,25 +41,25 @@ class NostrSchemeParser implements InlineParserInterface
case 'nprofile':
/** @var NProfile $decodedProfile */
$decodedProfile = $decoded->data;
- $inlineContext->getContainer()->appendChild(new NostrMentionLink(null, $decodedProfile->getPubkey()));
+ $inlineContext->getContainer()->appendChild(new NostrMentionLink(null, $decodedProfile->pubkey));
break;
case 'nevent':
/** @var NEvent $decodedNpub */
$decodedEvent = $decoded->data;
- $eventId = $decodedEvent->getId();
- $relays = $decodedEvent->getRelays();
- $author = $decodedEvent->getAuthor();
- $kind = $decodedEvent->getKind();
- $inlineContext->getContainer()->appendChild(new NostrSchemeData('nevent', $eventId, $relays, $author, $kind));
+ $eventId = $decodedEvent->id;
+ $relays = $decodedEvent->relays;
+ $author = $decodedEvent->author;
+ $kind = $decodedEvent->kind;
+ $inlineContext->getContainer()->appendChild(new NostrSchemeData('nevent', $bechEncoded, $relays, $author, $kind));
break;
case 'naddr':
/** @var NAddr $decodedNpub */
$decodedEvent = $decoded->data;
- $identifier = $decodedEvent->getIdentifier();
- $pubkey = $decodedEvent->getPubkey();
- $kind = $decodedEvent->getKind();
- $relays = $decodedEvent->getRelays();
- $inlineContext->getContainer()->appendChild(new NostrSchemeData('naddr', $identifier, $relays, $pubkey, $kind));
+ $identifier = $decodedEvent->identifier;
+ $pubkey = $decodedEvent->pubkey;
+ $kind = $decodedEvent->kind;
+ $relays = $decodedEvent->relays;
+ $inlineContext->getContainer()->appendChild(new NostrSchemeData('naddr', $bechEncoded, $relays, $pubkey, $kind));
break;
case 'nrelay':
// deprecated
diff --git a/templates/base.html.twig b/templates/base.html.twig
index ab981c1..8d789e0 100644
--- a/templates/base.html.twig
+++ b/templates/base.html.twig
@@ -10,9 +10,13 @@
+
+
+
{% block ogtags %}
+
{% endblock %}
{% block stylesheets %}
diff --git a/templates/components/Footer.html.twig b/templates/components/Footer.html.twig
index 2270cdd..604e4db 100644
--- a/templates/components/Footer.html.twig
+++ b/templates/components/Footer.html.twig
@@ -3,6 +3,7 @@
Roadmap -
{# Pricing -#}
Terms of service
-{# Decent Newsroom - Geyser fund#}
+
+ Decent Newsroom @ Geyser fund
-
{{ "now"|date("Y") }} Decent Newsroom - Preprint
+{{ "now"|date("Y") }} Decent Newsroom - v0.0.1 Preprint