aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-11-14 10:01:12 +0100
committerGitHub <noreply@github.com>2016-11-14 10:01:12 +0100
commitd37081e50b5c6f6d6d37523ab51082947c54fe03 (patch)
treeaa85385af6fe1002d9de3427c37ce5a643773ed4 /src
parent8315507384c5cbc26d6f73729aeb97395e3e55fa (diff)
parent8d7b4f0eff9d07f8d6d354e09fd926abf26aa4ce (diff)
downloadwallabag-d37081e50b5c6f6d6d37523ab51082947c54fe03.tar.gz
wallabag-d37081e50b5c6f6d6d37523ab51082947c54fe03.tar.zst
wallabag-d37081e50b5c6f6d6d37523ab51082947c54fe03.zip
Merge pull request #2562 from wallabag/image-bigger
Bigger image preview in case of only image content
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php8
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig14
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_full_image.html.twig28
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_no_preview.html.twig26
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_preview.html.twig47
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig75
6 files changed, 130 insertions, 68 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index 8019df42..bbd5db5d 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -8,6 +8,7 @@ use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Entity\Tag; 8use Wallabag\CoreBundle\Entity\Tag;
9use Wallabag\CoreBundle\Tools\Utils; 9use Wallabag\CoreBundle\Tools\Utils;
10use Wallabag\CoreBundle\Repository\TagRepository; 10use Wallabag\CoreBundle\Repository\TagRepository;
11use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
11 12
12/** 13/**
13 * This kind of proxy class take care of getting the content from an url 14 * This kind of proxy class take care of getting the content from an url
@@ -19,6 +20,7 @@ class ContentProxy
19 protected $tagger; 20 protected $tagger;
20 protected $logger; 21 protected $logger;
21 protected $tagRepository; 22 protected $tagRepository;
23 protected $mimeGuesser;
22 24
23 public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, Logger $logger) 25 public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, Logger $logger)
24 { 26 {
@@ -26,6 +28,7 @@ class ContentProxy
26 $this->tagger = $tagger; 28 $this->tagger = $tagger;
27 $this->logger = $logger; 29 $this->logger = $logger;
28 $this->tagRepository = $tagRepository; 30 $this->tagRepository = $tagRepository;
31 $this->mimeGuesser = new MimeTypeExtensionGuesser();
29 } 32 }
30 33
31 /** 34 /**
@@ -79,6 +82,11 @@ class ContentProxy
79 $entry->setPreviewPicture($content['open_graph']['og_image']); 82 $entry->setPreviewPicture($content['open_graph']['og_image']);
80 } 83 }
81 84
85 // if content is an image define as a preview too
86 if (in_array($this->mimeGuesser->guess($content['content_type']), ['jpeg', 'jpg', 'gif', 'png'], true)) {
87 $entry->setPreviewPicture($content['url']);
88 }
89
82 try { 90 try {
83 $this->tagger->tag($entry); 91 $this->tagger->tag($entry);
84 } catch (\Exception $e) { 92 } catch (\Exception $e) {
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig
new file mode 100644
index 00000000..9f696d06
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig
@@ -0,0 +1,14 @@
1<div class="card-action">
2 <span class="reading-time grey-text">
3 <i class="material-icons" title="{{ 'entry.list.reading_time'|trans }}">timer</i>
4 {{ entry.readingTime / app.user.config.readingSpeed|round }} min
5 </span>
6
7 <ul class="tools right">
8 <li>
9 <a title="{{ 'entry.list.toogle_as_read'|trans }}" class="tool grey-text" href="{{ path('archive_entry', { 'id': entry.id }) }}"><i class="material-icons">{% if entry.isArchived == 0 %}done{% else %}redo{% endif %}</i></a>
10 <a title="{{ 'entry.list.toogle_as_star'|trans }}" class="tool grey-text" href="{{ path('star_entry', { 'id': entry.id }) }}"><i class="material-icons">{% if entry.isStarred == 0 %}star_border{% else %}star{% endif %}</i></a>
11 <a title="{{ 'entry.list.delete'|trans }}" class="tool grey-text delete" href="{{ path('delete_entry', { 'id': entry.id }) }}"><i class="material-icons">delete</i></a>
12 </li>
13 </ul>
14</div>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_full_image.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_full_image.html.twig
new file mode 100644
index 00000000..0fdd5996
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_full_image.html.twig
@@ -0,0 +1,28 @@
1<div class="card">
2 <div class="card-body">
3 <div class="card-fullimage">
4 <ul class="card-entry-labels">
5 {% for tag in entry.tags | slice(0, 3) %}
6 <li><a href="{{ path('tag_entries', {'slug': tag.slug}) }}">{{ tag.label }}</a></li>
7 {% endfor %}
8 </ul>
9 <div class="preview activator" style="background-image: url({{ entry.previewPicture }})"></div>
10 </div>
11
12 <div class="card-content">
13 <span class="card-title dot-ellipsis dot-resize-update">
14 <a href="{{ path('view', { 'id': entry.id }) }}" title="{{ entry.title | raw | striptags }}">
15 {{ entry.title | raw | striptags | truncate(80, true, '…') }}
16 </a>
17 </span>
18
19 <div class="original grey-text">
20 <a href="{{ entry.url|e }}" target="_blank" title="{{ entry.domainName|removeWww }}" class="tool original grey-text">
21 <span>{{ entry.domainName|removeWww }}</span>
22 </a>
23 </div>
24 </div>
25 </div>
26
27 {% include "@WallabagCore/themes/material/Entry/_card_actions.html.twig" with {'entry': entry} only %}
28</div>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_no_preview.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_no_preview.html.twig
new file mode 100644
index 00000000..19a400b4
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_no_preview.html.twig
@@ -0,0 +1,26 @@
1<div class="card">
2 <div class="card-body">
3 <div class="card-content">
4 <span class="card-title dot-ellipsis dot-resize-update">
5 <a href="{{ path('view', { 'id': entry.id }) }}" title="{{ entry.title | raw | striptags }}">
6 {{ entry.title | raw | striptags | truncate(80, true, '…') }}
7 </a>
8 </span>
9
10 <div class="original grey-text">
11 <a href="{{ entry.url|e }}" target="_blank" title="{{ entry.domainName|removeWww }}" class="tool original grey-text">
12 <span>{{ entry.domainName|removeWww }}</span>
13 </a>
14 </div>
15
16 <p>{{ entry.content|striptags|slice(0, 250)|raw }}&hellip;</p>
17 <ul class="card-entry-labels-hidden">
18 {% for tag in entry.tags | slice(0, 2) %}
19 <li><a href="{{ path('tag_entries', {'slug': tag.slug}) }}">{{ tag.label }}</a></li>
20 {% endfor %}
21 </ul>
22 </div>
23 </div>
24
25 {% include "@WallabagCore/themes/material/Entry/_card_actions.html.twig" with {'entry': entry} only %}
26</div>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_preview.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_preview.html.twig
new file mode 100644
index 00000000..b0e3c06d
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_preview.html.twig
@@ -0,0 +1,47 @@
1<div class="card">
2 <div class="card-body">
3 <div class="card-image waves-effect waves-block waves-light">
4 <ul class="card-entry-labels">
5 {% for tag in entry.tags | slice(0, 3) %}
6 <li><a href="{{ path('tag_entries', {'slug': tag.slug}) }}">{{ tag.label }}</a></li>
7 {% endfor %}
8 </ul>
9 <div class="preview activator" style="background-image: url({{ entry.previewPicture }})"></div>
10 </div>
11
12 <div class="card-content">
13 <i class="grey-text text-darken-4 activator material-icons right">more_vert</i>
14
15 <span class="card-title dot-ellipsis dot-resize-update">
16 <a href="{{ path('view', { 'id': entry.id }) }}" title="{{ entry.title | raw | striptags }}">
17 {{ entry.title| striptags | truncate(80, true, '…') | raw }}
18 </a>
19 </span>
20
21 <div class="original grey-text">
22 <a href="{{ entry.url|e }}" target="_blank" title="{{ entry.domainName|removeWww }}" class="tool original grey-text">
23 <span>{{ entry.domainName|removeWww }}</span>
24 </a>
25 </div>
26 </div>
27 </div>
28
29 <div class="card-reveal">
30 <i class="card-title activator grey-text text-darken-4 material-icons right">clear</i>
31 <span class="card-title">
32 <a href="{{ path('view', { 'id': entry.id }) }}" title="{{ entry.title | raw | striptags }}">
33 {{ entry.title | raw | striptags | truncate(80, true, '…') }}
34 </a>
35 </span>
36
37 <p>{{ entry.content|striptags|slice(0, 250)|raw }}&hellip;</p>
38
39 <ul class="card-entry-labels-hidden">
40 {% for tag in entry.tags %}
41 <li><a href="{{ path('tag_entries', {'slug': tag.slug}) }}">{{ tag.label }}</a></li>
42 {% endfor %}
43 </ul>
44 </div>
45
46 {% include "@WallabagCore/themes/material/Entry/_card_actions.html.twig" with {'entry': entry} only %}
47</div>
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 498234b9..c610c8d2 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
@@ -22,74 +22,13 @@
22 <ul class="row data"> 22 <ul class="row data">
23 {% for entry in entries %} 23 {% for entry in entries %}
24 <li id="entry-{{ entry.id|e }}" class="col l3 m6 s12"> 24 <li id="entry-{{ entry.id|e }}" class="col l3 m6 s12">
25 <div class="card"> 25 {% if entry.previewPicture is null %}
26 26 {% include "@WallabagCore/themes/material/Entry/_card_no_preview.html.twig" with {'entry': entry} only %}
27 <div class="card-body"> 27 {% elseif not entry.previewPicture is null and entry.mimetype starts with 'image/' %}
28 {% if not entry.previewPicture is null %} 28 {% include "@WallabagCore/themes/material/Entry/_card_full_image.html.twig" with {'entry': entry} only %}
29 <div class="card-image waves-effect waves-block waves-light"> 29 {% elseif not entry.previewPicture is null %}
30 <ul class="card-entry-labels"> 30 {% include "@WallabagCore/themes/material/Entry/_card_preview.html.twig" with {'entry': entry} only %}
31 {% for tag in entry.tags | slice(0, 3) %} 31 {% endif %}
32 <li><a href="{{ path('tag_entries', {'slug': tag.slug}) }}">{{ tag.label }}</a></li>
33 {% endfor %}
34 </ul>
35 <div class="preview activator" style="background-image: url({{ entry.previewPicture }})"></div>
36 </div>
37 {% endif %}
38
39 <div class="card-content">
40 {% if not entry.previewPicture is null %}
41 <i class="grey-text text-darken-4 activator material-icons right">more_vert</i>
42 {% endif %}
43
44 <span class="card-title dot-ellipsis dot-resize-update"><a href="{{ path('view', { 'id': entry.id }) }}" title="{{ entry.title | raw | striptags }}">{{ entry.title| striptags | truncate(80, true, '…') | raw }}</a></span>
45
46 <div class="original grey-text">
47 <a href="{{ entry.url|e }}" target="_blank" title="{{ entry.domainName|removeWww }}" class="tool original grey-text">
48 <span>{{ entry.domainName|removeWww }}</span>
49 </a>
50 </div>
51
52 {% if entry.previewPicture is null %}
53 <p>{{ entry.content|striptags|slice(0, 250)|raw }}&hellip;</p>
54 <ul class="card-entry-labels-hidden">
55 {% for tag in entry.tags | slice(0, 2) %}
56 <li><a href="{{ path('tag_entries', {'slug': tag.slug}) }}">{{ tag.label }}</a></li>
57 {% endfor %}
58 </ul>
59 {% endif %}
60 </div>
61 </div>
62
63 {% if not entry.previewPicture is null %}
64 <div class="card-reveal">
65 <i class="card-title activator grey-text text-darken-4 material-icons right">clear</i>
66 <span class="card-title" title="{{ entry.title | raw | striptags }}"><a href="{{ path('view', { 'id': entry.id }) }}">{{ entry.title | raw | striptags | truncate(90, true, '…') }}</a></span>
67
68 <p>{{ entry.content|striptags|slice(0, 250)|raw }}&hellip;</p>
69
70 <ul class="card-entry-labels-hidden">
71 {% for tag in entry.tags %}
72 <li><a href="{{ path('tag_entries', {'slug': tag.slug}) }}">{{ tag.label }}</a></li>
73 {% endfor %}
74 </ul>
75 </div>
76 {% endif %}
77
78 <div class="card-action">
79 <span class="reading-time grey-text">
80 <i class="material-icons" title="{{ 'entry.list.reading_time'|trans }}">timer</i>
81 {{ entry.readingTime / app.user.config.readingSpeed|round }} min
82 </span>
83
84 <ul class="tools right">
85 <li>
86 <a title="{{ 'entry.list.toogle_as_read'|trans }}" class="tool grey-text" href="{{ path('archive_entry', { 'id': entry.id }) }}"><i class="material-icons">{% if entry.isArchived == 0 %}done{% else %}redo{% endif %}</i></a>
87 <a title="{{ 'entry.list.toogle_as_star'|trans }}" class="tool grey-text" href="{{ path('star_entry', { 'id': entry.id }) }}"><i class="material-icons">{% if entry.isStarred == 0 %}star_border{% else %}star{% endif %}</i></a>
88 <a title="{{ 'entry.list.delete'|trans }}" class="tool grey-text delete" href="{{ path('delete_entry', { 'id': entry.id }) }}"><i class="material-icons">delete</i></a>
89 </li>
90 </ul>
91 </div>
92 </div>
93 </li> 32 </li>
94 {% endfor %} 33 {% endfor %}
95 </ul> 34 </ul>