From 8c65c78904225e92df045cac43700210936ca148 Mon Sep 17 00:00:00 2001 From: Carl Helmertz Date: Sun, 14 Oct 2018 16:28:24 +0200 Subject: [PATCH] NavHandler: Make "g f" go to feed, or list of feeds When you're reading an entry, you may want to go to the feed first, before quickly continuing to reading all of the feeds with another "g f". --- locale/translations.go | 21 ++++++++++++++------- locale/translations/de_DE.json | 1 + locale/translations/en_US.json | 1 + locale/translations/fr_FR.json | 1 + locale/translations/nl_NL.json | 1 + locale/translations/pl_PL.json | 1 + locale/translations/ru_RU.json | 1 + locale/translations/zh_CN.json | 1 + template/common.go | 3 ++- template/html/common/layout.html | 1 + ui/static/js.go | 6 ++++-- ui/static/js/bootstrap.js | 2 +- ui/static/js/nav_handler.js | 15 +++++++++++++++ 13 files changed, 44 insertions(+), 11 deletions(-) diff --git a/locale/translations.go b/locale/translations.go index 97614e12..216ca22b 100755 --- a/locale/translations.go +++ b/locale/translations.go @@ -119,6 +119,7 @@ var translations = map[string]string{ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Liste der Tastenkürzel anzeigen", "page.keyboard_shortcuts.go_to_previous_item": "Zum vorherigen Artikel gehen", "page.keyboard_shortcuts.go_to_next_item": "Zum nächsten Artikel gehen", + "page.keyboard_shortcuts.go_to_feed": "Gehe zum Abo", "page.keyboard_shortcuts.go_to_previous_page": "Zur vorherigen Seite gehen", "page.keyboard_shortcuts.go_to_next_page": "Zur nächsten Seite gehen", "page.keyboard_shortcuts.open_item": "Gewählten Artikel öffnen", @@ -409,6 +410,7 @@ var translations = map[string]string{ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Show keyboard shortcuts", "page.keyboard_shortcuts.go_to_previous_item": "Go to previous item", "page.keyboard_shortcuts.go_to_next_item": "Go to next item", + "page.keyboard_shortcuts.go_to_feed": "Go to feed", "page.keyboard_shortcuts.go_to_previous_page": "Go to previous page", "page.keyboard_shortcuts.go_to_next_page": "Go to next page", "page.keyboard_shortcuts.open_item": "Open selected item", @@ -679,6 +681,7 @@ var translations = map[string]string{ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Voir les raccourcis clavier", "page.keyboard_shortcuts.go_to_previous_item": "Élément précédent", "page.keyboard_shortcuts.go_to_next_item": "Élément suivant", + "page.keyboard_shortcuts.go_to_feed": "Voir abonnement", "page.keyboard_shortcuts.go_to_previous_page": "Page précédente", "page.keyboard_shortcuts.go_to_next_page": "Page suivante", "page.keyboard_shortcuts.open_item": "Ouvrir élément sélectionné", @@ -970,6 +973,7 @@ var translations = map[string]string{ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Laat sneltoetsen zien", "page.keyboard_shortcuts.go_to_previous_item": "Vorige item", "page.keyboard_shortcuts.go_to_next_item": "Volgende item", + "page.keyboard_shortcuts.go_to_feed": "Ga naar feed", "page.keyboard_shortcuts.go_to_previous_page": "Vorige pagina", "page.keyboard_shortcuts.go_to_next_page": "Volgende pagina", "page.keyboard_shortcuts.open_item": "Open geselecteerde link", @@ -1259,6 +1263,7 @@ var translations = map[string]string{ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Pokaż listę skrótów klawiszowych", "page.keyboard_shortcuts.go_to_previous_item": "Przejdź do poprzedniego artykułu", "page.keyboard_shortcuts.go_to_next_item": "Przejdź do następnego punktu artykułu", + "page.keyboard_shortcuts.go_to_feed": "Przejdź do subskrypcji", "page.keyboard_shortcuts.go_to_previous_page": "Przejdź do poprzedniej strony", "page.keyboard_shortcuts.go_to_next_page": "Przejdź do następnej strony", "page.keyboard_shortcuts.open_item": "Otwórz zaznaczony artykuł", @@ -1555,6 +1560,7 @@ var translations = map[string]string{ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Показать сочетания клавиш", "page.keyboard_shortcuts.go_to_previous_item": "Перейти к предыдущему элементу", "page.keyboard_shortcuts.go_to_next_item": "Перейти к следующему элементу", + "page.keyboard_shortcuts.go_to_feed": "Перейти к подписке", "page.keyboard_shortcuts.go_to_previous_page": "Перейти к предыдущей странице", "page.keyboard_shortcuts.go_to_next_page": "Перейти к следующей странице", "page.keyboard_shortcuts.open_item": "Открыть выбранный элемент", @@ -1829,6 +1835,7 @@ var translations = map[string]string{ "page.keyboard_shortcuts.show_keyboard_shortcuts": "显示快捷键", "page.keyboard_shortcuts.go_to_previous_item": "上一条目", "page.keyboard_shortcuts.go_to_next_item": "下一条目", + "page.keyboard_shortcuts.go_to_feed": "转到订阅", "page.keyboard_shortcuts.go_to_previous_page": "上一页", "page.keyboard_shortcuts.go_to_next_page": "下一页", "page.keyboard_shortcuts.open_item": "打开选定的条目", @@ -1998,11 +2005,11 @@ var translations = map[string]string{ } var translationsChecksums = map[string]string{ - "de_DE": "67d3a4bb4e3985ff62882ad0dc73dd86137e474d3e33d41162701a7228913b0a", - "en_US": "db7298b54554207287e2ba15de03646164774368dad54e00197f0162d541643f", - "fr_FR": "fb08492db1984800e5e095f0f784b9b430caa8172c7e0ecbbbc7de08f4adfa60", - "nl_NL": "3bdd3e0150878bc9c196300c7cacb30efd01b7b5df3926950c443d01084b9cee", - "pl_PL": "b81ddb5c5955b043c571701f84d9f3f0a75574e69240c458c7a42f3a20a5aa7e", - "ru_RU": "343393224e21437009e047deb728e4ed036646ed3e4df6101a6bc3cd084b9996", - "zh_CN": "74aefbf6be418ea198fa70d6ed5c7dd8bb3b7b112d9c3f90ebff41fba8c314a3", + "de_DE": "b1008d7ecf29c5f0cb841341cde621fd30db7a5d3ac65f8f8df31a0501d8e8ca", + "en_US": "d4342f431da69a4ce26162862d649c42cc395b4266e0125c5bc9df7577e401be", + "fr_FR": "687d1c0147eb3925911d48972b39c94a4accf2e03e7327fe99ae05e0b5f11a9f", + "nl_NL": "08513979f3194bb1df3207f14ea7adf81cc4a62abec347a9dacbc201ce6846f0", + "pl_PL": "7c445e94570e42c08268153ba63b297874e22da519eb161551fdf56957627a17", + "ru_RU": "03aef503278965e7dbc2f2d9b34d32d50c4e75c2834bd8814bbdd6c261450385", + "zh_CN": "effecdd0cd6139de8488fda0f26a6279b1958ed5ec8c7445b42e1cc361756134", } diff --git a/locale/translations/de_DE.json b/locale/translations/de_DE.json index d5bbad06..aef9f2ae 100644 --- a/locale/translations/de_DE.json +++ b/locale/translations/de_DE.json @@ -114,6 +114,7 @@ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Liste der Tastenkürzel anzeigen", "page.keyboard_shortcuts.go_to_previous_item": "Zum vorherigen Artikel gehen", "page.keyboard_shortcuts.go_to_next_item": "Zum nächsten Artikel gehen", + "page.keyboard_shortcuts.go_to_feed": "Gehe zum Abo", "page.keyboard_shortcuts.go_to_previous_page": "Zur vorherigen Seite gehen", "page.keyboard_shortcuts.go_to_next_page": "Zur nächsten Seite gehen", "page.keyboard_shortcuts.open_item": "Gewählten Artikel öffnen", diff --git a/locale/translations/en_US.json b/locale/translations/en_US.json index 83367be6..15ac2573 100644 --- a/locale/translations/en_US.json +++ b/locale/translations/en_US.json @@ -114,6 +114,7 @@ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Show keyboard shortcuts", "page.keyboard_shortcuts.go_to_previous_item": "Go to previous item", "page.keyboard_shortcuts.go_to_next_item": "Go to next item", + "page.keyboard_shortcuts.go_to_feed": "Go to feed", "page.keyboard_shortcuts.go_to_previous_page": "Go to previous page", "page.keyboard_shortcuts.go_to_next_page": "Go to next page", "page.keyboard_shortcuts.open_item": "Open selected item", diff --git a/locale/translations/fr_FR.json b/locale/translations/fr_FR.json index 9b2f47d3..1aeaeeb7 100644 --- a/locale/translations/fr_FR.json +++ b/locale/translations/fr_FR.json @@ -114,6 +114,7 @@ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Voir les raccourcis clavier", "page.keyboard_shortcuts.go_to_previous_item": "Élément précédent", "page.keyboard_shortcuts.go_to_next_item": "Élément suivant", + "page.keyboard_shortcuts.go_to_feed": "Voir abonnement", "page.keyboard_shortcuts.go_to_previous_page": "Page précédente", "page.keyboard_shortcuts.go_to_next_page": "Page suivante", "page.keyboard_shortcuts.open_item": "Ouvrir élément sélectionné", diff --git a/locale/translations/nl_NL.json b/locale/translations/nl_NL.json index ad54220d..fde071b4 100644 --- a/locale/translations/nl_NL.json +++ b/locale/translations/nl_NL.json @@ -115,6 +115,7 @@ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Laat sneltoetsen zien", "page.keyboard_shortcuts.go_to_previous_item": "Vorige item", "page.keyboard_shortcuts.go_to_next_item": "Volgende item", + "page.keyboard_shortcuts.go_to_feed": "Ga naar feed", "page.keyboard_shortcuts.go_to_previous_page": "Vorige pagina", "page.keyboard_shortcuts.go_to_next_page": "Volgende pagina", "page.keyboard_shortcuts.open_item": "Open geselecteerde link", diff --git a/locale/translations/pl_PL.json b/locale/translations/pl_PL.json index d9d4678c..3a3e0f6e 100755 --- a/locale/translations/pl_PL.json +++ b/locale/translations/pl_PL.json @@ -116,6 +116,7 @@ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Pokaż listę skrótów klawiszowych", "page.keyboard_shortcuts.go_to_previous_item": "Przejdź do poprzedniego artykułu", "page.keyboard_shortcuts.go_to_next_item": "Przejdź do następnego punktu artykułu", + "page.keyboard_shortcuts.go_to_feed": "Przejdź do subskrypcji", "page.keyboard_shortcuts.go_to_previous_page": "Przejdź do poprzedniej strony", "page.keyboard_shortcuts.go_to_next_page": "Przejdź do następnej strony", "page.keyboard_shortcuts.open_item": "Otwórz zaznaczony artykuł", diff --git a/locale/translations/ru_RU.json b/locale/translations/ru_RU.json index ef1a2006..60bd4ff6 100644 --- a/locale/translations/ru_RU.json +++ b/locale/translations/ru_RU.json @@ -116,6 +116,7 @@ "page.keyboard_shortcuts.show_keyboard_shortcuts": "Показать сочетания клавиш", "page.keyboard_shortcuts.go_to_previous_item": "Перейти к предыдущему элементу", "page.keyboard_shortcuts.go_to_next_item": "Перейти к следующему элементу", + "page.keyboard_shortcuts.go_to_feed": "Перейти к подписке", "page.keyboard_shortcuts.go_to_previous_page": "Перейти к предыдущей странице", "page.keyboard_shortcuts.go_to_next_page": "Перейти к следующей странице", "page.keyboard_shortcuts.open_item": "Открыть выбранный элемент", diff --git a/locale/translations/zh_CN.json b/locale/translations/zh_CN.json index 1501641c..35860d7a 100644 --- a/locale/translations/zh_CN.json +++ b/locale/translations/zh_CN.json @@ -112,6 +112,7 @@ "page.keyboard_shortcuts.show_keyboard_shortcuts": "显示快捷键", "page.keyboard_shortcuts.go_to_previous_item": "上一条目", "page.keyboard_shortcuts.go_to_next_item": "下一条目", + "page.keyboard_shortcuts.go_to_feed": "转到订阅", "page.keyboard_shortcuts.go_to_previous_page": "上一页", "page.keyboard_shortcuts.go_to_next_page": "下一页", "page.keyboard_shortcuts.open_item": "打开选定的条目", diff --git a/template/common.go b/template/common.go index 1afb9f1e..379f7f9c 100644 --- a/template/common.go +++ b/template/common.go @@ -191,6 +191,7 @@ var templateCommonMap = map[string]string{

