Skip to content

Commit

Permalink
EWPP-3696: Add atom:id element for RSS generation for list pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergepavle committed Nov 16, 2023
1 parent 2bfabb9 commit 75d648d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions oe_list_pages.module
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function oe_list_pages_theme($existing, $type, $theme, $path) {
'oe_list_pages_rss_item' => [
'variables' => [
'title' => '',
'id' => '',
'link' => '',
'guid' => '',
'item_description' => '',
Expand Down
1 change: 1 addition & 0 deletions src/Controller/ListPageRssController.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ protected function getItemList(NodeInterface $node, CacheableMetadata $cache_met
$result_item = [
'#theme' => 'oe_list_pages_rss_item',
'#title' => $entity->label(),
'#id' => $entity->toUrl('canonical', ['absolute' => TRUE, 'path_processing' => FALSE]),
'#link' => $entity->toUrl('canonical', ['absolute' => TRUE]),
'#guid' => $entity->toUrl('canonical', ['absolute' => TRUE]),
'#item_description' => (string) $description,
Expand Down
2 changes: 2 additions & 0 deletions templates/oe-list-pages-rss-item.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
* Available variables:
* - title: RSS item title.
* - id: RSS item id.
* - link: RSS item link.
* - guid: RSS item global unique identifier.
* - item_description: RSS body text.
Expand All @@ -13,6 +14,7 @@
#}
<item>
<title>{{ title }}</title>
<atom:id>{{ id }}</atom:id>
<link>{{ link }}</link>
<guid>{{ guid }}</guid>
<description>{{ item_description }}</description>
Expand Down
7 changes: 5 additions & 2 deletions tests/src/FunctionalJavascript/ListPageRssControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public function testListPageRssPage(): void {
$this->assertEquals(30, $items->count());
$first_item = $items->eq(0);
$this->assertEquals('that yellow fruit', $first_item->filterXpath('//title')->text());
$this->assertEquals('http://web:8080/build/node/2', $first_item->filterXpath('//atom:id')->text());
$this->assertEquals('&lt;p&gt;this is a banana&lt;/p&gt; ', $first_item->filterXpath('//description')->html());
$this->assertEquals('http://web:8080/build/node/2', $first_item->filterXpath('//link')->text());
$this->assertEquals('http://web:8080/build/node/2', $first_item->filterXpath('//guid')->text());
Expand All @@ -215,6 +216,7 @@ public function testListPageRssPage(): void {

$second_item = $items->eq(1);
$this->assertEquals('that red fruit', $second_item->filterXpath('//title')->text());
$this->assertEquals('http://web:8080/build/node/3', $second_item->filterXpath('//atom:id')->text());
$this->assertEquals('&lt;p&gt;this is a cherry&lt;/p&gt; ', $second_item->filterXpath('//description')->html());
$this->assertEquals('http://web:8080/build/node/3', $second_item->filterXpath('//link')->text());
$this->assertEquals('http://web:8080/build/node/3', $second_item->filterXpath('//guid')->text());
Expand Down Expand Up @@ -306,8 +308,9 @@ public function testListPageRssPage(): void {
$this->assertEquals('http://web:8080/build/es/node/1', $channel->filterXPath('//image/link')->text());
// Assert the date is not translated.
$items = $channel->filterXPath('//item');
$first_item = $items->eq(1);
$this->assertEquals('Thu, 20 Aug 2020 00:00:00 +1000', $first_item->filterXpath('//pubDate')->text());
$second_item = $items->eq(1);
$this->assertEquals('Thu, 20 Aug 2020 00:00:00 +1000', $second_item->filterXpath('//pubDate')->text());
$this->assertEquals('http://web:8080/build/node/3', $second_item->filterXpath('//atom:id')->text());
}

}

0 comments on commit 75d648d

Please sign in to comment.