Cleanup; Change badge text for #14

Unleaked / Leaked => Private / Public

It'll probably still confuse people, but to hell with it.
This commit is contained in:
Thomas Hounsell 2015-07-07 11:47:11 +01:00
parent e34a41351c
commit ce74b15e02
24 changed files with 239 additions and 257 deletions

View File

@ -14,12 +14,14 @@
{
RouteValueDictionary rvd = new RouteValueDictionary(rd);
rvd.Remove("page");
<li>@MvcIntrinsics.Html.ActionLink(HttpUtility.HtmlDecode("&laquo;"), view, rvd)</li>
}
else if (currentPage > 2)
{
RouteValueDictionary rvd = new RouteValueDictionary(rd);
rvd["page"] = currentPage - 1;
<li>@MvcIntrinsics.Html.ActionLink(HttpUtility.HtmlDecode("&laquo;"), multiView, rvd)</li>
}
else
@ -37,6 +39,7 @@
{
RouteValueDictionary rvd = new RouteValueDictionary(rd);
rvd["page"] = i;
<li @((i == currentPage) ? "class=active" : "")>@MvcIntrinsics.Html.ActionLink(i.ToString(), multiView, rvd)</li>
}
@ -45,6 +48,7 @@
{
RouteValueDictionary rvd = new RouteValueDictionary(rd);
rvd["page"] = currentPage + 1;
<li>@MvcIntrinsics.Html.ActionLink(HttpUtility.HtmlDecode("&raquo;"), multiView, rvd)</li>
}
else

View File

@ -1,5 +1,4 @@
using System.Web;
using System.Web.Optimization;
using System.Web.Optimization;
namespace BuildFeed
{
@ -9,20 +8,20 @@ public class BundleConfig
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jsrender").Include(
"~/Scripts/jsrender*"));
"~/Scripts/jsrender*"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
"~/Scripts/jquery.validate*"));
bundles.Add(new StyleBundle("~/content/css").Include(
"~/content/style.css"));
"~/content/style.css"));
// Set EnableOptimizations to false for debugging. For more information,
// visit http://go.microsoft.com/fwlink/?LinkId=301862
BundleTable.EnableOptimizations = true;
}
}
}
}

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Configuration;
namespace BuildFeed
{
@ -16,21 +12,21 @@ static DatabaseConfig()
{
Host = ConfigurationManager.AppSettings["data:ServerHost"];
int _port;
bool success = int.TryParse(ConfigurationManager.AppSettings["data:ServerPort"], out _port);
if(!success)
{
_port = 6379; // redis default port
}
Port = _port;
long _db;
success = long.TryParse(ConfigurationManager.AppSettings["data:ServerDB"], out _db);
int port;
bool success = int.TryParse(ConfigurationManager.AppSettings["data:ServerPort"], out port);
if (!success)
{
_db = 0; // redis default db
port = 6379; // redis default port
}
Database = _db;
Port = port;
long db;
success = long.TryParse(ConfigurationManager.AppSettings["data:ServerDB"], out db);
if (!success)
{
db = 0; // redis default db
}
Database = db;
}
}
}

View File

@ -1,13 +1,9 @@
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc;
namespace BuildFeed
{
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); }
}
}
}

View File

