Updated URL Replace addon #1483

Merged
MrPetovan merged 18 commits from toddy/friendica-addons:2024.03-rc into 2024.03-rc 2024-03-19 18:00:46 +01:00
Showing only changes of commit 890bc3712f - Show all commits

View file

@ -11,6 +11,10 @@ use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
CONST URL_REPLACE_NITTER_DEFAULT = 'https://nitter.net';
CONST URL_REPLACE_INVIDIOUS_DEFAULT = 'https://yewtu.be';
toddy marked this conversation as resolved Outdated

Out of interest: Why aren't we using https://invidio.us here? Wouldn't it be better to use the main instances as default values?

Out of interest: Why aren't we using https://invidio.us here? Wouldn't it be better to use the main instances as default values?

You cannot use it to watch something directly, they provide a hub to instances you can use to watch.

You cannot use it to watch something directly, they provide a hub to instances you can use to watch.

You will see this page where you have to select a server. But when you follow one of these links, your content will be loaded. So you will also be able to chose your individual server each time. Also: I just tested with one video. I had to try several servers, until I found one, that finally was able to display the video. So using https://invidio.us helps here.

You will see this page where you have to select a server. But when you follow one of these links, your content will be loaded. So you will also be able to chose your individual server each time. Also: I just tested with one video. I had to try several servers, until I found one, that finally was able to display the video. So using https://invidio.us helps here.

I agree with @heluecht , let’s use the official portal by default and let admins pick a specific instance later.

I agree with @heluecht , let’s use the official portal by default and let admins pick a specific instance later.
Outdated
Review

TBH, I'm not a big fan of that change. After all, it requires two clicks of the user instead of just one to watch the video. All other alternative frontends provided by this addon show the content directly after following the link.

Moreover, yewtu.be has been around for a long time already and seems to be rather reliable. So IMHO it makes for a good and sensible default server. And it has by far the coolest name. :-)

TBH, I'm not a big fan of that change. After all, it requires two clicks of the user instead of just one to watch the video. All other alternative frontends provided by this addon show the content directly after following the link. Moreover, yewtu.be has been around for a long time already and seems to be rather reliable. So IMHO it makes for a good and sensible default server. And it has by far the coolest name. :-)

Well, the first time I tried the service at yewtub.de, I received an error. I then had to try two other servers to finally find one, that was able to display it to me. So having the choice is a nice thing. Also this is only a default value, so people can enter their own preferred server afterwards - based on their own experience and their regional location.

Well, the first time I tried the service at `yewtub.de`, I received an error. I then had to try two other servers to finally find one, that was able to display it to me. So having the choice is a nice thing. Also this is only a default value, so people can enter their own preferred server afterwards - based on their own experience and their regional location.
Outdated
Review

If this is the last discussion point before being able to merge this PR, I'll give in. :-)

If this is the last discussion point before being able to merge this PR, I'll give in. :-)
CONST URL_REPLACE_PROXIGRAM_DEFAULT = 'https://proxigram.lunar.icu';
function url_replace_install()
{
Hook::register('prepare_body_final', 'addon/url_replace/url_replace.php', 'url_replace_render');
@ -68,9 +72,9 @@ function url_replace_addon_admin(string &$o)
'nitter_server',
DI::l10n()->t('Nitter server'),
$nitter_server,
DI::l10n()->t('Specify the URL with protocol. The default is https://nitter.net.'),
DI::l10n()->t('Specify the URL with protocol. The default is %s.', URL_REPLACE_NITTER_DEFAULT),
null,
'placeholder="https://nitter.net"',
'placeholder="'.URL_REPLACE_NITTER_DEFAULT.'"',
],
'$invidious_server_enabled' => [
'invidious_server_enabled',
@ -81,9 +85,9 @@ function url_replace_addon_admin(string &$o)
'invidious_server',
DI::l10n()->t('Invidious server'),
$invidious_server,
DI::l10n()->t('Specify the URL with protocol. The default is https://yewtu.be.'),
DI::l10n()->t('Specify the URL with protocol. The default is %s.', URL_REPLACE_INVIDIOUS_DEFAULT),
null,
'placeholder="https://yewtu.be"',
'placeholder="'.URL_REPLACE_INVIDIOUS_DEFAULT.'"',
],
'$proxigram_server_enabled' => [
toddy marked this conversation as resolved Outdated

Code standards: Please wrap operators with spaces.

Code standards: Please wrap operators with spaces.
Outdated
Review

Strange, I did run bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer for the file. However, I've seen that you've done some reformatting of my code as well in commit eeb783d71d -- I'm fine with that, but just out of curiosity: Could you please point me to the canonical configuration settings for PHP-CS-Fixer? I thought it's .php_cs.dist in the root directory, but when using that, my code does not get reformatted with spaces between operators.

Strange, I did run `bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer` for the file. However, I've seen that you've done some reformatting of my code as well in commit https://git.friendi.ca/friendica/friendica-addons/commit/eeb783d71d713df23038102048284c6b170634cb -- I'm fine with that, but just out of curiosity: Could you please point me to the canonical configuration settings for PHP-CS-Fixer? I thought it's `.php_cs.dist` in the root directory, but when using that, my code does not get reformatted with spaces between operators.

Sorry about that, we're following the PSR-12 coding standards: https://www.php-fig.org/psr/psr-12/#62-binary-operators

I don't use PHP CS Fixer myself so I'd be hard-pressed to verify the configuration is correct.

Sorry about that, we're following the PSR-12 coding standards: https://www.php-fig.org/psr/psr-12/#62-binary-operators I don't use PHP CS Fixer myself so I'd be hard-pressed to verify the configuration is correct.
'proxigram_server_enabled',
@ -94,9 +98,9 @@ function url_replace_addon_admin(string &$o)
'proxigram_server',
DI::l10n()->t('Proxigram server'),
$proxigram_server,
DI::l10n()->t('Specify the URL with protocol. The default is https://proxigram.lunar.icu.'),
DI::l10n()->t('Specify the URL with protocol. The default is %s.', URL_REPLACE_PROXIGRAM_DEFAULT),
null,
'placeholder="https://proxigram.lunar.icu"',
'placeholder="'.URL_REPLACE_PROXIGRAM_DEFAULT.'"',
],
'$twelvefeet_sites' => [
'twelvefeet_sites',
@ -119,7 +123,7 @@ function url_replace_render(array &$b)
$nitter_server = DI::config()->get('url_replace', 'nitter_server');
if (empty($nitter_server)) {
$nitter_server = 'https://nitter.net';
$nitter_server = URL_REPLACE_NITTER_DEFAULT;
}
$nitter_server_enabled = DI::config()->get('url_replace', 'nitter_server_enabled', true);
if ($nitter_server_enabled) {
@ -133,7 +137,7 @@ function url_replace_render(array &$b)
$invidious_server = DI::config()->get('url_replace', 'invidious_server');
if (empty($invidious_server)) {
$invidious_server = 'https://yewtu.be';
$invidious_server = URL_REPLACE_INVIDIOUS_DEFAULT;
}
$invidious_server_enabled = DI::config()->get('url_replace', 'invidious_server_enabled', true);
if ($invidious_server_enabled) {
@ -147,7 +151,7 @@ function url_replace_render(array &$b)
$proxigram_server = DI::config()->get('url_replace', 'proxigram_server');
if (empty($proxigram_server)) {
$proxigram_server = 'https://proxigram.lunar.icu';
$proxigram_server = URL_REPLACE_PROXIGRAM_DEFAULT;
}
$proxigram_server_enabled = DI::config()->get('url_replace', 'proxigram_server_enabled', true);
if ($proxigram_server_enabled) {