diff options
author | Nicolas Lœuillet <nicolas@loeuillet.org> | 2016-11-28 11:02:10 +0100 |
---|---|---|
committer | Nicolas Lœuillet <nicolas@loeuillet.org> | 2016-11-28 14:27:58 +0100 |
commit | 9f01d0fde09fa055a7db9f26e77c5e6b3d6c2224 (patch) | |
tree | c8f043dde3a6bdd653aac7136d742f6ed8c49b84 /src | |
parent | 34ea7be6228c633ef8da703994eed034026e9c18 (diff) | |
download | wallabag-9f01d0fde09fa055a7db9f26e77c5e6b3d6c2224.tar.gz wallabag-9f01d0fde09fa055a7db9f26e77c5e6b3d6c2224.tar.zst wallabag-9f01d0fde09fa055a7db9f26e77c5e6b3d6c2224.zip |
Added list view
Diffstat (limited to 'src')
5 files changed, 72 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 52a03070..ea7cd883 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php | |||
@@ -363,4 +363,25 @@ class ConfigController extends Controller | |||
363 | 363 | ||
364 | return $this->redirect($this->generateUrl('fos_user_security_login')); | 364 | return $this->redirect($this->generateUrl('fos_user_security_login')); |
365 | } | 365 | } |
366 | |||
367 | /** | ||
368 | * Switch view mode for current user. | ||
369 | * | ||
370 | * @Route("/config/view-mode", name="switch_view_mode") | ||
371 | * | ||
372 | * @param Request $request | ||
373 | * | ||
374 | * @return \Symfony\Component\HttpFoundation\RedirectResponse | ||
375 | */ | ||
376 | public function changeViewModeAction(Request $request) | ||
377 | { | ||
378 | $user = $this->getUser(); | ||
379 | $user->getConfig()->setViewMode(!$user->getConfig()->getViewMode()); | ||
380 | |||
381 | $em = $this->getDoctrine()->getManager(); | ||
382 | $em->persist($user); | ||
383 | $em->flush(); | ||
384 | |||
385 | return $this->redirect($request->headers->get('referer')); | ||
386 | } | ||
366 | } | 387 | } |
diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index e04f0a7b..70364ab6 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php | |||
@@ -98,6 +98,13 @@ class Config | |||
98 | private $actionMarkAsRead; | 98 | private $actionMarkAsRead; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * @var int | ||
102 | * | ||
103 | * @ORM\Column(name="view_mode", type="integer", nullable=true) | ||
104 | */ | ||
105 | private $viewMode; | ||
106 | |||
107 | /** | ||
101 | * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config") | 108 | * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config") |
102 | */ | 109 | */ |
103 | private $user; | 110 | private $user; |
@@ -340,6 +347,26 @@ class Config | |||
340 | } | 347 | } |
341 | 348 | ||
342 | /** | 349 | /** |
350 | * @return int | ||
351 | */ | ||
352 | public function getViewMode() | ||
353 | { | ||
354 | return $this->viewMode; | ||
355 | } | ||
356 | |||
357 | /** | ||
358 | * @param int $viewMode | ||
359 | * | ||
360 | * @return Config | ||
361 | */ | ||
362 | public function setViewMode($viewMode) | ||
363 | { | ||
364 | $this->viewMode = $viewMode; | ||
365 | |||
366 | return $this; | ||
367 | } | ||
368 | |||
369 | /** | ||
343 | * @param TaggingRule $rule | 370 | * @param TaggingRule $rule |
344 | * | 371 | * |
345 | * @return Config | 372 | * @return Config |
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig index a13fe903..3df990a3 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig | |||
@@ -13,9 +13,11 @@ | |||
13 | 13 | ||
14 | {% block content %} | 14 | {% block content %} |
15 | 15 | ||
16 | {% set viewMode = app.user.config.viewMode %} | ||
16 | <div class="results"> | 17 | <div class="results"> |
17 | <div class="nb-results">{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}</div> | 18 | <div class="nb-results">{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}</div> |
18 | <div class="pagination"> | 19 | <div class="pagination"> |
20 | <a href="{{ path('switch_view_mode') }}"><i class="viewmode-btn material-icons md-36">{% if viewMode == 0 %}list{% else %}view_module{% endif %}</i></a> | ||
19 | <i class="btn-clickable download-btn material-icons md-36">file_download</i> | 21 | <i class="btn-clickable download-btn material-icons md-36">file_download</i> |
20 | <i class="btn-clickable filter-btn material-icons md-36">filter_list</i> | 22 | <i class="btn-clickable filter-btn material-icons md-36">filter_list</i> |
21 | {% if entries.getNbPages > 1 %} | 23 | {% if entries.getNbPages > 1 %} |
@@ -25,7 +27,7 @@ | |||
25 | </div> | 27 | </div> |
26 | 28 | ||
27 | {% for entry in entries %} | 29 | {% for entry in entries %} |
28 | <div id="entry-{{ entry.id|e }}" class="entry"> | 30 | <div id="entry-{{ entry.id|e }}" class="{% if viewMode == 0 %}entry{% else %}listmode entry{% endif %}"> |
29 | <h2><a href="{{ path('view', { 'id': entry.id }) }}" title="{{ entry.title|raw }}">{{ entry.title|raw }}</a></h2> | 31 | <h2><a href="{{ path('view', { 'id': entry.id }) }}" title="{{ entry.title|raw }}">{{ entry.title|raw }}</a></h2> |
30 | 32 | ||
31 | {% set readingTime = entry.readingTime / app.user.config.readingSpeed %} | 33 | {% set readingTime = entry.readingTime / app.user.config.readingSpeed %} |
@@ -50,7 +52,7 @@ | |||
50 | <li><a title="{{ 'entry.list.delete'|trans }}" class="tool delete icon-trash icon" href="{{ path('delete_entry', { 'id': entry.id }) }}"><span>{{ 'entry.list.delete'|trans }}</span></a></li> | 52 | <li><a title="{{ 'entry.list.delete'|trans }}" class="tool delete icon-trash icon" href="{{ path('delete_entry', { 'id': entry.id }) }}"><span>{{ 'entry.list.delete'|trans }}</span></a></li> |
51 | <li><a href="{{ entry.url|e }}" target="_blank" title="{{ 'entry.list.original_article'|trans }} : {{ entry.title|e }}" class="tool link icon-link icon"><span>{{ entry.domainName|removeWww }}</span></a></li> | 53 | <li><a href="{{ entry.url|e }}" target="_blank" title="{{ 'entry.list.original_article'|trans }} : {{ entry.title|e }}" class="tool link icon-link icon"><span>{{ entry.domainName|removeWww }}</span></a></li> |
52 | </ul> | 54 | </ul> |
53 | {% if entry.previewPicture is null %} | 55 | {% if (entry.previewPicture is null or viewMode == 1) %} |
54 | <ul class="card-entry-tags"> | 56 | <ul class="card-entry-tags"> |
55 | {% for tag in entry.tags %} | 57 | {% for tag in entry.tags %} |
56 | <li><a href="{{ path('tag_entries', {'slug': tag.slug}) }}">{{ tag.label }}</a></li> | 58 | <li><a href="{{ path('tag_entries', {'slug': tag.slug}) }}">{{ tag.label }}</a></li> |
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig new file mode 100644 index 00000000..3d971f0b --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig | |||
@@ -0,0 +1,14 @@ | |||
1 | <div class="card"> | ||
2 | <div class="card-stacked"> | ||
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| striptags | truncate(120, true, '…') | raw }} | ||
7 | </a> | ||
8 | </span> | ||
9 | <p>{{ entry.content|striptags|slice(0, 500)|raw }}…</p> | ||
10 | </div> | ||
11 | |||
12 | {% include "@WallabagCore/themes/material/Entry/_card_actions.html.twig" with {'entry': entry} only %} | ||
13 | </div> | ||
14 | </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 00e8bf63..2921d366 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 | |||
@@ -12,9 +12,11 @@ | |||
12 | {% endblock %} | 12 | {% endblock %} |
13 | 13 | ||
14 | {% block content %} | 14 | {% block content %} |
15 | {% set viewMode = app.user.config.viewMode %} | ||
15 | <div class="results clearfix"> | 16 | <div class="results clearfix"> |
16 | <div class="nb-results left"> | 17 | <div class="nb-results left"> |
17 | {{ 'entry.list.number_on_the_page'|transchoice(entries.count) }} | 18 | {{ 'entry.list.number_on_the_page'|transchoice(entries.count) }} |
19 | <a href="{{ path('switch_view_mode') }}"><i class="material-icons">{% if viewMode == 0 %}view_list{% else %}view_module{% endif %}</i></a> | ||
18 | </div> | 20 | </div> |
19 | {% if entries.getNbPages > 1 %} | 21 | {% if entries.getNbPages > 1 %} |
20 | {{ pagerfanta(entries, 'twitter_bootstrap_translated', {'proximity': 1}) }} | 22 | {{ pagerfanta(entries, 'twitter_bootstrap_translated', {'proximity': 1}) }} |
@@ -24,8 +26,10 @@ | |||
24 | <br /> | 26 | <br /> |
25 | <ul class="row data"> | 27 | <ul class="row data"> |
26 | {% for entry in entries %} | 28 | {% for entry in entries %} |
27 | <li id="entry-{{ entry.id|e }}" class="col l3 m6 s12"> | 29 | <li id="entry-{{ entry.id|e }}" class="col {% if viewMode == 0 %}l3 m6{% endif %} s12"> |
28 | {% if entry.previewPicture is null %} | 30 | {% if viewMode == 1 %} |
31 | {% include "@WallabagCore/themes/material/Entry/_card_list.html.twig" with {'entry': entry} only %} | ||
32 | {% elseif entry.previewPicture is null %} | ||
29 | {% include "@WallabagCore/themes/material/Entry/_card_no_preview.html.twig" with {'entry': entry} only %} | 33 | {% include "@WallabagCore/themes/material/Entry/_card_no_preview.html.twig" with {'entry': entry} only %} |
30 | {% elseif not entry.previewPicture is null and entry.mimetype starts with 'image/' %} | 34 | {% elseif not entry.previewPicture is null and entry.mimetype starts with 'image/' %} |
31 | {% include "@WallabagCore/themes/material/Entry/_card_full_image.html.twig" with {'entry': entry} only %} | 35 | {% include "@WallabagCore/themes/material/Entry/_card_full_image.html.twig" with {'entry': entry} only %} |