Move all URLs to lower-case, some refactoring

This commit is contained in:
Thomas Hounsell 2014-10-28 23:39:18 +00:00
parent 83f32e37ee
commit 133163292d
13 changed files with 106 additions and 131 deletions

View File

@ -19,61 +19,61 @@ public static void RegisterRoutes(RouteCollection routes)
routes.MapRoute( routes.MapRoute(
name: "Site Root", name: "Site Root",
url: "", url: "",
defaults: new { controller = "Build", action = "Index", page = 1 } defaults: new { controller = "Build", action = "index", page = 1 }
); );
routes.MapRoute( routes.MapRoute(
name: "Pagination", name: "Pagination",
url: "page/{page}/", url: "page/{page}/",
defaults: new { controller = "Build", action = "Index", page = 1 } defaults: new { controller = "Build", action = "index", page = 1 }
); );
routes.MapRoute( routes.MapRoute(
name: "Lab Root", name: "Lab Root",
url: "lab/{lab}/", url: "lab/{lab}/",
defaults: new { controller = "Build", action = "Lab", page = 1 } defaults: new { controller = "Build", action = "lab", page = 1 }
); );
routes.MapRoute( routes.MapRoute(
name: "Lab", name: "Lab",
url: "lab/{lab}/page/{page}/", url: "lab/{lab}/page/{page}/",
defaults: new { controller = "Build", action = "Lab", page = 1 } defaults: new { controller = "Build", action = "lab", page = 1 }
); );
routes.MapRoute( routes.MapRoute(
name: "Version Root", name: "Version Root",
url: "version/{major}.{minor}/", url: "version/{major}.{minor}/",
defaults: new { controller = "Build", action = "Version", page = 1 } defaults: new { controller = "Build", action = "version", page = 1 }
); );
routes.MapRoute( routes.MapRoute(
name: "Version", name: "Version",
url: "version/{major}.{minor}/page/{page}/", url: "version/{major}.{minor}/page/{page}/",
defaults: new { controller = "Build", action = "Version", page = 1 } defaults: new { controller = "Build", action = "version", page = 1 }
); );
routes.MapRoute( routes.MapRoute(
name: "Year Root", name: "Year Root",
url: "year/{year}/", url: "year/{year}/",
defaults: new { controller = "Build", action = "Year", page = 1 } defaults: new { controller = "Build", action = "year", page = 1 }
); );
routes.MapRoute( routes.MapRoute(
name: "Year", name: "Year",
url: "year/{year}/{page}/", url: "year/{year}/{page}/",
defaults: new { controller = "Build", action = "Year", page = 1 } defaults: new { controller = "Build", action = "year", page = 1 }
); );
routes.MapRoute( routes.MapRoute(
name: "Source Root", name: "Source Root",
url: "source/{source}/", url: "source/{source}/",
defaults: new { controller = "Build", action = "Source", page = 1 } defaults: new { controller = "Build", action = "source", page = 1 }
); );
routes.MapRoute( routes.MapRoute(
name: "Source", name: "Source",
url: "source/{source}/{page}/", url: "source/{source}/{page}/",
defaults: new { controller = "Build", action = "Source", page = 1 } defaults: new { controller = "Build", action = "source", page = 1 }
); );
routes.MapRoute( routes.MapRoute(
@ -91,7 +91,7 @@ public static void RegisterRoutes(RouteCollection routes)
routes.MapRoute( routes.MapRoute(
name: "Support", name: "Support",
url: "support/{action}/", url: "support/{action}/",
defaults: new { controller = "Support", action = "Index" } defaults: new { controller = "Support", action = "index" }
); );
routes.MapHttpRoute( routes.MapHttpRoute(
@ -103,7 +103,7 @@ public static void RegisterRoutes(RouteCollection routes)
routes.MapRoute( routes.MapRoute(
name: "Actions", name: "Actions",
url: "actions/{action}/{id}", url: "actions/{action}/{id}",
defaults: new { controller = "Build", action = "Index", id = UrlParameter.Optional } defaults: new { controller = "Build", action = "index", id = UrlParameter.Optional }
); );
} }
} }

