aboutsummaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-11-16 09:35:59 +0100
committerGitHub <noreply@github.com>2016-11-16 09:35:59 +0100
commite042a5d78fc7676eb399f61d199e8ec0045fbd1f (patch)
tree2bc79fda2ca07baf246a36543fd4419a7af7a7a8 /app
parent644b340178136ef9465fdc3cf40f1de0f5f8c3d3 (diff)
parent94f2057ffefdb164ae388a6971b4ed052082a434 (diff)
downloadwallabag-e042a5d78fc7676eb399f61d199e8ec0045fbd1f.tar.gz
wallabag-e042a5d78fc7676eb399f61d199e8ec0045fbd1f.tar.zst
wallabag-e042a5d78fc7676eb399f61d199e8ec0045fbd1f.zip
Merge pull request #2495 from wallabag/add-shortcuts
Added shortcuts
Diffstat (limited to 'app')
-rw-r--r--app/AppKernel.php1
-rw-r--r--app/Resources/static/themes/_global/js/bookmarklet.js1
-rw-r--r--app/Resources/static/themes/_global/js/shortcuts/entry.js0
-rw-r--r--app/Resources/static/themes/_global/js/shortcuts/main.js15
-rw-r--r--app/Resources/static/themes/_global/js/tools.js4
-rwxr-xr-xapp/Resources/static/themes/baggy/js/autoCompleteTags.js2
-rwxr-xr-xapp/Resources/static/themes/baggy/js/init.js27
-rw-r--r--app/Resources/static/themes/baggy/js/shortcuts/entry.js22
-rw-r--r--app/Resources/static/themes/baggy/js/shortcuts/main.js0
-rw-r--r--app/Resources/static/themes/baggy/js/uiTools.js4
-rwxr-xr-xapp/Resources/static/themes/material/js/init.js17
-rw-r--r--app/Resources/static/themes/material/js/shortcuts/entry.js22
-rw-r--r--app/Resources/static/themes/material/js/shortcuts/main.js70
-rw-r--r--app/config/config.yml13
-rw-r--r--app/config/routing.yml3
15 files changed, 187 insertions, 14 deletions
diff --git a/app/AppKernel.php b/app/AppKernel.php
index 342bd139..81b83ef9 100644
--- a/app/AppKernel.php
+++ b/app/AppKernel.php
@@ -30,6 +30,7 @@ class AppKernel extends Kernel
30 new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), 30 new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
31 new Craue\ConfigBundle\CraueConfigBundle(), 31 new Craue\ConfigBundle\CraueConfigBundle(),
32 new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(), 32 new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
33 new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
33 34
34 // wallabag bundles 35 // wallabag bundles
35 new Wallabag\CoreBundle\WallabagCoreBundle(), 36 new Wallabag\CoreBundle\WallabagCoreBundle(),
diff --git a/app/Resources/static/themes/_global/js/bookmarklet.js b/app/Resources/static/themes/_global/js/bookmarklet.js
index 5174ff47..a497628b 100644
--- a/app/Resources/static/themes/_global/js/bookmarklet.js
+++ b/app/Resources/static/themes/_global/js/bookmarklet.js
@@ -1,4 +1,3 @@
1
2top['bookmarklet-url@wallabag.org'] = 1top['bookmarklet-url@wallabag.org'] =
3 '<!DOCTYPE html><html><head><title>bag it!</title>' + 2 '<!DOCTYPE html><html><head><title>bag it!</title>' +
4 '<link rel="icon" href="tpl/img/favicon.ico" />' + 3 '<link rel="icon" href="tpl/img/favicon.ico" />' +
diff --git a/app/Resources/static/themes/_global/js/shortcuts/entry.js b/app/Resources/static/themes/_global/js/shortcuts/entry.js
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/app/Resources/static/themes/_global/js/shortcuts/entry.js
diff --git a/app/Resources/static/themes/_global/js/shortcuts/main.js b/app/Resources/static/themes/_global/js/shortcuts/main.js
new file mode 100644
index 00000000..ef6a1b84
--- /dev/null
+++ b/app/Resources/static/themes/_global/js/shortcuts/main.js
@@ -0,0 +1,15 @@
1import Mousetrap from 'mousetrap';
2
3/** Shortcuts **/
4
5/* Go to */
6Mousetrap.bind('g u', () => { window.location.href = Routing.generate('homepage'); });
7Mousetrap.bind('g s', () => { window.location.href = Routing.generate('starred'); });
8Mousetrap.bind('g r', () => { window.location.href = Routing.generate('archive'); });
9Mousetrap.bind('g a', () => { window.location.href = Routing.generate('all'); });
10Mousetrap.bind('g t', () => { window.location.href = Routing.generate('tag'); });
11Mousetrap.bind('g c', () => { window.location.href = Routing.generate('config'); });
12Mousetrap.bind('g i', () => { window.location.href = Routing.generate('import'); });
13Mousetrap.bind('g d', () => { window.location.href = Routing.generate('developer'); });
14Mousetrap.bind('?', () => { window.location.href = Routing.generate('howto'); });
15Mousetrap.bind('g l', () => { window.location.href = Routing.generate('logout'); });
diff --git a/app/Resources/static/themes/_global/js/tools.js b/app/Resources/static/themes/_global/js/tools.js
index 55de090c..568b2dce 100644
--- a/app/Resources/static/themes/_global/js/tools.js
+++ b/app/Resources/static/themes/_global/js/tools.js
@@ -1,4 +1,6 @@
1const $ = require('jquery'); 1import $ from 'jquery';
2import './shortcuts/main';
3import './shortcuts/entry';
2 4
3/* Allows inline call qr-code call */ 5/* Allows inline call qr-code call */
4import jrQrcode from 'jr-qrcode'; // eslint-disable-line 6import jrQrcode from 'jr-qrcode'; // eslint-disable-line
diff --git a/app/Resources/static/themes/baggy/js/autoCompleteTags.js b/app/Resources/static/themes/baggy/js/autoCompleteTags.js
index f287ebfa..64fdaa92 100755
--- a/app/Resources/static/themes/baggy/js/autoCompleteTags.js
+++ b/app/Resources/static/themes/baggy/js/autoCompleteTags.js
@@ -5,4 +5,4 @@ function extractLast(term) {
5 return split(term).pop(); 5 return split(term).pop();
6} 6}
7 7
8export { split, extractLast }; 8export default { split, extractLast };
diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js
index dc11043a..05360a28 100755
--- a/app/Resources/static/themes/baggy/js/init.js
+++ b/app/Resources/static/themes/baggy/js/init.js
@@ -1,11 +1,26 @@
1import { savePercent, retrievePercent } from '../../_global/js/tools'; 1/* jQuery */
2import { toggleSaveLinkForm } from './uiTools'; 2import $ from 'jquery';
3
4/* eslint-disable no-unused-vars */
5/* jquery has default scope */
6import cookie from 'jquery.cookie';
7import ui from 'jquery-ui-browserify';
8/* eslint-enable no-unused-vars */
9
10/* Annotations */
11import annotator from 'annotator';
3 12
4const $ = global.jquery = require('jquery'); 13/* Shortcuts */
5require('jquery.cookie'); 14import './shortcuts/main';
6require('jquery-ui-browserify'); 15import './shortcuts/entry';
7const annotator = require('annotator'); 16import '../../_global/js/shortcuts/main';
17import '../../_global/js/shortcuts/entry';
18
19/* Tools */
20import { savePercent, retrievePercent } from '../../_global/js/tools';
21import toggleSaveLinkForm from './uiTools';
8 22
23global.jquery = $;
9 24
10$.fn.ready(() => { 25$.fn.ready(() => {
11 const $listmode = $('#listmode'); 26 const $listmode = $('#listmode');
diff --git a/app/Resources/static/themes/baggy/js/shortcuts/entry.js b/app/Resources/static/themes/baggy/js/shortcuts/entry.js
new file mode 100644
index 00000000..728df8bd
--- /dev/null
+++ b/app/Resources/static/themes/baggy/js/shortcuts/entry.js
@@ -0,0 +1,22 @@
1import Mousetrap from 'mousetrap';
2import $ from 'jquery';
3
4/* Article view */
5Mousetrap.bind('o', () => {
6 $('div#article_toolbar ul.links a.original')[0].click();
7});
8
9/* mark as favorite */
10Mousetrap.bind('s', () => {
11 $('div#article_toolbar ul.links a.favorite')[0].click();
12});
13
14/* mark as read */
15Mousetrap.bind('a', () => {
16 $('div#article_toolbar ul.links a.markasread')[0].click();
17});
18
19/* delete */
20Mousetrap.bind('del', () => {
21 $('div#article_toolbar ul.links a.delete')[0].click();
22});
diff --git a/app/Resources/static/themes/baggy/js/shortcuts/main.js b/app/Resources/static/themes/baggy/js/shortcuts/main.js
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/app/Resources/static/themes/baggy/js/shortcuts/main.js
diff --git a/app/Resources/static/themes/baggy/js/uiTools.js b/app/Resources/static/themes/baggy/js/uiTools.js
index 900b2707..713c53f7 100644
--- a/app/Resources/static/themes/baggy/js/uiTools.js
+++ b/app/Resources/static/themes/baggy/js/uiTools.js
@@ -1,4 +1,4 @@
1const $ = require('jquery'); 1import $ from 'jquery';
2 2
3function toggleSaveLinkForm(url, event) { 3function toggleSaveLinkForm(url, event) {
4 $('#add-link-result').empty(); 4 $('#add-link-result').empty();
@@ -32,4 +32,4 @@ function toggleSaveLinkForm(url, event) {
32 plainUrl.focus(); 32 plainUrl.focus();
33} 33}
34 34
35export { toggleSaveLinkForm }; 35export default toggleSaveLinkForm;
diff --git a/app/Resources/static/themes/material/js/init.js b/app/Resources/static/themes/material/js/init.js
index a68269e0..9746224b 100755
--- a/app/Resources/static/themes/material/js/init.js
+++ b/app/Resources/static/themes/material/js/init.js
@@ -1,10 +1,21 @@
1/* jQuery */
2import $ from 'jquery';
3
4/* Annotations */
5import annotator from 'annotator';
6
7/* Tools */
1import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools'; 8import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools';
2 9
3const $ = require('jquery'); 10/* Import shortcuts */
11import './shortcuts/main';
12import './shortcuts/entry';
13import '../../_global/js/shortcuts/main';
14import '../../_global/js/shortcuts/entry';
4 15
5global.jQuery = $;
6require('materialize'); // eslint-disable-line 16require('materialize'); // eslint-disable-line
7const annotator = require('annotator'); 17
18global.jQuery = $;
8 19
9$(document).ready(() => { 20$(document).ready(() => {
10 // sideNav 21 // sideNav
diff --git a/app/Resources/static/themes/material/js/shortcuts/entry.js b/app/Resources/static/themes/material/js/shortcuts/entry.js
new file mode 100644
index 00000000..357c22fe
--- /dev/null
+++ b/app/Resources/static/themes/material/js/shortcuts/entry.js
@@ -0,0 +1,22 @@
1import Mousetrap from 'mousetrap';
2import $ from 'jquery';
3
4/* open original article */
5Mousetrap.bind('o', () => {
6 $('ul.side-nav a.original i')[0].click();
7});
8
9/* mark as favorite */
10Mousetrap.bind('s', () => {
11 $('ul.side-nav a.favorite i')[0].click();
12});
13
14/* mark as read */
15Mousetrap.bind('a', () => {
16 $('ul.side-nav a.markasread i')[0].click();
17});
18
19/* delete */
20Mousetrap.bind('del', () => {
21 $('ul.side-nav a.delete i')[0].click();
22});
diff --git a/app/Resources/static/themes/material/js/shortcuts/main.js b/app/Resources/static/themes/material/js/shortcuts/main.js
new file mode 100644
index 00000000..8514f71e
--- /dev/null
+++ b/app/Resources/static/themes/material/js/shortcuts/main.js
@@ -0,0 +1,70 @@
1import Mousetrap from 'mousetrap';
2import $ from 'jquery';
3
4function toggleFocus(cardToToogleFocus) {
5 if (cardToToogleFocus) {
6 $(cardToToogleFocus).toggleClass('z-depth-4');
7 }
8}
9
10$(document).ready(() => {
11 let cardIndex = 0;
12 const cardNumber = $('#content ul.data > li').length;
13 let card = $('#content ul.data > li')[cardIndex];
14 const pagination = $('.pagination');
15
16 /* Show nothing on quickstart */
17 if ($('#content > div.quickstart').length > 0) {
18 return;
19 }
20
21 /* If we come from next page */
22 if (window.location.hash === '#prev') {
23 cardIndex = cardNumber - 1;
24 card = $('ul.data > li')[cardIndex];
25 }
26
27 /* Focus current card */
28 toggleFocus(card);
29
30 /* Actions */
31 Mousetrap.bind('g n', () => {
32 $('#nav-btn-add').trigger('click');
33 });
34
35 Mousetrap.bind('esc', () => {
36 $('.close').trigger('click');
37 });
38
39 /* Select right card. If there's a next page, go to next page */
40 Mousetrap.bind('right', () => {
41 if (cardIndex >= 0 && cardIndex < cardNumber - 1) {
42 toggleFocus(card);
43 cardIndex += 1;
44 card = $('ul.data > li')[cardIndex];
45 toggleFocus(card);
46 return;
47 }
48 if (pagination.length > 0 && pagination.find('li.next:not(.disabled)').length > 0 && cardIndex === cardNumber - 1) {
49 window.location.href = window.location.origin + $(pagination).find('li.next a').attr('href');
50 }
51 });
52
53 /* Select previous card. If there's a previous page, go to next page */
54 Mousetrap.bind('left', () => {
55 if (cardIndex > 0 && cardIndex < cardNumber) {
56 toggleFocus(card);
57 cardIndex -= 1;
58 card = $('ul.data > li')[cardIndex];
59 toggleFocus(card);
60 return;
61 }
62 if (pagination.length > 0 && $(pagination).find('li.prev:not(.disabled)').length > 0 && cardIndex === 0) {
63 window.location.href = `${window.location.origin + $(pagination).find('li.prev a').attr('href')}#prev`;
64 }
65 });
66
67 Mousetrap.bind('enter', () => {
68 window.location.href = window.location.origin + $(card).find('span.card-title a').attr('href');
69 });
70});
diff --git a/app/config/config.yml b/app/config/config.yml
index 168634cf..e0e1ad97 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -351,3 +351,16 @@ old_sound_rabbit_mq:
351 queue_options: 351 queue_options:
352 name: 'wallabag.import.chrome' 352 name: 'wallabag.import.chrome'
353 callback: wallabag_import.consumer.amqp.chrome 353 callback: wallabag_import.consumer.amqp.chrome
354
355fos_js_routing:
356 routes_to_expose:
357 - homepage
358 - starred
359 - archive
360 - all
361 - tag
362 - config
363 - import
364 - developer
365 - howto
366 - logout
diff --git a/app/config/routing.yml b/app/config/routing.yml
index 750ed435..eedf51d5 100644
--- a/app/config/routing.yml
+++ b/app/config/routing.yml
@@ -52,3 +52,6 @@ craue_config_settings_modify:
52 path: /settings 52 path: /settings
53 defaults: 53 defaults:
54 _controller: CraueConfigBundle:Settings:modify 54 _controller: CraueConfigBundle:Settings:modify
55
56fos_js_routing:
57 resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"