2014-12-16 22:43:26 +08:00
|
|
|
|
using BuildFeed.Models;
|
2014-10-11 06:57:02 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using X.Web.RSS;
|
|
|
|
|
using X.Web.RSS.Enumerators;
|
|
|
|
|
using X.Web.RSS.Structure;
|
|
|
|
|
using X.Web.RSS.Structure.Validators;
|
|
|
|
|
|
|
|
|
|
namespace BuildFeed.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class rssController : Controller
|
|
|
|
|
{
|
2015-03-22 03:29:21 +08:00
|
|
|
|
[Route("rss/compiled")]
|
2014-10-21 20:53:27 +08:00
|
|
|
|
public async Task<ActionResult> index()
|
2014-10-11 06:57:02 +08:00
|
|
|
|
{
|
|
|
|
|
var builds = Build.SelectInBuildOrder().Take(20);
|
|
|
|
|
|
|
|
|
|
RssDocument rdoc = new RssDocument()
|
|
|
|
|
{
|
|
|
|
|
Channel = new RssChannel()
|
|
|
|
|
{
|
|
|
|
|
Title = "BuildFeed RSS - Recently Compiled",
|
|
|
|
|
Description = "",
|
|
|
|
|
Generator = "BuildFeed.net RSS Controller",
|
|
|
|
|
Link = new RssUrl(string.Format("{0}://{1}", 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,
|
2014-10-29 07:39:18 +08:00
|
|
|
|
Link = new RssUrl(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id }))),
|
|
|
|
|
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id })) },
|
2014-10-11 06:57:02 +08:00
|
|
|
|
}).ToList()
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Response.ContentType = "application/rss+xml";
|
|
|
|
|
|
|
|
|
|
await Response.Output.WriteAsync(rdoc.ToXml());
|
|
|
|
|
|
|
|
|
|
return new EmptyResult();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-22 03:29:21 +08:00
|
|
|
|
[Route("rss/added")]
|
2014-10-21 20:53:27 +08:00
|
|
|
|
public async Task<ActionResult> added()
|
2014-10-11 06:57:02 +08:00
|
|
|
|
{
|
|
|
|
|
var builds = Build.Select().OrderByDescending(b => b.Added).Take(20);
|
|
|
|
|
|
|
|
|
|
RssDocument rdoc = new RssDocument()
|
|
|
|
|
{
|
|
|
|
|
Channel = new RssChannel()
|
|
|
|
|
{
|
|
|
|
|
Title = "BuildFeed RSS - Recently Added",
|
|
|
|
|
Description = "",
|
|
|
|
|
Generator = "BuildFeed.net RSS Controller",
|
|
|
|
|
Link = new RssUrl(string.Format("{0}://{1}", 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,
|
2014-10-29 07:39:18 +08:00
|
|
|
|
Link = new RssUrl(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id }))),
|
|
|
|
|
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id })) },
|
2014-12-16 22:43:26 +08:00
|
|
|
|
InternalPubDate = new RssDate(build.Added).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
|
2014-10-11 06:57:02 +08:00
|
|
|
|
}).ToList()
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Response.ContentType = "application/rss+xml";
|
|
|
|
|
|
|
|
|
|
await Response.Output.WriteAsync(rdoc.ToXml());
|
|
|
|
|
|
|
|
|
|
return new EmptyResult();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-22 03:29:21 +08:00
|
|
|
|
[Route("rss/leaked")]
|
2015-01-30 01:31:51 +08:00
|
|
|
|
public async Task<ActionResult> leaked()
|
|
|
|
|
{
|
|
|
|
|
var builds = Build.Select().Where(b => b.LeakDate.HasValue).OrderByDescending(b => b.LeakDate.Value).Take(20);
|
|
|
|
|
|
|
|
|
|
RssDocument rdoc = new RssDocument()
|
|
|
|
|
{
|
|
|
|
|
Channel = new RssChannel()
|
|
|
|
|
{
|
|
|
|
|
Title = "BuildFeed RSS - Recently Leaked",
|
|
|
|
|
Description = "",
|
|
|
|
|
Generator = "BuildFeed.net RSS Controller",
|
|
|
|
|
Link = new RssUrl(string.Format("{0}://{1}", 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(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id }))),
|
|
|
|
|
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id })) },
|
|
|
|
|
InternalPubDate = new RssDate(build.LeakDate.Value).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
|
|
|
|
|
}).ToList()
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Response.ContentType = "application/rss+xml";
|
|
|
|
|
|
|
|
|
|
await Response.Output.WriteAsync(rdoc.ToXml());
|
|
|
|
|
|
|
|
|
|
return new EmptyResult();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-22 03:29:21 +08:00
|
|
|
|
[Route("rss/version")]
|
2014-10-21 20:53:27 +08:00
|
|
|
|
public async Task<ActionResult> version()
|
2014-10-11 06:57:02 +08:00
|
|
|
|
{
|
2014-11-01 03:28:16 +08:00
|
|
|
|
var builds = Build.SelectInVersionOrder()
|
2014-10-11 06:57:02 +08:00
|
|
|
|
.Take(20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RssDocument rdoc = new RssDocument()
|
|
|
|
|
{
|
|
|
|
|
Channel = new RssChannel()
|
|
|
|
|
{
|
|
|
|
|
Title = "BuildFeed RSS - Highest Version",
|
|
|
|
|
Description = "",
|
|
|
|
|
Generator = "BuildFeed.net RSS Controller",
|
|
|
|
|
Link = new RssUrl(string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority)),
|
2014-10-21 20:53:27 +08:00
|
|
|
|
SkipHours = new List<Hour>(),
|
|
|
|
|
SkipDays = new List<Day>(),
|
|
|
|
|
|
|
|
|
|
Items = (from build in builds
|
|
|
|
|
select new RssItem()
|
|
|
|
|
{
|
|
|
|
|
Title = build.FullBuildString,
|
2014-10-29 07:39:18 +08:00
|
|
|
|
Link = new RssUrl(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id }))),
|
|
|
|
|
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id })) },
|
2014-10-21 20:53:27 +08:00
|
|
|
|
}).ToList()
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Response.ContentType = "application/rss+xml";
|
|
|
|
|
|
|
|
|
|
await Response.Output.WriteAsync(rdoc.ToXml());
|
|
|
|
|
|
|
|
|
|
return new EmptyResult();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-22 03:29:21 +08:00
|
|
|
|
[Route("rss/flight/{id}")]
|
2014-10-21 20:53:27 +08:00
|
|
|
|
public async Task<ActionResult> flight(LevelOfFlight id)
|
|
|
|
|
{
|
|
|
|
|
var builds = Build.SelectInBuildOrder()
|
|
|
|
|
.Where(b => b.FlightLevel == id)
|
|
|
|
|
.Take(20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RssDocument rdoc = new RssDocument()
|
|
|
|
|
{
|
|
|
|
|
Channel = new RssChannel()
|
|
|
|
|
{
|
|
|
|
|
Title = string.Format("BuildFeed RSS - {0} Flight Level", id),
|
|
|
|
|
Description = "",
|
|
|
|
|
Generator = "BuildFeed.net RSS Controller",
|
|
|
|
|
Link = new RssUrl(string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority)),
|
2014-10-11 06:57:02 +08:00
|
|
|
|
SkipHours = new List<Hour>(),
|
|
|
|
|
SkipDays = new List<Day>(),
|
|
|
|
|
|
|
|
|
|
Items = (from build in builds
|
|
|
|
|
select new RssItem()
|
|
|
|
|
{
|
|
|
|
|
Title = build.FullBuildString,
|
2014-10-29 07:39:18 +08:00
|
|
|
|
Link = new RssUrl(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id }))),
|
|
|
|
|
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id })) },
|
2014-10-11 06:57:02 +08:00
|
|
|
|
}).ToList()
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Response.ContentType = "application/rss+xml";
|
|
|
|
|
|
|
|
|
|
await Response.Output.WriteAsync(rdoc.ToXml());
|
|
|
|
|
|
|
|
|
|
return new EmptyResult();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|