@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Http;
namespace BuildFeed
{
@ -13,16 +9,15 @@ public class RouteConfig
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapHttpRoute(
name: "API",
routeTemplate: "api/{action}/{id}",
defaults: new { controller = "api", action = "GetBuilds", id = UrlParameter.Optional }
);
routes.MapHttpRoute("API", "api/{action}/{id}",
new
{
controller = "api",
action = "GetBuilds",
id = UrlParameter.Optional
});
routes.AppendTrailingSlash = true;
routes.MapMvcAttributeRoutes();
}
}
}
}

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc;
using System.Web.Security;
namespace BuildFeed.Areas.admin.Controllers
@ -11,10 +7,7 @@ public class baseController : Controller
{
[Authorize(Roles = "Administrators")]
// GET: admin/base
public ActionResult index()
{
return View();
}
public ActionResult index() { return View(); }
[Authorize(Users = "hounsell")]
public ActionResult setup()

View File

@ -1,10 +1,7 @@
using BuildFeed.Areas.admin.Models.ViewModel;
using BuildFeed.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Linq;
using System.Web.Mvc;
using BuildFeed.Areas.admin.Models.ViewModel;
using BuildFeed.Models;
namespace BuildFeed.Areas.admin.Controllers
{
@ -15,46 +12,48 @@ public class metaController : Controller
public ActionResult index()
{
var currentItems = from i in MetaItem.Select()
group i by i.Id.Type into b
group i by i.Id.Type
into b
select b;
var pendingLabs = MetaItem.SelectUnusedLabs();
return View(new MetaListing()
return View(new MetaListing
{
CurrentItems = from i in MetaItem.Select()
group i by i.Id.Type into b
group i by i.Id.Type
into b
orderby b.Key.ToString()
select b,
NewItems = from i in (from l in MetaItem.SelectUnusedLabs()
select new MetaItem()
select new MetaItem
{
Id = new MetaItemKey()
Id = new MetaItemKey
{
Type = MetaType.Lab,
Value = l
}
}).Concat(
from v in MetaItem.SelectUnusedVersions()
select new MetaItem()
{
Id = new MetaItemKey()
{
Type = MetaType.Version,
Value = v
}
}).Concat(
from y in MetaItem.SelectUnusedYears()
select new MetaItem()
{
Id = new MetaItemKey()
{
Type = MetaType.Year,
Value = y
}
})
group i by i.Id.Type into b
.Concat(from v in MetaItem.SelectUnusedVersions()
select new MetaItem
{
Id = new MetaItemKey
{
Type = MetaType.Version,
Value = v
}
})
.Concat(from y in MetaItem.SelectUnusedYears()
select new MetaItem
{
Id = new MetaItemKey
{
Type = MetaType.Year,
Value = y
}
})
group i by i.Id.Type
into b
orderby b.Key.ToString()
select b
});
@ -62,7 +61,14 @@ select b
public ActionResult create(MetaType type, string value)
{
return View(new MetaItem() { Id = new MetaItemKey() { Type = type, Value = value } });
return View(new MetaItem
{
Id = new MetaItemKey
{
Type = type,
Value = value
}
});
}
[HttpPost]
@ -79,7 +85,11 @@ public ActionResult create(MetaItem meta)
public ActionResult edit(MetaType type, string value)
{
return View("create", MetaItem.SelectById(new MetaItemKey() { Type = type, Value = value }));
return View("create", MetaItem.SelectById(new MetaItemKey
{
Type = type,
Value = value
}));
}
[HttpPost]

View File

@ -1,10 +1,8 @@
using RedisAuth;
using System;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using RedisAuth;
namespace BuildFeed.Areas.admin.Controllers
{
@ -14,16 +12,17 @@ public class usersController : Controller
// GET: admin/users
public ActionResult index()
{
return View(Membership.GetAllUsers().Cast<MembershipUser>().OrderByDescending(m => m.IsApproved).ThenBy(m => m.UserName));
return View(Membership.GetAllUsers()
.Cast<MembershipUser>()
.OrderByDescending(m => m.IsApproved)
.ThenBy(m => m.UserName));
}
public ActionResult admins()
{
List<MembershipUser> admins = new List<MembershipUser>();
foreach (var m in Roles.GetUsersInRole("Administrators"))
{
admins.Add(Membership.GetUser(m));
}
var admins = Roles.GetUsersInRole("Administrators")
.Select(Membership.GetUser)
.ToList();
return View(admins.OrderByDescending(m => m.UserName));
}
@ -42,39 +41,39 @@ public ActionResult demote(string id)
public ActionResult approve(Guid id)
{
var provider = (Membership.Provider as RedisMembershipProvider);
provider.ChangeApproval(id, true);
RedisMembershipProvider provider = (Membership.Provider as RedisMembershipProvider);
provider?.ChangeApproval(id, true);
return RedirectToAction("Index");
}
public ActionResult unapprove(Guid id)
{
var provider = (Membership.Provider as RedisMembershipProvider);
provider.ChangeApproval(id, false);
RedisMembershipProvider provider = (Membership.Provider as RedisMembershipProvider);
provider?.ChangeApproval(id, false);
return RedirectToAction("Index");
}
public ActionResult @lock(Guid id)
{
var provider = (Membership.Provider as RedisMembershipProvider);
provider.ChangeLockStatus(id, true);
RedisMembershipProvider provider = (Membership.Provider as RedisMembershipProvider);
provider?.ChangeLockStatus(id, true);
return RedirectToAction("Index");
}
public ActionResult unlock(Guid id)
{
var provider = (Membership.Provider as RedisMembershipProvider);
provider.ChangeLockStatus(id, false);
RedisMembershipProvider provider = (Membership.Provider as RedisMembershipProvider);
provider?.ChangeLockStatus(id, false);
return RedirectToAction("Index");
}
public ActionResult cleanup()
{
var users = Membership.GetAllUsers();
MembershipUserCollection users = Membership.GetAllUsers();
foreach (MembershipUser user in users)
{
if(!user.IsApproved && (user.CreationDate.AddDays(30) < DateTime.Now))
if (!user.IsApproved && (user.CreationDate.AddDays(30) < DateTime.Now))
{
Membership.DeleteUser(user.UserName);
}

View File

@ -1,17 +1,17 @@
@model BuildFeed.Models.MetaItem
@{
ViewBag.Title = string.Format("Add metadata for {0} | BuildFeed", Model.Id.Value);
ViewBag.Title = $"Add metadata for {Model.Id.Value} | BuildFeed";
}
<h2>@string.Format("Add metadata for {0}", Model.Id.Value)</h2>
<h2>@($"Add metadata for {Model.Id.Value}")</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.HiddenFor(model => model.Id.Type);
@Html.HiddenFor(model => model.Id.Value);
@Html.HiddenFor(model => model.Id.Type)
@Html.HiddenFor(model => model.Id.Value)
<div class="form-horizontal">
<div class="form-group">

View File

@ -1,4 +1,4 @@
@model IEnumerable<System.Web.Security.MembershipUser>
@model IEnumerable<MembershipUser>
@{
ViewBag.Title = "View administrators | BuildFeed";

View File

@ -1,4 +1,4 @@
@model IEnumerable<System.Web.Security.MembershipUser>
@model IEnumerable<MembershipUser>
@{
ViewBag.Title = "Manage users | BuildFeed";
@ -54,24 +54,18 @@
@Html.DisplayFor(modelItem => mu.LastLockoutDate)
</td>
<td class="text-right">
@if (mu.IsApproved)
{
@Html.ActionLink("Unapprove", "unapprove", new { id = mu.ProviderUserKey }, new { @class = "btn btn-danger", style = "width:90px;" })
}
else
{
@Html.ActionLink("Approve", "approve", new { id = mu.ProviderUserKey }, new { @class = "btn btn-success", style = "width:90px;" })
}
@(
mu.IsApproved ?
Html.ActionLink("Unapprove", "unapprove", new { id = mu.ProviderUserKey }, new { @class = "btn btn-danger", style = "width:90px;" }) :
Html.ActionLink("Approve", "approve", new { id = mu.ProviderUserKey }, new { @class = "btn btn-success", style = "width:90px;" })
)
</td>
<td class="text-right">
@if (!mu.IsLockedOut)
{
@Html.ActionLink("Lock", "lock", new { id = mu.ProviderUserKey }, new { @class = "btn btn-danger", style = "width:90px;" })
}
else
{
@Html.ActionLink("Unlock", "unlock", new { id = mu.ProviderUserKey }, new { @class = "btn btn-success", style = "width:90px;" })
}
@(
!mu.IsLockedOut ?
Html.ActionLink("Lock", "lock", new { id = mu.ProviderUserKey }, new { @class = "btn btn-danger", style = "width:90px;" }) :
Html.ActionLink("Unlock", "unlock", new { id = mu.ProviderUserKey }, new { @class = "btn btn-success", style = "width:90px;" })
)
</td>
</tr>
}

View File

@ -18,7 +18,6 @@
<add namespace="System.Web.Routing" />
<add namespace="System.Web.Optimization" />
<add namespace="BuildFeed" />
</namespaces>
</pages>
</system.web.webPages.razor>

View File

@ -4,13 +4,7 @@ namespace BuildFeed.Areas.admin
{
public class adminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "admin";
}
}
public override string AreaName => "admin";
public override void RegisterArea(AreaRegistrationContext context)
{

View File

@ -24,7 +24,7 @@
<ApplicationInsightsResourceId>/subscriptions/4af45631-0e5c-4253-9e38-d0c47f9c5b32/resourcegroups/Default-ApplicationInsights-CentralUS/providers/microsoft.insights/components/BuildFeed</ApplicationInsightsResourceId>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TypeScriptToolsVersion>1.4</TypeScriptToolsVersion>
<TypeScriptToolsVersion>1.5</TypeScriptToolsVersion>
<UseGlobalApplicationHostFile />
<TargetFrameworkProfile />
</PropertyGroup>

View File

@ -16,7 +16,7 @@ public override object BindModel(ControllerContext controllerContext, ModelBindi
success = DateTime.TryParseExact(value.AttemptedValue, "yyMMdd-HHmm", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out retValue);
}
return success ? retValue as DateTime? : null as DateTime?;
return success ? retValue as DateTime? : null;
}
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace BuildFeed
@ -8,8 +7,8 @@ public static class DisplayHelpers
{
public static string GetDisplayTextForEnum(object o)
{
var result = null as string;
var display = o.GetType()
string result = null as string;
DisplayAttribute display = o.GetType()
.GetMember(o.ToString()).First()
.GetCustomAttributes(false)
.OfType<DisplayAttribute>()

View File

@ -1,17 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.WebPages;
namespace BuildFeed.Code
{
public static class MvcIntrinsics
{
public static System.Web.Mvc.HtmlHelper Html => ((System.Web.Mvc.WebViewPage) WebPageContext.Current.Page).Html;
public static HtmlHelper Html => ((WebViewPage) WebPageContext.Current.Page).Html;
public static System.Web.Mvc.AjaxHelper Ajax => ((System.Web.Mvc.WebViewPage) WebPageContext.Current.Page).Ajax;
public static AjaxHelper Ajax => ((WebViewPage) WebPageContext.Current.Page).Ajax;
public static System.Web.Mvc.UrlHelper Url => ((System.Web.Mvc.WebViewPage) WebPageContext.Current.Page).Url;
public static UrlHelper Url => ((WebViewPage) WebPageContext.Current.Page).Url;
}
}

View File

@ -1,13 +1,13 @@
using BuildFeed.Code;
using BuildFeed.Models;
using BuildFeed.Models.ViewModel.Front;
using System;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Linq;
using System.Web.Mvc;
using BuildFeed.Code;
using BuildFeed.Models;
using BuildFeed.Models.ViewModel.Front;
namespace BuildFeed.Controllers
{
@ -19,10 +19,7 @@ public class frontController : Controller
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult index()
{
return indexPage(1);
}
public ActionResult index() { return indexPage(1); }
[Route("page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
@ -31,23 +28,24 @@ public ActionResult index()
public ActionResult indexPage(int page)
{
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 new FrontBuildGroup()
{
Key = bg.Key,
LastBuild = bg.Max(m => m.BuildTime),
BuildCount = bg.Count()
}).ToArray();
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 new FrontBuildGroup
{
Key = bg.Key,
LastBuild = bg.Max(m => m.BuildTime),
BuildCount = bg.Count()
}).ToArray();
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(buildGroups.Length) / Convert.ToDouble(PAGE_SIZE));
@ -67,13 +65,14 @@ bg.Key.Revision descending
public ActionResult viewGroup(byte major, byte minor, ushort number, ushort? revision = null)
{
var builds = (from b in Build.Select()
group b by new BuildGroup()
{
Major = b.MajorVersion,
Minor = b.MinorVersion,
Build = b.Number,
Revision = b.Revision
} into bg
group b by new BuildGroup
{
Major = b.MajorVersion,
Minor = b.MinorVersion,
Build = b.Number,
Revision = b.Revision
}
into bg
where bg.Key.Major == major
where bg.Key.Minor == minor
where bg.Key.Build == number
@ -81,8 +80,8 @@ public ActionResult viewGroup(byte major, byte minor, ushort number, ushort? rev
select bg).Single();
return builds.Count() == 1 ?
RedirectToAction("viewBuild", new { id = builds.Single().Id }) as ActionResult :
View(builds);
RedirectToAction("viewBuild", new {id = builds.Single().Id}) as ActionResult :
View(builds);
}
[Route("build/{id}/", Name = "Build")]
@ -105,25 +104,27 @@ public ActionResult twitterCard(long id)
Build b = Build.SelectById(id);
using (Bitmap bm = new Bitmap(560, 300))
using (Graphics gr = Graphics.FromImage(bm))
{
GraphicsPath gp = new GraphicsPath();
gr.CompositingMode = CompositingMode.SourceOver;
gr.CompositingQuality = CompositingQuality.HighQuality;
gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
gr.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
gr.SmoothingMode = SmoothingMode.HighQuality;
gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
using (Graphics gr = Graphics.FromImage(bm))
{
GraphicsPath gp = new GraphicsPath();
gr.CompositingMode = CompositingMode.SourceOver;
gr.CompositingQuality = CompositingQuality.HighQuality;
gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
gr.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
gr.SmoothingMode = SmoothingMode.HighQuality;
gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
gr.FillRectangle(new SolidBrush(Color.FromArgb(0x30, 0x30, 0x30)), 0, 0, 560, 300);
gp.AddString("BUILDFEED", new FontFamily("Segoe UI"), (int)FontStyle.Bold, 16, new Point(20, 20), StringFormat.GenericTypographic);
gp.AddString($"Windows NT {b.MajorVersion}.{b.MinorVersion} build", new FontFamily("Segoe UI"), 0, 24, new Point(20, 40), StringFormat.GenericTypographic);
gp.AddString(b.Number.ToString(), new FontFamily("Segoe UI Light"), 0, 180, new Point(12, 20), StringFormat.GenericTypographic);
gp.AddString($"{b.Lab}", new FontFamily("Segoe UI"), 0, 40, new Point(16, 220), StringFormat.GenericTypographic);
gr.FillPath(Brushes.White, gp);
gr.FillRectangle(new SolidBrush(Color.FromArgb(0x30, 0x30, 0x30)), 0, 0, 560, 300);
gp.AddString("BUILDFEED", new FontFamily("Segoe UI"), (int) FontStyle.Bold, 16, new Point(20, 20), StringFormat.GenericTypographic);
gp.AddString($"Windows NT {b.MajorVersion}.{b.MinorVersion} build", new FontFamily("Segoe UI"), 0, 24, new Point(20, 40), StringFormat.GenericTypographic);
gp.AddString(b.Number.ToString(), new FontFamily("Segoe UI Light"), 0, 180, new Point(12, 20), StringFormat.GenericTypographic);
gp.AddString($"{b.Lab}", new FontFamily("Segoe UI"), 0, 40, new Point(16, 220), StringFormat.GenericTypographic);
gr.FillPath(Brushes.White, gp);
Response.ContentType = "image/png";
bm.Save(Response.OutputStream, ImageFormat.Png);
Response.ContentType = "image/png";
bm.Save(Response.OutputStream, ImageFormat.Png);
}
}
return new EmptyResult();
@ -133,10 +134,7 @@ public ActionResult twitterCard(long id)
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult viewLab(string lab)
{
return viewLabPage(lab, 1);
}
public ActionResult viewLab(string lab) { return viewLabPage(lab, 1); }
[Route("lab/{lab}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
@ -144,7 +142,11 @@ public ActionResult viewLab(string lab)
#endif
public ActionResult viewLabPage(string lab, int page)
{
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey() { Type = MetaType.Lab, Value = lab });
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey
{
Type = MetaType.Lab,
Value = lab
});
ViewBag.ItemId = lab;
var builds = Build.SelectInBuildOrder().Where(b => b.Lab != null && (b.Lab.ToLower() == lab.ToLower())).ToArray();
@ -164,10 +166,7 @@ public ActionResult viewLabPage(string lab, int page)
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult viewSource(TypeOfSource source)
{
return viewSourcePage(source, 1);
}
public ActionResult viewSource(TypeOfSource source) { return viewSourcePage(source, 1); }
[Route("source/{source}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
@ -175,7 +174,11 @@ public ActionResult viewSource(TypeOfSource source)
#endif
public ActionResult viewSourcePage(TypeOfSource source, int page)
{
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey() { Type = MetaType.Source, Value = source.ToString() });
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey
{
Type = MetaType.Source,
Value = source.ToString()
});
ViewBag.ItemId = DisplayHelpers.GetDisplayTextForEnum(source);
var builds = Build.SelectInBuildOrder().Where(b => b.SourceType == source).ToArray();
@ -195,10 +198,7 @@ public ActionResult viewSourcePage(TypeOfSource source, int page)
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult viewYear(int year)
{
return viewYearPage(year, 1);
}
public ActionResult viewYear(int year) { return viewYearPage(year, 1); }
[Route("year/{year}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
@ -206,7 +206,11 @@ public ActionResult viewYear(int year)
#endif
public ActionResult viewYearPage(int year, int page)
{
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey() { Type = MetaType.Year, Value = year.ToString() });
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey
{
Type = MetaType.Year,
Value = year.ToString()
});
ViewBag.ItemId = year.ToString();
var builds = Build.SelectInBuildOrder().Where(b => b.BuildTime.HasValue && b.BuildTime.Value.Year == year).ToArray();
@ -226,10 +230,7 @@ public ActionResult viewYearPage(int year, int page)
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult viewVersion(int major, int minor)
{
return viewVersionPage(major, minor, 1);
}
public ActionResult viewVersion(int major, int minor) { return viewVersionPage(major, minor, 1); }
[Route("version/{major}.{minor}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
@ -238,7 +239,11 @@ public ActionResult viewVersion(int major, int minor)
public ActionResult viewVersionPage(int major, int minor, int page)
{
string valueString = $"{major}.{minor}";
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey() { Type = MetaType.Version, Value = valueString });
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey
{
Type = MetaType.Version,
Value = valueString
});
ViewBag.ItemId = valueString;
var builds = Build.SelectInBuildOrder().Where(b => b.MajorVersion == major && b.MinorVersion == minor).ToArray();
@ -255,10 +260,7 @@ public ActionResult viewVersionPage(int major, int minor, int page)
}
[Route("add/"), Authorize]
public ActionResult addBuild()
{
return View("editBuild");
}
public ActionResult addBuild() { return View("editBuild"); }
[Route("add/"), Authorize, HttpPost]
public ActionResult addBuild(Build build)
@ -275,12 +277,12 @@ public ActionResult addBuild(Build build)
{
return View("editBuild", build);
}
return RedirectToAction("viewBuild", new { id = build.Id });
}
else
{
return View("editBuild", build);
return RedirectToAction("viewBuild", new
{
id = build.Id
});
}
return View("editBuild", build);
}
[Route("edit/{id}/"), Authorize]
@ -306,10 +308,7 @@ public ActionResult editBuild(long id, Build build)
return RedirectToAction("viewBuild", new { id = build.Id });
}
else
{
return View(build);
}
return View(build);
}
[Route("delete/{id}/"), Authorize(Roles = "Administrators")]

View File

@ -32,10 +32,10 @@ public ActionResult login(LoginUser ru)
var ticket = new FormsAuthenticationTicket(ru.UserName, true, expiryLength);
var encryptedTicket = FormsAuthentication.Encrypt(ticket);
var cookieTicket = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
{
Expires = DateTime.Now.AddMinutes(expiryLength),
Path = FormsAuthentication.FormsCookiePath
};
{
Expires = DateTime.Now.AddMinutes(expiryLength),
Path = FormsAuthentication.FormsCookiePath
};
Response.Cookies.Add(cookieTicket);
string returnUrl = string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]) ? "/" : Request.QueryString["ReturnUrl"];
@ -142,7 +142,7 @@ public ActionResult sitemap()
Dictionary<string, SitemapPagedAction[]> actions = new Dictionary<string, SitemapPagedAction[]>
{
{
"Pages", new SitemapPagedAction[]
"Pages", new[]
{
new SitemapPagedAction()
{
@ -325,14 +325,18 @@ public ActionResult stats()
List<MonthCount> additions = new List<MonthCount>();
var rawAdditions = (from b in builds
where b.Added > DateTime.Now.AddYears(-1)
group b by new { Year = b.Added.Year, Week = Convert.ToInt32(Math.Floor(b.Added.DayOfYear / 7m)) } into bm
select new MonthCount()
{
Month = bm.Key.Week,
Year = bm.Key.Year,
Count = bm.Count()
}).ToArray();
where b.Added > DateTime.Now.AddYears(-1)
group b by new
{
Year = b.Added.Year,
Week = Convert.ToInt32(Math.Floor(b.Added.DayOfYear / 7m))
} into bm
select new MonthCount()
{
Month = bm.Key.Week,
Year = bm.Key.Year,
Count = bm.Count()
}).ToArray();
for (int i = -52; i <= 0; i++)
{
@ -348,7 +352,11 @@ public ActionResult stats()
List<MonthCount> compiles = new List<MonthCount>();
var rawCompiles = from b in builds
where b.BuildTime.HasValue
group b by new { Year = b.BuildTime.Value.Year, Month = Convert.ToInt32(Math.Floor((b.BuildTime.Value.Month - 0.1m) / 3m) * 3) + 1 } into bm
group b by new
{
Year = b.BuildTime.Value.Year,
Month = Convert.ToInt32(Math.Floor((b.BuildTime.Value.Month - 0.1m) / 3m) * 3) + 1
} into bm
select new MonthCount()
{
Month = bm.Key.Month,

View File

@ -32,11 +32,11 @@
<p>
@if (build.IsLeaked)
{
<span class="label label-success label-build-status">Leaked</span>
<span class="label label-success label-build-status">Public</span>
}
else
{
<span class="label label-danger label-build-status">Unleaked</span>
<span class="label label-danger label-build-status">Private</span>
}
</p>
</div>

View File

@ -58,11 +58,11 @@
<p>
@if (build.IsLeaked)
{
<span class="label label-success label-build-status">Leaked</span>
<span class="label label-success label-build-status">Public</span>
}
else
{
<span class="label label-danger label-build-status">Unleaked</span>
<span class="label label-danger label-build-status">Private</span>
}
</p>
</div>

View File

@ -57,11 +57,11 @@
<p>
@if (build.IsLeaked)
{
<span class="label label-success label-build-status">Leaked</span>
<span class="label label-success label-build-status">Public</span>
}
else
{
<span class="label label-danger label-build-status">Unleaked</span>
<span class="label label-danger label-build-status">Private</span>
}
</p>
</div>

View File

@ -57,11 +57,11 @@
<p>
@if (build.IsLeaked)
{
<span class="label label-success label-build-status">Leaked</span>
<span class="label label-success label-build-status">Public</span>
}
else
{
<span class="label label-danger label-build-status">Unleaked</span>
<span class="label label-danger label-build-status">Private</span>
}
</p>
</div>

View File

@ -62,11 +62,11 @@
<p>
@if (build.IsLeaked)
{
<span class="label label-success label-build-status">Leaked</span>
<span class="label label-success label-build-status">Public</span>
}
else
{
<span class="label label-danger label-build-status">Unleaked</span>
<span class="label label-danger label-build-status">Private</span>
}
</p>
</div>