From 727eca1ce7797f818a5a0aa0b445283dced09205 Mon Sep 17 00:00:00 2001 From: loma-one Date: Sat, 16 Sep 2023 16:54:54 +0200 Subject: [PATCH 01/18] Coloured box added Among other things, I use the page header to inform about current maintenance work or other upcoming work. The information should therefore be provided within an appropriate framework. With a little CSS, the page header gets a frame in green. The font was adjusted to an appropriate size. --- pageheader/pageheader.css | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pageheader/pageheader.css b/pageheader/pageheader.css index 8b3282fb..17ad64c1 100644 --- a/pageheader/pageheader.css +++ b/pageheader/pageheader.css @@ -21,3 +21,13 @@ margin-top: 25px; font-size: 20px; } + +/* The pageheader box */ +.pageheader { + padding: 20px; + background-color: #2eb885; /* Green */ + color: white; + border: 1px solid transparent; + border-radius: 2px; + margin-bottom: 15px; +} From d685663ac068584d4ed88f5424ab74ef55a4d9c1 Mon Sep 17 00:00:00 2001 From: loma-one Date: Wed, 20 Sep 2023 15:32:18 +0200 Subject: [PATCH 02/18] Coloured box added --- pageheader/pageheader.css | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pageheader/pageheader.css b/pageheader/pageheader.css index 17ad64c1..3360522e 100644 --- a/pageheader/pageheader.css +++ b/pageheader/pageheader.css @@ -20,14 +20,11 @@ width: 100%; margin-top: 25px; font-size: 20px; -} - -/* The pageheader box */ -.pageheader { - padding: 20px; - background-color: #2eb885; /* Green */ - color: white; - border: 1px solid transparent; - border-radius: 2px; - margin-bottom: 15px; + /* The pageheader box */ + padding: 20px; + background-color: #2eb885; /* Green */ + color: white; + border: 1px solid transparent; + border-radius: 2px; + margin-bottom: 15px; } From 9315b185e8b9a4ad39db90f731ae93098d551634 Mon Sep 17 00:00:00 2001 From: loma-one Date: Sat, 23 Sep 2023 18:28:54 +0200 Subject: [PATCH 03/18] pageheader/pageheader.css aktualisiert --- pageheader/pageheader.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pageheader/pageheader.css b/pageheader/pageheader.css index 3360522e..33ab6ad7 100644 --- a/pageheader/pageheader.css +++ b/pageheader/pageheader.css @@ -22,8 +22,8 @@ font-size: 20px; /* The pageheader box */ padding: 20px; - background-color: #2eb885; /* Green */ - color: white; + /*background-color: #2eb885; /* Green */ + /*color: white;*/ border: 1px solid transparent; border-radius: 2px; margin-bottom: 15px; From 2c2a813324a192e9441a059c30a52292add56fea Mon Sep 17 00:00:00 2001 From: loma-one Date: Tue, 3 Oct 2023 10:51:42 +0200 Subject: [PATCH 04/18] [pageheader] Improve visibility Removed commented out code from your pull request --- pageheader/pageheader.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/pageheader/pageheader.css b/pageheader/pageheader.css index 33ab6ad7..f6c28fbf 100644 --- a/pageheader/pageheader.css +++ b/pageheader/pageheader.css @@ -22,8 +22,6 @@ font-size: 20px; /* The pageheader box */ padding: 20px; - /*background-color: #2eb885; /* Green */ - /*color: white;*/ border: 1px solid transparent; border-radius: 2px; margin-bottom: 15px; From eadbcc069f0dd793625afb54732b127c5bada676 Mon Sep 17 00:00:00 2001 From: loma-one Date: Sun, 3 Dec 2023 13:01:40 +0100 Subject: [PATCH 05/18] =?UTF-8?q?invidious=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- invidious | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 invidious diff --git a/invidious b/invidious new file mode 100644 index 00000000..e69de29b From 46fdcc1c0ed09bc7c6e71f87845668362c2ee9ac Mon Sep 17 00:00:00 2001 From: loma-one Date: Sun, 3 Dec 2023 13:02:03 +0100 Subject: [PATCH 06/18] =?UTF-8?q?invidious=20gel=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- invidious | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 invidious diff --git a/invidious b/invidious deleted file mode 100644 index e69de29b..00000000 From 9d932e6fa04e128451ea8907e69f10ea1e698c7f Mon Sep 17 00:00:00 2001 From: loma-one Date: Sun, 3 Dec 2023 13:07:45 +0100 Subject: [PATCH 07/18] Dateien nach "invidious" hochladen Replaces links to youtube.com to an invidious instance in all displays of postings on a node. --- invidious/invidious.php | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 invidious/invidious.php diff --git a/invidious/invidious.php b/invidious/invidious.php new file mode 100644 index 00000000..4ff57fc0 --- /dev/null +++ b/invidious/invidious.php @@ -0,0 +1,64 @@ + + * + */ + +use Friendica\App; +use Friendica\Core\Hook; +use Friendica\Core\Renderer; +use Friendica\DI; + +function invidious_install() +{ + Hook::register('prepare_body_final', 'addon/invidious/invidious.php', 'invidious_render'); +} + +/* Handle the send data from the admin settings + */ +function invidious_addon_admin_post() +{ + DI::config()->set('invidious', 'server', rtrim(trim($_POST['invidiousserver']), '/')); +} + +/* Hook into the admin settings to let the admin choose an + * invidious server to use for the replacement. + */ +function invidious_addon_admin(string &$o) +{ + $invidiousserver = DI::config()->get('invidious', 'server'); + $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/invidious/'); + $o = Renderer::replaceMacros($t, [ + '$settingdescription' => DI::l10n()->t('Which Invidious server shall be used for the replacements in the post bodies? Use the URL with servername and protocol. See %s for a list of available public Invidious servers.', 'https://redirect.invidious.io'), + '$invidiousserver' => ['invidiousserver', DI::l10n()->t('Invidious server'), $invidiousserver, 'https://example.com'], + '$submit' => DI::l10n()->t('Save Settings'), + ]); +} + +/* + * replace "youtube.com" with the chosen Invidious instance + */ +function invidious_render(array &$b) +{ + // this needs to be a system setting + $replaced = false; + $invidious = DI::config()->get('invidious', 'server', 'https://invidio.us'); + if (strstr($b['html'], 'https://www.youtube.com')) { + $b['html'] = str_replace('https://www.youtube.com', $invidious, $b['html']); + $replaced = true; + } + if (strstr($b['html'], 'https://youtube.com')) { + $b['html'] = str_replace('https://youtube.com', $invidious, $b['html']); + $replaced = true; + } + if (strstr($b['html'], 'https://youtu.be')) { + $b['html'] = str_replace('https://youtu.be', $invidious, $b['html']); + $replaced = true; + } + if ($replaced) { + $b['html'] .= '

' . DI::l10n()->t('(Invidious addon enabled: YouTube links via %s)', $invidious) . '

'; + } +} From ebf5ff1276b82f832736532bee75ebe1504b70ed Mon Sep 17 00:00:00 2001 From: loma-one Date: Sun, 3 Dec 2023 13:09:02 +0100 Subject: [PATCH 08/18] Dateien nach "invidious/templates" hochladen --- invidious/templates/admin.tpl | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 invidious/templates/admin.tpl diff --git a/invidious/templates/admin.tpl b/invidious/templates/admin.tpl new file mode 100644 index 00000000..1db85ff9 --- /dev/null +++ b/invidious/templates/admin.tpl @@ -0,0 +1,5 @@ +

{{$settingdescription}}

+ +{{include file="field_input.tpl" field=$invidiousserver}} + +
From f46980c7361139892ca4fc2fd563daca3f95a379 Mon Sep 17 00:00:00 2001 From: loma-one Date: Sun, 3 Dec 2023 13:11:50 +0100 Subject: [PATCH 09/18] Dateien nach "invidious/lang/C" hochladen --- invidious/lang/C/messages.po | 1 + 1 file changed, 1 insertion(+) create mode 100644 invidious/lang/C/messages.po diff --git a/invidious/lang/C/messages.po b/invidious/lang/C/messages.po new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/invidious/lang/C/messages.po @@ -0,0 +1 @@ + From c98caaf41776d6c99657dc27bbcc09df255e0c9d Mon Sep 17 00:00:00 2001 From: loma-one Date: Sun, 3 Dec 2023 13:12:19 +0100 Subject: [PATCH 10/18] Dateien nach "invidious" hochladen --- invidious/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 invidious/README.md diff --git a/invidious/README.md b/invidious/README.md new file mode 100644 index 00000000..0f91fa02 --- /dev/null +++ b/invidious/README.md @@ -0,0 +1,4 @@ +invidious Addon for Friendica +========================== + +This addon will replace "youtube.com" with the chosen Invidious instance From 0f65c2349040eff6ecee294f8262faf6a3ddb11c Mon Sep 17 00:00:00 2001 From: loma-one Date: Sun, 3 Dec 2023 18:54:39 +0100 Subject: [PATCH 11/18] invidious/invidious.php aktualisiert Redirects from youtu.be do not work reliably. Therefore this one has been removed. --- invidious/invidious.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/invidious/invidious.php b/invidious/invidious.php index 4ff57fc0..c647fd1b 100644 --- a/invidious/invidious.php +++ b/invidious/invidious.php @@ -53,10 +53,6 @@ function invidious_render(array &$b) if (strstr($b['html'], 'https://youtube.com')) { $b['html'] = str_replace('https://youtube.com', $invidious, $b['html']); $replaced = true; - } - if (strstr($b['html'], 'https://youtu.be')) { - $b['html'] = str_replace('https://youtu.be', $invidious, $b['html']); - $replaced = true; } if ($replaced) { $b['html'] .= '

' . DI::l10n()->t('(Invidious addon enabled: YouTube links via %s)', $invidious) . '

'; From dc2d00b6c626f7777e02de061421bf71f31ae6a6 Mon Sep 17 00:00:00 2001 From: loma-one Date: Sun, 3 Dec 2023 20:29:19 +0100 Subject: [PATCH 12/18] invidious/lang/C/messages.po aktualisiert --- invidious/lang/C/messages.po | 41 +++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/invidious/lang/C/messages.po b/invidious/lang/C/messages.po index 8d1c8b69..f93a87d6 100644 --- a/invidious/lang/C/messages.po +++ b/invidious/lang/C/messages.po @@ -1 +1,40 @@ - + # ADDON invidious +# Copyright (C) +# This file is distributed under the same license as the Friendica invidious addon package. +# +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-12-03 20:21+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: invidious.php:35 +#, php-format +msgid "" +"Which Invidious server shall be used for the replacements in the post " +"bodies? Use the URL with servername and protocol. See %s for a list of " +"available public Invidious servers." +msgstr "" + +#: invidious.php:36 +msgid "Invidious server" +msgstr "" + +#: invidious.php:37 +msgid "Save Settings" +msgstr "" + +#: invidious.php:64 +#, php-format +msgid "(Invidious addon enabled: YouTube links via %s)" +msgstr "" + From 668ea972ccb3974ceba4be993a8a39a9734c3cad Mon Sep 17 00:00:00 2001 From: loma-one Date: Mon, 4 Dec 2023 22:01:46 +0100 Subject: [PATCH 13/18] invidious/invidious.php aktualisiert --- invidious/invidious.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/invidious/invidious.php b/invidious/invidious.php index c647fd1b..e6ac4ac3 100644 --- a/invidious/invidious.php +++ b/invidious/invidious.php @@ -50,7 +50,7 @@ function invidious_render(array &$b) $b['html'] = str_replace('https://www.youtube.com', $invidious, $b['html']); $replaced = true; } - if (strstr($b['html'], 'https://youtube.com')) { + if (strstr($b['html'], 'https://youtube.com')) { $b['html'] = str_replace('https://youtube.com', $invidious, $b['html']); $replaced = true; } From 90d897f4fab3f2c2fb7bb01daebdb58fffc710a1 Mon Sep 17 00:00:00 2001 From: loma-one Date: Tue, 5 Dec 2023 09:08:36 +0100 Subject: [PATCH 14/18] This addon will replace "youtube.com" with the chosen Invidious instance URL combine --- invidious/invidious.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/invidious/invidious.php b/invidious/invidious.php index e6ac4ac3..5c625009 100644 --- a/invidious/invidious.php +++ b/invidious/invidious.php @@ -2,7 +2,7 @@ /* * Name: invidious * Description: Replaces links to youtube.com to an invidious instance in all displays of postings on a node. - * Version: 0.1 + * Version: 0.2 * Author: Matthias Ebers <@feb@loma.ml> * */ @@ -46,14 +46,19 @@ function invidious_render(array &$b) // this needs to be a system setting $replaced = false; $invidious = DI::config()->get('invidious', 'server', 'https://invidio.us'); - if (strstr($b['html'], 'https://www.youtube.com')) { - $b['html'] = str_replace('https://www.youtube.com', $invidious, $b['html']); - $replaced = true; - } - if (strstr($b['html'], 'https://youtube.com')) { - $b['html'] = str_replace('https://youtube.com', $invidious, $b['html']); - $replaced = true; + + $youtubeUrls = [ + 'https://www.youtube.com', + 'https://youtube.com', + ]; + + foreach ($youtubeUrls as $youtubeUrl) { + if (strstr($b['html'], $youtubeUrl)) { + $b['html'] = str_replace($youtubeUrl, $invidious, $b['html']); + $replaced = true; + } } + if ($replaced) { $b['html'] .= '

' . DI::l10n()->t('(Invidious addon enabled: YouTube links via %s)', $invidious) . '

'; } From 26983977c4e5453e72912d54dcd984c793ee1f8f Mon Sep 17 00:00:00 2001 From: loma-one Date: Tue, 5 Dec 2023 22:40:49 +0100 Subject: [PATCH 15/18] This addon will replace "youtube.com" with the chosen Invidious instance Suggestion from @heluecht for combined URLs adopted --- invidious/invidious.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/invidious/invidious.php b/invidious/invidious.php index 5c625009..a92c49a6 100644 --- a/invidious/invidious.php +++ b/invidious/invidious.php @@ -3,7 +3,7 @@ * Name: invidious * Description: Replaces links to youtube.com to an invidious instance in all displays of postings on a node. * Version: 0.2 - * Author: Matthias Ebers <@feb@loma.ml> + * Author: Matthias Ebers * */ @@ -46,19 +46,10 @@ function invidious_render(array &$b) // this needs to be a system setting $replaced = false; $invidious = DI::config()->get('invidious', 'server', 'https://invidio.us'); - - $youtubeUrls = [ - 'https://www.youtube.com', - 'https://youtube.com', - ]; - - foreach ($youtubeUrls as $youtubeUrl) { - if (strstr($b['html'], $youtubeUrl)) { - $b['html'] = str_replace($youtubeUrl, $invidious, $b['html']); - $replaced = true; - } + if (strstr($b['html'], 'https://www.youtube.com')) { + $b['html'] = str_replace(['https://www.youtube.com', 'https://youtube.com'], $invidious, $b['html']); + $replaced = true; } - if ($replaced) { $b['html'] .= '

' . DI::l10n()->t('(Invidious addon enabled: YouTube links via %s)', $invidious) . '

'; } From f45f6ba992d7382abb742b0fb24021ba9c29afe4 Mon Sep 17 00:00:00 2001 From: loma-one Date: Wed, 6 Dec 2023 18:00:35 +0100 Subject: [PATCH 16/18] https://youtu.be Link Many thanks for the hint. With a small change '/watch?v=' the link to https://youtu.be now also works --- invidious/invidious.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/invidious/invidious.php b/invidious/invidious.php index a92c49a6..821d904c 100644 --- a/invidious/invidious.php +++ b/invidious/invidious.php @@ -46,9 +46,9 @@ function invidious_render(array &$b) // this needs to be a system setting $replaced = false; $invidious = DI::config()->get('invidious', 'server', 'https://invidio.us'); - if (strstr($b['html'], 'https://www.youtube.com')) { - $b['html'] = str_replace(['https://www.youtube.com', 'https://youtube.com'], $invidious, $b['html']); - $replaced = true; + if (strpos($b['html'], 'https://www.youtube.com/') !== false || strpos($b['html'], 'https://youtube.com/') !== false || strpos($b['html'], 'https://youtu.be/') !== false) { + $b['html'] = str_replace('https://youtu.be/', $invidious . '/watch?v=', $b['html']); + $b['html'] = str_replace(['https://www.youtube.com/', 'https://youtube.com/'], $invidious . '/', $b['html']); } if ($replaced) { $b['html'] .= '

' . DI::l10n()->t('(Invidious addon enabled: YouTube links via %s)', $invidious) . '

'; From 372e75a91cde21e5057392d94e55cc4e722ccf12 Mon Sep 17 00:00:00 2001 From: loma-one Date: Wed, 6 Dec 2023 18:03:48 +0100 Subject: [PATCH 17/18] invidious/invidious.php aktualisiert --- invidious/invidious.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/invidious/invidious.php b/invidious/invidious.php index 821d904c..ff984f6f 100644 --- a/invidious/invidious.php +++ b/invidious/invidious.php @@ -47,8 +47,8 @@ function invidious_render(array &$b) $replaced = false; $invidious = DI::config()->get('invidious', 'server', 'https://invidio.us'); if (strpos($b['html'], 'https://www.youtube.com/') !== false || strpos($b['html'], 'https://youtube.com/') !== false || strpos($b['html'], 'https://youtu.be/') !== false) { - $b['html'] = str_replace('https://youtu.be/', $invidious . '/watch?v=', $b['html']); - $b['html'] = str_replace(['https://www.youtube.com/', 'https://youtube.com/'], $invidious . '/', $b['html']); + $b['html'] = str_replace('https://youtu.be/', $invidious . '/watch?v=', $b['html']); + $b['html'] = str_replace(['https://www.youtube.com/', 'https://youtube.com/'], $invidious . '/', $b['html']); } if ($replaced) { $b['html'] .= '

' . DI::l10n()->t('(Invidious addon enabled: YouTube links via %s)', $invidious) . '

'; From d53ad98af2cbce01d2cdd8375e2c2383d9f0eb98 Mon Sep 17 00:00:00 2001 From: loma-one Date: Wed, 6 Dec 2023 18:07:21 +0100 Subject: [PATCH 18/18] invidious/invidious.php aktualisiert --- invidious/invidious.php | 1 + 1 file changed, 1 insertion(+) diff --git a/invidious/invidious.php b/invidious/invidious.php index ff984f6f..7692229d 100644 --- a/invidious/invidious.php +++ b/invidious/invidious.php @@ -49,6 +49,7 @@ function invidious_render(array &$b) if (strpos($b['html'], 'https://www.youtube.com/') !== false || strpos($b['html'], 'https://youtube.com/') !== false || strpos($b['html'], 'https://youtu.be/') !== false) { $b['html'] = str_replace('https://youtu.be/', $invidious . '/watch?v=', $b['html']); $b['html'] = str_replace(['https://www.youtube.com/', 'https://youtube.com/'], $invidious . '/', $b['html']); + $replaced = true; } if ($replaced) { $b['html'] .= '

' . DI::l10n()->t('(Invidious addon enabled: YouTube links via %s)', $invidious) . '

';