View File

@ -54,7 +54,7 @@
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.5\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.6.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="NServiceKit.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="NServiceKit.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@ -145,7 +145,8 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="App_Code\BuildDateTimeModelBinder.cs" /> <Compile Include="Code\BuildDateTimeModelBinder.cs" />
<Compile Include="Code\DisplayHelpers.cs" />
<Compile Include="App_Start\BundleConfig.cs" /> <Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\DatabaseConfig.cs" /> <Compile Include="App_Start\DatabaseConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" /> <Compile Include="App_Start\FilterConfig.cs" />

View File

@ -1,8 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Text;
using System.Web.Mvc; using System.Web.Mvc;
namespace BuildFeed namespace BuildFeed

26
Code/DisplayHelpers.cs Normal file
View File

@ -0,0 +1,26 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace BuildFeed
{
public static class DisplayHelpers
{
public static string GetDisplayTextForEnum(object o)
{
var result = null as string;
var display = o.GetType()
.GetMember(o.ToString()).First()
.GetCustomAttributes(false)
.OfType<DisplayAttribute>()
.LastOrDefault();
if (display != null)
{
result = display.GetName();
}
return result ?? o.ToString();
}
}
}

View File

@ -10,11 +10,11 @@ namespace BuildFeed.Controllers
{ {
public class buildController : Controller public class buildController : Controller
{ {
public int pageSize { get { return 12; } } public int pageSize { get { return 15; } }
// //
// GET: /build/ // GET: /build/
public ActionResult Index(int page = 1) public ActionResult index(int page = 1)
{ {
var builds = Build.SelectInBuildOrder(); var builds = Build.SelectInBuildOrder();
var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize); var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize);
@ -25,7 +25,7 @@ public ActionResult Index(int page = 1)
return View(pageBuilds); return View(pageBuilds);
} }
public ActionResult Year(int year, int page = 1) public ActionResult year(int year, int page = 1)
{ {
var builds = Build.SelectInBuildOrder().Where(b => b.BuildTime.HasValue && b.BuildTime.Value.Year == year); var builds = Build.SelectInBuildOrder().Where(b => b.BuildTime.HasValue && b.BuildTime.Value.Year == year);
var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize); var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize);
@ -33,10 +33,10 @@ public ActionResult Year(int year, int page = 1)
ViewBag.PageNumber = page; ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(pageSize)); ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(pageSize));
return View("Index", pageBuilds); return View("index", pageBuilds);
} }
public ActionResult Lab(string lab, int page = 1) public ActionResult lab(string lab, int page = 1)
{ {
var builds = Build.SelectInBuildOrder().Where(b => b.Lab != null && (b.Lab.ToLower() == lab.ToLower())); var builds = Build.SelectInBuildOrder().Where(b => b.Lab != null && (b.Lab.ToLower() == lab.ToLower()));
var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize); var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize);
@ -44,10 +44,10 @@ public ActionResult Lab(string lab, int page = 1)
ViewBag.PageNumber = page; ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(pageSize)); ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(pageSize));
return View("Index", pageBuilds); return View("index", pageBuilds);
} }
public ActionResult Version(int major, int minor, int page = 1) public ActionResult version(int major, int minor, int page = 1)
{ {
var builds = Build.SelectInBuildOrder().Where(b => b.MajorVersion == major && b.MinorVersion == minor); var builds = Build.SelectInBuildOrder().Where(b => b.MajorVersion == major && b.MinorVersion == minor);
var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize); var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize);
@ -55,10 +55,10 @@ public ActionResult Version(int major, int minor, int page = 1)
ViewBag.PageNumber = page; ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(pageSize)); ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(pageSize));
return View("Index", pageBuilds); return View("index", pageBuilds);
} }
public ActionResult Source(TypeOfSource source, int page = 1) public ActionResult source(TypeOfSource source, int page = 1)
{ {
var builds = Build.SelectInBuildOrder().Where(b => b.SourceType == source); var builds = Build.SelectInBuildOrder().Where(b => b.SourceType == source);
var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize); var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize);
@ -66,13 +66,13 @@ public ActionResult Source(TypeOfSource source, int page = 1)
ViewBag.PageNumber = page; ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(pageSize)); ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(pageSize));
return View("Index", pageBuilds); return View("index", pageBuilds);
} }
// //
// GET: /build/Info/5 // GET: /build/Info/5
public ActionResult Info(int id) public ActionResult info(int id)
{ {
Build b = Build.SelectById(id); Build b = Build.SelectById(id);
@ -87,7 +87,7 @@ public ActionResult Info(int id)
// //
// GET: /build/Create // GET: /build/Create
[Authorize] [Authorize]
public ActionResult Create() public ActionResult create()
{ {
return View(); return View();
} }
@ -96,7 +96,7 @@ public ActionResult Create()
// POST: /build/Create // POST: /build/Create
[Authorize] [Authorize]
[HttpPost] [HttpPost]
public ActionResult Create(Build build) public ActionResult create(Build build)
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -109,7 +109,7 @@ public ActionResult Create(Build build)
{ {
return View(build); return View(build);
} }
return RedirectToAction("Index"); return RedirectToAction("index");
} }
else else
{ {
@ -120,17 +120,17 @@ public ActionResult Create(Build build)
// //
// GET: /build/Edit/5 // GET: /build/Edit/5
[Authorize] [Authorize]
public ActionResult Edit(long id) public ActionResult edit(long id)
{ {
Build b = Build.SelectById(id); Build b = Build.SelectById(id);
return View("Create", b); return View("create", b);
} }
// //
// POST: /build/Edit/5 // POST: /build/Edit/5
[Authorize] [Authorize]
[HttpPost] [HttpPost]
public ActionResult Edit(long id, Build build) public ActionResult edit(long id, Build build)
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -143,16 +143,16 @@ public ActionResult Edit(long id, Build build)
return View(); return View();
} }
return RedirectToAction("Index"); return RedirectToAction("index");
} }
else else
{ {
return View("Create", build); return View("create", build);
} }
} }
[Authorize(Users = "hounsell")] [Authorize(Users = "hounsell")]
public ActionResult Delete(long id) public ActionResult delete(long id)
{ {
Build.DeleteById(id); Build.DeleteById(id);
return Redirect("/"); return Redirect("/");

View File

@ -36,8 +36,8 @@ public async Task<ActionResult> index()
select new RssItem() select new RssItem()
{ {
Title = build.FullBuildString, 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 }))), 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 })) }, 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 })) },
}).ToList() }).ToList()
} }
}; };
@ -68,8 +68,8 @@ public async Task<ActionResult> added()
select new RssItem() select new RssItem()
{ {
Title = build.FullBuildString, 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 }))), 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 })) }, 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 })) },
PubDate = build.Added PubDate = build.Added
}).ToList() }).ToList()
} }
@ -109,8 +109,8 @@ public async Task<ActionResult> version()
select new RssItem() select new RssItem()
{ {
Title = build.FullBuildString, 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 }))), 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 })) }, 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 })) },
}).ToList() }).ToList()
} }
}; };
@ -145,8 +145,8 @@ public async Task<ActionResult> flight(LevelOfFlight id)
select new RssItem() select new RssItem()
{ {
Title = build.FullBuildString, 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 }))), 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 })) }, 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 })) },
}).ToList() }).ToList()
} }
}; };

