]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #1440 from wallabag/v2-fix-1433
authorThomas Citharel <tcit@tcit.fr>
Tue, 29 Sep 2015 21:23:58 +0000 (23:23 +0200)
committerThomas Citharel <tcit@tcit.fr>
Tue, 29 Sep 2015 21:23:58 +0000 (23:23 +0200)
fix #1433: remove www. on entries view

app/config/services.yml
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
src/Wallabag/CoreBundle/Twig/WallabagExtension.php [new file with mode: 0644]

index a7fa9bfea3a3bdcd53ce850355b3f9819e42f43d..965bc3195e68d69924753ef7929a85b15526d30d 100644 (file)
@@ -17,3 +17,9 @@ services:
         class: Twig_Extensions_Extension_Text
         tags:
             - { name: twig.extension }
+
+    wallabag.twig_extension:
+        class: Wallabag\CoreBundle\Twig\WallabagExtension
+        public: false
+        tags:
+            - { name: twig.extension }
index 08f3fe60bd98e24bc3b60c356b03bdde618ee036..abbcb3899412dd3d55ee58a1dfca61bf50aad67a 100644 (file)
@@ -36,7 +36,7 @@
                     <li><a title="{% trans %}Toggle mark as read{% endtrans %}" class="tool icon-check icon {% if entry.isArchived == 0 %}archive-off{% else %}archive{% endif %}" href="{{ path('archive_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li>
                     <li><a title="{% trans %}toggle favorite{% endtrans %}" class="tool icon-star icon {% if entry.isStarred == 0 %}fav-off{% else %}fav{% endif %}" href="{{ path('star_entry', { 'id': entry.id }) }}"><span>{% trans %}toggle favorite{% endtrans %}</span></a></li>
                     <li><a title="{% trans %}delete{% endtrans %}" class="tool delete icon-trash icon" href="{{ path('delete_entry', { 'id': entry.id }) }}"><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.domainName }}</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.domainName|removeWww }}</span></a></li>
                 </ul>
                 {% if entry.previewPicture is null %}
                     <p>{{ entry.content|striptags|slice(0, 300) }}&hellip;</p>
index dcdf7c09117fec309c100866b101544c02034ae3..ff69e8213620790402b57b8f35db156a27450b24 100644 (file)
@@ -76,7 +76,7 @@
                     {% endif %}
 
                     <div class="card-action">
-                        <span class="bold"><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %}: {{ entry.title|e }} - {{ entry.domainName }}" class="tool original grey-text"><span>{{ entry.domainName | truncate(18) }}</span></a></bold>
+                        <span class="bold"><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %}: {{ entry.title|e }} - {{ entry.domainName|removeWww }}" class="tool original grey-text"><span>{{ entry.domainName|removeWww|truncate(18) }}</span></a></bold>
 
                         <ul class="tools links right">
                             <li>
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
new file mode 100644 (file)
index 0000000..f832886
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+
+namespace Wallabag\CoreBundle\Twig;
+
+class WallabagExtension extends \Twig_Extension
+{
+    public function getFilters()
+    {
+        return array(
+            new \Twig_SimpleFilter('removeWww', array($this, 'removeWww')),
+        );
+    }
+
+    public function removeWww($url)
+    {
+        return preg_replace('/^www\./i', '',$url);
+    }
+
+    public function getName()
+    {
+        return 'wallabag_extension';
+    }
+}