Skip to content

Commit

Permalink
simplify Rss feed generation
Browse files Browse the repository at this point in the history
  • Loading branch information
adelikat committed Mar 28, 2024
1 parent 916510c commit 3b1cfa3
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 86 deletions.
12 changes: 11 additions & 1 deletion TASVideos/Pages/RssFeeds/News.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@
<atom:link href="@(Settings.BaseUrl)/sublications.rss" rel="self" type="application/rss+xml" xmlns="atom" />
@foreach (var news in Model.News)
{
<partial model="news" name="_RssNews" />
var postUrl = $"{Settings.BaseUrl}/Forum/Posts/{news.PostId}";
<item>
<title>@news.Subject</title>
<rss-link>@postUrl</rss-link>
<description>
<forum-markup markup="@news.Text" enable-html="@news.EnableHtml" enable-bb-code="@news.EnableBbCode"></forum-markup>
</description>
<comments>@postUrl</comments>
<guid>@postUrl</guid>
<pubDate>@news.PubDate</pubDate>
</item>
}
</channel>
</rss>
32 changes: 31 additions & 1 deletion TASVideos/Pages/RssFeeds/Publications.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page
@using System.Globalization
@inject AppSettings Settings
@model PublicationsModel
@{
Expand All @@ -13,7 +14,36 @@
<atom:link href="@(Settings.BaseUrl)/publications.rss" rel="self" type="application/rss+xml" xmlns="atom" />
@foreach (var pub in Model.Publications)
{
<partial model="pub" name="_RssPublication"/>
var movieUrl = $"{Settings.BaseUrl}/{pub.Id}M";
var primaryStreaming = pub.StreamingUrls.FirstOrDefault(u => u.Contains("youtube"));
var secondaryStreaming = pub.StreamingUrls.Where(u => u != primaryStreaming);
<item>
<title>@pub.Title</title>
<rss-link>@movieUrl</rss-link>
<description>
<html-encode>
<wiki-markup markup="@pub.Wiki.Markup" page-data="@pub.Wiki"></wiki-markup>
</html-encode>
</description>
@foreach (var tag in pub.TagNames)
{
<category>@tag</category>
}
<media:group>
<media:content url="@(movieUrl)?handler=Download" fileSize="@pub.MovieFileSize" type="application/zip" medium="document" />
<media:thumbnail url="@(Settings.BaseUrl)/media/@pub.ScreenshotPath" />
@foreach (var url in secondaryStreaming)
{
<media:content url="@url" type="video" medium="video" />
}
<media:player url="@primaryStreaming" />
<media:community>
<media:starRating average="@pub.RatingAverage" count="@pub.RatingCount" min="@pub.RatingMin" max="@pub.RatingMax" />
</media:community>
</media:group>
<guid>@movieUrl</guid>
<pubDate>@pub.CreateTimestamp.ToString("u", CultureInfo.InvariantCulture)</pubDate>
</item>
}
</channel>
</rss>
16 changes: 15 additions & 1 deletion TASVideos/Pages/RssFeeds/Submissions.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page
@using System.Globalization
@inject AppSettings Settings
@model SubmissionsModel
@{
Expand All @@ -13,7 +14,20 @@
<atom:link href="@(Settings.BaseUrl)/sublications.rss" rel="self" type="application/rss+xml" xmlns="atom" />
@foreach (var sub in Model.Submissions)
{
<partial model="sub" name="_RssSubmission"/>
var subUrl = $"{Settings.BaseUrl}/{sub.Id}S";
<item>
<title>@sub.Title</title>
<rss-link>@subUrl</rss-link>
<description>
<html-encode>
<wiki-markup markup="@sub.Wiki.Markup" page-data="@sub.Wiki"></wiki-markup>
</html-encode>
</description>
<comments condition="@sub.TopicId.HasValue">@(Settings.BaseUrl)/Forum/Topics/@sub.TopicId</comments>
<enclosure url="@(subUrl)?handler=Download" />
<guid>@subUrl</guid>
<pubDate>@sub.CreateTimestamp.ToString("u", CultureInfo.InvariantCulture)</pubDate>
</item>
}
</channel>
</rss>
16 changes: 0 additions & 16 deletions TASVideos/Pages/RssFeeds/_RssNews.cshtml

This file was deleted.

37 changes: 0 additions & 37 deletions TASVideos/Pages/RssFeeds/_RssPublication.cshtml

This file was deleted.

21 changes: 0 additions & 21 deletions TASVideos/Pages/RssFeeds/_RssSubmission.cshtml

This file was deleted.

9 changes: 0 additions & 9 deletions TASVideos/TASVideos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,9 @@
<Content Update="Pages\RssFeeds\_RssChannel.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Pages\RssFeeds\_RssNews.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Pages\RssFeeds\_RssWiki.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Pages\RssFeeds\_RssSubmission.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Pages\RssFeeds\_RssPublication.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Pages\Shared\Components\FirstEditionTas\Default.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
Expand Down
12 changes: 12 additions & 0 deletions TASVideos/TagHelpers/RssLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Razor.TagHelpers;

namespace TASVideos.TagHelpers;

// A work-around for the fact that tools do not understand we are building RSS and not HTML, this makes errors and warnings go away
public class RssLink : TagHelper
{
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "link";
}
}

0 comments on commit 3b1cfa3

Please sign in to comment.