Merge pull request #1440 from wallabag/v2-fix-1433

fix #1433: remove www. on entries view
This commit is contained in:
Thomas Citharel 2015-09-29 23:23:58 +02:00
commit d2755b1c30
4 changed files with 31 additions and 2 deletions

View file

@ -17,3 +17,9 @@ services:
class: Twig_Extensions_Extension_Text class: Twig_Extensions_Extension_Text
tags: tags:
- { name: twig.extension } - { name: twig.extension }
wallabag.twig_extension:
class: Wallabag\CoreBundle\Twig\WallabagExtension
public: false
tags:
- { name: twig.extension }

View 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 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 %}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 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> </ul>
{% if entry.previewPicture is null %} {% if entry.previewPicture is null %}
<p>{{ entry.content|striptags|slice(0, 300) }}&hellip;</p> <p>{{ entry.content|striptags|slice(0, 300) }}&hellip;</p>

View file

@ -76,7 +76,7 @@
{% endif %} {% endif %}
<div class="card-action"> <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"> <ul class="tools links right">
<li> <li>

View file

@ -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';
}
}