From 6e2ab6c3af5f6f0d7c4b24afd7988082b38c6127 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 8 Jul 2023 21:01:48 -0400 Subject: [PATCH 1/4] Centralize Vary header declaration in ActivityPub::isRequest - Vary header should be set every time we vary the display based on an HTTP header value --- src/App.php | 3 +++ src/Module/ActivityPub/Objects.php | 2 -- src/Module/Friendica.php | 2 -- src/Module/Item/Display.php | 2 -- src/Module/Profile/Profile.php | 2 -- src/Module/Xrd.php | 2 ++ src/Protocol/ActivityPub.php | 2 ++ 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/App.php b/src/App.php index 8d253ec76..a48e21571 100644 --- a/src/App.php +++ b/src/App.php @@ -695,6 +695,9 @@ class App $module = $router->getModule(); } + // Display can change depending on the requested language, so it shouldn't be cached whole + header('Vary: Accept-Language', false); + // Processes data from GET requests $httpinput = $httpInput->process(); $input = array_merge($httpinput['variables'], $httpinput['files'], $request ?? $_REQUEST); diff --git a/src/Module/ActivityPub/Objects.php b/src/Module/ActivityPub/Objects.php index f93c8b957..34d460951 100644 --- a/src/Module/ActivityPub/Objects.php +++ b/src/Module/ActivityPub/Objects.php @@ -46,8 +46,6 @@ class Objects extends BaseModule throw new HTTPException\BadRequestException(); } - header('Vary: Accept', false); - if (!ActivityPub::isRequest()) { DI::baseUrl()->redirect(str_replace('objects/', 'display/', DI::args()->getQueryString())); } diff --git a/src/Module/Friendica.php b/src/Module/Friendica.php index 73d5f633c..90869878e 100644 --- a/src/Module/Friendica.php +++ b/src/Module/Friendica.php @@ -115,8 +115,6 @@ class Friendica extends BaseModule protected function rawContent(array $request = []) { - header('Vary: Accept', false); - // @TODO: Replace with parameter from router if (DI::args()->getArgc() <= 1 || (DI::args()->getArgv()[1] !== 'json')) { if (!ActivityPub::isRequest()) { diff --git a/src/Module/Item/Display.php b/src/Module/Item/Display.php index a0d1ecbf5..b2ed43c5b 100644 --- a/src/Module/Item/Display.php +++ b/src/Module/Item/Display.php @@ -88,8 +88,6 @@ class Display extends BaseModule protected function content(array $request = []): string { - header('Vary: Accept', false); - if (ActivityPub::isRequest()) { $this->baseUrl->redirect(str_replace('display/', 'objects/', $this->args->getQueryString())); } diff --git a/src/Module/Profile/Profile.php b/src/Module/Profile/Profile.php index 31ef8d05b..5e5028cb8 100644 --- a/src/Module/Profile/Profile.php +++ b/src/Module/Profile/Profile.php @@ -80,8 +80,6 @@ class Profile extends BaseProfile protected function rawContent(array $request = []) { - header('Vary: Accept', false); - if (ActivityPub::isRequest()) { $user = $this->database->selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname'] ?? '', 'account_removed' => false]); if ($user) { diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index 3267e9e9a..af40bc3b0 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -38,6 +38,8 @@ class Xrd extends BaseModule { protected function rawContent(array $request = []) { + header('Vary: Accept', false); + // @TODO: Replace with parameter from router if (DI::args()->getArgv()[0] == 'xrd') { if (empty($_GET['uri'])) { diff --git a/src/Protocol/ActivityPub.php b/src/Protocol/ActivityPub.php index eaf34669b..ad1e9367c 100644 --- a/src/Protocol/ActivityPub.php +++ b/src/Protocol/ActivityPub.php @@ -87,6 +87,8 @@ class ActivityPub */ public static function isRequest(): bool { + header('Vary: Accept', false); + $isrequest = stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') || stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/json') || stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/ld+json'); From 31a3c7cf50fc03092353efdc8fbcb7e7a88e9be0 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 8 Jul 2023 21:09:29 -0400 Subject: [PATCH 2/4] [frio] Add link to About page in user menu --- view/theme/frio/templates/nav.tpl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/view/theme/frio/templates/nav.tpl b/view/theme/frio/templates/nav.tpl index 88a8e4bf6..77077fdd9 100644 --- a/view/theme/frio/templates/nav.tpl +++ b/view/theme/frio/templates/nav.tpl @@ -274,8 +274,14 @@ {{/if}} + +
  • + + {{$nav.about.1}} + +
  • {{if $nav.tos}} -
  • {{/if}} + + + {{if $nav.logout}}