Compare commits
28 commits
5478552040
...
872a438dcf
Author | SHA1 | Date | |
---|---|---|---|
Hypolite Petovan | 872a438dcf | ||
Hypolite Petovan | da8681c8c4 | ||
Hypolite Petovan | 67c44792fd | ||
cfbbeaac62 | |||
32f698ce10 | |||
a110b2f6c1 | |||
fc33555cd6 | |||
e24e3f758a | |||
127ab370fc | |||
890bc3712f | |||
2cff751b12 | |||
89134542b4 | |||
453772e393 | |||
0bcf2d7c89 | |||
c6daf2381c | |||
51797d975b | |||
a40bd7009b | |||
1bcd23f684 | |||
Hypolite Petovan | f3bddaf7d6 | ||
Michael | 4a14bc47ee | ||
Hypolite Petovan | 09b3f01558 | ||
Philipp Holzer | e1f27d88b7 | ||
Philipp Holzer | 57c4735ad6 | ||
Philipp Holzer | 372a850103 | ||
Philipp Holzer | 7e890124a8 | ||
Philipp Holzer | 904bf11e54 | ||
Tobias Diekershoff | 1af97e5c9e | ||
Michael | 02a6fdd9a2 |
|
@ -45,7 +45,7 @@ pipeline:
|
||||||
branch: [ develop, '*-rc' ]
|
branch: [ develop, '*-rc' ]
|
||||||
event: push
|
event: push
|
||||||
composer_install:
|
composer_install:
|
||||||
image: friendicaci/php7.4:php7.4.33
|
image: friendicaci/php8.2:php8.2.16
|
||||||
commands:
|
commands:
|
||||||
- export COMPOSER_HOME=.composer
|
- export COMPOSER_HOME=.composer
|
||||||
- composer validate
|
- composer validate
|
||||||
|
|
|
@ -5,9 +5,11 @@ matrix:
|
||||||
- PHP_MAJOR_VERSION: 8.0
|
- PHP_MAJOR_VERSION: 8.0
|
||||||
PHP_VERSION: 8.0.30
|
PHP_VERSION: 8.0.30
|
||||||
- PHP_MAJOR_VERSION: 8.1
|
- PHP_MAJOR_VERSION: 8.1
|
||||||
PHP_VERSION: 8.1.23
|
PHP_VERSION: 8.1.27
|
||||||
- PHP_MAJOR_VERSION: 8.2
|
- PHP_MAJOR_VERSION: 8.2
|
||||||
PHP_VERSION: 8.2.11
|
PHP_VERSION: 8.2.16
|
||||||
|
- PHP_MAJOR_VERSION: 8.3
|
||||||
|
PHP_VERSION: 8.3.3
|
||||||
|
|
||||||
# This forces PHP Unit executions at the "opensocial" labeled location (because of much more power...)
|
# This forces PHP Unit executions at the "opensocial" labeled location (because of much more power...)
|
||||||
labels:
|
labels:
|
||||||
|
@ -76,7 +78,7 @@ pipeline:
|
||||||
- cp config/local-sample.config.php config/local.config.php
|
- cp config/local-sample.config.php config/local.config.php
|
||||||
- if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
|
- if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
|
||||||
- mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
|
- mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
|
||||||
- if [ "${PHP_MAJOR_VERSION}" = "7.4" -a "${CI_REPO}" = "friendica/friendica-addons" ]; then
|
- if [ "${PHP_MAJOR_VERSION}" = "8.2" -a "${CI_REPO}" = "friendica/friendica-addons" ]; then
|
||||||
phpenmod xdebug;
|
phpenmod xdebug;
|
||||||
export XDEBUG_MODE=coverage;
|
export XDEBUG_MODE=coverage;
|
||||||
phpunit --configuration tests/phpunit-addons.xml --coverage-clover clover.xml;
|
phpunit --configuration tests/phpunit-addons.xml --coverage-clover clover.xml;
|
||||||
|
@ -87,8 +89,8 @@ pipeline:
|
||||||
image: friendicaci/codecov
|
image: friendicaci/codecov
|
||||||
when:
|
when:
|
||||||
matrix:
|
matrix:
|
||||||
PHP_MAJOR_VERSION: 7.4
|
PHP_MAJOR_VERSION: 8.2
|
||||||
PHP_VERSION: 7.4.33
|
PHP_VERSION: 8.2.16
|
||||||
repo:
|
repo:
|
||||||
- friendica/friendica-addons
|
- friendica/friendica-addons
|
||||||
commands:
|
commands:
|
||||||
|
|
|
@ -42,7 +42,7 @@ pipeline:
|
||||||
repo: friendica/friendica-addons
|
repo: friendica/friendica-addons
|
||||||
event: tag
|
event: tag
|
||||||
composer_install:
|
composer_install:
|
||||||
image: friendicaci/php7.4:php7.4.33
|
image: friendicaci/php8.2:php8.2.16
|
||||||
commands:
|
commands:
|
||||||
- export COMPOSER_HOME=.composer
|
- export COMPOSER_HOME=.composer
|
||||||
- composer validate
|
- composer validate
|
||||||
|
|
|
@ -61,7 +61,7 @@ function blockbot_init_1()
|
||||||
'adscanner/', 'HeadlessChrome', 'wpif', 'startmebot/', 'Googlebot/', 'Applebot/',
|
'adscanner/', 'HeadlessChrome', 'wpif', 'startmebot/', 'Googlebot/', 'Applebot/',
|
||||||
'GoogleImageProxy', 'bingbot/', 'heritrix/', 'ldspider',
|
'GoogleImageProxy', 'bingbot/', 'heritrix/', 'ldspider',
|
||||||
'AwarioRssBot/', 'TweetmemeBot/', 'dcrawl/', 'PhantomJS/', 'Googlebot-Image/',
|
'AwarioRssBot/', 'TweetmemeBot/', 'dcrawl/', 'PhantomJS/', 'Googlebot-Image/',
|
||||||
'CrowdTanglebot/', 'Mediapartners-Google', 'Baiduspider/', 'datagnionbot',
|
'CrowdTanglebot/', 'Mediapartners-Google', 'Baiduspider', 'datagnionbot',
|
||||||
'MegaIndex.ru/', 'SMUrlExpander', 'Hatena-Favicon/', 'Wappalyzer', 'FlipboardProxy/',
|
'MegaIndex.ru/', 'SMUrlExpander', 'Hatena-Favicon/', 'Wappalyzer', 'FlipboardProxy/',
|
||||||
'NetcraftSurveyAgent/', 'Dataprovider.com', 'SMTBot/', 'Nimbostratus-Bot/',
|
'NetcraftSurveyAgent/', 'Dataprovider.com', 'SMTBot/', 'Nimbostratus-Bot/',
|
||||||
'DuckDuckGo-Favicons-Bot/', 'IndieWebCards/', 'proximic', 'netEstate NE Crawler',
|
'DuckDuckGo-Favicons-Bot/', 'IndieWebCards/', 'proximic', 'netEstate NE Crawler',
|
||||||
|
@ -83,7 +83,11 @@ function blockbot_init_1()
|
||||||
'BitSightBot/', 'ev-crawler/', 'CensysInspect/1.1', 'Protopage/', 'Gaisbot/', 'WellKnownBot/',
|
'BitSightBot/', 'ev-crawler/', 'CensysInspect/1.1', 'Protopage/', 'Gaisbot/', 'WellKnownBot/',
|
||||||
'SuperBot/', 'Googlebot-Mobile/', 'GPTBot/', 'GenomeCrawlerd/', '2ip bot/', 'Ocarinabot',
|
'SuperBot/', 'Googlebot-Mobile/', 'GPTBot/', 'GenomeCrawlerd/', '2ip bot/', 'Ocarinabot',
|
||||||
'Yahoo! Slurp;', 'AdsBot-Google', 'Gregarius/', 'FAST-WebCrawler/', 'Xenu Link Sleuth/',
|
'Yahoo! Slurp;', 'AdsBot-Google', 'Gregarius/', 'FAST-WebCrawler/', 'Xenu Link Sleuth/',
|
||||||
'Ask Jeeves'
|
'Ask Jeeves', 'alexa site audit/', 'Yahoo! Slurp China;', 'Microsoft URL Control',
|
||||||
|
'Facebot', 'Googlebot-Video/', 'msnbot/', 'Offline Explorer/', 'YandexNews/', 'msnbot-media/',
|
||||||
|
'EmailWolf', 'Download Demon/', 'FeedFetcher-Google;', 'WebCopier', '+ONB_Bot_Btrix',
|
||||||
|
'scoopit-crawler/', 'ia_archiver', 'Quora-Bot/', 'WebwikiBot/', 'FullStoryBot/',
|
||||||
|
'wpbot/', 'SearchExpress', 'DuckDuckBot/', 'Google Web Preview',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (DI::config()->get('blockbot', 'block_gab')) {
|
if (DI::config()->get('blockbot', 'block_gab')) {
|
||||||
|
@ -97,7 +101,8 @@ function blockbot_init_1()
|
||||||
'PTST/', 'Zabbix', 'Poduptime/', 'FediFetcher', 'lemmy-stats-crawler',
|
'PTST/', 'Zabbix', 'Poduptime/', 'FediFetcher', 'lemmy-stats-crawler',
|
||||||
'FedditLemmyverseCrawler/', 'lemmy-explorer-crawler/', 'URIports Validator',
|
'FedditLemmyverseCrawler/', 'lemmy-explorer-crawler/', 'URIports Validator',
|
||||||
'rss-is-dead.lol web bot;', 'fedistatsCrawler/', 'W3C_CSS_Validator_JFouffa/',
|
'rss-is-dead.lol web bot;', 'fedistatsCrawler/', 'W3C_CSS_Validator_JFouffa/',
|
||||||
'IABot/', 'Slackbot 1',
|
'IABot/', 'Slackbot 1', 'BeeperBot/', 'Matrix-Media-Repo/', 'P3P Validator',
|
||||||
|
'KeybaseBot;',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!DI::config()->get('blockbot', 'good_crawlers')) {
|
if (!DI::config()->get('blockbot', 'good_crawlers')) {
|
||||||
|
@ -110,7 +115,7 @@ function blockbot_init_1()
|
||||||
$socialmedia_agents = ['Twitterbot', 'facebookexternalhit/', 'SkypeUriPreview Preview/',
|
$socialmedia_agents = ['Twitterbot', 'facebookexternalhit/', 'SkypeUriPreview Preview/',
|
||||||
'TelegramBot', 'WhatsApp/', 'github-camo', 'Bluesky Cardyb/', 'XING-contenttabreceiver/',
|
'TelegramBot', 'WhatsApp/', 'github-camo', 'Bluesky Cardyb/', 'XING-contenttabreceiver/',
|
||||||
'LinkedInBot/', 'Instagram ', 'Synapse (bot; ', 'Discordbot/', 'SummalyBot/',
|
'LinkedInBot/', 'Instagram ', 'Synapse (bot; ', 'Discordbot/', 'SummalyBot/',
|
||||||
'Slackbot-LinkExpanding', 'Slack-ImgProxy',
|
'Slackbot-LinkExpanding', 'Slack-ImgProxy', 'Iframely/',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!DI::config()->get('blockbot', 'socialmedia_agents')) {
|
if (!DI::config()->get('blockbot', 'socialmedia_agents')) {
|
||||||
|
@ -159,7 +164,7 @@ function blockbot_init_1()
|
||||||
'Slackbot-LinkExpanding', 'Firefish/', 'Takahe/', 'Akkoma ', 'Misskey/', 'Lynx/',
|
'Slackbot-LinkExpanding', 'Firefish/', 'Takahe/', 'Akkoma ', 'Misskey/', 'Lynx/',
|
||||||
'camo-rs asset proxy', 'gotosocial/', 'incestoma ', 'SpaceCowboys Android RSS Reader',
|
'camo-rs asset proxy', 'gotosocial/', 'incestoma ', 'SpaceCowboys Android RSS Reader',
|
||||||
'NewsBlur Feed Finder', 'Lemmy/', 'enby-town/', 'rss2tg bot;', '; HTTrack ',
|
'NewsBlur Feed Finder', 'Lemmy/', 'enby-town/', 'rss2tg bot;', '; HTTrack ',
|
||||||
'MbinBot', 'kbinBot'
|
'MbinBot', 'kbinBot', 'Pixelfed/', 'NewsBlur Feed Fetcher', 'NewsBlur Page Fetcher',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (blockbot_match($agents)) {
|
if (blockbot_match($agents)) {
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
* Version: 0.3
|
* Version: 0.3
|
||||||
* Author: Matthias Ebers <https://loma.ml/profile/feb>
|
* Author: Matthias Ebers <https://loma.ml/profile/feb>
|
||||||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||||
*
|
* Status: Unsupported
|
||||||
|
* Note: Please use the URL Replace addon instead
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
* Description: Replaces links to twitter.com to a nitter server in all displays of postings on a node.
|
* Description: Replaces links to twitter.com to a nitter server in all displays of postings on a node.
|
||||||
* Version: 2.0
|
* Version: 2.0
|
||||||
* Author: Tobias Diekershoff <tobias@social.diekershoff.de>
|
* Author: Tobias Diekershoff <tobias@social.diekershoff.de>
|
||||||
|
* Status: Unsupported
|
||||||
|
* Note: Please use the URL Replace addon instead
|
||||||
*
|
*
|
||||||
* Copyright (c) 2020 Tobias Diekershoff
|
* Copyright (c) 2020 Tobias Diekershoff
|
||||||
*
|
*
|
||||||
|
|
|
@ -4,7 +4,8 @@ This addon will replace all occurrences of specified URLs with the address of
|
||||||
alternative servers in all displayed postings on a Friendica node.
|
alternative servers in all displayed postings on a Friendica node.
|
||||||
|
|
||||||
You can use this to switch from Twitter (or X) to a nitter instance, from
|
You can use this to switch from Twitter (or X) to a nitter instance, from
|
||||||
YouTube to an invidious instance, or from some news sites to 12ft.io.
|
YouTube to an invidious instance, from Instagram to a proxigram instance,
|
||||||
|
or from some news sites to 12ft.io.
|
||||||
|
|
||||||
Note: If you are using the twitter connector on your server, the links to the
|
Note: If you are using the twitter connector on your server, the links to the
|
||||||
contacts profile pages will not be replaced by this addon. Only links in the
|
contacts profile pages will not be replaced by this addon. Only links in the
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2024-01-05 00:06+0100\n"
|
"POT-Creation-Date: 2024-03-14 09:05+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -17,34 +17,48 @@ msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#: url_replace.php:54
|
#: url_replace.php:68
|
||||||
|
msgid "Replace links to X."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: url_replace.php:73
|
||||||
msgid "Nitter server"
|
msgid "Nitter server"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: url_replace.php:56
|
#: url_replace.php:75 url_replace.php:88 url_replace.php:101
|
||||||
msgid "Specify the URL with protocol. The default is https://nitter.net."
|
#, php-format
|
||||||
|
msgid "Specify the URL with protocol. The default is %s."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: url_replace.php:62
|
#: url_replace.php:81
|
||||||
|
msgid "Replace links to YouTube."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: url_replace.php:86
|
||||||
msgid "Invidious server"
|
msgid "Invidious server"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: url_replace.php:64
|
#: url_replace.php:94
|
||||||
msgid "Specify the URL with protocol. The default is https://yewtu.be."
|
msgid "Replace links to Instagram."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: url_replace.php:70
|
#: url_replace.php:99
|
||||||
|
msgid "Proxigram server"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: url_replace.php:107
|
||||||
msgid "Sites which are accessed through 12ft.io"
|
msgid "Sites which are accessed through 12ft.io"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: url_replace.php:72
|
#: url_replace.php:109
|
||||||
msgid "Specify the URLs with protocol, one per line."
|
msgid "Specify the URLs with protocol, one per line."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: url_replace.php:76
|
#: url_replace.php:113
|
||||||
msgid "Save settings"
|
msgid "Save settings"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: url_replace.php:125
|
#: url_replace.php:179
|
||||||
msgid "(URL replace addon enabled for X, YouTube and some news sites.)"
|
msgid ""
|
||||||
|
"(URL replace addon enabled for X, YouTube, Instagram and some news sites.)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
|
{{include file="field_checkbox.tpl" field=$nitter_server_enabled}}
|
||||||
{{include file="field_input.tpl" field=$nitter_server}}
|
{{include file="field_input.tpl" field=$nitter_server}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$invidious_server_enabled}}
|
||||||
{{include file="field_input.tpl" field=$invidious_server}}
|
{{include file="field_input.tpl" field=$invidious_server}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$proxigram_server_enabled}}
|
||||||
|
{{include file="field_input.tpl" field=$proxigram_server}}
|
||||||
{{include file="field_textarea.tpl" field=$twelvefeet_sites}}
|
{{include file="field_textarea.tpl" field=$twelvefeet_sites}}
|
||||||
|
|
||||||
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
|
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* Name: URL Replace
|
* Name: URL Replace
|
||||||
* Description: Replaces occurrences of specified URLs with the address of alternative servers in all displays of postings on a node.
|
* Description: Replaces occurrences of specified URLs with the address of alternative servers in all displays of postings on a node.
|
||||||
* Version: 1.0
|
* Version: 1.1
|
||||||
* Author: Dr. Tobias Quathamer <https://social.anoxinon.de/@toddy>
|
* Author: Dr. Tobias Quathamer <https://social.anoxinon.de/@toddy>
|
||||||
* Maintainer: Dr. Tobias Quathamer <https://social.anoxinon.de/@toddy>
|
* Maintainer: Dr. Tobias Quathamer <https://social.anoxinon.de/@toddy>
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,10 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
const URL_REPLACE_NITTER_DEFAULT = 'https://nitter.net';
|
||||||
|
const URL_REPLACE_INVIDIOUS_DEFAULT = 'https://invidio.us';
|
||||||
|
const URL_REPLACE_PROXIGRAM_DEFAULT = 'https://proxigram.lunar.icu';
|
||||||
|
|
||||||
function url_replace_install()
|
function url_replace_install()
|
||||||
{
|
{
|
||||||
Hook::register('prepare_body_final', 'addon/url_replace/url_replace.php', 'url_replace_render');
|
Hook::register('prepare_body_final', 'addon/url_replace/url_replace.php', 'url_replace_render');
|
||||||
|
@ -21,18 +25,37 @@ function url_replace_install()
|
||||||
*/
|
*/
|
||||||
function url_replace_addon_admin_post()
|
function url_replace_addon_admin_post()
|
||||||
{
|
{
|
||||||
DI::config()->set('url_replace', 'nitter_server', rtrim(trim($_POST['nitter_server']), '/'));
|
DI::config()->set('url_replace', 'nitter_server_enabled', !empty($_POST['nitter_server_enabled']));
|
||||||
DI::config()->set('url_replace', 'invidious_server', rtrim(trim($_POST['invidious_server']), '/'));
|
$nitter_server = rtrim(trim($_POST['nitter_server']), '/');
|
||||||
|
if ($nitter_server) {
|
||||||
|
DI::config()->set('url_replace', 'nitter_server', $nitter_server);
|
||||||
|
} else {
|
||||||
|
DI::config()->delete('url_replace', 'nitter_server');
|
||||||
|
}
|
||||||
|
DI::config()->set('url_replace', 'invidious_server_enabled', !empty($_POST['invidious_server_enabled']));
|
||||||
|
$invidious_server = rtrim(trim($_POST['invidious_server']), '/');
|
||||||
|
if ($invidious_server) {
|
||||||
|
DI::config()->set('url_replace', 'invidious_server', $invidious_server);
|
||||||
|
} else {
|
||||||
|
DI::config()->delete('url_replace', 'invidious_server');
|
||||||
|
}
|
||||||
|
DI::config()->set('url_replace', 'proxigram_server_enabled', !empty($_POST['proxigram_server_enabled']));
|
||||||
|
$proxigram_server = rtrim(trim($_POST['proxigram_server']), '/');
|
||||||
|
if ($proxigram_server) {
|
||||||
|
DI::config()->set('url_replace', 'proxigram_server', $proxigram_server);
|
||||||
|
} else {
|
||||||
|
DI::config()->delete('url_replace', 'proxigram_server');
|
||||||
|
}
|
||||||
// Convert twelvefeet_sites into an array before setting the new value
|
// Convert twelvefeet_sites into an array before setting the new value
|
||||||
$twelvefeet_sites = explode(PHP_EOL, $_POST['twelvefeet_sites']);
|
$twelvefeet_sites = explode(PHP_EOL, $_POST['twelvefeet_sites']);
|
||||||
// Normalize URLs by using lower case, removing a trailing slash and whitespace
|
// Normalize URLs by using lower case, removing a trailing slash and whitespace
|
||||||
$twelvefeet_sites = array_map(fn($value): string => rtrim(trim(strtolower($value)), '/'), $twelvefeet_sites);
|
$twelvefeet_sites = array_map(fn ($value): string => rtrim(trim(strtolower($value)), '/'), $twelvefeet_sites);
|
||||||
// Do not store empty lines or duplicates
|
// Do not store empty lines or duplicates
|
||||||
$twelvefeet_sites = array_filter($twelvefeet_sites, fn($value): bool => !empty($value));
|
$twelvefeet_sites = array_filter($twelvefeet_sites, fn ($value): bool => !empty($value));
|
||||||
$twelvefeet_sites = array_unique($twelvefeet_sites);
|
$twelvefeet_sites = array_unique($twelvefeet_sites);
|
||||||
// Ensure a protocol and default to HTTPS
|
// Ensure a protocol and default to HTTPS
|
||||||
$twelvefeet_sites = array_map(
|
$twelvefeet_sites = array_map(
|
||||||
fn($value): string => substr($value, 0, 4) !== 'http' ? 'https://' . $value : $value,
|
fn ($value): string => substr($value, 0, 4) !== 'http' ? 'https://' . $value : $value,
|
||||||
$twelvefeet_sites
|
$twelvefeet_sites
|
||||||
);
|
);
|
||||||
asort($twelvefeet_sites);
|
asort($twelvefeet_sites);
|
||||||
|
@ -41,31 +64,58 @@ function url_replace_addon_admin_post()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook into admin settings to enable choosing a different server
|
* Hook into admin settings to enable choosing a different server
|
||||||
* for twitter, youtube, and news sites.
|
* for Twitter, YouTube, Instagram, and news sites.
|
||||||
*/
|
*/
|
||||||
function url_replace_addon_admin(string &$o)
|
function url_replace_addon_admin(string &$o)
|
||||||
{
|
{
|
||||||
$nitter_server = DI::config()->get('url_replace', 'nitter_server');
|
$nitter_server_enabled = DI::config()->get('url_replace', 'nitter_server_enabled') ?? true;
|
||||||
$invidious_server = DI::config()->get('url_replace', 'invidious_server');
|
$nitter_server = DI::config()->get('url_replace', 'nitter_server') ?? '';
|
||||||
$twelvefeet_sites = implode(PHP_EOL, DI::config()->get('url_replace', 'twelvefeet_sites') ?? [] ?: []);
|
$invidious_server_enabled = DI::config()->get('url_replace', 'invidious_server_enabled') ?? true;
|
||||||
|
$invidious_server = DI::config()->get('url_replace', 'invidious_server') ?? '';
|
||||||
|
$proxigram_server_enabled = DI::config()->get('url_replace', 'proxigram_server_enabled') ?? true;
|
||||||
|
$proxigram_server = DI::config()->get('url_replace', 'proxigram_server') ?? '';
|
||||||
|
$twelvefeet_sites = implode(PHP_EOL, DI::config()->get('url_replace', 'twelvefeet_sites') ?? []);
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/url_replace/');
|
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/url_replace/');
|
||||||
$o = Renderer::replaceMacros($t, [
|
$o = Renderer::replaceMacros($t, [
|
||||||
|
'$nitter_server_enabled' => [
|
||||||
|
'nitter_server_enabled',
|
||||||
|
DI::l10n()->t('Replace links to X.'),
|
||||||
|
$nitter_server_enabled,
|
||||||
|
],
|
||||||
'$nitter_server' => [
|
'$nitter_server' => [
|
||||||
'nitter_server',
|
'nitter_server',
|
||||||
DI::l10n()->t('Nitter server'),
|
DI::l10n()->t('Nitter server'),
|
||||||
$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,
|
null,
|
||||||
'placeholder="https://nitter.net"',
|
'placeholder="' . URL_REPLACE_NITTER_DEFAULT . '"',
|
||||||
|
],
|
||||||
|
'$invidious_server_enabled' => [
|
||||||
|
'invidious_server_enabled',
|
||||||
|
DI::l10n()->t('Replace links to YouTube.'),
|
||||||
|
$invidious_server_enabled,
|
||||||
],
|
],
|
||||||
'$invidious_server' => [
|
'$invidious_server' => [
|
||||||
'invidious_server',
|
'invidious_server',
|
||||||
DI::l10n()->t('Invidious server'),
|
DI::l10n()->t('Invidious server'),
|
||||||
$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,
|
null,
|
||||||
'placeholder="https://yewtu.be"',
|
'placeholder="' . URL_REPLACE_INVIDIOUS_DEFAULT . '"',
|
||||||
|
],
|
||||||
|
'$proxigram_server_enabled' => [
|
||||||
|
'proxigram_server_enabled',
|
||||||
|
DI::l10n()->t('Replace links to Instagram.'),
|
||||||
|
$proxigram_server_enabled,
|
||||||
|
],
|
||||||
|
'$proxigram_server' => [
|
||||||
|
'proxigram_server',
|
||||||
|
DI::l10n()->t('Proxigram server'),
|
||||||
|
$proxigram_server,
|
||||||
|
DI::l10n()->t('Specify the URL with protocol. The default is %s.', URL_REPLACE_PROXIGRAM_DEFAULT),
|
||||||
|
null,
|
||||||
|
'placeholder="' . URL_REPLACE_PROXIGRAM_DEFAULT . '"',
|
||||||
],
|
],
|
||||||
'$twelvefeet_sites' => [
|
'$twelvefeet_sites' => [
|
||||||
'twelvefeet_sites',
|
'twelvefeet_sites',
|
||||||
|
@ -84,29 +134,41 @@ function url_replace_addon_admin(string &$o)
|
||||||
*/
|
*/
|
||||||
function url_replace_render(array &$b)
|
function url_replace_render(array &$b)
|
||||||
{
|
{
|
||||||
$replaced = false;
|
$replaced = false;
|
||||||
|
$replacements = [];
|
||||||
|
|
||||||
$nitter_server = DI::config()->get('url_replace', 'nitter_server');
|
$nitter_server = DI::config()->get('url_replace', 'nitter_server') ?? URL_REPLACE_NITTER_DEFAULT;
|
||||||
if (empty($nitter_server)) {
|
$nitter_server_enabled = DI::config()->get('url_replace', 'nitter_server_enabled') ?? true;
|
||||||
$nitter_server = 'https://nitter.net';
|
if ($nitter_server_enabled) {
|
||||||
|
$replacements = array_merge($replacements, [
|
||||||
|
'https://mobile.twitter.com' => $nitter_server,
|
||||||
|
'https://twitter.com' => $nitter_server,
|
||||||
|
'https://mobile.x.com' => $nitter_server,
|
||||||
|
'https://x.com' => $nitter_server,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$invidious_server = DI::config()->get('url_replace', 'invidious_server');
|
$invidious_server = DI::config()->get('url_replace', 'invidious_server') ?? URL_REPLACE_INVIDIOUS_DEFAULT;
|
||||||
if (empty($invidious_server)) {
|
$invidious_server_enabled = DI::config()->get('url_replace', 'invidious_server_enabled') ?? true;
|
||||||
$invidious_server = 'https://yewtu.be';
|
if ($invidious_server_enabled) {
|
||||||
|
$replacements = array_merge($replacements, [
|
||||||
|
'https://www.youtube.com' => $invidious_server,
|
||||||
|
'https://youtube.com' => $invidious_server,
|
||||||
|
'https://m.youtube.com' => $invidious_server,
|
||||||
|
'https://youtu.be' => $invidious_server,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$proxigram_server = DI::config()->get('url_replace', 'proxigram_server') ?? URL_REPLACE_PROXIGRAM_DEFAULT;
|
||||||
|
$proxigram_server_enabled = DI::config()->get('url_replace', 'proxigram_server_enabled') ?? true;
|
||||||
|
if ($proxigram_server_enabled) {
|
||||||
|
$replacements = array_merge($replacements, [
|
||||||
|
'https://www.instagram.com' => $proxigram_server,
|
||||||
|
'https://instagram.com' => $proxigram_server,
|
||||||
|
'https://ig.me' => $proxigram_server,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle some of twitter and youtube
|
|
||||||
$replacements = [
|
|
||||||
'https://mobile.twitter.com' => $nitter_server,
|
|
||||||
'https://twitter.com' => $nitter_server,
|
|
||||||
'https://mobile.x.com' => $nitter_server,
|
|
||||||
'https://x.com' => $nitter_server,
|
|
||||||
'https://www.youtube.com' => $invidious_server,
|
|
||||||
'https://youtube.com' => $invidious_server,
|
|
||||||
'https://m.youtube.com' => $invidious_server,
|
|
||||||
'https://youtu.be' => $invidious_server,
|
|
||||||
];
|
|
||||||
foreach ($replacements as $server => $replacement) {
|
foreach ($replacements as $server => $replacement) {
|
||||||
if (strpos($b['html'], $server) !== false) {
|
if (strpos($b['html'], $server) !== false) {
|
||||||
$b['html'] = str_replace($server, $replacement, $b['html']);
|
$b['html'] = str_replace($server, $replacement, $b['html']);
|
||||||
|
@ -114,7 +176,7 @@ function url_replace_render(array &$b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$twelvefeet_sites = DI::config()->get('url_replace', 'twelvefeet_sites') ?? [] ?: [];
|
$twelvefeet_sites = DI::config()->get('url_replace', 'twelvefeet_sites') ?? [];
|
||||||
foreach ($twelvefeet_sites as $twelvefeet_site) {
|
foreach ($twelvefeet_sites as $twelvefeet_site) {
|
||||||
if (strpos($b['html'], $twelvefeet_site) !== false) {
|
if (strpos($b['html'], $twelvefeet_site) !== false) {
|
||||||
$b['html'] = str_replace($twelvefeet_site, 'https://12ft.io/' . $twelvefeet_site, $b['html']);
|
$b['html'] = str_replace($twelvefeet_site, 'https://12ft.io/' . $twelvefeet_site, $b['html']);
|
||||||
|
@ -122,8 +184,7 @@ function url_replace_render(array &$b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($replaced) {
|
if ($replaced) {
|
||||||
$b['html'] .= '<hr><p><small>' . DI::l10n()->t('(URL replace addon enabled for X, YouTube and some news sites.)') . '</small></p>';
|
$b['html'] .= '<hr><p><small>' . DI::l10n()->t('(URL replace addon enabled for X, YouTube, Instagram and some news sites.)') . '</small></p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue