diff options
-rw-r--r-- | app/config/config.yml | 15 | ||||
-rw-r--r-- | src/WallabagBundle/Controller/EntryController.php | 47 | ||||
-rw-r--r-- | src/WallabagBundle/Repository/EntriesRepository.php | 32 | ||||
-rw-r--r-- | src/WallabagBundle/Resources/views/Entry/entries.html.twig | 43 | ||||
-rw-r--r-- | src/WallabagBundle/Resources/views/Entry/entry.html.twig | 104 | ||||
-rw-r--r-- | src/WallabagBundle/Resources/views/_menu.html.twig | 17 | ||||
-rwxr-xr-x | src/WallabagBundle/Resources/views/_top.html.twig | 3 |
7 files changed, 232 insertions, 29 deletions
diff --git a/app/config/config.yml b/app/config/config.yml index ca7fb467..c6bed797 100644 --- a/app/config/config.yml +++ b/app/config/config.yml | |||
@@ -29,6 +29,21 @@ framework: | |||
29 | twig: | 29 | twig: |
30 | debug: "%kernel.debug%" | 30 | debug: "%kernel.debug%" |
31 | strict_variables: "%kernel.debug%" | 31 | strict_variables: "%kernel.debug%" |
32 | globals: | ||
33 | share_twitter: %share_twitter% | ||
34 | share_mail: %share_mail% | ||
35 | share_shaarli: %share_shaarli% | ||
36 | shaarli_url: %shaarli_url% | ||
37 | share_diaspora: %share_diaspora% | ||
38 | diaspora_url: %diaspora_url% | ||
39 | flattr: %flattr% | ||
40 | flattrable: 1 | ||
41 | flattred: 2 | ||
42 | carrot: %carrot% | ||
43 | show_printlink: %show_printlink% | ||
44 | export_epub: %export_epub% | ||
45 | export_mobi: %export_mobi% | ||
46 | export_pdf: %export_pdf% | ||
32 | 47 | ||
33 | # Assetic Configuration | 48 | # Assetic Configuration |
34 | assetic: | 49 | assetic: |
diff --git a/src/WallabagBundle/Controller/EntryController.php b/src/WallabagBundle/Controller/EntryController.php index 0c0c1569..233a6c32 100644 --- a/src/WallabagBundle/Controller/EntryController.php +++ b/src/WallabagBundle/Controller/EntryController.php | |||
@@ -11,7 +11,7 @@ class EntryController extends Controller | |||
11 | /** | 11 | /** |
12 | * @Route("/unread", name="unread") | 12 | * @Route("/unread", name="unread") |
13 | */ | 13 | */ |
14 | public function unreadAction() | 14 | public function showUnreadAction() |
15 | { | 15 | { |
16 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); | 16 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); |
17 | $entries = $repository->findUnreadByUser(1); | 17 | $entries = $repository->findUnreadByUser(1); |
@@ -22,4 +22,49 @@ class EntryController extends Controller | |||
22 | ); | 22 | ); |
23 | 23 | ||
24 | } | 24 | } |
25 | |||
26 | /** | ||
27 | * @Route("/archive", name="archive") | ||
28 | */ | ||
29 | public function showArchiveAction() | ||
30 | { | ||
31 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); | ||
32 | $entries = $repository->findArchiveByUser(1); | ||
33 | |||
34 | return $this->render( | ||
35 | 'WallabagBundle:Entry:entries.html.twig', | ||
36 | array('entries' => $entries) | ||
37 | ); | ||
38 | |||
39 | } | ||
40 | |||
41 | /** | ||
42 | * @Route("/starred", name="starred") | ||
43 | */ | ||
44 | public function showStarredAction() | ||
45 | { | ||
46 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); | ||
47 | $entries = $repository->findStarredByUser(1); | ||
48 | |||
49 | return $this->render( | ||
50 | 'WallabagBundle:Entry:entries.html.twig', | ||
51 | array('entries' => $entries) | ||
52 | ); | ||
53 | |||
54 | } | ||
55 | |||
56 | /** | ||
57 | * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view") | ||
58 | */ | ||
59 | public function viewAction($id) | ||
60 | { | ||
61 | $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries'); | ||
62 | $entry = $repository->find($id); | ||
63 | |||
64 | return $this->render( | ||
65 | 'WallabagBundle:Entry:entry.html.twig', | ||
66 | array('entry' => $entry) | ||
67 | ); | ||
68 | |||
69 | } | ||
25 | } | 70 | } |
diff --git a/src/WallabagBundle/Repository/EntriesRepository.php b/src/WallabagBundle/Repository/EntriesRepository.php index 4c13c9c2..c355a012 100644 --- a/src/WallabagBundle/Repository/EntriesRepository.php +++ b/src/WallabagBundle/Repository/EntriesRepository.php | |||
@@ -13,14 +13,6 @@ use Doctrine\ORM\EntityRepository; | |||
13 | */ | 13 | */ |
14 | class EntriesRepository extends EntityRepository | 14 | class EntriesRepository extends EntityRepository |
15 | { | 15 | { |
16 | /* public function findUnreadByUser($userId) | ||
17 | { | ||
18 | return $this->createQueryBuilder('e') | ||
19 | ->where('e.is_read = 0') | ||
20 | ->andWhere('e.user_id = :userId') | ||
21 | ->setParameter('userId', $userId) | ||
22 | ->getQuery(); | ||
23 | }*/ | ||
24 | public function findUnreadByUser($userId) | 16 | public function findUnreadByUser($userId) |
25 | { | 17 | { |
26 | $qb = $this->createQueryBuilder('e') | 18 | $qb = $this->createQueryBuilder('e') |
@@ -32,4 +24,28 @@ class EntriesRepository extends EntityRepository | |||
32 | 24 | ||
33 | return $qb; | 25 | return $qb; |
34 | } | 26 | } |
27 | |||
28 | public function findArchiveByUser($userId) | ||
29 | { | ||
30 | $qb = $this->createQueryBuilder('e') | ||
31 | ->select('e') | ||
32 | ->where('e.isRead = 1') | ||
33 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | ||
34 | ->getQuery() | ||
35 | ->getResult(Query::HYDRATE_ARRAY); | ||
36 | |||
37 | return $qb; | ||
38 | } | ||
39 | |||
40 | public function findStarredByUser($userId) | ||
41 | { | ||
42 | $qb = $this->createQueryBuilder('e') | ||
43 | ->select('e') | ||
44 | ->where('e.isFav = 1') | ||
45 | ->andWhere('e.userId =:userId')->setParameter('userId', $userId) | ||
46 | ->getQuery() | ||
47 | ->getResult(Query::HYDRATE_ARRAY); | ||
48 | |||
49 | return $qb; | ||
50 | } | ||
35 | } | 51 | } |
diff --git a/src/WallabagBundle/Resources/views/Entry/entries.html.twig b/src/WallabagBundle/Resources/views/Entry/entries.html.twig index f4d7a7ab..81177298 100644 --- a/src/WallabagBundle/Resources/views/Entry/entries.html.twig +++ b/src/WallabagBundle/Resources/views/Entry/entries.html.twig | |||
@@ -2,25 +2,32 @@ | |||
2 | 2 | ||
3 | {% block title "Unread" %} | 3 | {% block title "Unread" %} |
4 | 4 | ||
5 | {% block content_header '' %} | 5 | {% block menu %} |
6 | {% include "WallabagBundle::_menu.html.twig" %} | ||
7 | {% endblock %} | ||
6 | 8 | ||
7 | {% block content %} | 9 | {% block content %} |
8 | {% for entry in entries %} | ||
9 | <div id="entry-{{ entry.id|e }}" class="entrie"> | ||
10 | <h2><a href="index.php?view=view&id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2> | ||
11 | {% if entry.content| readingTime > 0 %} | ||
12 | <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} {{ entry.content| readingTime }} min</span></div> | ||
13 | {% else %} | ||
14 | <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} <small class="inferieur"><</small> 1 min</span></div> | ||
15 | {% endif %} | ||
16 | 10 | ||
17 | <ul class="tools links"> | 11 | {% if entries is empty %} |
18 | <li><a title="{% trans %}Toggle mark as read{% endtrans %}" class="tool icon-check icon {% if entry.isRead == 0 %}archive-off{% else %}archive{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li> | 12 | <div class="messages warning"><p>{% trans %}No articles found.{% endtrans %}</p></div> |
19 | <li><a title="{% trans %}toggle favorite{% endtrans %}" class="tool icon-star icon {% if entry.isFav == 0 %}fav-off{% else %}fav{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span>{% trans %}toggle favorite{% endtrans %}</span></a></li> | 13 | {% else %} |
20 | <li><a title="{% trans %}delete{% endtrans %}" class="tool delete icon-trash icon" href="./?action=delete&id={{ entry.id|e }}"><span>{% trans %}delete{% endtrans %}</span></a></li> | 14 | {% for entry in entries %} |
21 | <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> | 15 | <div id="entry-{{ entry.id|e }}" class="entrie"> |
22 | </ul> | 16 | <h2><a href="{{ path('view', { 'id': entry.id }) }}">{{ entry.title|raw }}</a></h2> |
23 | <p>{{ entry.content|striptags|slice(0, 300) }}...</p> | 17 | {% if entry.content| readingTime > 0 %} |
24 | </div> | 18 | <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} {{ entry.content| readingTime }} min</span></div> |
25 | {% endfor %} | 19 | {% else %} |
20 | <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} <small class="inferieur"><</small> 1 min</span></div> | ||
21 | {% endif %} | ||
22 | |||
23 | <ul class="tools links"> | ||
24 | <li><a title="{% trans %}Toggle mark as read{% endtrans %}" class="tool icon-check icon {% if entry.isRead == 0 %}archive-off{% else %}archive{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li> | ||
25 | <li><a title="{% trans %}toggle favorite{% endtrans %}" class="tool icon-star icon {% if entry.isFav == 0 %}fav-off{% else %}fav{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span>{% trans %}toggle favorite{% endtrans %}</span></a></li> | ||
26 | <li><a title="{% trans %}delete{% endtrans %}" class="tool delete icon-trash icon" href="./?action=delete&id={{ entry.id|e }}"><span>{% trans %}delete{% endtrans %}</span></a></li> | ||
27 | <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> | ||
28 | </ul> | ||
29 | <p>{{ entry.content|striptags|slice(0, 300) }}...</p> | ||
30 | </div> | ||
31 | {% endfor %} | ||
32 | {% endif %} | ||
26 | {% endblock %} | 33 | {% endblock %} |
diff --git a/src/WallabagBundle/Resources/views/Entry/entry.html.twig b/src/WallabagBundle/Resources/views/Entry/entry.html.twig new file mode 100644 index 00000000..19d4650e --- /dev/null +++ b/src/WallabagBundle/Resources/views/Entry/entry.html.twig | |||
@@ -0,0 +1,104 @@ | |||
1 | {% extends "WallabagBundle::layout.html.twig" %} | ||
2 | |||
3 | {% block title %}{{ entry.title|raw }} ({{ entry.url | e | domainName }}){% endblock %} | ||
4 | |||
5 | {% block menu %} | ||
6 | {% include "WallabagBundle::_menu.html.twig" %} | ||
7 | {% endblock %} | ||
8 | |||
9 | {% block content %} | ||
10 | <div id="article_toolbar"> | ||
11 | <ul class="links"> | ||
12 | <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> | ||
13 | <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> | ||
14 | <li><a title="{% trans %}Mark as read{% endtrans %}" class="tool icon icon-check {% if entry.isRead == 0 %}archive-off{% else %}archive{% endif %}" href="javascript: void(null);" id="markAsRead"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li> | ||
15 | <li><a title="{% trans %}Favorite{% endtrans %}" class="tool icon icon-star {% if entry.isFav == 0 %}fav-off{% else %}fav{% endif %}" href="javascript: void(null);" id="setFav"><span>{% trans %}Toggle favorite{% endtrans %}</span></a></li> | ||
16 | <li><a title="{% trans %}Delete{% endtrans %}" class="tool delete icon icon-trash" href="./?action=delete&id={{ entry.id|e }}"><span>{% trans %}Delete{% endtrans %}</span></a></li> | ||
17 | {% if share_twitter %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="{% trans %}Tweet{% endtrans %}"><span>{% trans %}Tweet{% endtrans %}</span></a></li>{% endif %} | ||
18 | {% if share_mail %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&body={{ entry.url|url_encode }}%20via%20@wallabagapp" class="tool email icon icon-mail" title="{% trans %}Email{% endtrans %}"><span>{% trans %}Email{% endtrans %}</span></a></li>{% endif %} | ||
19 | {% if share_shaarli %}<li><a href="{{ shaarli_url }}/index.php?post={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans %}shaarli{% endtrans %}"><span>{% trans %}shaarli{% endtrans %}</span></a></li>{% endif %} | ||
20 | {% if share_diaspora %}<li><a href="{{ diaspora_url }}/bookmarklet?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}¬es=&v=1&noui=1&jump=doclose" target="_blank" class="tool diaspora icon-image icon-image--diaspora" title="{% trans %}diaspora{% endtrans %}"><span>{% trans %}diaspora{% endtrans %}</span></a></li>{% endif %} | ||
21 | {# {% if flattr %}{% if flattr.status == flattrable %}<li><a href="http://flattr.com/submit/auto?url={{ entry.url }}" class="tool flattr icon icon-flattr" target="_blank" title="{% trans %}flattr{% endtrans %}"><span>{% trans %}flattr{% endtrans %}</span></a></li>{% elseif flattr.status == flattred %}<li><a href="{{ flattr.flattrItemURL }}" class="tool flattr icon icon-flattr" target="_blank" title="{% trans %}flattr{% endtrans %}><span>{% trans %}flattr{% endtrans %}</span> ({{ flattr.numFlattrs }})</a></li>{% endif %}{% endif %} #} | ||
22 | {% if carrot %}<li><a href="https://secure.carrot.org/GiveAndGetBack.do?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" class="tool carrot icon-image icon-image--carrot" target="_blank" title="{% trans %}carrot{% endtrans %}"><span>Carrot</span></a></li>{% endif %} | ||
23 | {% if show_printlink %}<li><a title="{% trans %}Print{% endtrans %}" class="tool icon icon-print" href="javascript: window.print();"><span>{% trans %}Print{% endtrans %}</span></a></li>{% endif %} | ||
24 | {% if export_epub %}<li><a href="./?epub&method=id&value={{ entry.id|e }}" title="Generate ePub file">EPUB</a></li>{% endif %} | ||
25 | {% if export_mobi %}<li><a href="./?mobi&method=id&value={{ entry.id|e }}" title="Generate Mobi file">MOBI</a></li>{% endif %} | ||
26 | {% if export_pdf %}<li><a href="./?pdf&method=id&value={{ entry.id|e }}" title="Generate PDF file">PDF</a></li>{% endif %} | ||
27 | <li><a href="mailto:hello@wallabag.org?subject=Wrong%20display%20in%20wallabag&body={{ entry.url|url_encode }}" title="{% trans %}Does this article appear wrong?{% endtrans %}" class="tool bad-display icon icon-delete"><span>{% trans %}Does this article appear wrong?{% endtrans %}</span></a></li> | ||
28 | </ul> | ||
29 | </div> | ||
30 | <div id="article"> | ||
31 | <header class="mbm"> | ||
32 | <h1>{{ entry.title|raw }}</h1> | ||
33 | </header> | ||
34 | <aside class="tags"> | ||
35 | tags: {# {% for tag in tags %}<a href="./?view=tag&id={{ tag.id }}">{{ tag.value }}</a> {% endfor %}<a href="./?view=edit-tags&id={{ entry.id|e }}" title="{% trans %}Edit tags{% endtrans %}">✎</a> #} | ||
36 | </aside> | ||
37 | <article> | ||
38 | {{ entry.content | raw }} | ||
39 | </article> | ||
40 | </div> | ||
41 | <script src="{{ asset('themes/_global/js/restoreScroll.js')}}"></script> | ||
42 | <script type="text/javascript"> | ||
43 | $(document).ready(function() { | ||
44 | |||
45 | // toggle read property of current article | ||
46 | $('#markAsRead').click(function(){ | ||
47 | $("body").css("cursor", "wait"); | ||
48 | $.ajax( { url: './?action=toggle_archive&id={{ entry.id|e }}' }).done( | ||
49 | function( data ) { | ||
50 | if ( data == '1' ) { | ||
51 | if ( $('#markAsRead').hasClass("archive-off") ) { | ||
52 | $('#markAsRead').removeClass("archive-off"); | ||
53 | $('#markAsRead').addClass("archive"); | ||
54 | } | ||
55 | else { | ||
56 | $('#markAsRead').removeClass("archive"); | ||
57 | $('#markAsRead').addClass("archive-off"); | ||
58 | } | ||
59 | } | ||
60 | else { | ||
61 | alert('Error! Pls check if you are logged in.'); | ||
62 | } | ||
63 | }); | ||
64 | $("body").css("cursor", "auto"); | ||
65 | }); | ||
66 | |||
67 | // toggle favorite property of current article | ||
68 | $('#setFav').click(function(){ | ||
69 | $("body").css("cursor", "wait"); | ||
70 | $.ajax( { url: './?action=toggle_fav&id={{ entry.id|e }}' }).done( | ||
71 | function( data ) { | ||
72 | if ( data == '1' ) { | ||
73 | if ( $('#setFav').hasClass("fav-off") ) { | ||
74 | $('#setFav').removeClass("fav-off"); | ||
75 | $('#setFav').addClass("fav"); | ||
76 | } | ||
77 | else { | ||
78 | $('#setFav').removeClass("fav"); | ||
79 | $('#setFav').addClass("fav-off"); | ||
80 | } | ||
81 | } | ||
82 | else { | ||
83 | alert('Error! Pls check if you are logged in.'); | ||
84 | } | ||
85 | }); | ||
86 | $("body").css("cursor", "auto"); | ||
87 | }); | ||
88 | |||
89 | $(window).scroll(function(e){ | ||
90 | var scrollTop = $(window).scrollTop(); | ||
91 | var docHeight = $(document).height(); | ||
92 | var scrollPercent = (scrollTop) / (docHeight); | ||
93 | var scrollPercentRounded = Math.round(scrollPercent*100)/100; | ||
94 | savePercent({{ entry.id|e }}, scrollPercentRounded); | ||
95 | }); | ||
96 | |||
97 | retrievePercent({{ entry.id|e }}); | ||
98 | |||
99 | $(window).resize(function(){ | ||
100 | retrievePercent({{ entry.id|e }}); | ||
101 | }); | ||
102 | }); | ||
103 | </script> | ||
104 | {% endblock %} \ No newline at end of file | ||
diff --git a/src/WallabagBundle/Resources/views/_menu.html.twig b/src/WallabagBundle/Resources/views/_menu.html.twig new file mode 100644 index 00000000..b001aec5 --- /dev/null +++ b/src/WallabagBundle/Resources/views/_menu.html.twig | |||
@@ -0,0 +1,17 @@ | |||
1 | <button id="menu" class="icon icon-menu desktopHide"><span>Menu</span></button> | ||
2 | <ul id="links" class="links"> | ||
3 | <li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li> | ||
4 | <li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li> | ||
5 | <li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li> | ||
6 | <li><a href="./?view=tags">{% trans %}tags{% endtrans %}</a></li> | ||
7 | <li style="position: relative;"><a href="javascript: void(null);" id="bagit">{% trans %}save a link{% endtrans %}</a> | ||
8 | |||
9 | </li> | ||
10 | <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a> | ||
11 | |||
12 | </li> | ||
13 | <li><a href="./?view=config">{% trans %}config{% endtrans %}</a></li> | ||
14 | <li><a href="./?view=about">{% trans %}about{% endtrans %}</a></li> | ||
15 | <li><a class="icon icon-power" href="./?logout" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li> | ||
16 | </ul> | ||
17 | |||
diff --git a/src/WallabagBundle/Resources/views/_top.html.twig b/src/WallabagBundle/Resources/views/_top.html.twig index 576df806..34d925df 100755 --- a/src/WallabagBundle/Resources/views/_top.html.twig +++ b/src/WallabagBundle/Resources/views/_top.html.twig | |||
@@ -1,6 +1,5 @@ | |||
1 | <header class="w600p center mbm"> | 1 | <header class="w600p center mbm"> |
2 | <h1> | 2 | <h1> |
3 | {% block logo %}<img width="100" height="100" src="{{ asset('themes/baggy/img/logo-other_themes.png') }}" alt="wallabag logo" />{% endblock %} | 3 | {% block logo %}<img width="100" height="100" src="{{ asset('themes/baggy/img/logo-w.png') }}" alt="wallabag logo" />{% endblock %} |
4 | |||
5 | </h1> | 4 | </h1> |
6 | </header> | 5 | </header> |