1
0
Fork 0

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".
This commit is contained in:
Carl Helmertz 2018-10-14 16:28:24 +02:00 committed by fguillot
parent 74c35ad000
commit 8c65c78904
13 changed files with 44 additions and 11 deletions

View file

@ -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",
}

View file

@ -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",

View file

@ -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",

View file

@ -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é",

View file

@ -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",

View file

@ -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ł",

View file

@ -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": "Открыть выбранный элемент",

View file

@ -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": "打开选定的条目",

View file

@ -191,6 +191,7 @@ var templateCommonMap = map[string]string{
<ul>
<li>{{ t "page.keyboard_shortcuts.go_to_previous_item" }} = <strong>p</strong>, <strong>j</strong>, <strong></strong></li>
<li>{{ t "page.keyboard_shortcuts.go_to_next_item" }} = <strong>n</strong>, <strong>k</strong>, <strong></strong></li>
<li>{{ t "page.keyboard_shortcuts.go_to_feed" }} = <strong>g + f</strong></li>
</ul>
<p>{{ t "page.keyboard_shortcuts.subtitle.pages" }}</p>
@ -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",
}

View file

@ -117,6 +117,7 @@
<ul>
<li>{{ t "page.keyboard_shortcuts.go_to_previous_item" }} = <strong>p</strong>, <strong>j</strong>, <strong></strong></li>
<li>{{ t "page.keyboard_shortcuts.go_to_next_item" }} = <strong>n</strong>, <strong>k</strong>, <strong></strong></li>
<li>{{ t "page.keyboard_shortcuts.go_to_feed" }} = <strong>g + f</strong></li>
</ul>
<p>{{ t "page.keyboard_shortcuts.subtitle.pages" }}</p>

View file

@ -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<items.length;i++){if(items[i].classList.contains("current-item")){items[i].classList.remove("current-item");if(i-1>=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;i<items.length;i++){if(items[i].classList.contains("current-item")){items[i].classList.remove("current-item");if(i+1<items.length){items[i+1].classList.add("current-item");DomHelper.scrollPageTo(items[i+1]);items[i+1].querySelector('.item-header a').focus();}
break;}}}
isEntry(){return document.querySelector("section.entry")!==null;}
isListView(){return document.querySelector(".items")!==null;}}
class LinkStateHandler{static flip(element){let labelElement=document.createElement("span");labelElement.className="link-flipped-state";labelElement.appendChild(document.createTextNode(element.dataset.labelNewState));element.parentNode.appendChild(labelElement);element.parentNode.removeChild(element);}}
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.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",
}

View file

@ -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());

View file

@ -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;
}