From 824fc310a9f335fead8188cc2138ccc434ce0c7c Mon Sep 17 00:00:00 2001 From: Thiago Perrotta Date: Sat, 29 Jan 2022 16:53:10 -0500 Subject: [PATCH] Add new keyboard shortcut: 'M' - toggle read/unread, go to prev item Currently there is "Toggle read/unread = m", which toggles and then goes to the next item. Having the opposite operation available is handy, especially when adding new feeds and going through them from oldest to newest posts. It seems natural to map 'M' (= shift + 'm') for this action. Closes https://github.com/miniflux/v2/issues/1352 --- locale/translations/de_DE.json | 3 +- locale/translations/el_EL.json | 3 +- locale/translations/en_US.json | 3 +- locale/translations/es_ES.json | 3 +- locale/translations/fi_FI.json | 3 +- locale/translations/fr_FR.json | 3 +- locale/translations/it_IT.json | 3 +- locale/translations/ja_JP.json | 3 +- locale/translations/nl_NL.json | 3 +- locale/translations/pl_PL.json | 3 +- locale/translations/pt_BR.json | 3 +- locale/translations/ru_RU.json | 3 +- locale/translations/tr_TR.json | 3 +- locale/translations/zh_CN.json | 3 +- template/templates/common/layout.html | 3 +- ui/static/js/app.js | 48 +++++++++++++++++++++++++++ ui/static/js/bootstrap.js | 1 + 17 files changed, 79 insertions(+), 15 deletions(-) diff --git a/locale/translations/de_DE.json b/locale/translations/de_DE.json index 647c9486..14410d20 100644 --- a/locale/translations/de_DE.json +++ b/locale/translations/de_DE.json @@ -152,7 +152,8 @@ "page.keyboard_shortcuts.open_original_same_window": "Öffne den Original-Link in der aktuellen Registerkarte", "page.keyboard_shortcuts.open_comments": "Kommentare öffnen", "page.keyboard_shortcuts.open_comments_same_window": "Öffne den Kommentare-Link in der aktuellen Registerkarte", - "page.keyboard_shortcuts.toggle_read_status": "Gewählten Artikel als gelesen/ungelesen markieren", + "page.keyboard_shortcuts.toggle_read_status_next": "Gewählten Artikel als gelesen/ungelesen markieren, fokus als nächstes", + "page.keyboard_shortcuts.toggle_read_status_prev": "Gewählten Artikel als gelesen/ungelesen markieren, fokus vorherige", "page.keyboard_shortcuts.refresh_all_feeds": "Alle Abonnements im Hintergrund aktualisieren", "page.keyboard_shortcuts.mark_page_as_read": "Aktuelle Seite als gelesen markieren", "page.keyboard_shortcuts.download_content": "Vollständigen Inhalt herunterladen", diff --git a/locale/translations/el_EL.json b/locale/translations/el_EL.json index d5d92881..79c8c50d 100644 --- a/locale/translations/el_EL.json +++ b/locale/translations/el_EL.json @@ -152,7 +152,8 @@ "page.keyboard_shortcuts.open_original_same_window": "Άνοιγμα αρχικού συνδέσμου στην τρέχουσα καρτέλα", "page.keyboard_shortcuts.open_comments": "Άνοιγμα συνδέσμου σχολίων", "page.keyboard_shortcuts.open_comments_same_window": "Άνοιγμα συνδέσμου σχολίων στην τρέχουσα καρτέλα", - "page.keyboard_shortcuts.toggle_read_status": "Εναλλαγή ανάγνωσης / μη αναγνωσμένης", + "page.keyboard_shortcuts.toggle_read_status_next": "Εναλλαγή ανάγνωσης / μη αναγνωσμένης, εστίαση στη συνέχεια", + "page.keyboard_shortcuts.toggle_read_status_prev": "Εναλλαγή ανάγνωσης / μη αναγνωσμένης, εστίαση στο προηγούμενο", "page.keyboard_shortcuts.refresh_all_feeds": "Ανανέωση όλων των ροών στο παρασκήνιο", "page.keyboard_shortcuts.mark_page_as_read": "Σημείωση της τρέχουσας σελίδας ως αναγνωσμένη", "page.keyboard_shortcuts.download_content": "Κατεβάστε το αρχικό περιεχόμενο", diff --git a/locale/translations/en_US.json b/locale/translations/en_US.json index fad37f60..5b303f35 100644 --- a/locale/translations/en_US.json +++ b/locale/translations/en_US.json @@ -152,7 +152,8 @@ "page.keyboard_shortcuts.open_original_same_window": "Open original link in current tab", "page.keyboard_shortcuts.open_comments": "Open comments link", "page.keyboard_shortcuts.open_comments_same_window": "Open comments link in current tab", - "page.keyboard_shortcuts.toggle_read_status": "Toggle read/unread", + "page.keyboard_shortcuts.toggle_read_status_next": "Toggle read/unread, focus next", + "page.keyboard_shortcuts.toggle_read_status_prev": "Toggle read/unread, focus previous", "page.keyboard_shortcuts.refresh_all_feeds": "Refresh all feeds in the background", "page.keyboard_shortcuts.mark_page_as_read": "Mark current page as read", "page.keyboard_shortcuts.download_content": "Download original content", diff --git a/locale/translations/es_ES.json b/locale/translations/es_ES.json index fe2a2ed1..cc9a0fee 100644 --- a/locale/translations/es_ES.json +++ b/locale/translations/es_ES.json @@ -152,7 +152,8 @@ "page.keyboard_shortcuts.open_original_same_window": "Abrir enlace original en la pestaña actual", "page.keyboard_shortcuts.open_comments": "Abrir el enlace de comentarios", "page.keyboard_shortcuts.open_comments_same_window": "Abrir enlace de comentarios en la pestaña actual", - "page.keyboard_shortcuts.toggle_read_status": "Marcar como leído o no leído", + "page.keyboard_shortcuts.toggle_read_status_next": "Marcar como leído o no leído, enfoque siguiente", + "page.keyboard_shortcuts.toggle_read_status_prev": "Marcar como leído o no leído, foco anterior", "page.keyboard_shortcuts.refresh_all_feeds": "Refrescar todas las fuentes en el fondo", "page.keyboard_shortcuts.mark_page_as_read": "Marcar pagína actual como leída", "page.keyboard_shortcuts.download_content": "Descargar el contento original", diff --git a/locale/translations/fi_FI.json b/locale/translations/fi_FI.json index c399ac74..1b40b326 100644 --- a/locale/translations/fi_FI.json +++ b/locale/translations/fi_FI.json @@ -152,7 +152,8 @@ "page.keyboard_shortcuts.open_original_same_window": "Avaa alkuperäinen linkki nykyisessä välilehdessä", "page.keyboard_shortcuts.open_comments": "Avaa kommenttilinkki", "page.keyboard_shortcuts.open_comments_same_window": "Avaa kommenttilinkki nykyisessä välilehdessä", - "page.keyboard_shortcuts.toggle_read_status": "Vaihda luettu/lukematon", + "page.keyboard_shortcuts.toggle_read_status_next": "Vaihda luettu/lukematon, keskity seuraavaksi", + "page.keyboard_shortcuts.toggle_read_status_prev": "Vaihda luettu/lukematon, keskity edelliseen", "page.keyboard_shortcuts.refresh_all_feeds": "Päivitä kaikki syötteet taustalla", "page.keyboard_shortcuts.mark_page_as_read": "Merkitse nykyinen sivu luetuksi", "page.keyboard_shortcuts.download_content": "Lataa alkuperäinen sisältö", diff --git a/locale/translations/fr_FR.json b/locale/translations/fr_FR.json index 01a197b7..27879e5a 100644 --- a/locale/translations/fr_FR.json +++ b/locale/translations/fr_FR.json @@ -152,7 +152,8 @@ "page.keyboard_shortcuts.open_original_same_window": "Ouvrir le lien original dans l'onglet en cours", "page.keyboard_shortcuts.open_comments": "Ouvrir le lien des commentaires", "page.keyboard_shortcuts.open_comments_same_window": "Ouvrir le lien des commentaires dans l'onglet en cours", - "page.keyboard_shortcuts.toggle_read_status": "Basculer entre lu/non lu", + "page.keyboard_shortcuts.toggle_read_status_next": "Basculer entre lu/non lu, et changer le focus sur l'élément suivant", + "page.keyboard_shortcuts.toggle_read_status_prev": "Basculer entre lu/non lu, et changer le focus sur l'élément précédent", "page.keyboard_shortcuts.refresh_all_feeds": "Actualiser les abonnements en arrière-plan", "page.keyboard_shortcuts.mark_page_as_read": "Marquer la page actuelle comme lu", "page.keyboard_shortcuts.download_content": "Télécharger le contenu original", diff --git a/locale/translations/it_IT.json b/locale/translations/it_IT.json index 16cbbcca..6713f4c5 100644 --- a/locale/translations/it_IT.json +++ b/locale/translations/it_IT.json @@ -152,7 +152,8 @@ "page.keyboard_shortcuts.open_original_same_window": "Apri il link originale nella scheda corrente", "page.keyboard_shortcuts.open_comments": "Apri la pagina web dei commenti", "page.keyboard_shortcuts.open_comments_same_window": "Apri il link dei commenti nella scheda corrente", - "page.keyboard_shortcuts.toggle_read_status": "Cambia lo stato di lettura (letto/da leggere)", + "page.keyboard_shortcuts.toggle_read_status_next": "Cambia lo stato di lettura (letto/da leggere), concentrati dopo", + "page.keyboard_shortcuts.toggle_read_status_prev": "Cambia lo stato di lettura (letto/da leggere), focus precedente", "page.keyboard_shortcuts.refresh_all_feeds": "Aggiorna tutti i feed in background", "page.keyboard_shortcuts.mark_page_as_read": "Segna la pagina attuale come letta", "page.keyboard_shortcuts.download_content": "Scarica il contenuto integrale", diff --git a/locale/translations/ja_JP.json b/locale/translations/ja_JP.json index 4be5ecbe..4caaef57 100644 --- a/locale/translations/ja_JP.json +++ b/locale/translations/ja_JP.json @@ -152,7 +152,8 @@ "page.keyboard_shortcuts.open_original_same_window": "現在のタブでオリジナルのリンクを開く", "page.keyboard_shortcuts.open_comments": "コメントリンクを開く", "page.keyboard_shortcuts.open_comments_same_window": "現在のタブでコメントリンクを開く", - "page.keyboard_shortcuts.toggle_read_status": "既読/未読 切り替え", + "page.keyboard_shortcuts.toggle_read_status_next": "既読/未読 切り替え, 次に焦点を合わせる", + "page.keyboard_shortcuts.toggle_read_status_prev": "既読/未読 切り替え, 前にフォーカス", "page.keyboard_shortcuts.refresh_all_feeds": "全てのフィードをバックグラウンドで更新", "page.keyboard_shortcuts.mark_page_as_read": "現在のページを既読にする", "page.keyboard_shortcuts.download_content": "オリジナルの内容をダウンロード", diff --git a/locale/translations/nl_NL.json b/locale/translations/nl_NL.json index 7e122cf9..951ed13d 100644 --- a/locale/translations/nl_NL.json +++ b/locale/translations/nl_NL.json @@ -153,7 +153,8 @@ "page.keyboard_shortcuts.open_original_same_window": "Oorspronkelijke koppeling op huidig tabblad openen", "page.keyboard_shortcuts.open_comments": "Open opmerkingen link", "page.keyboard_shortcuts.open_comments_same_window": "Open de reactiekoppeling op het huidige tabblad", - "page.keyboard_shortcuts.toggle_read_status": "Markeer gelezen/ongelezen", + "page.keyboard_shortcuts.toggle_read_status_next": "Markeer gelezen/ongelezen, focus volgende", + "page.keyboard_shortcuts.toggle_read_status_prev": "Markeer gelezen/ongelezen, focus vorige", "page.keyboard_shortcuts.refresh_all_feeds": "Vernieuw alle feeds in de achtergrond", "page.keyboard_shortcuts.mark_page_as_read": "Markeer deze pagina als gelezen", "page.keyboard_shortcuts.download_content": "Download originele content", diff --git a/locale/translations/pl_PL.json b/locale/translations/pl_PL.json index d7e3f493..b96cefb3 100644 --- a/locale/translations/pl_PL.json +++ b/locale/translations/pl_PL.json @@ -154,7 +154,8 @@ "page.keyboard_shortcuts.open_original_same_window": "Otwórz oryginalny link w bieżącej karcie", "page.keyboard_shortcuts.open_comments": "Otwórz link do komentarzy", "page.keyboard_shortcuts.open_comments_same_window": "Otwórz link do komentarzy w bieżącej karcie", - "page.keyboard_shortcuts.toggle_read_status": "Oznacz jako przeczytane/nieprzeczytane", + "page.keyboard_shortcuts.toggle_read_status_next": "Oznacz jako przeczytane/nieprzeczytane, skup się dalej", + "page.keyboard_shortcuts.toggle_read_status_prev": "Oznacz jako przeczytane/nieprzeczytane, skup poprzednie", "page.keyboard_shortcuts.refresh_all_feeds": "Odśwież wszystkie subskrypcje w tle", "page.keyboard_shortcuts.mark_page_as_read": "Zaznacz aktualną stronę jako przeczytaną", "page.keyboard_shortcuts.download_content": "Pobierz oryginalną zawartość", diff --git a/locale/translations/pt_BR.json b/locale/translations/pt_BR.json index 04af5311..6c85f858 100644 --- a/locale/translations/pt_BR.json +++ b/locale/translations/pt_BR.json @@ -152,7 +152,8 @@ "page.keyboard_shortcuts.open_original_same_window": "Abrir o conteúdo original na janela atual", "page.keyboard_shortcuts.open_comments": "Abrir os comentários", "page.keyboard_shortcuts.open_comments_same_window": "Abrir os comentários na janela atual", - "page.keyboard_shortcuts.toggle_read_status": "Inverter estado de leitura do item", + "page.keyboard_shortcuts.toggle_read_status_next": "Inverter estado de leitura do item, focar próximo item", + "page.keyboard_shortcuts.toggle_read_status_prev": "Inverter estado de leitura do item, focar item anterior", "page.keyboard_shortcuts.refresh_all_feeds": "Atualizar todas as fontes", "page.keyboard_shortcuts.mark_page_as_read": "Marcar página atual como lida", "page.keyboard_shortcuts.download_content": "Buscar o conteúdo original", diff --git a/locale/translations/ru_RU.json b/locale/translations/ru_RU.json index 135d705c..622df04d 100644 --- a/locale/translations/ru_RU.json +++ b/locale/translations/ru_RU.json @@ -154,7 +154,8 @@ "page.keyboard_shortcuts.open_original": "Открыть оригинальную ссылку", "page.keyboard_shortcuts.open_comments_same_window": "Открыть ссылку на комментарии в текущей вкладке", "page.keyboard_shortcuts.open_comments": "Открыть ссылку для комментариев", - "page.keyboard_shortcuts.toggle_read_status": "Переключатель прочитанного", + "page.keyboard_shortcuts.toggle_read_status_next": "Переключатель прочитанного, сосредоточиться на следующем", + "page.keyboard_shortcuts.toggle_read_status_prev": "Переключатель прочитанного, фокус предыдущий", "page.keyboard_shortcuts.refresh_all_feeds": "Обновить все подписки в фоне", "page.keyboard_shortcuts.mark_page_as_read": "Отметить текущую страницу прочитанной", "page.keyboard_shortcuts.download_content": "Загрузить оригинальное содержимое", diff --git a/locale/translations/tr_TR.json b/locale/translations/tr_TR.json index 24aaf817..131af760 100644 --- a/locale/translations/tr_TR.json +++ b/locale/translations/tr_TR.json @@ -152,7 +152,8 @@ "page.keyboard_shortcuts.open_original_same_window": "Orijinal bağlantıyı mevcut sekmede aç", "page.keyboard_shortcuts.open_comments": "Yorumlar bağlantısını aç", "page.keyboard_shortcuts.open_comments_same_window": "Yorumlar bağlantısını mevcut sekmede aç", - "page.keyboard_shortcuts.toggle_read_status": "Okundu/okunmadı arasında geçiş yap", + "page.keyboard_shortcuts.toggle_read_status_next": "Okundu/okunmadı arasında geçiş yap, sonrakine odaklan", + "page.keyboard_shortcuts.toggle_read_status_prev": "Okundu/okunmadı arasında geçiş yap, öncekine odaklan", "page.keyboard_shortcuts.refresh_all_feeds": "Tüm beslemeleri arka planda yenile", "page.keyboard_shortcuts.mark_page_as_read": "Mevcut sayfayı okundu olarak işaretle", "page.keyboard_shortcuts.download_content": "Orijinal içeriği indir", diff --git a/locale/translations/zh_CN.json b/locale/translations/zh_CN.json index 8d0c3c5b..520ff5f7 100644 --- a/locale/translations/zh_CN.json +++ b/locale/translations/zh_CN.json @@ -150,7 +150,8 @@ "page.keyboard_shortcuts.open_original_same_window": "在当前标签页中打开原始链接", "page.keyboard_shortcuts.open_comments": "打开评论链接", "page.keyboard_shortcuts.open_comments_same_window": "在当前标签页中打开评论链接", - "page.keyboard_shortcuts.toggle_read_status": "切换已读/未读状态", + "page.keyboard_shortcuts.toggle_read_status_next": "切换已读/未读状态, 关注下一个", + "page.keyboard_shortcuts.toggle_read_status_prev": "切换已读/未读状态, 关注前一个", "page.keyboard_shortcuts.refresh_all_feeds": "在后台更新全部源", "page.keyboard_shortcuts.mark_page_as_read": "标记当前页已读", "page.keyboard_shortcuts.download_content": "抓取全文内容", diff --git a/template/templates/common/layout.html b/template/templates/common/layout.html index 3c7c64de..65c3b15a 100644 --- a/template/templates/common/layout.html +++ b/template/templates/common/layout.html @@ -147,7 +147,8 @@
  • {{ t "page.keyboard_shortcuts.open_original_same_window" }} = V
  • {{ t "page.keyboard_shortcuts.open_comments" }} = c
  • {{ t "page.keyboard_shortcuts.open_comments_same_window" }} = C
  • -
  • {{ t "page.keyboard_shortcuts.toggle_read_status" }} = m
  • +
  • {{ t "page.keyboard_shortcuts.toggle_read_status_next" }} = m
  • +
  • {{ t "page.keyboard_shortcuts.toggle_read_status_prev" }} = M
  • {{ t "page.keyboard_shortcuts.mark_page_as_read" }} = A
  • {{ t "page.keyboard_shortcuts.download_content" }} = d
  • {{ t "page.keyboard_shortcuts.toggle_bookmark_status" }} = f
  • diff --git a/ui/static/js/app.js b/ui/static/js/app.js index 2864103e..a8c0bce0 100644 --- a/ui/static/js/app.js +++ b/ui/static/js/app.js @@ -128,6 +128,7 @@ function markPageAsRead() { } // Handle entry status changes from the list view and entry view. +// Focus the previous entry if it exists. function handleEntryStatus(element, setToRead) { let toasting = !element; let currentEntry = findEntry(element); @@ -141,6 +142,21 @@ function handleEntryStatus(element, setToRead) { } } +// Handle entry status changes from the list view and entry view. +// Focus the next entry if it exists. +function handleEntryStatusNext(element, setToRead) { + let toasting = !element; + let currentEntry = findEntry(element); + if (currentEntry) { + if (!setToRead || currentEntry.querySelector("a[data-toggle-status]").dataset.value == "unread") { + toggleEntryStatus(currentEntry, toasting); + } + if (isListView() && currentEntry.classList.contains('current-item')) { + goToPrevListItem(); + } + } +} + // Change the entry status to the opposite value. function toggleEntryStatus(element, toasting) { let entryID = parseInt(element.dataset.id, 10); @@ -512,6 +528,38 @@ function goToNextListItem() { } } +function goToPrevListItem() { + 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"); + + let prevItem; + if (i - 1 >= 0) { + prevItem = items[i - 1]; + } else { + prevItem = items[items.length - 1]; + } + + prevItem.classList.add("current-item"); + DomHelper.scrollPageTo(prevItem); + prevItem.querySelector('.item-header a').focus(); + + break; + } + } +} + function scrollToCurrentItem() { let currentItem = document.querySelector(".current-item"); if (currentItem !== null) { diff --git a/ui/static/js/bootstrap.js b/ui/static/js/bootstrap.js index 624ef17e..6c41003d 100644 --- a/ui/static/js/bootstrap.js +++ b/ui/static/js/bootstrap.js @@ -24,6 +24,7 @@ document.addEventListener("DOMContentLoaded", function () { keyboardHandler.on("c", () => openCommentLink()); keyboardHandler.on("C", () => openCommentLink(true)); keyboardHandler.on("m", () => handleEntryStatus()); + keyboardHandler.on("M", () => handleEntryStatusNext()); keyboardHandler.on("A", () => markPageAsRead()); keyboardHandler.on("s", () => handleSaveEntry()); keyboardHandler.on("d", () => handleFetchOriginalContent());