Skip to content

Commit 15b46cf

Browse files
authored
Merge pull request #1400 from nextcloud/feat/add-server-name-to-rss-feed
feat(rss): Add server name to the RSS feed title
2 parents d15e171 + c4065c9 commit 15b46cf

6 files changed

Lines changed: 42 additions & 7 deletions

File tree

lib/Controller/FeedController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use OCA\Activity\Data;
2626
use OCA\Activity\GroupHelper;
2727
use OCA\Activity\UserSettings;
28+
use OCA\Theming\ThemingDefaults;
2829
use OCP\Activity\IManager;
2930
use OCP\AppFramework\Controller;
3031
use OCP\AppFramework\Http\TemplateResponse;
@@ -48,7 +49,9 @@ public function __construct(
4849
protected IURLGenerator $urlGenerator,
4950
protected IManager $activityManager,
5051
protected IFactory $l10nFactory,
51-
protected IConfig $config) {
52+
protected IConfig $config,
53+
protected ThemingDefaults $themingDefaults,
54+
) {
5255
parent::__construct($appName, $request);
5356
}
5457

@@ -85,11 +88,13 @@ public function show() {
8588
];
8689
}
8790

91+
$title = $this->themingDefaults->getTitle();
8892
$response = new TemplateResponse('activity', 'rss', [
8993
'rssLang' => $this->l->getLanguageCode(),
9094
'rssLink' => $this->urlGenerator->linkToRouteAbsolute('activity.Feed.show'),
9195
'rssPubDate' => date('r'),
9296
'description' => $description,
97+
'title' => $title !== '' ? $this->l->t('Activity feed for %1$s', [$title]) : $this->l->t('Activity feed'),
9398
'activities' => $activities,
9499
], '');
95100

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@
5050
<file name="tests/stubs/oc_hooks_emitter.php" />
5151
<file name="tests/stubs/oca_files_event.php" preloadClasses="true"/>
5252
<file name="tests/stubs/oca_viewer_event.php" preloadClasses="true"/>
53+
<file name="tests/stubs/oca_theming_defaults.php" preloadClasses="true"/>
5354
</stubs>
5455
</psalm>

templates/rss.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
2727
<channel>
28-
<title><?php p($l->t('Activity feed')); ?></title>
28+
<title><?php p($_['title']); ?></title>
2929
<language><?php p($_['rssLang']); ?></language>
3030
<link><?php p($_['rssLink']); ?></link>
3131
<description><?php p($_['description']); ?></description>

tests/Controller/FeedControllerTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use OCA\Activity\GroupHelper;
3030
use OCA\Activity\Tests\TestCase;
3131
use OCA\Activity\UserSettings;
32+
use OCA\Theming\ThemingDefaults;
3233
use OCP\Activity\IManager;
3334
use OCP\AppFramework\Http\TemplateResponse;
3435
use OCP\IConfig;
@@ -64,6 +65,9 @@ class FeedControllerTest extends TestCase {
6465
/** @var \OCP\IL10N */
6566
protected $l10n;
6667

68+
/** @var ThemingDefaults|MockObject */
69+
protected $themingDefault;
70+
6771
/** @var FeedController */
6872
protected $controller;
6973

@@ -78,6 +82,7 @@ protected function setUp(): void {
7882
$this->request = $this->createMock(IRequest::class);
7983
$this->session = $this->createMock(IUserSession::class);
8084
$this->manager = $this->createMock(IManager::class);
85+
$this->themingDefault = $this->createMock(ThemingDefaults::class);
8186

8287
/** @var $urlGenerator IURLGenerator|MockObject */
8388
$urlGenerator = $this->createMock(IURLGenerator::class);
@@ -91,7 +96,8 @@ protected function setUp(): void {
9196
$urlGenerator,
9297
$this->manager,
9398
\OC::$server->getL10NFactory(),
94-
$this->config
99+
$this->config,
100+
$this->themingDefault,
95101
);
96102
}
97103

tests/Template/RssTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
class RssTest extends TestCase {
3131
public function dataEmpty(): array {
3232
return [
33-
['de', 'http://localhost', 'description', 'Fri, 28 Aug 2015 11:47:14 +0000'],
34-
['en', 'http://nextcloud.org', 'Desc', 'Fri, 28 Aug 2015 11:47:15 +0000'],
33+
['de', 'http://localhost', 'title', 'description', 'Fri, 28 Aug 2015 11:47:14 +0000'],
34+
['en', 'http://nextcloud.org', 'The title', 'Desc', 'Fri, 28 Aug 2015 11:47:15 +0000'],
3535
];
3636
}
3737

@@ -43,20 +43,21 @@ public function dataEmpty(): array {
4343
* @param string $description
4444
* @param string $timeDate
4545
*/
46-
public function testEmpty(string $language, string $link, string $description, string $timeDate): void {
46+
public function testEmpty(string $language, string $link, string $title, string $description, string $timeDate): void {
4747
$template = new TemplateResponse('activity', 'rss', [
4848
'rssLang' => $language,
4949
'rssLink' => $link,
5050
'rssPubDate' => $timeDate,
5151
'description' => $description,
52+
'title' => $title,
5253
'activities' => [],
5354
], '');
5455

5556
$this->assertSame(
5657
'<?xml version="1.0" encoding="UTF-8"?>'
5758
. "\n" . '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'
5859
. "\n" . ' <channel>'
59-
. "\n" . ' <title>Activity feed</title>'
60+
. "\n" . ' <title>' . $title . '</title>'
6061
. "\n" . ' <language>' . $language . '</language>'
6162
. "\n" . ' <link>' . $link . '</link>'
6263
. "\n" . ' <description>' . $description . '</description>'
@@ -118,6 +119,7 @@ public function testContent(array $activities, string $expected): void {
118119
'rssLink' => 'http://nextcloud.org',
119120
'rssPubDate' => 'Fri, 28 Aug 2015 11:47:15 +0000',
120121
'description' => 'Desc',
122+
'title' => 'Activity feed',
121123
'activities' => $activities,
122124
], '');
123125
$rendered = $template->render();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace OCA\Theming {
4+
interface ThemingDefaults {
5+
public function getName(): string;
6+
7+
public function getHTMLName(): string;
8+
9+
public function getTitle(): string;
10+
11+
public function getProductName(): string;
12+
13+
public function getBaseUrl(): string;
14+
15+
public function getSlogan(?string $lang = null): string;
16+
17+
public function getImprintUrl(): string;
18+
19+
public function getPrivacyUrl(): string;
20+
}
21+
}

0 commit comments

Comments
 (0)