diff --git a/App_Start/RouteConfig.cs b/App_Start/RouteConfig.cs index 87263e4..c0daab6 100644 --- a/App_Start/RouteConfig.cs +++ b/App_Start/RouteConfig.cs @@ -16,95 +16,7 @@ public static void RegisterRoutes(RouteCollection routes) routes.AppendTrailingSlash = true; - routes.MapRoute( - name: "Site Root", - url: "", - defaults: new { controller = "Build", action = "index", page = 1 } - ); - - routes.MapRoute( - name: "Pagination", - url: "page/{page}/", - defaults: new { controller = "Build", action = "index", page = 1 } - ); - - routes.MapRoute( - name: "Lab Root", - url: "lab/{lab}/", - defaults: new { controller = "Build", action = "lab", page = 1 } - ); - - routes.MapRoute( - name: "Lab", - url: "lab/{lab}/page/{page}/", - defaults: new { controller = "Build", action = "lab", page = 1 } - ); - - routes.MapRoute( - name: "Version Root", - url: "version/{major}.{minor}/", - defaults: new { controller = "Build", action = "version", page = 1 } - ); - - routes.MapRoute( - name: "Version", - url: "version/{major}.{minor}/page/{page}/", - defaults: new { controller = "Build", action = "version", page = 1 } - ); - - routes.MapRoute( - name: "Year Root", - url: "year/{year}/", - defaults: new { controller = "Build", action = "year", page = 1 } - ); - - routes.MapRoute( - name: "Year", - url: "year/{year}/page/{page}/", - defaults: new { controller = "Build", action = "year", page = 1 } - ); - - routes.MapRoute( - name: "Source Root", - url: "source/{source}/", - defaults: new { controller = "Build", action = "source", page = 1 } - ); - - routes.MapRoute( - name: "Source", - url: "source/{source}/page/{page}/", - defaults: new { controller = "Build", action = "source", page = 1 } - ); - - routes.MapRoute( - name: "RSS (with ID)", - url: "rss/{action}/{id}/", - defaults: new { controller = "rss", action = "index" } - ); - - routes.MapRoute( - name: "RSS", - url: "rss/{action}", - defaults: new { controller = "rss", action = "index" } - ); - - routes.MapRoute( - name: "Support", - url: "support/{action}/", - defaults: new { controller = "Support", action = "index" } - ); - - routes.MapHttpRoute( - name: "API", - routeTemplate: "api/{action}/{id}", - defaults: new { controller = "api", action = "GetBuilds", id = UrlParameter.Optional } - ); - - routes.MapRoute( - name: "Actions", - url: "actions/{action}/{id}", - defaults: new { controller = "Build", action = "index", id = UrlParameter.Optional } - ); + routes.MapMvcAttributeRoutes(); } } } diff --git a/BuildFeed.csproj b/BuildFeed.csproj index 9bee53f..9a6d526 100644 --- a/BuildFeed.csproj +++ b/BuildFeed.csproj @@ -193,6 +193,7 @@ + @@ -314,6 +315,7 @@ Designer + diff --git a/Controllers/frontController.cs b/Controllers/frontController.cs new file mode 100644 index 0000000..67ec423 --- /dev/null +++ b/Controllers/frontController.cs @@ -0,0 +1,34 @@ +using BuildFeed.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace BuildFeed.Controllers +{ + public class frontController : Controller + { + private const int _pageSize = 25; + + [Route("")] + [OutputCache(Duration = 600, VaryByParam = "none")] + public ActionResult index() + { + var buildGroups = from b in Build.Select() + group b by new BuildGroup() + { + Major = b.MajorVersion, + Minor = b.MinorVersion, + Build = b.Number, + Revision = b.Revision + } into bg + orderby bg.Key.Major descending, + bg.Key.Minor descending, + bg.Key.Build descending, + bg.Key.Revision descending + select bg; + return View(buildGroups); + } + } +} \ No newline at end of file diff --git a/Controllers/supportController.cs b/Controllers/supportController.cs index ce07a9f..9160aab 100644 --- a/Controllers/supportController.cs +++ b/Controllers/supportController.cs @@ -167,6 +167,8 @@ public ActionResult rss() return View(); } + [Route("support/sitemap")] + [OutputCache(Duration = 3600, VaryByParam = "none")] public ActionResult sitemap() { IEnumerable builds = Build.SelectInVersionOrder(); @@ -265,6 +267,8 @@ orderby bv.Key return View(model); } + [Route("support/xmlsitemap")] + [OutputCache(Duration = 3600, VaryByParam = "none")] public ActionResult xmlsitemap() { XNamespace xn = XNamespace.Get("http://www.sitemaps.org/schemas/sitemap/0.9"); @@ -299,6 +303,8 @@ public ActionResult xmlsitemap() return new EmptyResult(); } + [Route("support/stats")] + [OutputCache(Duration = 3600, VaryByParam = "none")] public ActionResult stats() { var builds = Build.Select(); @@ -341,7 +347,7 @@ where b.BuildTime.HasValue where !string.IsNullOrEmpty(b.Lab) group b by b.Lab into bl select bl) - where bl.Count() > 19 + where bl.Count() > 24 orderby bl.Count() descending select new Tuple(bl.Key, bl.Count()); diff --git a/Models/Build.cs b/Models/Build.cs index d487897..31b7c09 100644 --- a/Models/Build.cs +++ b/Models/Build.cs @@ -337,4 +337,19 @@ public override string ToString() return string.Format("{0}.{1}", Major, Minor); } } + + public struct BuildGroup + { + public byte Major { get; set; } + public byte Minor { get; set; } + public ushort Build { get; set; } + public ushort? Revision { get; set; } + + public override string ToString() + { + return Revision.HasValue ? + string.Format("{0}.{1}.{2}.{3}", Major, Minor, Build, Revision.Value) : + string.Format("{0}.{1}.{2}", Major, Minor, Build); + } + } } \ No newline at end of file diff --git a/Views/front/index.cshtml b/Views/front/index.cshtml new file mode 100644 index 0000000..5984db7 --- /dev/null +++ b/Views/front/index.cshtml @@ -0,0 +1,20 @@ +@model IEnumerable> +@{ + ViewBag.Title = "BuildFeed"; +} + +
+ @foreach (var group in Model) + { +
+

@group.Key.ToString()

+

+ @if(group.Any(k => k.BuildTime.HasValue)) + { + @group.Max(k => k.BuildTime).Value.ToString("dd MMMM yyyy")
+ } + @group.Count().ToString() variants +

+
+ } +
diff --git a/Views/shared/_default.cshtml b/Views/shared/_default.cshtml index 7900c35..0a3372c 100644 --- a/Views/shared/_default.cshtml +++ b/Views/shared/_default.cshtml @@ -42,20 +42,19 @@ ga('send', 'pageview');
- +
diff --git a/Views/support/stats.cshtml b/Views/support/stats.cshtml index 2a12533..2c37584 100644 --- a/Views/support/stats.cshtml +++ b/Views/support/stats.cshtml @@ -13,7 +13,7 @@

Recorded builds in each lab

-

Only labs with more than 20 recorded builds are included.

+

Only labs with 25 or more recorded builds are included.

@section scripts diff --git a/content/style.css b/content/style.css index 939e062..1e1bdd0 100644 --- a/content/style.css +++ b/content/style.css @@ -15,16 +15,11 @@ h1 color: #000; } -.social-links +#page-content { - margin: 30px 0 6px; + padding-top: 70px; } - .social-links a - { - margin-left: 1em; - } - .build-head { margin-bottom: 0.33em;