View File

@ -11,18 +11,18 @@ namespace BuildFeed.Controllers
public class supportController : Controller public class supportController : Controller
{ {
// GET: support // GET: support
public ActionResult Index() public ActionResult index()
{ {
return View(); return View();
} }
public ActionResult Login() public ActionResult login()
{ {
return View(); return View();
} }
[HttpPost] [HttpPost]
public ActionResult Login(LoginUser ru) public ActionResult login(LoginUser ru)
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -43,13 +43,13 @@ public ActionResult Login(LoginUser ru)
} }
[Authorize] [Authorize]
public ActionResult Password() public ActionResult password()
{ {
return View(); return View();
} }
[HttpPost] [HttpPost]
public ActionResult Password(ChangePassword cp) public ActionResult password(ChangePassword cp)
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -66,19 +66,19 @@ public ActionResult Password(ChangePassword cp)
return View(cp); return View(cp);
} }
public ActionResult Logout() public ActionResult logout()
{ {
FormsAuthentication.SignOut(); FormsAuthentication.SignOut();
return Redirect("/"); return Redirect("/");
} }
public ActionResult Register() public ActionResult register()
{ {
return View(); return View();
} }
[HttpPost] [HttpPost]
public ActionResult Register(RegistrationUser ru) public ActionResult register(RegistrationUser ru)
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {

View File

@ -1,23 +1,7 @@
@model IEnumerable<BuildFeed.Models.Build> @model IEnumerable<BuildFeed.Models.Build>
@{ @{
Func<object, string> GetDisplayName = o => ViewBag.Action = ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString().ToLower();
{
var result = null as string;
var display = o.GetType()
.GetMember(o.ToString()).First()
.GetCustomAttributes(false)
.OfType<System.ComponentModel.DataAnnotations.DisplayAttribute>()
.LastOrDefault();
if (display != null)
{
result = display.GetName();
}
return result ?? o.ToString();
};
ViewBag.Action = ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString();
ViewBag.Title = "BuildFeed"; ViewBag.Title = "BuildFeed";
@ -28,23 +12,23 @@
switch (ViewBag.Action as string) switch (ViewBag.Action as string)
{ {
case "Index": case "index":
ViewBag.Title = "BuildFeed | The collaborative build list"; ViewBag.Title = "BuildFeed | The collaborative build list";
break; break;
case "Lab": case "lab":
ViewBag.ItemId = ViewContext.Controller.ValueProvider.GetValue("lab").RawValue; ViewBag.ItemId = ViewContext.Controller.ValueProvider.GetValue("lab").RawValue;
ViewBag.Title = string.Format("Builds from {1} | {0}", ViewBag.Title, ViewBag.ItemId); ViewBag.Title = string.Format("Builds from {1} | {0}", ViewBag.Title, ViewBag.ItemId);
break; break;
case "Year": case "year":
ViewBag.ItemId = ViewContext.Controller.ValueProvider.GetValue("year").RawValue; ViewBag.ItemId = ViewContext.Controller.ValueProvider.GetValue("year").RawValue;
ViewBag.Title = string.Format("Builds from {1} | {0}", ViewBag.Title, ViewBag.ItemId); ViewBag.Title = string.Format("Builds from {1} | {0}", ViewBag.Title, ViewBag.ItemId);
break; break;
case "Version": case "version":
ViewBag.ItemId = string.Format("{0}.{1}", ViewContext.Controller.ValueProvider.GetValue("major").RawValue, ViewContext.Controller.ValueProvider.GetValue("minor").RawValue); ViewBag.ItemId = string.Format("{0}.{1}", ViewContext.Controller.ValueProvider.GetValue("major").RawValue, ViewContext.Controller.ValueProvider.GetValue("minor").RawValue);
ViewBag.Title = string.Format("Windows NT {1} | {0}", ViewBag.Title, ViewBag.ItemId); ViewBag.Title = string.Format("Windows NT {1} | {0}", ViewBag.Title, ViewBag.ItemId);
break; break;
case "Source": case "source":
ViewBag.ItemId = GetDisplayName(Enum.Parse(typeof(BuildFeed.Models.TypeOfSource), ViewContext.Controller.ValueProvider.GetValue("source").RawValue.ToString())); ViewBag.ItemId = DisplayHelpers.GetDisplayTextForEnum(Enum.Parse(typeof(BuildFeed.Models.TypeOfSource), ViewContext.Controller.ValueProvider.GetValue("source").RawValue.ToString()));
ViewBag.Title = string.Format("{1} | {0}", ViewBag.Title, ViewBag.ItemId); ViewBag.Title = string.Format("{1} | {0}", ViewBag.Title, ViewBag.ItemId);
break; break;
} }
@ -54,15 +38,15 @@
{ {
@switch (ViewBag.Action as string) @switch (ViewBag.Action as string)
{ {
case "Index": case "index":
<meta name="description" content="BuildFeed is a collaborative build list for Microsoft Windows. Keep up to date with the latest Windows 10 builds or take a peek at the list back to 2000" /> <meta name="description" content="BuildFeed is a collaborative build list for Microsoft Windows. Keep up to date with the latest Windows 10 builds or take a peek at the list back to 2000" />
<meta property="og:description" content="BuildFeed is a collaborative build list for Microsoft Windows. Keep up to date with the latest Windows 10 builds or take a peek at the list back to 2000" /> <meta property="og:description" content="BuildFeed is a collaborative build list for Microsoft Windows. Keep up to date with the latest Windows 10 builds or take a peek at the list back to 2000" />
break; break;
case "Lab": case "lab":
<meta name="description" content="Check out all the known builds to come out of the Windows development lab @ViewBag.ItemId through BuildFeed, a collaborative Windows build list" /> <meta name="description" content="Check out all the known builds to come out of the Windows development lab @ViewBag.ItemId through BuildFeed, a collaborative Windows build list" />
<meta property="og:description" content="Check out all the known builds to come out of the Windows development lab @ViewBag.ItemId through BuildFeed, a collaborative Windows build list" /> <meta property="og:description" content="Check out all the known builds to come out of the Windows development lab @ViewBag.ItemId through BuildFeed, a collaborative Windows build list" />
break; break;
case "Year": case "year":
<meta name="description" content="View a list of all Windows builds compiled in @ViewBag.ViewId, and watch how Windows developed steadily over time, through the collaborative build list, BuildFeed" /> <meta name="description" content="View a list of all Windows builds compiled in @ViewBag.ViewId, and watch how Windows developed steadily over time, through the collaborative build list, BuildFeed" />
<meta property="og:description" content="View a list of all Windows builds compiled in @ViewBag.ViewId, and watch how Windows developed steadily over time, through the collaborative build list, BuildFeed" /> <meta property="og:description" content="View a list of all Windows builds compiled in @ViewBag.ViewId, and watch how Windows developed steadily over time, through the collaborative build list, BuildFeed" />
break; break;
@ -76,14 +60,14 @@
{ {
<li> <li>
<div class="build-head"> <div class="build-head">
@Html.ActionLink("Info", "Info", new { id = item.Id }, new { @class = "btn btn-info btn-xs" }) @Html.ActionLink("Info", "info", new { id = item.Id }, new { @class = "btn btn-info btn-xs" })
@if (User.Identity.IsAuthenticated) @if (User.Identity.IsAuthenticated)
{ {
@Html.ActionLink("Edit", "Edit", new { id = item.Id }, new { @class = "btn btn-default btn-xs" }) @Html.ActionLink("Edit", "edit", new { id = item.Id }, new { @class = "btn btn-default btn-xs" })
} }
@if (User.Identity.Name == "hounsell") @if (User.Identity.Name == "hounsell")
{ {
@Html.ActionLink("Delete", "Delete", new { id = item.Id }, new { @class = "btn btn-danger btn-xs" }) @Html.ActionLink("Delete", "delete", new { id = item.Id }, new { @class = "btn btn-danger btn-xs" })
} }
<h3>@Html.DisplayFor(modelItem => item.FullBuildString)</h3> <h3>@Html.DisplayFor(modelItem => item.FullBuildString)</h3>
</div> </div>
@ -131,7 +115,7 @@
<div id="filter-clear" class="panel-collapse collapse @(ViewBag.Action == "Index" ? "in" : "")"> <div id="filter-clear" class="panel-collapse collapse @(ViewBag.Action == "Index" ? "in" : "")">
<div class="panel-body"> <div class="panel-body">
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
<li>@Html.ActionLink("Clear Filters", "Index", new { page = 1 })</li> <li>@Html.ActionLink("Clear Filters", "index", new { page = 1 })</li>
</ul> </ul>
</div> </div>
</div> </div>
@ -150,7 +134,7 @@
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
@foreach (BuildFeed.Models.BuildVersion ver in BuildFeed.Models.Build.SelectBuildVersions()) @foreach (BuildFeed.Models.BuildVersion ver in BuildFeed.Models.Build.SelectBuildVersions())
{ {
<li><a href="@Url.Action("Version", new { minor = ver.Minor, major = ver.Major, page = 1 })">@string.Format("{0}.{1}", ver.Major, ver.Minor)</a></li> <li><a href="@Url.Action("version", new { minor = ver.Minor, major = ver.Major, page = 1 })">@string.Format("{0}.{1}", ver.Major, ver.Minor)</a></li>
} }
</ul> </ul>
</div> </div>
@ -170,7 +154,7 @@
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
@foreach (string lab in BuildFeed.Models.Build.SelectBuildLabs()) @foreach (string lab in BuildFeed.Models.Build.SelectBuildLabs())
{ {
<li>@Html.ActionLink(lab, "Lab", new { lab = lab, page = 1 })</li> <li>@Html.ActionLink(lab, "lab", new { lab = lab, page = 1 })</li>
} }
</ul> </ul>
</div> </div>
@ -190,7 +174,7 @@
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
@foreach (int year in BuildFeed.Models.Build.SelectBuildYears()) @foreach (int year in BuildFeed.Models.Build.SelectBuildYears())
{ {
<li>@Html.ActionLink(year.ToString(), "Year", new { year = year, page = 1 })</li> <li>@Html.ActionLink(year.ToString(), "year", new { year = year, page = 1 })</li>
} }
</ul> </ul>
</div> </div>
@ -210,7 +194,7 @@
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
@foreach (BuildFeed.Models.TypeOfSource s in Enum.GetValues(typeof(BuildFeed.Models.TypeOfSource)).Cast<BuildFeed.Models.TypeOfSource>().OrderBy(d => d.ToString())) @foreach (BuildFeed.Models.TypeOfSource s in Enum.GetValues(typeof(BuildFeed.Models.TypeOfSource)).Cast<BuildFeed.Models.TypeOfSource>().OrderBy(d => d.ToString()))
{ {
<li><a href="@Url.Action("Source", new { source = s })">@Html.DisplayFor(TypeOfSource => s, "Enumeration")</a></li> <li><a href="@Url.Action("source", new { source = s })">@Html.DisplayFor(TypeOfSource => s, "Enumeration")</a></li>
} }
</ul> </ul>
</div> </div>
@ -230,15 +214,15 @@
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
@if (User.Identity.IsAuthenticated) @if (User.Identity.IsAuthenticated)
{ {
<li>@Html.ActionLink("Add a build", "Create", "build")</li> <li>@Html.ActionLink("Add a build", "create", "build")</li>
<li>&nbsp;</li> <li>&nbsp;</li>
<li>@Html.ActionLink("Change your password", "Password", "support")</li> <li>@Html.ActionLink("Change your password", "password", "support")</li>
<li>@Html.ActionLink("Log out", "Logout", "support")</li> <li>@Html.ActionLink("Log out", "logout", "support")</li>
} }
else else
{ {
<li>@Html.ActionLink("Log in", "Login", "support")</li> <li>@Html.ActionLink("Log in", "login", "support")</li>
<li>@Html.ActionLink("Register", "Register", "support")</li> <li>@Html.ActionLink("Register", "register", "support")</li>
} }
</ul> </ul>
</div> </div>

View File

@ -2,22 +2,4 @@
@model Enum @model Enum
@{ @DisplayHelpers.GetDisplayTextForEnum(ViewData.Model)
Func<object, string> GetDisplayName = o =>
{
var result = null as string;
var display = o.GetType()
.GetMember(o.ToString()).First()
.GetCustomAttributes(false)
.OfType<DisplayAttribute>()
.LastOrDefault();
if (display != null)
{
result = display.GetName();
}
return result ?? o.ToString();
};
}
@GetDisplayName(ViewData.Model)

View File

@ -3,27 +3,11 @@
@model Enum @model Enum
@{ @{
Func<object, string> GetDisplayName = o =>
{
var result = null as string;
var display = o.GetType()
.GetMember(o.ToString()).First()
.GetCustomAttributes(false)
.OfType<DisplayAttribute>()
.LastOrDefault();
if (display != null)
{
result = display.GetName();
}
return result ?? o.ToString();
};
var values = Enum.GetValues(ViewData.ModelMetadata.ModelType).Cast<object>() var values = Enum.GetValues(ViewData.ModelMetadata.ModelType).Cast<object>()
.Select(v => new SelectListItem .Select(v => new SelectListItem
{ {
Selected = v.Equals(Model), Selected = v.Equals(Model),
Text = GetDisplayName(v), Text = DisplayHelpers.GetDisplayTextForEnum(v),
Value = v.ToString() Value = v.ToString()
}); });
} }

View File

@ -8,6 +8,7 @@
<link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,400italic" rel="stylesheet" type="text/css" /> <link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,400italic" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="~/favicon.ico" /> <link rel="shortcut icon" href="~/favicon.ico" />
<link rel="icon" href="~/favicon.ico" /> <link rel="icon" href="~/favicon.ico" />
<link rel="canonical" href="@Url.Action()" />
<meta name="application-name" content="BuildFeed" /> <meta name="application-name" content="BuildFeed" />
@Styles.Render("~/content/css") @Styles.Render("~/content/css")
@ -32,7 +33,7 @@
<header id="page-header"> <header id="page-header">
<div class="row"> <div class="row">
<div class="col-sm-9"> <div class="col-sm-9">
<h1>@Html.ActionLink("BuildFeed", "Index", new { controller = "build", area = "", page = 1 })</h1> <h1>@Html.ActionLink("BuildFeed", "index", new { controller = "build", area = "", page = 1 })</h1>
</div> </div>
<div class="col-sm-3 text-right"> <div class="col-sm-3 text-right">
<p class="social-links"> <p class="social-links">

View File

@ -34,7 +34,7 @@
<header id="page-header"> <header id="page-header">
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
<h1>@Html.ActionLink("BuildFeed", "Index", new { controller = "build", area = "", page = 1 })</h1> <h1>@Html.ActionLink("BuildFeed", "index", new { controller = "build", area = "", page = 1 })</h1>
</div> </div>
</div> </div>
</header> </header>

View File

@ -15,7 +15,7 @@
<package id="Microsoft.AspNet.WebPages" version="3.2.2" targetFramework="net45" /> <package id="Microsoft.AspNet.WebPages" version="3.2.2" targetFramework="net45" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.2" targetFramework="net45" /> <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.2" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" /> <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net45" /> <package id="Newtonsoft.Json" version="6.0.6" targetFramework="net45" />
<package id="NServiceKit.Common" version="1.0.27" targetFramework="net45" /> <package id="NServiceKit.Common" version="1.0.27" targetFramework="net45" />
<package id="NServiceKit.Redis" version="1.0.7" targetFramework="net45" /> <package id="NServiceKit.Redis" version="1.0.7" targetFramework="net45" />
<package id="NServiceKit.Text" version="1.0.10" targetFramework="net45" /> <package id="NServiceKit.Text" version="1.0.10" targetFramework="net45" />