{{ t "page.keyboard_shortcuts.subtitle.pages" }}

@@ -244,6 +245,6 @@ var templateCommonMap = map[string]string{ var templateCommonMapChecksums = map[string]string{ "entry_pagination": "4faa91e2eae150c5e4eab4d258e039dfdd413bab7602f0009360e6d52898e353", "item_meta": "34deb081a054f2948ad808bdb2c8603d6ab00c58f2f50c4ead0b47ae092888eb", - "layout": "69ba8db45fde768cf71bab7dba60cece39968a185cec58850582dec11668efec", + "layout": "4a5339267f67b5999a22ece7584df4c75785bc3bf95d44e1891da763aaea7991", "pagination": "3386e90c6e1230311459e9a484629bc5d5bf39514a75ef2e73bbbc61142f7abb", } diff --git a/template/html/common/layout.html b/template/html/common/layout.html index cf49fa55..312c21f3 100644 --- a/template/html/common/layout.html +++ b/template/html/common/layout.html @@ -117,6 +117,7 @@

{{ t "page.keyboard_shortcuts.subtitle.pages" }}

diff --git a/ui/static/js.go b/ui/static/js.go index 5ffc0b8c..02ae43dc 100644 --- a/ui/static/js.go +++ b/ui/static/js.go @@ -85,6 +85,7 @@ unsubscribeFromFeed(){let unsubscribeLinks=document.querySelectorAll("[data-acti goToPage(page,fallbackSelf){let element=document.querySelector("a[data-page="+page+"]");if(element){document.location.href=element.href;}else if(fallbackSelf){window.location.reload();}} goToPrevious(){if(this.isListView()){this.goToPreviousListItem();}else{this.goToPage("previous");}} goToNext(){if(this.isListView()){this.goToNextListItem();}else{this.goToPage("next");}} +goToFeedOrFeeds(){if(this.isEntry()){let feedAnchor=document.querySelector("span.entry-website a");if(feedAnchor!==null){window.location.href=feedAnchor.href;}}else{this.goToPage('feeds');}} goToPreviousListItem(){let items=DomHelper.getVisibleElements(".items .item");if(items.length===0){return;} if(document.querySelector(".current-item")===null){items[0].classList.add("current-item");items[0].querySelector('.item-header a').focus();return;} for(let i=0;i=0){items[i-1].classList.add("current-item");DomHelper.scrollPageTo(items[i-1]);items[i-1].querySelector('.item-header a').focus();} @@ -93,15 +94,16 @@ goToNextListItem(){let currentItem=document.querySelector(".current-item");let i if(currentItem===null){items[0].classList.add("current-item");items[0].querySelector('.item-header a').focus();return;} for(let i=0;inavHandler.goToPage("unread"));keyboardHandler.on("g b",()=>navHandler.goToPage("starred"));keyboardHandler.on("g h",()=>navHandler.goToPage("history"));keyboardHandler.on("g f",()=>navHandler.goToPage("feeds"));keyboardHandler.on("g c",()=>navHandler.goToPage("categories"));keyboardHandler.on("g s",()=>navHandler.goToPage("settings"));keyboardHandler.on("ArrowLeft",()=>navHandler.goToPrevious());keyboardHandler.on("ArrowRight",()=>navHandler.goToNext());keyboardHandler.on("j",()=>navHandler.goToPrevious());keyboardHandler.on("p",()=>navHandler.goToPrevious());keyboardHandler.on("k",()=>navHandler.goToNext());keyboardHandler.on("n",()=>navHandler.goToNext());keyboardHandler.on("h",()=>navHandler.goToPage("previous"));keyboardHandler.on("l",()=>navHandler.goToPage("next"));keyboardHandler.on("o",()=>navHandler.openSelectedItem());keyboardHandler.on("v",()=>navHandler.openOriginalLink());keyboardHandler.on("m",()=>navHandler.toggleEntryStatus());keyboardHandler.on("A",()=>navHandler.markPageAsRead());keyboardHandler.on("s",()=>navHandler.saveEntry());keyboardHandler.on("d",()=>navHandler.fetchOriginalContent());keyboardHandler.on("f",()=>navHandler.toggleBookmark());keyboardHandler.on("?",()=>navHandler.showKeyboardShortcuts());keyboardHandler.on("#",()=>navHandler.unsubscribeFromFeed());keyboardHandler.on("/",(e)=>navHandler.setFocusToSearchInput(e));keyboardHandler.on("Escape",()=>ModalHandler.close());keyboardHandler.listen();let mouseHandler=new MouseHandler();mouseHandler.onClick("a[data-save-entry]",(event)=>{EntryHandler.saveEntry(event.target);});mouseHandler.onClick("a[data-toggle-bookmark]",(event)=>{EntryHandler.toggleBookmark(event.target);});mouseHandler.onClick("a[data-toggle-status]",(event)=>{let currentItem=DomHelper.findParent(event.target,"entry");if(!currentItem){currentItem=DomHelper.findParent(event.target,"item");} +document.addEventListener("DOMContentLoaded",function(){FormHandler.handleSubmitButtons();let touchHandler=new TouchHandler();touchHandler.listen();let navHandler=new NavHandler();let keyboardHandler=new KeyboardHandler();keyboardHandler.on("g u",()=>navHandler.goToPage("unread"));keyboardHandler.on("g b",()=>navHandler.goToPage("starred"));keyboardHandler.on("g h",()=>navHandler.goToPage("history"));keyboardHandler.on("g f",()=>navHandler.goToFeedOrFeeds());keyboardHandler.on("g c",()=>navHandler.goToPage("categories"));keyboardHandler.on("g s",()=>navHandler.goToPage("settings"));keyboardHandler.on("ArrowLeft",()=>navHandler.goToPrevious());keyboardHandler.on("ArrowRight",()=>navHandler.goToNext());keyboardHandler.on("j",()=>navHandler.goToPrevious());keyboardHandler.on("p",()=>navHandler.goToPrevious());keyboardHandler.on("k",()=>navHandler.goToNext());keyboardHandler.on("n",()=>navHandler.goToNext());keyboardHandler.on("h",()=>navHandler.goToPage("previous"));keyboardHandler.on("l",()=>navHandler.goToPage("next"));keyboardHandler.on("o",()=>navHandler.openSelectedItem());keyboardHandler.on("v",()=>navHandler.openOriginalLink());keyboardHandler.on("m",()=>navHandler.toggleEntryStatus());keyboardHandler.on("A",()=>navHandler.markPageAsRead());keyboardHandler.on("s",()=>navHandler.saveEntry());keyboardHandler.on("d",()=>navHandler.fetchOriginalContent());keyboardHandler.on("f",()=>navHandler.toggleBookmark());keyboardHandler.on("?",()=>navHandler.showKeyboardShortcuts());keyboardHandler.on("#",()=>navHandler.unsubscribeFromFeed());keyboardHandler.on("/",(e)=>navHandler.setFocusToSearchInput(e));keyboardHandler.on("Escape",()=>ModalHandler.close());keyboardHandler.listen();let mouseHandler=new MouseHandler();mouseHandler.onClick("a[data-save-entry]",(event)=>{EntryHandler.saveEntry(event.target);});mouseHandler.onClick("a[data-toggle-bookmark]",(event)=>{EntryHandler.toggleBookmark(event.target);});mouseHandler.onClick("a[data-toggle-status]",(event)=>{let currentItem=DomHelper.findParent(event.target,"entry");if(!currentItem){currentItem=DomHelper.findParent(event.target,"item");} if(currentItem){EntryHandler.toggleEntryStatus(currentItem);}});mouseHandler.onClick("a[data-fetch-content-entry]",(event)=>{EntryHandler.fetchOriginalContent(event.target);});mouseHandler.onClick("a[data-on-click=markPageAsRead]",()=>navHandler.markPageAsRead());mouseHandler.onClick("a[data-confirm]",(event)=>{(new ConfirmHandler()).handle(event);});mouseHandler.onClick("a[data-action=search]",(event)=>{navHandler.setFocusToSearchInput(event);});mouseHandler.onClick("a[data-link-state=flip]",(event)=>{LinkStateHandler.flip(event.target);},true);if(document.documentElement.clientWidth<600){let menuHandler=new MenuHandler();mouseHandler.onClick(".logo",()=>menuHandler.toggleMainMenu());mouseHandler.onClick(".header nav li",(event)=>menuHandler.clickMenuListItem(event));} if("serviceWorker"in navigator){let scriptElement=document.getElementById("service-worker-script");if(scriptElement){navigator.serviceWorker.register(scriptElement.src);}}});})();`, "sw": `'use strict';self.addEventListener("fetch",(event)=>{if(event.request.url.includes("/feed/icon/")){event.respondWith(caches.open("feed_icons").then((cache)=>{return cache.match(event.request).then((response)=>{return response||fetch(event.request).then((response)=>{cache.put(event.request,response.clone());return response;});});}));}});`, } var JavascriptsChecksums = map[string]string{ - "app": "6d1dc775cab31cdb7275e38c32c4ae714e330df897c7515e84e021878359e3d5", + "app": "0ad0d1aea5dc06d811998bd6cd6fede09a73ae00d682f28a850621bb750947e3", "sw": "55fffa223919cc18572788fb9c62fccf92166c0eb5d3a1d6f91c31f24d020be9", } diff --git a/ui/static/js/bootstrap.js b/ui/static/js/bootstrap.js index 3c2bb359..5c0bfac9 100644 --- a/ui/static/js/bootstrap.js +++ b/ui/static/js/bootstrap.js @@ -9,7 +9,7 @@ document.addEventListener("DOMContentLoaded", function() { keyboardHandler.on("g u", () => navHandler.goToPage("unread")); keyboardHandler.on("g b", () => navHandler.goToPage("starred")); keyboardHandler.on("g h", () => navHandler.goToPage("history")); - keyboardHandler.on("g f", () => navHandler.goToPage("feeds")); + keyboardHandler.on("g f", () => navHandler.goToFeedOrFeeds()); keyboardHandler.on("g c", () => navHandler.goToPage("categories")); keyboardHandler.on("g s", () => navHandler.goToPage("settings")); keyboardHandler.on("ArrowLeft", () => navHandler.goToPrevious()); diff --git a/ui/static/js/nav_handler.js b/ui/static/js/nav_handler.js index 5f611e0a..dd106074 100644 --- a/ui/static/js/nav_handler.js +++ b/ui/static/js/nav_handler.js @@ -173,6 +173,17 @@ class NavHandler { } } + goToFeedOrFeeds() { + if (this.isEntry()) { + let feedAnchor = document.querySelector("span.entry-website a"); + if (feedAnchor !== null) { + window.location.href = feedAnchor.href; + } + } else { + this.goToPage('feeds'); + } + } + goToPreviousListItem() { let items = DomHelper.getVisibleElements(".items .item"); if (items.length === 0) { @@ -228,6 +239,10 @@ class NavHandler { } } + isEntry() { + return document.querySelector("section.entry") !== null; + } + isListView() { return document.querySelector(".items") !== null; }