Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create the RSS 2.0 feed #326

Merged
merged 15 commits into from
Jul 30, 2024
Merged

Create the RSS 2.0 feed #326

merged 15 commits into from
Jul 30, 2024

Conversation

amieiro
Copy link
Collaborator

@amieiro amieiro commented Jun 19, 2024

This PR adds:

  • A new class to generate an RSS 2.0 feed.
  • Two routes (/events/feed and /events/rss) to get the RSS feed.
  • A new method (get_current_and_upcoming_events) in the event repository to get all events that are currently active or happening in the future, in order by the start date.

The:

  • The pubDate element defines the last publication date for an item.
    • In the main file, the pubDate is the date of the last update of all events in the RSS file.
    • In the event (item), the pubDate is the last update of this event.
  • The lastBuildDate element defines the last-modified date of the content of the feed, so it is the same value that the pubDate in the main file.

I have used the http://purl.org/rss/1.0/modules/event/ namespace to be able to add the ev:startdate and ev:enddate elements to each event.

Date format:

  • The pubDate has the DATE_RSS format: 'D, d M Y H:i:s O'.
  • the ev:startdate and ev:enddate have the DateTimeInterface::ATOM format: 'Y-m-d\TH:i:sP'.

You can validate the RSS feed using the W3C Feed Validation Service, coping and pasting the generated content. You will get some warning like this, because the local URL is not accessible from this tool:

image

One example with the generated RSS feed:

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://purl.org/rss/1.0/modules/event/" version="2.0">
   <channel>
      <title>WordPress.org Global Translation Events</title>
      <link>https://glotpress.test/glotpress/events/</link>
      <description>WordPress.org Global Translation Events</description>
      <language>en-us</language>
      <pubDate>Sat, 29 Jun 2024 10:13:45 +0000</pubDate>
      <lastBuildDate>Sat, 29 Jun 2024 10:13:45 +0000</lastBuildDate>
      <docs>https://www.rssboard.org/rss-specification</docs>
      <generator>Translation Events</generator>
      <atom:link href="https://glotpress.test/glotpress/events/rss/" rel="self" type="application/rss+xml" />
      <item>
         <title>July event</title>
         <link>https://glotpress.test/glotpress/events/july-event__trashed/</link>
         <description>Lorem ipsum</description>
         <enclosure url="https://glotpress.test/glotpress/events/image/366/" type="image/png" length="1200" />
         <pubDate>Wed, 10 Apr 2024 23:26:18 +0000</pubDate>
         <ev:startdate>2024-07-01T12:01:00+00:00</ev:startdate>
         <ev:enddate>2024-08-01T11:59:00+00:00</ev:enddate>
         <guid>https://glotpress.test/glotpress/events/july-event__trashed/</guid>
      </item>
      <item>
         <title>August event</title>
         <link>https://glotpress.test/glotpress/events/august-event__trashed/</link>
         <description />
         <enclosure url="https://glotpress.test/glotpress/events/image/365/" type="image/png" length="1200" />
         <pubDate>Thu, 21 Mar 2024 12:17:19 +0000</pubDate>
         <ev:startdate>2024-07-31T22:00:00+00:00</ev:startdate>
         <ev:enddate>2024-08-31T01:09:09+00:00</ev:enddate>
         <guid>https://glotpress.test/glotpress/events/august-event__trashed/</guid>
      </item>
      <item>
         <title>September event</title>
         <link>https://glotpress.test/glotpress/events/september-event/</link>
         <description>Lorem ipsum</description>
         <enclosure url="https://glotpress.test/glotpress/events/image/532/" type="image/png" length="1200" />
         <pubDate>Thu, 09 May 2024 10:15:59 +0000</pubDate>
         <ev:startdate>2024-08-31T22:01:00+00:00</ev:startdate>
         <ev:enddate>2024-09-30T21:59:00+00:00</ev:enddate>
         <guid>https://glotpress.test/glotpress/events/september-event/</guid>
      </item>
   </channel>
</rss>

Fixes #217.

@amieiro amieiro marked this pull request as ready for review July 5, 2024 08:28
Copy link
Member

@psrpinto psrpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Change tabs to spaces in the RSS document, because the tabs were
raising some validation issues
@amieiro amieiro merged commit 5648277 into trunk Jul 30, 2024
3 checks passed
@amieiro amieiro deleted the rss-feed branch July 30, 2024 07:32
@akirk
Copy link
Member

akirk commented Jul 31, 2024

Could we add a <link rel="alternate" href=""> to expose this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants