]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Added button to show entries with the same domain
authorNicolas Lœuillet <nicolas@loeuillet.org>
Mon, 18 Nov 2019 16:26:41 +0000 (17:26 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Thu, 30 Apr 2020 13:48:20 +0000 (15:48 +0200)
src/Wallabag/CoreBundle/Controller/EntryController.php
src/Wallabag/CoreBundle/Repository/EntryRepository.php
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_content.html.twig

index 9b2954e7d5d0525711ac4a61dec9cbae3f6eeda1..fad2b51cd5a760515447ec232a59423454ddfc26 100644 (file)
@@ -517,6 +517,24 @@ class EntryController extends Controller
         );
     }
 
+    /**
+     * List the entries with the same domain as the current one.
+     *
+     * @param int $page
+     *
+     * @Route("/same-domain/{id}/{page}", requirements={"id" = ".+"}, defaults={"page" = 1}, name="same_domain")
+     *
+     * @return \Symfony\Component\HttpFoundation\Response
+     */
+    public function getSameDomainEntries(Request $request, $page = 1)
+    {
+        if (!$this->get('craue_config')->get('share_public')) {
+            throw $this->createAccessDeniedException('Sharing an entry is disabled for this user.');
+        }
+
+        return $this->showEntries('same-domain', $request, $page);
+    }
+
     /**
      * Global method to retrieve entries depending on the given type
      * It returns the response to be send.
@@ -548,6 +566,9 @@ class EntryController extends Controller
             case 'unread':
                 $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
                 break;
+            case 'same-domain':
+                $qb = $repository->getBuilderForSameDomainByUser($this->getUser()->getId(), $request->get('id'));
+                break;
             case 'all':
                 $qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
                 break;
index bfd079377ac783bdd4c2e0e2f84cb3f2e9d0496b..f2c73bbfffcdfbd99ee629e1cf449fde626f67ba 100644 (file)
@@ -36,6 +36,26 @@ class EntryRepository extends EntityRepository
      */
     public function getBuilderForUnreadByUser($userId)
     {
+        return $this
+            ->getSortedQueryBuilderByUser($userId)
+            ->andWhere('e.isArchived = false')
+            ;
+    }
+
+    /**
+     * Retrieves entries with the same domain.
+     *
+     * @param int $userId
+     * @param int $entryId
+     *
+     * @return QueryBuilder
+     */
+    public function getBuilderForSameDomainByUser($userId, $entryId)
+    {
+        dump($entryId);die;
+
+        $
+
         return $this
             ->getSortedQueryBuilderByUser($userId)
             ->andWhere('e.isArchived = false')
index 1102a0bdb8bfac7b9b267dee154261a7d5621b32..e66cdf2c195244a05f06de7c9b375d0c12033feb 100644 (file)
@@ -7,7 +7,7 @@
     </a>
 
     <div class="{{ subClass|default('original grey-text') }}">
-        <a href="{{ entry.url|e }}" target="_blank" title="{{ entry.domainName|removeWww }}" class="tool grey-text">{{ entry.domainName|removeWww }}</a>
+        <a href="{{ entry.url|e }}" target="_blank" title="{{ entry.domainName|removeWww }}" class="tool grey-text">{{ entry.domainName|removeWww }}</a> <a href="{{ path('same_domain', { 'id': entry.id }) }}"><i class="material-icons">language</i></a>
         {% if withMetadata is defined %}
             {% include "@WallabagCore/themes/material/Entry/_tags.html.twig" with {'tags': entry.tags | slice(0, 3), 'entryId': entry.id, 'listClass': ' hide-on-med-and-down'} only %}
             <div class="reading-time grey-text">