From d45cd932783d14b7a24bdf2f4753126723ae7906 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 12 Jan 2025 19:43:34 +0000 Subject: [PATCH 001/125] Improved performance on relation discovery --- src/Model/Contact/Relation.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Model/Contact/Relation.php b/src/Model/Contact/Relation.php index 5172d87c70..736c4361dd 100644 --- a/src/Model/Contact/Relation.php +++ b/src/Model/Contact/Relation.php @@ -10,6 +10,7 @@ namespace Friendica\Model\Contact; use Exception; use Friendica\Content\Widget; use Friendica\Core\Protocol; +use Friendica\Core\Worker; use Friendica\Database\Database; use Friendica\Database\DBA; use Friendica\DI; @@ -21,6 +22,7 @@ use Friendica\Model\Verb; use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityPub; use Friendica\Util\DateTimeFormat; +use Friendica\Util\Network; use Friendica\Util\Strings; /** @@ -162,20 +164,22 @@ class Relation $following_counter = 0; DI::logger()->info('Discover contacts', ['id' => $target, 'url' => $url, 'contacts' => count($contacts)]); - foreach ($contacts as $contact) { - $actor = Contact::getIdForURL($contact); - if (!empty($actor)) { - if (in_array($contact, $followers)) { - $fields = ['cid' => $target, 'relation-cid' => $actor, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()]; + foreach ($contacts as $contact_url) { + $contact = Contact::getByURL($contact_url, false, ['id']); + if (!empty($contact['id'])) { + if (in_array($contact_url, $followers)) { + $fields = ['cid' => $target, 'relation-cid' => $contact['id'], 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()]; DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE); $follower_counter++; } - if (in_array($contact, $followings)) { - $fields = ['cid' => $actor, 'relation-cid' => $target, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()]; + if (in_array($contact_url, $followings)) { + $fields = ['cid' => $contact['id'], 'relation-cid' => $target, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()]; DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE); $following_counter++; } + } elseif (!Network::isUrlBlocked($contact_url)) { + Worker::add(Worker::PRIORITY_LOW, 'AddContact', 0, $contact_url); } } From e5bf1b976ae07ce2a5bf26e86de96f56222db3ff Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 23 Jan 2025 21:42:11 +0000 Subject: [PATCH 002/125] New function "add" --- src/Model/Contact/Relation.php | 3 ++- src/Worker/AddContact.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Model/Contact/Relation.php b/src/Model/Contact/Relation.php index 736c4361dd..b5c6680f3e 100644 --- a/src/Model/Contact/Relation.php +++ b/src/Model/Contact/Relation.php @@ -24,6 +24,7 @@ use Friendica\Protocol\ActivityPub; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\Strings; +use Friendica\Worker\AddContact; /** * This class provides relationship information based on the `contact-relation` table. @@ -179,7 +180,7 @@ class Relation $following_counter++; } } elseif (!Network::isUrlBlocked($contact_url)) { - Worker::add(Worker::PRIORITY_LOW, 'AddContact', 0, $contact_url); + AddContact::add(Worker::PRIORITY_LOW, 0, $contact_url); } } diff --git a/src/Worker/AddContact.php b/src/Worker/AddContact.php index 3b27c7e78d..658a1ebcd1 100644 --- a/src/Worker/AddContact.php +++ b/src/Worker/AddContact.php @@ -7,10 +7,12 @@ namespace Friendica\Worker; +use Friendica\Core\Worker; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Network\HTTPException\NotFoundException; +use Friendica\Util\Network; class AddContact { @@ -39,4 +41,20 @@ class AddContact DI::logger()->notice('Imagick not found.', ['exception' => $e, 'uid' => $uid, 'url' => $url]); } } + + /** + * @param array|int $run_parameters Priority constant or array of options described in Worker::add + * @param int $uid User ID + * @param string $url Contact link + * @return int + */ + public static function add($run_parameters, int $uid, string $url): int + { + if (Network::isUrlBlocked($url)) { + return 0; + } + + DI::logger()->debug('Add contact', ['uid' => $uid, 'url' => $url]); + return Worker::add($run_parameters, 'AddContact', 0, $url); + } } From 80fe8f837e14b9d3fc5eb2ebe594ff86cb08a85b Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 24 Jan 2025 06:53:48 +0000 Subject: [PATCH 003/125] Unneeded check removed --- src/Model/Contact/Relation.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Model/Contact/Relation.php b/src/Model/Contact/Relation.php index b5c6680f3e..b32f8e964c 100644 --- a/src/Model/Contact/Relation.php +++ b/src/Model/Contact/Relation.php @@ -22,7 +22,6 @@ use Friendica\Model\Verb; use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityPub; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Worker\AddContact; @@ -179,7 +178,7 @@ class Relation DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE); $following_counter++; } - } elseif (!Network::isUrlBlocked($contact_url)) { + } else { AddContact::add(Worker::PRIORITY_LOW, 0, $contact_url); } } From 5cd6d9a0f1dcdc8c35ae128501fd60f0d0b4d65d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 25 Jan 2025 12:45:47 -0500 Subject: [PATCH 004/125] Remove test code from GroupManager::widget Oops. --- src/Content/GroupManager.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Content/GroupManager.php b/src/Content/GroupManager.php index a484ba73ce..4e364b9053 100644 --- a/src/Content/GroupManager.php +++ b/src/Content/GroupManager.php @@ -108,8 +108,6 @@ class GroupManager $entries = []; - $contacts = []; - foreach ($contacts as $contact) { $entry = [ 'url' => 'contact/' . $contact['id'] . '/conversations', From f3a160598f6b7b58914e8c18647cf96016797524 Mon Sep 17 00:00:00 2001 From: Marek Bachmann Date: Sat, 25 Jan 2025 22:40:23 +0000 Subject: [PATCH 005/125] Refactor view.tpl for admin/logs: Use class variable for log rows to eliminate whitespace from indentation in tr class attribute" --- view/theme/frio/templates/admin/logs/view.tpl | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/view/theme/frio/templates/admin/logs/view.tpl b/view/theme/frio/templates/admin/logs/view.tpl index 8f43a6b7e2..650cee9bc0 100644 --- a/view/theme/frio/templates/admin/logs/view.tpl +++ b/view/theme/frio/templates/admin/logs/view.tpl @@ -70,17 +70,17 @@ aria-label="{{$l10n.View_details}}" aria-haspopup="true" aria-expanded="false" data-data="{{$row->data}}" data-source="{{$row->source}}"> {{$row->date}} - level == "ALERT"}}bg-danger - {{elseif $row->level == "CRITICAL"}}bg-danger - {{elseif $row->level == "ERROR"}}bg-danger - {{elseif $row->level == "WARNING"}}bg-warning - {{elseif $row->level == "NOTICE"}}bg-info - {{elseif $row->level == "INFO"}}bg-info - {{else}}text-muted - {{/if}} - ">{{$row->level}} + {{assign var="class" value="bg-info"}} + {{if $row->level == "EMERGENCY" || $row->level == "ALERT" || $row->level == "CRITICAL" || $row->level == "ERROR"}} + {{assign var="class" value="bg-danger"}} + {{elseif $row->level == "WARNING"}} + {{assign var="class" value="bg-warning"}} + {{elseif $row->level == "NOTICE" || $row->level == "INFO"}} + {{assign var="class" value="bg-info"}} + {{else}} + {{ assign var="class" value="text-muted"}} + {{/if}} + {{$row->level}} {{$row->context}} {{$row->message}} From 2e472f84a77e9624aa95bcd31b57b00e9893f5c4 Mon Sep 17 00:00:00 2001 From: Marek Bachmann Date: Sat, 25 Jan 2025 22:53:42 +0000 Subject: [PATCH 006/125] Refactor view.tpl for admin/logs: Assign bootstrap.css bg and text classes dynamically for log rows --- view/theme/frio/templates/admin/logs/view.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/view/theme/frio/templates/admin/logs/view.tpl b/view/theme/frio/templates/admin/logs/view.tpl index 650cee9bc0..2e27ce025e 100644 --- a/view/theme/frio/templates/admin/logs/view.tpl +++ b/view/theme/frio/templates/admin/logs/view.tpl @@ -70,13 +70,13 @@ aria-label="{{$l10n.View_details}}" aria-haspopup="true" aria-expanded="false" data-data="{{$row->data}}" data-source="{{$row->source}}"> {{$row->date}} - {{assign var="class" value="bg-info"}} + {{assign var="class" value="bg-info text-info"}} {{if $row->level == "EMERGENCY" || $row->level == "ALERT" || $row->level == "CRITICAL" || $row->level == "ERROR"}} - {{assign var="class" value="bg-danger"}} + {{assign var="class" value="bg-danger text-danger"}} {{elseif $row->level == "WARNING"}} - {{assign var="class" value="bg-warning"}} + {{assign var="class" value="bg-warning text-warning"}} {{elseif $row->level == "NOTICE" || $row->level == "INFO"}} - {{assign var="class" value="bg-info"}} + {{assign var="class" value="bg-info text-info"}} {{else}} {{ assign var="class" value="text-muted"}} {{/if}} From dc0d0946109dca7ab7fb01d7a0a7c02db553f700 Mon Sep 17 00:00:00 2001 From: Marek Bachmann Date: Sat, 25 Jan 2025 23:07:17 +0000 Subject: [PATCH 007/125] Refactor view.tpl for admin/logs: Assign bootstrap.css text classes only (no bg adjustment) --- view/theme/frio/templates/admin/logs/view.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/view/theme/frio/templates/admin/logs/view.tpl b/view/theme/frio/templates/admin/logs/view.tpl index 2e27ce025e..ce0babdb04 100644 --- a/view/theme/frio/templates/admin/logs/view.tpl +++ b/view/theme/frio/templates/admin/logs/view.tpl @@ -70,13 +70,13 @@ aria-label="{{$l10n.View_details}}" aria-haspopup="true" aria-expanded="false" data-data="{{$row->data}}" data-source="{{$row->source}}"> {{$row->date}} - {{assign var="class" value="bg-info text-info"}} + {{assign var="class" value="text-info"}} {{if $row->level == "EMERGENCY" || $row->level == "ALERT" || $row->level == "CRITICAL" || $row->level == "ERROR"}} - {{assign var="class" value="bg-danger text-danger"}} + {{assign var="class" value="text-danger"}} {{elseif $row->level == "WARNING"}} - {{assign var="class" value="bg-warning text-warning"}} + {{assign var="class" value="text-warning"}} {{elseif $row->level == "NOTICE" || $row->level == "INFO"}} - {{assign var="class" value="bg-info text-info"}} + {{assign var="class" value="text-info"}} {{else}} {{ assign var="class" value="text-muted"}} {{/if}} From c978c8e02728e322d79b059d054c06aad098f83f Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 26 Jan 2025 12:35:26 +0000 Subject: [PATCH 008/125] Several accessibility improvements --- src/App/Page.php | 1 + src/Content/Text/BBCode.php | 4 ++-- src/Module/BaseProfile.php | 2 +- src/Module/Calendar/Show.php | 2 ++ src/Module/Contact.php | 4 ++-- src/Module/Conversation/Channel.php | 2 +- src/Module/Conversation/Community.php | 2 +- src/Module/Conversation/Network.php | 2 +- src/Module/Moderation/BaseUsers.php | 2 +- src/Object/Post.php | 3 +++ tests/src/Content/Text/BBCodeTest.php | 4 ++-- view/theme/frio/css/style.css | 9 +++++---- view/theme/frio/php/default.php | 2 +- view/theme/frio/php/minimal.php | 5 ++++- view/theme/frio/php/standard.php | 4 ++-- view/theme/frio/templates/calendar/calendar.tpl | 4 ++-- view/theme/frio/templates/common_tabs.tpl | 4 ++-- view/theme/frio/templates/footer.tpl | 2 +- view/theme/frio/templates/search_item.tpl | 6 +++--- view/theme/frio/templates/wall_thread.tpl | 16 ++++++++-------- 20 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/App/Page.php b/src/App/Page.php index 87493a67e4..ca83173184 100644 --- a/src/App/Page.php +++ b/src/App/Page.php @@ -356,6 +356,7 @@ class Page implements ArrayAccess $tpl = Renderer::getMarkupTemplate('footer.tpl'); $this->page['footer'] = Renderer::replaceMacros($tpl, [ '$footerScripts' => array_unique($this->footerScripts), + '$close' => $l10n->t('Close'), ]) . $this->page['footer']; } diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index f03dfa84be..2102b43a32 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1583,7 +1583,7 @@ class BBCode // Check for headers if ($simple_html == self::INTERNAL) { - //Ensure to always start with

if possible + //Ensure to always start with

if possible $heading_count = 0; for ($level = 6; $level > 0; $level--) { if (preg_match("(\[h$level\].*?\[\/h$level\])ism", $text)) { @@ -1591,7 +1591,7 @@ class BBCode } } if ($heading_count > 0) { - $heading = min($heading_count + 3, 6); + $heading = min($heading_count + 2, 6); for ($level = 6; $level > 0; $level--) { if (preg_match("(\[h$level\].*?\[\/h$level\])ism", $text)) { $text = preg_replace("(\[h$level\](.*?)\[\/h$level\])ism", "

$1

", $text); diff --git a/src/Module/BaseProfile.php b/src/Module/BaseProfile.php index 2fab793152..c034287469 100644 --- a/src/Module/BaseProfile.php +++ b/src/Module/BaseProfile.php @@ -134,6 +134,6 @@ class BaseProfile extends BaseModule $tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); - return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]); + return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs'], '$more' => DI::l10n()->t('More')]); } } diff --git a/src/Module/Calendar/Show.php b/src/Module/Calendar/Show.php index 0a55f7ada7..f808c9d50a 100644 --- a/src/Module/Calendar/Show.php +++ b/src/Module/Calendar/Show.php @@ -119,6 +119,8 @@ class Show extends BaseModule '$week' => $this->t('week'), '$day' => $this->t('day'), '$list' => $this->t('list'), + '$prev' => $this->t('prev'), + '$next' => $this->t('next'), ]); return $o; diff --git a/src/Module/Contact.php b/src/Module/Contact.php index b352648df7..e998160845 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -387,7 +387,7 @@ class Contact extends BaseModule ]; $tabs_tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); - $tabs_html = Renderer::replaceMacros($tabs_tpl, ['$tabs' => $tabs]); + $tabs_html = Renderer::replaceMacros($tabs_tpl, ['$tabs' => $tabs, '$more' => DI::l10n()->t('More')]); switch ($rel) { case 'followers': @@ -534,7 +534,7 @@ class Contact extends BaseModule } $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); - $tab_str = Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]); + $tab_str = Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs, '$more' => DI::l10n()->t('More')]); return $tab_str; } diff --git a/src/Module/Conversation/Channel.php b/src/Module/Conversation/Channel.php index b711a58f4e..4c060b65d7 100644 --- a/src/Module/Conversation/Channel.php +++ b/src/Module/Conversation/Channel.php @@ -95,7 +95,7 @@ class Channel extends Timeline $tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'channel')); $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); - $o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]); + $o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs, '$more' => $this->l10n->t('More')]); Nav::setSelected('channel'); diff --git a/src/Module/Conversation/Community.php b/src/Module/Conversation/Community.php index 375c86ee61..e3f75ddeaf 100644 --- a/src/Module/Conversation/Community.php +++ b/src/Module/Conversation/Community.php @@ -88,7 +88,7 @@ class Community extends Timeline if (!$this->raw) { $tabs = $this->getTabArray($this->community->getTimelines($this->session->isAuthenticated()), 'community'); $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); - $o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]); + $o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs, '$more' => $this->l10n->t('More')]); Nav::setSelected('community'); diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index bf8b0614a9..d94aeb6cde 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -292,7 +292,7 @@ class Network extends Timeline $tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); - return Renderer::replaceMacros($tpl, ['$tabs' => $tabs]); + return Renderer::replaceMacros($tpl, ['$tabs' => $tabs, '$more' => $this->l10n->t('More')]); } protected function parseRequest(array $request) diff --git a/src/Module/Moderation/BaseUsers.php b/src/Module/Moderation/BaseUsers.php index 0123ce5bc8..fcf4b4aa16 100644 --- a/src/Module/Moderation/BaseUsers.php +++ b/src/Module/Moderation/BaseUsers.php @@ -99,7 +99,7 @@ abstract class BaseUsers extends BaseModeration Hook::callAll('moderation_users_tabs', $tabs_arr); $tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); - return Renderer::replaceMacros($tpl, ['$tabs' => $tabs_arr['tabs']]); + return Renderer::replaceMacros($tpl, ['$tabs' => $tabs_arr['tabs'], '$more' => $this->t('More')]); } protected function setupUserCallback(): \Closure diff --git a/src/Object/Post.php b/src/Object/Post.php index aafe1b305b..363ad5e7a9 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -498,8 +498,10 @@ class Post } $languages = []; + $language = ''; if (!empty($item['language'])) { $languages = DI::l10n()->t('Languages'); + $language = array_key_first(json_decode($item['language'], true)); } if (in_array($item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($item['network'], Protocol::FEDERATED)) { @@ -579,6 +581,7 @@ class Post 'tagger' => $tagger, 'filer' => $filer, 'language' => $languages, + 'lang' => $language, 'searchtext' => DI::l10n()->t('Search Text'), 'drop' => $drop, 'block' => $block, diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index 6d6c610762..4757200000 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -248,11 +248,11 @@ Karl Marx - Die ursprüngliche Akkumulation 'text' => '[emoji=https://fedi.underscore.world/emoji/custom/custom/heart_nb.png]:heart_nb:[/emoji]', ], 'task-12900-multiple-paragraphs' => [ - 'expectedHTML' => '

Header

  • One
  • Two

This is a paragraph
with a line feed.

Second Chapter

', + 'expectedHTML' => '

Header

  • One
  • Two

This is a paragraph
with a line feed.

Second Chapter

', 'text' => "[h4]Header[/h4][ul][li]One[li]Two[/ul]\n\nThis is a paragraph\nwith a line feed.\n\nSecond Chapter", ], 'task-12900-header-with-paragraphs' => [ - 'expectedHTML' => '

Header

Some Chapter

', + 'expectedHTML' => '

Header

Some Chapter

', 'text' => '[h4]Header[/h4]Some Chapter', ], 'bug-12842-ul-newlines' => [ diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index ddcb9abef6..811f9afc4f 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -1806,7 +1806,8 @@ blockquote.shared_content { } /* wall items contact info */ -.media .media-body h4.media-heading { +.media .media-body h1.media-heading, +.media .media-body h2.media-heading { font-size: 14px; font-weight: 500; color: $font_color_darker; @@ -2604,7 +2605,7 @@ ul.viewcontact_wrapper > li { .contact-entry-checkbox { margin-top: -20px; } -.contact-wrapper .media-body .contact-entry-name h4.media-heading a { +.contact-wrapper .media-body .contact-entry-name h1.media-heading a { font-weight: bold !important; color: $link_color; font-size: 15px !important; @@ -2706,10 +2707,10 @@ ul li:hover .contact-wrapper .contact-action-link:hover { #circle-update-wrapper .shortmode .contact-entry-desc { font-size: 12px !important; } -#circle-update-wrapper .shortmode .contact-entry-desc h4.media-heading { +#circle-update-wrapper .shortmode .contact-entry-desc h1.media-heading { margin: 0; } -#circle-update-wrapper .shortmode .contact-entry-desc h4.media-heading a { +#circle-update-wrapper .shortmode .contact-entry-desc h1.media-heading a { font-size: 13px !important; white-space: nowrap; } diff --git a/view/theme/frio/php/default.php b/view/theme/frio/php/default.php index 0f79ca718e..a0d67b474f 100644 --- a/view/theme/frio/php/default.php +++ b/view/theme/frio/php/default.php @@ -67,7 +67,7 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser"; "> - t('Skip to main content'); ?> + t('Skip to main content'); ?> @@ -27,7 +30,7 @@