From 78773d732672d8985795fb040a39dd7e946c7b7c Mon Sep 17 00:00:00 2001 From: Emilien Devos Date: Sat, 22 May 2021 17:42:23 +0200 Subject: [PATCH 01/88] add the ability to listen on unix sockets --- src/invidious.cr | 15 ++++++++++++--- src/invidious/helpers/helpers.cr | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index ae20e13e..65b1091b 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -3917,6 +3917,15 @@ add_context_storage_type(Preferences) add_context_storage_type(User) Kemal.config.logger = LOGGER -Kemal.config.host_binding = Kemal.config.host_binding != "0.0.0.0" ? Kemal.config.host_binding : CONFIG.host_binding -Kemal.config.port = Kemal.config.port != 3000 ? Kemal.config.port : CONFIG.port -Kemal.run + +Kemal.run do |config| + if CONFIG.bind_unix + if File.exists?(CONFIG.bind_unix.not_nil!) + File.delete(CONFIG.bind_unix.not_nil!) + end + config.server.not_nil!.bind_unix CONFIG.bind_unix.not_nil! + else + config.host_binding = config.host_binding != "0.0.0.0" ? config.host_binding : CONFIG.host_binding + config.port = config.port != 3000 ? config.port : CONFIG.port + end +end diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index e1d877b7..6a5789a0 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -98,6 +98,7 @@ class Config property force_resolve : Socket::Family = Socket::Family::UNSPEC # Connect to YouTube over 'ipv6', 'ipv4'. Will sometimes resolve fix issues with rate-limiting (see https://github.com/ytdl-org/youtube-dl/issues/21729) property port : Int32 = 3000 # Port to listen for connections (overrided by command line argument) property host_binding : String = "0.0.0.0" # Host to bind (overrided by command line argument) + property bind_unix : String? = nil # Make Invidious listening on UNIX sockets - Example: /tmp/invidious.sock property pool_size : Int32 = 100 # Pool size for HTTP requests to youtube.com and ytimg.com (each domain has a separate pool of `pool_size`) property use_quic : Bool = true # Use quic transport for youtube api From 905582db6684233645a05bca0094b597499cbbbb Mon Sep 17 00:00:00 2001 From: RadoslavL Date: Wed, 27 Sep 2023 11:28:47 +0300 Subject: [PATCH 02/88] Added a first page button --- locales/de.json | 1 + locales/en-US.json | 1 + locales/ru.json | 1 + src/invidious/frontend/pagination.cr | 19 +++++++++++++++++-- src/invidious/views/channel.ecr | 3 ++- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/locales/de.json b/locales/de.json index 6ceaa44b..309d1e49 100644 --- a/locales/de.json +++ b/locales/de.json @@ -11,6 +11,7 @@ "last": "neueste", "Next page": "Nächste Seite", "Previous page": "Vorherige Seite", + "First page": "Erste Seite", "Clear watch history?": "Verlauf löschen?", "New password": "Neues Passwort", "New passwords must match": "Neue Passwörter müssen übereinstimmen", diff --git a/locales/en-US.json b/locales/en-US.json index 06d095dc..b8264bc4 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -28,6 +28,7 @@ "last": "last", "Next page": "Next page", "Previous page": "Previous page", + "First page": "First page", "Clear watch history?": "Clear watch history?", "New password": "New password", "New passwords must match": "New passwords must match", diff --git a/locales/ru.json b/locales/ru.json index 5325a9b6..ec615fac 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -11,6 +11,7 @@ "last": "недавние", "Next page": "Следующая страница", "Previous page": "Предыдущая страница", + "First page": "Первая страница", "Clear watch history?": "Очистить историю просмотров?", "New password": "Новый пароль", "New passwords must match": "Новые пароли не совпадают", diff --git a/src/invidious/frontend/pagination.cr b/src/invidious/frontend/pagination.cr index 3f931f4e..85e588ff 100644 --- a/src/invidious/frontend/pagination.cr +++ b/src/invidious/frontend/pagination.cr @@ -3,6 +3,15 @@ require "uri" module Invidious::Frontend::Pagination extend self + private def first_page(str : String::Builder, locale : String?, url : String) + str << %() + + str << translate(locale, "First page") + str << "  " + str << %() + str << "" + end + private def previous_page(str : String::Builder, locale : String?, url : String) # Link str << %() @@ -72,12 +81,18 @@ module Invidious::Frontend::Pagination end end - def nav_ctoken(locale : String?, *, base_url : String | URI, ctoken : String?) + def nav_ctoken(locale : String?, *, base_url : String | URI, ctoken : String?, first_page : String?) return String.build do |str| str << %(
\n) str << %(