From 5cdbc184c73019d72c100bf0069cddce2294a32e Mon Sep 17 00:00:00 2001 From: RadoslavL Date: Sat, 30 Sep 2023 18:36:43 +0300 Subject: [PATCH] Added a previous_page_button preference option and made switching between the first page and previous page buttons possible --- locales/en-US.json | 1 + src/invidious/config.cr | 1 + src/invidious/frontend/pagination.cr | 12 +++++++++--- src/invidious/routes/before_all.cr | 3 +++ src/invidious/routes/preferences.cr | 5 +++++ src/invidious/user/preferences.cr | 1 + src/invidious/views/channel.ecr | 7 ++++++- src/invidious/views/components/items_paginated.ecr | 10 ++++++++++ src/invidious/views/user/preferences.ecr | 6 ++++++ 9 files changed, 42 insertions(+), 4 deletions(-) diff --git a/locales/en-US.json b/locales/en-US.json index 573fb71d..e3ffadb9 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -105,6 +105,7 @@ "preferences_category_visual": "Visual preferences", "preferences_region_label": "Content country: ", "preferences_player_style_label": "Player style: ", + "preferences_previous_page_button_label": "Previous page button (requires Javascript):", "Dark mode: ": "Dark mode: ", "preferences_dark_mode_label": "Theme: ", "dark": "dark", diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 429d9246..56c09beb 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -44,6 +44,7 @@ struct ConfigPreferences property vr_mode : Bool = true property show_nick : Bool = true property save_player_pos : Bool = false + property previous_page_button : Bool = true def to_tuple {% begin %} diff --git a/src/invidious/frontend/pagination.cr b/src/invidious/frontend/pagination.cr index 13464503..4a9d76d7 100644 --- a/src/invidious/frontend/pagination.cr +++ b/src/invidious/frontend/pagination.cr @@ -3,7 +3,10 @@ require "uri" module Invidious::Frontend::Pagination extend self - private def first_page(str : String::Builder, locale : String?, url : String) + private def first_page(str : String::Builder, locale : String?, url : String, previous_page_button : Bool) + if previous_page_button + str << %(" + end end private def previous_page(str : String::Builder, locale : String?, url : String) @@ -90,7 +96,7 @@ module Invidious::Frontend::Pagination end end - def nav_ctoken(locale : String?, *, base_url : String | URI, ctoken : String?, first_page : Bool) + def nav_ctoken(locale : String?, *, base_url : String | URI, ctoken : String?, first_page : Bool, previous_page_button : Bool) return String.build do |str| str << %(
\n) str << %( + +
+ + checked<% end %>> +
+ <% if env.get? "user" %>