aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2015-08-12 21:16:00 +0200
committerNicolas Lœuillet <nicolas@loeuillet.org>2015-08-12 21:16:00 +0200
commitc2257428b2188fc709c76ec8f531287888de9741 (patch)
tree92c6dbc5f3027f0f8be9f21433bf678a4c6c2954 /src/Wallabag/CoreBundle
parentd990dc6f0535cad745929ca90d1e4bb00ba47584 (diff)
downloadwallabag-c2257428b2188fc709c76ec8f531287888de9741.tar.gz
wallabag-c2257428b2188fc709c76ec8f531287888de9741.tar.zst
wallabag-c2257428b2188fc709c76ec8f531287888de9741.zip
store domainName in database
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php1
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml5
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig4
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig6
-rw-r--r--src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php30
7 files changed, 8 insertions, 42 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 9aebc55b..7d2d2027 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -266,6 +266,7 @@ class Entry
266 { 266 {
267 $this->content = $content; 267 $this->content = $content;
268 $this->readingTime = Tools::getReadingTime($content); 268 $this->readingTime = Tools::getReadingTime($content);
269 $this->domainName = parse_url($this->url, PHP_URL_HOST);
269 270
270 return $this; 271 return $this;
271 } 272 }
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index d8bd8d52..08eae327 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -1,9 +1,4 @@
1services: 1services:
2 wallabag_core.twig.extension:
3 class: Wallabag\CoreBundle\Twig\Extension\WallabagExtension
4 tags:
5 - { name: twig.extension }
6
7 wallabag_core.helper.detect_active_theme: 2 wallabag_core.helper.detect_active_theme:
8 class: Wallabag\CoreBundle\Helper\DetectActiveTheme 3 class: Wallabag\CoreBundle\Helper\DetectActiveTheme
9 arguments: 4 arguments:
diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
index ea4a9976..539c035f 100644
--- a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
@@ -35,7 +35,7 @@
35 <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> 35 <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>
36 <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> 36 <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>
37 <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> 37 <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>
38 <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> 38 <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>
39 </ul> 39 </ul>
40 <p>{{ entry.content|striptags|slice(0, 300) }}...</p> 40 <p>{{ entry.content|striptags|slice(0, 300) }}...</p>
41 </div> 41 </div>
diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig
index f5c19ea3..00480d1a 100644
--- a/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig
@@ -1,12 +1,12 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %} 1{% extends "WallabagCoreBundle::layout.html.twig" %}
2 2
3{% block title %}{{ entry.title|raw }} ({{ entry.url | e | domainName }}){% endblock %} 3{% block title %}{{ entry.title|raw }} ({{ entry.domainName }}){% endblock %}
4 4
5{% block content %} 5{% block content %}
6 <div id="article_toolbar"> 6 <div id="article_toolbar">
7 <ul class="links"> 7 <ul class="links">
8 <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> 8 <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>
9 <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> 9 <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>
10 <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> 10 <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>
11 <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> 11 <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>
12 <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> 12 <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>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
index 55e3540d..7777dc7f 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
@@ -47,7 +47,7 @@
47 <p>{{ entry.content|striptags|slice(0, 300) }}...</p> 47 <p>{{ entry.content|striptags|slice(0, 300) }}...</p>
48 </div> 48 </div>
49 <div class="card-action"> 49 <div class="card-action">
50 <span class="bold"><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %}: {{ entry.title|e }}" class="tool original grey-text"><span>{{ entry.url | e | domainName }}</span></a></bold> 50 <span class="bold"><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %}: {{ entry.title|e }}" class="tool original grey-text"><span>{{ entry.domainName }}</span></a></bold>
51 51
52 <ul class="tools links right"> 52 <ul class="tools links right">
53 <li> 53 <li>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
index 5d098232..6b91be97 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
@@ -1,6 +1,6 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %} 1{% extends "WallabagCoreBundle::layout.html.twig" %}
2 2
3{% block title %}{{ entry.title|raw }} ({{ entry.url | e | domainName }}){% endblock %} 3{% block title %}{{ entry.title|raw }} ({{ entry.domainName }}){% endblock %}
4 4
5{% block menu %} 5{% block menu %}
6 <nav class="hide-on-large-only"> 6 <nav class="hide-on-large-only">
@@ -123,7 +123,7 @@ main {
123 <div id="article"> 123 <div id="article">
124 <header class="mbm"> 124 <header class="mbm">
125 <h1>{{ entry.title|raw }} <a href="{{ path('edit', { 'id': entry.id }) }}" title="{% trans %}Edit title{% endtrans %}">✎</a></h1> 125 <h1>{{ entry.title|raw }} <a href="{{ path('edit', { 'id': entry.id }) }}" title="{% trans %}Edit title{% endtrans %}">✎</a></h1>
126 <a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link"><span>{{ entry.url | e | domainName }}</span></a> 126 <a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link"><span>{{ entry.domainName }}</span></a>
127 </header> 127 </header>
128 <aside class="tags"> 128 <aside class="tags">
129 tags: {% for tag in entry.tags %}<a href="./?view=tag&amp;id={{ tag.id }}">{{ tag.label }}</a> {% endfor %}<a href="./?view=edit-tags&amp;id={{ entry.id }}" title="{% trans %}Edit tags{% endtrans %}">✎</a> 129 tags: {% for tag in entry.tags %}<a href="./?view=tag&amp;id={{ tag.id }}">{{ tag.label }}</a> {% endfor %}<a href="./?view=edit-tags&amp;id={{ entry.id }}" title="{% trans %}Edit tags{% endtrans %}">✎</a>
@@ -135,4 +135,4 @@ main {
135{% endblock %} 135{% endblock %}
136 136
137{% block footer %} 137{% block footer %}
138{% endblock %} \ No newline at end of file 138{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php
deleted file mode 100644
index 5f0a9643..00000000
--- a/src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php
+++ /dev/null
@@ -1,30 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Twig\Extension;
4
5class WallabagExtension extends \Twig_Extension
6{
7 public function getFilters()
8 {
9 return array(
10 new \Twig_SimpleFilter('domainName', array($this, 'getDomainName')),
11 );
12 }
13
14 /**
15 * Returns the domain name for a URL.
16 *
17 * @param $url
18 *
19 * @return string
20 */
21 public static function getDomainName($url)
22 {
23 return parse_url($url, PHP_URL_HOST);
24 }
25
26 public function getName()
27 {
28 return 'wallabag_extension';
29 }
30}