]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #1461 from wallabag/v2-test-for-www
authorJeremy Benoist <j0k3r@users.noreply.github.com>
Tue, 6 Oct 2015 07:16:52 +0000 (09:16 +0200)
committerJeremy Benoist <j0k3r@users.noreply.github.com>
Tue, 6 Oct 2015 07:16:52 +0000 (09:16 +0200)
fix #1433: add test for removeWww Twig Extension

src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
src/Wallabag/CoreBundle/Tests/Twig/WallabagExtensionTest.php [new file with mode: 0644]

index f58d0399bbe3a70a63e395e9f5c9f8f51635b3c4..b3f4709802e715af651853ab9c7aa4d60a12661a 100644 (file)
@@ -1,12 +1,12 @@
 {% extends "WallabagCoreBundle::layout.html.twig" %}
 
-{% block title %}{{ entry.title|raw }} ({{ entry.domainName }}){% endblock %}
+{% block title %}{{ entry.title|raw }} ({{ entry.domainName|removeWww }}){% 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.domainName }}</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.domainName|removeWww }}</span></a></li>
             <li><a title="{% trans %}Mark as read{% endtrans %}" class="tool icon icon-check {% 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 %}Favorite{% endtrans %}" class="tool icon icon-star {% 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 icon-trash" href="{{ path('delete_entry', { 'id': entry.id }) }}"><span>{% trans %}Delete{% endtrans %}</span></a></li>
index 9fb820b4a5bdd7086f4a9efa2cce4fa1697ab764..7230506c347fd8e9882445470aad369ad920356d 100644 (file)
@@ -1,6 +1,6 @@
 {% extends "WallabagCoreBundle::layout.html.twig" %}
 
-{% block title %}{{ entry.title|raw }} ({{ entry.domainName }}){% endblock %}
+{% block title %}{{ entry.title|raw }} ({{ entry.domainName|removeWww }}){% endblock %}
 
 {% block menu %}
     <div class="progress">
@@ -144,7 +144,7 @@ main {
             <h1>{{ entry.title|raw }} <a href="{{ path('edit', { 'id': entry.id }) }}" title="{% trans %}Edit title{% endtrans %}">✎</a></h1>
         </header>
         <aside>
-            <a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link mdi-content-link"> <span>{{ entry.domainName }}</span></a>
+            <a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link mdi-content-link"> <span>{{ entry.domainName|removeWww }}</span></a>
             <div id="list">
                 {% for tag in entry.tags %}
                     <div class="chip">
diff --git a/src/Wallabag/CoreBundle/Tests/Twig/WallabagExtensionTest.php b/src/Wallabag/CoreBundle/Tests/Twig/WallabagExtensionTest.php
new file mode 100644 (file)
index 0000000..4945e9a
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+namespace Wallabag\CoreBundle\Tests\Twig;
+
+use Wallabag\CoreBundle\Twig\WallabagExtension;
+
+class WallabagExtensionTest extends \PHPUnit_Framework_TestCase
+{
+    public function testRemoveWww()
+    {
+        $extension = new WallabagExtension();
+
+        $this->assertEquals("lemonde.fr", $extension->removeWww('www.lemonde.fr'));
+        $this->assertEquals("lemonde.fr", $extension->removeWww('lemonde.fr'));
+        $this->assertEquals("gist.github.com", $extension->removeWww('gist.github.com'));
+    }
+}