]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
article view, fav list, archive list
authorNicolas Lœuillet <nicolas@loeuillet.org>
Thu, 22 Jan 2015 20:11:22 +0000 (21:11 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Thu, 22 Jan 2015 20:11:22 +0000 (21:11 +0100)
app/config/config.yml
src/WallabagBundle/Controller/EntryController.php
src/WallabagBundle/Repository/EntriesRepository.php
src/WallabagBundle/Resources/views/Entry/entries.html.twig
src/WallabagBundle/Resources/views/Entry/entry.html.twig [new file with mode: 0644]
src/WallabagBundle/Resources/views/_menu.html.twig [new file with mode: 0644]
src/WallabagBundle/Resources/views/_top.html.twig

index ca7fb467d1716423f6823c3e7c2d83d6aa611b92..c6bed7970c3ba01bfb59d8ad967556ce6cfb3f52 100644 (file)
@@ -29,6 +29,21 @@ framework:
 twig:
     debug:            "%kernel.debug%"
     strict_variables: "%kernel.debug%"
+    globals:
+        share_twitter: %share_twitter%
+        share_mail: %share_mail%
+        share_shaarli: %share_shaarli%
+        shaarli_url: %shaarli_url%
+        share_diaspora: %share_diaspora%
+        diaspora_url: %diaspora_url%
+        flattr: %flattr%
+        flattrable: 1
+        flattred: 2
+        carrot: %carrot%
+        show_printlink: %show_printlink%
+        export_epub: %export_epub%
+        export_mobi: %export_mobi%
+        export_pdf: %export_pdf%
 
 # Assetic Configuration
 assetic:
index 0c0c156905b9d899a240ca2421fdcec0b1335eb6..233a6c32bcf37946368eaf570e78e69023c24680 100644 (file)
@@ -11,7 +11,7 @@ class EntryController extends Controller
     /**
      * @Route("/unread", name="unread")
      */
-    public function unreadAction()
+    public function showUnreadAction()
     {
         $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
         $entries = $repository->findUnreadByUser(1);
@@ -22,4 +22,49 @@ class EntryController extends Controller
         );
 
     }
+
+    /**
+     * @Route("/archive", name="archive")
+     */
+    public function showArchiveAction()
+    {
+        $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
+        $entries = $repository->findArchiveByUser(1);
+
+        return $this->render(
+            'WallabagBundle:Entry:entries.html.twig',
+            array('entries' => $entries)
+        );
+
+    }
+
+    /**
+     * @Route("/starred", name="starred")
+     */
+    public function showStarredAction()
+    {
+        $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
+        $entries = $repository->findStarredByUser(1);
+
+        return $this->render(
+            'WallabagBundle:Entry:entries.html.twig',
+            array('entries' => $entries)
+        );
+
+    }
+
+    /**
+     * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view")
+     */
+    public function viewAction($id)
+    {
+        $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
+        $entry = $repository->find($id);
+
+        return $this->render(
+            'WallabagBundle:Entry:entry.html.twig',
+            array('entry' => $entry)
+        );
+
+    }
 }
index 4c13c9c2fd65f07fa6b104207a3f990714e556a8..c355a012c61dd51a68ccc0a1e914f4d9468e3a42 100644 (file)
@@ -13,14 +13,6 @@ use Doctrine\ORM\EntityRepository;
  */
 class EntriesRepository extends EntityRepository
 {
-  /*  public function findUnreadByUser($userId)
-    {
-        return $this->createQueryBuilder('e')
-            ->where('e.is_read = 0')
-            ->andWhere('e.user_id = :userId')
-            ->setParameter('userId', $userId)
-            ->getQuery();
-    }*/
     public function findUnreadByUser($userId)
     {
         $qb = $this->createQueryBuilder('e')
@@ -32,4 +24,28 @@ class EntriesRepository extends EntityRepository
 
         return $qb;
     }
+
+    public function findArchiveByUser($userId)
+    {
+        $qb = $this->createQueryBuilder('e')
+            ->select('e')
+            ->where('e.isRead = 1')
+            ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
+            ->getQuery()
+            ->getResult(Query::HYDRATE_ARRAY);
+
+        return $qb;
+    }
+
+    public function findStarredByUser($userId)
+    {
+        $qb = $this->createQueryBuilder('e')
+            ->select('e')
+            ->where('e.isFav = 1')
+            ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
+            ->getQuery()
+            ->getResult(Query::HYDRATE_ARRAY);
+
+        return $qb;
+    }
 }
