forked from mozilla/releases_insights
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an RSS feed to the app but don't expose it yet in the html
- Loading branch information
1 parent
f7f3ef0
commit f304948
Showing
7 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use ReleaseInsights\{Model, Template}; | ||
|
||
[$latest_release_date, $releases] = (new Model('rss'))->get(); | ||
|
||
header("Content-Type: application/xml; charset=UTF-8"); | ||
|
||
(new Template( | ||
'releases.rss.twig', | ||
[ | ||
'title' => 'Firefox Desktop and Android releases', | ||
'description' => 'Release dates for Firefox Desktop and Android. Includes major and minor releases.', | ||
'site_link' => 'https://whattrainisitnow.com', | ||
'latest_release_date' => $latest_release_date, | ||
'releases' => $releases, | ||
] | ||
))->render(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use ReleaseInsights\Data; | ||
|
||
$data = new Data(); | ||
|
||
// We reformat the data to the same format as getDotReleases() before merging them | ||
$major_releases = []; | ||
foreach ($data->getMajorPastReleases() as $version => $date) { | ||
$major_releases[$version] = [ | ||
'date' => $date, | ||
'platform' => 'both', | ||
]; | ||
} | ||
|
||
// We merge and reorder the releases to have the latest first | ||
$releases = array_merge($major_releases, $data->getDotReleases()); | ||
krsort($releases, SORT_NATURAL); | ||
|
||
// Limit our RSS feed to 30 items, roughly a year of releases | ||
$releases = array_slice($releases, 0, 30); | ||
|
||
$rss = []; | ||
foreach ($releases as $key => $values) { | ||
$rss[] = [ | ||
'date' => (new DateTime($values['date']))->setTime(13, 0)->format(DateTime::RFC822), | ||
'version' => $key, | ||
'platform' => $values['platform'], | ||
'relnotes' => 'https://www.mozilla.org/en-US/firefox/' . $key . '/releasenotes/', | ||
]; | ||
} | ||
|
||
// We take the last update to the feed as the first item (latest release) in the sorted array | ||
$latest_release_date = (new DateTime(reset($releases)['date']))->setTime(13,0)->format(DateTime::RFC822); | ||
|
||
return [$latest_release_date, $rss]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<rss version="2.0"> | ||
<channel> | ||
<title>{{ title }}</title> | ||
<description>{{ description }}</description> | ||
<link>{{ site_link }}</link> | ||
<language>en-US</language> | ||
<lastBuildDate>{{ latest_release_date }}</lastBuildDate> | ||
<ttl>1440</ttl> | ||
{% for release in releases %} | ||
<item> | ||
<title>Firefox {{ release.version }}</title> | ||
<description> | ||
Firefox release {{ release.version }} shipped on {{ release.date|format_date(pattern='MMMM d, YYYY', locale='en') }} | ||
{% if release.platform == 'android' %}<br>This is an Android-only release{% endif %} | ||
{% if release.platform == 'desktop' %}<br>This is a desktop-only release{% endif %} | ||
</description> | ||
{% if release.platform == 'android' %} | ||
<link>https://www.mozilla.org/en-US/firefox/android/{{ release.version }}/releasenotes/</link> | ||
{% else %} | ||
<link>{{ release.relnotes }}</link> | ||
{% endif %} | ||
<pubDate>{{ release.date }}</pubDate> | ||
</item> | ||
{% endfor %} | ||
</channel> | ||
</rss> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters