RSS Library swap

This commit is contained in:
Thomas Hounsell 2016-07-13 12:35:21 +01:00
parent 7d6ed90e3d
commit ccb4e3d024
8 changed files with 109 additions and 209 deletions

View File

@ -9,14 +9,14 @@ public class RouteConfig
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapHttpRoute("API", "api/{action}/{id}",
new
routes.AppendTrailingSlash = true;
routes.MapHttpRoute("API", "api/{action}/{id}", new
{
controller = "api",
action = "GetBuilds",
id = UrlParameter.Optional
});
routes.AppendTrailingSlash = true;
routes.MapMvcAttributeRoutes();
}
}

View File

@ -106,6 +106,7 @@
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
@ -168,8 +169,9 @@
<Reference Include="System.Net.Http.WebRequest">
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="X.Web.RSS">
<HintPath>..\packages\xwebrss.1.2.1.130\lib\net40-client\X.Web.RSS.dll</HintPath>
<Reference Include="WilderMinds.RssSyndication, Version=1.0.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WilderMinds.RssSyndication.1.0.4\lib\netstandard1.3\WilderMinds.RssSyndication.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>

View File

@ -6,10 +6,7 @@
using System.Web.Mvc;
using BuildFeed.Code;
using BuildFeed.Models;
using X.Web.RSS;
using X.Web.RSS.Enumerators;
using X.Web.RSS.Structure;
using X.Web.RSS.Structure.Validators;
using WilderMinds.RssSyndication;
namespace BuildFeed.Controllers
{
@ -23,35 +20,28 @@ public class RssController : LocalController
[Route("rss/compiled")]
public async Task<ActionResult> Index()
{
var builds = await _bModel.SelectBuildsByCompileDate(RSS_SIZE, 0);
List<BuildModel> builds = await _bModel.SelectBuildsByCompileDate(RSS_SIZE, 0);
RssDocument rdoc = new RssDocument
{
Channel = new RssChannel
Feed feed = new Feed
{
Title = "BuildFeed RSS - Recently Compiled",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}"),
Items = (from build in builds
select new RssItem
select new Item
{
Title = build.FullBuildString,
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"),
Guid = new RssGuid
{
IsPermaLink = true,
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"
}
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories = {
build.Family.ToString()
},
PublishDate = DateTime.SpecifyKind(build.BuildTime.GetValueOrDefault(), DateTimeKind.Utc)
}).ToList()
}
};
return new ContentResult
{
Content = rdoc.ToXml(),
Content = feed.Serialize(),
ContentType = "application/rss+xml",
ContentEncoding = Encoding.UTF8
};
@ -60,38 +50,28 @@ public async Task<ActionResult> Index()
[Route("rss/added")]
public async Task<ActionResult> Added()
{
var builds = await _bModel.SelectBuildsByAddedDate(RSS_SIZE, 0);
List<BuildModel> builds = await _bModel.SelectBuildsByAddedDate(RSS_SIZE, 0);
RssDocument rdoc = new RssDocument()
{
Channel = new RssChannel()
Feed feed = new Feed
{
Title = "BuildFeed RSS - Recently Added",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}"),
Items = (from build in builds
select new RssItem()
select new Item
{
Title = build.FullBuildString,
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"),
Guid = new RssGuid()
{
IsPermaLink = true,
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories = {
build.Family.ToString()
},
Category = new RssCategory() { Text = build.Family.ToString() },
InternalPubDate = new RssDate(build.Added).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
PublishDate = DateTime.SpecifyKind(build.Added, DateTimeKind.Utc)
}).ToList()
}
};
return new ContentResult
{
Content = rdoc.ToXml(),
Content = feed.Serialize(),
ContentType = "application/rss+xml",
ContentEncoding = Encoding.UTF8
};
@ -100,37 +80,28 @@ public async Task<ActionResult> Added()
[Route("rss/leaked")]
public async Task<ActionResult> Leaked()
{
var builds = await _bModel.SelectBuildsByLeakedDate(RSS_SIZE, 0);
List<BuildModel> builds = await _bModel.SelectBuildsByLeakedDate(RSS_SIZE, 0);
RssDocument rdoc = new RssDocument()
{
Channel = new RssChannel()
Feed feed = new Feed
{
Title = "BuildFeed RSS - Recently Leaked",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}"),
Items = (from build in builds
select new RssItem()
select new Item
{
Title = build.FullBuildString,
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"),
Guid = new RssGuid()
{
IsPermaLink = true,
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories = {
build.Family.ToString()
},
InternalPubDate = new RssDate(build.LeakDate.Value).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
PublishDate = DateTime.SpecifyKind(build.LeakDate.GetValueOrDefault(), DateTimeKind.Utc)
}).ToList()
}
};
return new ContentResult
{
Content = rdoc.ToXml(),
Content = feed.Serialize(),
ContentType = "application/rss+xml",
ContentEncoding = Encoding.UTF8
};
@ -139,75 +110,27 @@ public async Task<ActionResult> Leaked()
[Route("rss/version")]
public async Task<ActionResult> Version()
{
var builds = await _bModel.SelectBuildsByOrder(RSS_SIZE, 0);
List<BuildModel> builds = await _bModel.SelectBuildsByOrder(RSS_SIZE, 0);
RssDocument rdoc = new RssDocument()
{
Channel = new RssChannel()
Feed feed = new Feed
{
Title = "BuildFeed RSS - Highest Version",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}"),
Items = (from build in builds
select new RssItem()
select new Item
{
Title = build.FullBuildString,
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"),
Guid = new RssGuid()
{
IsPermaLink = true,
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"
},
}).ToList()
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories = {
build.Family.ToString()
}
}).ToList()
};
return new ContentResult
{
Content = rdoc.ToXml(),
ContentType = "application/rss+xml",
ContentEncoding = Encoding.UTF8
};
}
[Route("rss/flight/{id}")]
public async Task<ActionResult> Flight(LevelOfFlight id)
{
var builds = await _bModel.SelectFlight(id, RSS_SIZE, 0);
RssDocument rdoc = new RssDocument()
{
Channel = new RssChannel()
{
Title = $"BuildFeed RSS - {id} Flight Level",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
Items = (from build in builds
select new RssItem()
{
Title = build.FullBuildString,
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"),
Guid = new RssGuid()
{
IsPermaLink = true,
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"
},
}).ToList()
}
};
return new ContentResult
{
Content = rdoc.ToXml(),
Content = feed.Serialize(),
ContentType = "application/rss+xml",
ContentEncoding = Encoding.UTF8
};
@ -216,36 +139,27 @@ public async Task<ActionResult> Flight(LevelOfFlight id)
[Route("rss/lab/{lab}")]
public async Task<ActionResult> Lab(string lab)
{
var builds = await _bModel.SelectLab(lab, RSS_SIZE, 0);
List<BuildModel> builds = await _bModel.SelectLab(lab, RSS_SIZE, 0);
RssDocument rdoc = new RssDocument()
{
Channel = new RssChannel()
Feed feed = new Feed
{
Title = $"BuildFeed RSS - {lab} Lab",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}"),
Items = (from build in builds
select new RssItem()
select new Item
{
Title = build.FullBuildString,
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"),
Guid = new RssGuid()
{
IsPermaLink = true,
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("ViewBuild", new { controller = "Front", id = build.Id })}"
},
}).ToList()
Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"),
Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}",
Categories = {
build.Family.ToString()
}
}).ToList()
};
return new ContentResult
{
Content = rdoc.ToXml(),
Content = feed.Serialize(),
ContentType = "application/rss+xml",
ContentEncoding = Encoding.UTF8
};

View File

@ -6,7 +6,7 @@
namespace BuildFeed
{
public class MvcApplication : System.Web.HttpApplication
public class MvcApplication : HttpApplication
{
protected void Application_Start()
{

View File

@ -9,16 +9,6 @@
<li><a href="@Url.Action("Leaked", new { controller = "Rss" })" title="@BuildFeed.Local.Support.RecentlyLeaked"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Support.RecentlyLeaked</a></li>
<li><a href="@Url.Action("Added", new { controller = "Rss" })" title="@BuildFeed.Local.Support.RecentlyAdded"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Support.RecentlyAdded</a></li>
<li><a href="@Url.Action("Version", new { controller = "Rss" })" title="@BuildFeed.Local.Support.HighestVersion"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Support.HighestVersion</a></li>
<li>
@BuildFeed.Local.Model.FlightLevel
<ul>
<li><a href="@Url.Action("Flight", new { controller = "Rss", id = "wis" })" title="@BuildFeed.Local.Model.FlightWIS"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Model.FlightWIS</a></li>
<li><a href="@Url.Action("Flight", new { controller = "Rss", id = "wif" })" title="@BuildFeed.Local.Model.FlightWIF"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Model.FlightWIF</a></li>
<li><a href="@Url.Action("Flight", new { controller = "Rss", id = "osg" })" title="@BuildFeed.Local.Model.FlightOSG"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Model.FlightOSG</a></li>
<li><a href="@Url.Action("Flight", new { controller = "Rss", id = "msit" })" title="@BuildFeed.Local.Model.FlightMSIT"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Model.FlightMSIT</a></li>
<li><a href="@Url.Action("Flight", new { controller = "Rss", id = "canary" })" title="@BuildFeed.Local.Model.FlightCanary"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Model.FlightCanary</a></li>
</ul>
</li>
<li>
<a href="#rss-labs" data-toggle="collapse">@BuildFeed.Local.Model.Lab</a>
<ul id="rss-labs" class="collapse">

View File

@ -69,16 +69,6 @@
<li><a href="@Url.Action("Leaked", new { controller = "Rss" })" title="@BuildFeed.Local.Support.RecentlyLeaked"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Support.RecentlyLeaked</a></li>
<li><a href="@Url.Action("Added", new { controller = "Rss" })" title="@BuildFeed.Local.Support.RecentlyAdded"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Support.RecentlyAdded</a></li>
<li><a href="@Url.Action("Version", new { controller = "Rss" })" title="@BuildFeed.Local.Support.HighestVersion"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Support.HighestVersion</a></li>
<li>
@BuildFeed.Local.Model.FlightLevel
<ul>
<li><a href="@Url.Action("Flight", new { controller = "Rss", id = "wis" })" title="@BuildFeed.Local.Model.FlightWIS"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Model.FlightWIS</a></li>
<li><a href="@Url.Action("Flight", new { controller = "Rss", id = "wif" })" title="@BuildFeed.Local.Model.FlightWIF"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Model.FlightWIF</a></li>
<li><a href="@Url.Action("Flight", new { controller = "Rss", id = "osg" })" title="@BuildFeed.Local.Model.FlightOSG"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Model.FlightOSG</a></li>
<li><a href="@Url.Action("Flight", new { controller = "Rss", id = "msit" })" title="@BuildFeed.Local.Model.FlightMSIT"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Model.FlightMSIT</a></li>
<li><a href="@Url.Action("Flight", new { controller = "Rss", id = "canary" })" title="@BuildFeed.Local.Model.FlightCanary"><i class="fa fa-sm fa-rss"></i> @BuildFeed.Local.Model.FlightCanary</a></li>
</ul>
</li>
<li>
<a href="#rss-labs" data-toggle="collapse">@BuildFeed.Local.Model.Lab</a>
<ul id="rss-labs" class="collapse">

View File

@ -63,16 +63,14 @@
<match url="^actions/info/([0-9a-f-]+)/(\?.+)?$" />
<action type="Redirect" redirectType="Permanent" url="/build/{R:1}/{R:2}" />
</rule>
<rule name="(2016-07) RSS Flights">
<match url="^rss/flight/([a-z-]+)/(\?.+)?$" />
<action type="Redirect" redirectType="Permanent" url="/rss/" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="Support Pages">
<add key="/statistics/" value="/" />
<add key="/rss/flight/low/" value="/rss/feed/wif/" />
<add key="/rss/flight/medium/" value="/rss/feed/msit/" />
<add key="/rss/flight/high/" value="/rss/feed/osg/" />
<add key="/rss/feed/low/" value="/rss/feed/wif/" />
<add key="/rss/feed/medium/" value="/rss/feed/msit/" />
<add key="/rss/feed/high/" value="/rss/feed/osg/" />
<add key="/support/question/" value="/" />
<add key="/support/stats/" value="/" />
<add key="/support/rss/" value="/rss/" />

View File

@ -21,6 +21,7 @@
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.1" targetFramework="net461" />
<package id="Microsoft.CSharp" version="4.0.1" targetFramework="net461" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.Net.Compilers" version="1.3.2" targetFramework="net461" developmentDependency="true" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
@ -28,5 +29,10 @@
<package id="MongoDB.Driver" version="2.2.4" targetFramework="net461" />
<package id="MongoDB.Driver.Core" version="2.2.4" targetFramework="net461" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net461" />
<package id="xwebrss" version="1.2.1.130" targetFramework="net45" />
<package id="System.Collections" version="4.0.11" targetFramework="net461" />
<package id="System.Linq" version="4.1.0" targetFramework="net461" />
<package id="System.Runtime" version="4.1.0" targetFramework="net461" />
<package id="System.Threading" version="4.0.11" targetFramework="net461" />
<package id="System.Xml.XDocument" version="4.0.11" targetFramework="net461" />
<package id="WilderMinds.RssSyndication" version="1.0.4" targetFramework="net461" />
</packages>