index f4d7a7ab8af4545bb64a92b34cfd794ce40249b5..8117729801d6c105c60d07dd64e7c91ac2da1497 100644 (file)
@@ -2,25 +2,32 @@
 
 {% block title "Unread" %}
 
-{% block content_header '' %}
+{% block menu %}
+    {% include "WallabagBundle::_menu.html.twig" %}
+{% endblock %}
 
 {% block content %}
-    {% for entry in entries %}
-        <div id="entry-{{ entry.id|e }}" class="entrie">
-            <h2><a href="index.php?view=view&amp;id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2>
-            {% if entry.content| readingTime > 0 %}
-                <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} {{ entry.content| readingTime }} min</span></div>
-            {% else %}
-                <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} <small class="inferieur">&lt;</small> 1 min</span></div>
-            {% endif %}
 
-            <ul class="tools links">
-                <li><a title="{% trans %}Toggle mark as read{% endtrans %}" class="tool icon-check icon {% if entry.isRead == 0 %}archive-off{% else %}archive{% endif %}" href="./?action=toggle_archive&amp;id={{ entry.id|e }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li>
-                <li><a title="{% trans %}toggle favorite{% endtrans %}" class="tool icon-star icon {% if entry.isFav == 0 %}fav-off{% else %}fav{% endif %}" href="./?action=toggle_fav&amp;id={{ entry.id|e }}"><span>{% trans %}toggle favorite{% endtrans %}</span></a></li>
-                <li><a title="{% trans %}delete{% endtrans %}" class="tool delete icon-trash icon" href="./?action=delete&amp;id={{ entry.id|e }}"><span>{% trans %}delete{% endtrans %}</span></a></li>
-                <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link icon-link icon"><span>{{ entry.url | e | domainName }}</span></a></li>
-            </ul>
-            <p>{{ entry.content|striptags|slice(0, 300) }}...</p>
-        </div>
-    {% endfor %}
+    {% if entries is empty %}
+        <div class="messages warning"><p>{% trans %}No articles found.{% endtrans %}</p></div>
+    {% else %}
+        {% for entry in entries %}
+            <div id="entry-{{ entry.id|e }}" class="entrie">
+                <h2><a href="{{ path('view', { 'id': entry.id }) }}">{{ entry.title|raw }}</a></h2>
+                {% if entry.content| readingTime > 0 %}
+                    <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} {{ entry.content| readingTime }} min</span></div>
+                {% else %}
+                    <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} <small class="inferieur">&lt;</small> 1 min</span></div>
+                {% endif %}
+
+                <ul class="tools links">
+                    <li><a title="{% trans %}Toggle mark as read{% endtrans %}" class="tool icon-check icon {% if entry.isRead == 0 %}archive-off{% else %}archive{% endif %}" href="./?action=toggle_archive&amp;id={{ entry.id|e }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li>
+                    <li><a title="{% trans %}toggle favorite{% endtrans %}" class="tool icon-star icon {% if entry.isFav == 0 %}fav-off{% else %}fav{% endif %}" href="./?action=toggle_fav&amp;id={{ entry.id|e }}"><span>{% trans %}toggle favorite{% endtrans %}</span></a></li>
+                    <li><a title="{% trans %}delete{% endtrans %}" class="tool delete icon-trash icon" href="./?action=delete&amp;id={{ entry.id|e }}"><span>{% trans %}delete{% endtrans %}</span></a></li>
+                    <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link icon-link icon"><span>{{ entry.url | e | domainName }}</span></a></li>
+                </ul>
+                <p>{{ entry.content|striptags|slice(0, 300) }}...</p>
+            </div>
+        {% endfor %}
+    {% endif %}
 {% endblock %}
diff --git a/src/WallabagBundle/Resources/views/Entry/entry.html.twig b/src/WallabagBundle/Resources/views/Entry/entry.html.twig
new file mode 100644 (file)
index 0000000..19d4650
--- /dev/null
@@ -0,0 +1,104 @@
+{% extends "WallabagBundle::layout.html.twig" %}
+
+{% block title %}{{ entry.title|raw }} ({{ entry.url | e | domainName }}){% endblock %}
+
+{% block menu %}
+    {% include "WallabagBundle::_menu.html.twig" %}
+{% endblock %}
+
+{% block content %}
+    <div id="article_toolbar">
+        <ul class="links">
+            <li class="topPosF"><a href="#top" title="{% trans %}Back to top{% endtrans %}" class="tool top icon icon-arrow-up-thick"><span>{% trans %}Back to top{% endtrans %}</span></a></li>
+            <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link icon icon-link"><span>{{ entry.url | e | domainName }}</span></a></li>
+            <li><a title="{% trans %}Mark as read{% endtrans %}" class="tool icon icon-check {% if entry.isRead == 0 %}archive-off{% else %}archive{% endif %}" href="javascript: void(null);" id="markAsRead"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li>
+            <li><a title="{% trans %}Favorite{% endtrans %}" class="tool icon icon-star {% if entry.isFav == 0 %}fav-off{% else %}fav{% endif %}" href="javascript: void(null);" id="setFav"><span>{% trans %}Toggle favorite{% endtrans %}</span></a></li>
+            <li><a title="{% trans %}Delete{% endtrans %}" class="tool delete icon icon-trash" href="./?action=delete&amp;id={{ entry.id|e }}"><span>{% trans %}Delete{% endtrans %}</span></a></li>
+            {% if share_twitter %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="{% trans %}Tweet{% endtrans %}"><span>{% trans %}Tweet{% endtrans %}</span></a></li>{% endif %}
+            {% if share_mail %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&amp;body={{ entry.url|url_encode }}%20via%20@wallabagapp" class="tool email icon icon-mail" title="{% trans %}Email{% endtrans %}"><span>{% trans %}Email{% endtrans %}</span></a></li>{% endif %}
+            {% if share_shaarli %}<li><a href="{{ shaarli_url }}/index.php?post={{ entry.url|url_encode }}&amp;title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans %}shaarli{% endtrans %}"><span>{% trans %}shaarli{% endtrans %}</span></a></li>{% endif %}
+            {% if share_diaspora %}<li><a href="{{ diaspora_url }}/bookmarklet?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}&notes=&v=1&noui=1&jump=doclose" target="_blank" class="tool diaspora icon-image icon-image--diaspora" title="{% trans %}diaspora{% endtrans %}"><span>{% trans %}diaspora{% endtrans %}</span></a></li>{% endif %}
+            {#  {% if flattr %}{% if flattr.status == flattrable %}<li><a href="http://flattr.com/submit/auto?url={{ entry.url }}" class="tool flattr icon icon-flattr" target="_blank" title="{% trans %}flattr{% endtrans %}"><span>{% trans %}flattr{% endtrans %}</span></a></li>{% elseif flattr.status == flattred %}<li><a href="{{ flattr.flattrItemURL }}" class="tool flattr icon icon-flattr" target="_blank" title="{% trans %}flattr{% endtrans %}><span>{% trans %}flattr{% endtrans %}</span> ({{ flattr.numFlattrs }})</a></li>{% endif %}{% endif %} #}
+            {% if carrot %}<li><a href="https://secure.carrot.org/GiveAndGetBack.do?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" class="tool carrot icon-image icon-image--carrot" target="_blank" title="{% trans %}carrot{% endtrans %}"><span>Carrot</span></a></li>{% endif %}
+            {% if show_printlink %}<li><a title="{% trans %}Print{% endtrans %}" class="tool icon icon-print" href="javascript: window.print();"><span>{% trans %}Print{% endtrans %}</span></a></li>{% endif %}
+            {% if export_epub %}<li><a href="./?epub&amp;method=id&amp;value={{ entry.id|e }}" title="Generate ePub file">EPUB</a></li>{% endif %}
+            {% if export_mobi %}<li><a href="./?mobi&amp;method=id&amp;value={{ entry.id|e }}" title="Generate Mobi file">MOBI</a></li>{% endif %}
+            {% if export_pdf %}<li><a href="./?pdf&amp;method=id&amp;value={{ entry.id|e }}" title="Generate PDF file">PDF</a></li>{% endif %}
+            <li><a href="mailto:hello@wallabag.org?subject=Wrong%20display%20in%20wallabag&amp;body={{ entry.url|url_encode }}" title="{% trans %}Does this article appear wrong?{% endtrans %}" class="tool bad-display icon icon-delete"><span>{% trans %}Does this article appear wrong?{% endtrans %}</span></a></li>
+        </ul>
+    </div>
+    <div id="article">
+        <header class="mbm">
+            <h1>{{ entry.title|raw }}</h1>
+        </header>
+        <aside class="tags">
+            tags: {# {% for tag in tags %}<a href="./?view=tag&amp;id={{ tag.id }}">{{ tag.value }}</a> {% endfor %}<a href="./?view=edit-tags&amp;id={{ entry.id|e }}" title="{% trans %}Edit tags{% endtrans %}">✎</a> #}
+        </aside>
+        <article>
+            {{ entry.content | raw }}
+        </article>
+    </div>
+    <script src="{{ asset('themes/_global/js/restoreScroll.js')}}"></script>
+    <script type="text/javascript">
+        $(document).ready(function() {
+
+            // toggle read property of current article
+            $('#markAsRead').click(function(){
+                $("body").css("cursor", "wait");
+                $.ajax( { url: './?action=toggle_archive&id={{ entry.id|e }}' }).done(
+                        function( data ) {
+                            if ( data == '1' ) {
+                                if ( $('#markAsRead').hasClass("archive-off") ) {
+                                    $('#markAsRead').removeClass("archive-off");
+                                    $('#markAsRead').addClass("archive");
+                                }
+                                else {
+                                    $('#markAsRead').removeClass("archive");
+                                    $('#markAsRead').addClass("archive-off");
+                                }
+                            }
+                            else {
+                                alert('Error! Pls check if you are logged in.');
+                            }
+                        });
+                $("body").css("cursor", "auto");
+            });
+
+            // toggle favorite property of current article
+            $('#setFav').click(function(){
+                $("body").css("cursor", "wait");
+                $.ajax( { url: './?action=toggle_fav&id={{ entry.id|e }}' }).done(
+                        function( data ) {
+                            if ( data == '1' ) {
+                                if ( $('#setFav').hasClass("fav-off") ) {
+                                    $('#setFav').removeClass("fav-off");
+                                    $('#setFav').addClass("fav");
+                                }
+                                else {
+                                    $('#setFav').removeClass("fav");
+                                    $('#setFav').addClass("fav-off");
+                                }
+                            }
+                            else {
+                                alert('Error! Pls check if you are logged in.');
+                            }
+                        });
+                $("body").css("cursor", "auto");
+            });
+
+            $(window).scroll(function(e){
+                var scrollTop = $(window).scrollTop();
+                var docHeight = $(document).height();
+                var scrollPercent = (scrollTop) / (docHeight);
+                var scrollPercentRounded = Math.round(scrollPercent*100)/100;
+                savePercent({{ entry.id|e }}, scrollPercentRounded);
+            });
+
+            retrievePercent({{ entry.id|e }});
+
+            $(window).resize(function(){
+                retrievePercent({{ entry.id|e }});
+            });
+        });
+    </script>
+{% endblock %}
\ No newline at end of file
diff --git a/src/WallabagBundle/Resources/views/_menu.html.twig b/src/WallabagBundle/Resources/views/_menu.html.twig
new file mode 100644 (file)
index 0000000..b001aec
--- /dev/null
@@ -0,0 +1,17 @@
+            <button id="menu" class="icon icon-menu desktopHide"><span>Menu</span></button>
+            <ul id="links" class="links">
+                <li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
+                <li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li>
+                <li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li>
+                <li><a href="./?view=tags">{% trans %}tags{% endtrans %}</a></li>
+                <li style="position: relative;"><a href="javascript: void(null);" id="bagit">{% trans %}save a link{% endtrans %}</a>
+
+                </li>
+                <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a>
+
+                </li>
+                <li><a href="./?view=config">{% trans %}config{% endtrans %}</a></li>
+                <li><a href="./?view=about">{% trans %}about{% endtrans %}</a></li>
+                <li><a class="icon icon-power" href="./?logout" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li>
+            </ul>
+
index 576df806439d9f2aa76abc8637331d3528263d19..34d925df5d696e2369c65f10355c01ec6539e822 100755 (executable)
@@ -1,6 +1,5 @@
         <header class="w600p center mbm">
             <h1>
-                {% block logo %}<img width="100" height="100" src="{{ asset('themes/baggy/img/logo-other_themes.png') }}" alt="wallabag logo" />{% endblock %}
-
+                {% block logo %}<img width="100" height="100" src="{{ asset('themes/baggy/img/logo-w.png') }}" alt="wallabag logo" />{% endblock %}
             </h1>
         </header>