mirror of
https://gitlab.com/buildfeed/BuildFeed.git
synced 2024-03-22 21:10:34 +08:00
Refresh Pt 5e
the build controller is finally gone!
This commit is contained in:
parent
f070d2a5cd
commit
1b625408d9
|
@ -43,7 +43,15 @@ orderby b.Key.ToString()
|
|||
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
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
}
|
||||
|
||||
<h2>Manage metadata</h2>
|
||||
<ul>
|
||||
<li>@Html.ActionLink("Manage users", "index")</li>
|
||||
<li>@Html.ActionLink("Return to admin panel", "index", "base")</li>
|
||||
</ul>
|
||||
<h3>Current items</h3>
|
||||
<table class="table table-striped table-bordered table-admin">
|
||||
<thead>
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
<th>
|
||||
Email Address
|
||||
</th>
|
||||
<td>
|
||||
Registration Time
|
||||
</td>
|
||||
<td>
|
||||
Last Login Time
|
||||
</td>
|
||||
|
@ -41,6 +44,9 @@
|
|||
<td>
|
||||
@Html.DisplayFor(modelItem => mu.Email)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => mu.CreationDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => mu.LastLoginDate)
|
||||
</td>
|
||||
|
|
|
@ -173,7 +173,6 @@
|
|||
<Compile Include="Areas\admin\adminAreaRegistration.cs" />
|
||||
<Compile Include="Areas\admin\Controllers\usersController.cs" />
|
||||
<Compile Include="Controllers\apiController.cs" />
|
||||
<Compile Include="Controllers\buildController.cs" />
|
||||
<Compile Include="Controllers\frontController.cs" />
|
||||
<Compile Include="Controllers\rssController.cs" />
|
||||
<Compile Include="Controllers\supportController.cs" />
|
||||
|
@ -310,6 +309,8 @@
|
|||
<Content Include="Views\front\viewBuild.cshtml" />
|
||||
<Content Include="Views\front\viewLab.cshtml" />
|
||||
<Content Include="Views\front\viewSource.cshtml" />
|
||||
<Content Include="Views\front\viewYear.cshtml" />
|
||||
<Content Include="Views\front\viewVersion.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
using BuildFeed.Models;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace BuildFeed.Controllers
|
||||
{
|
||||
public class buildController : Controller
|
||||
{
|
||||
public static int pageSize { get { return 25; } }
|
||||
//
|
||||
// GET: /build/
|
||||
|
||||
public ActionResult index(int page = 1)
|
||||
{
|
||||
return RedirectToActionPermanent("index", "front");
|
||||
}
|
||||
|
||||
public ActionResult year(int year, int page = 1)
|
||||
{
|
||||
var builds = Build.SelectInBuildOrder().Where(b => b.BuildTime.HasValue && b.BuildTime.Value.Year == year);
|
||||
var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize);
|
||||
|
||||
ViewBag.PageNumber = page;
|
||||
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(pageSize));
|
||||
|
||||
return View("index", pageBuilds);
|
||||
}
|
||||
|
||||
public ActionResult lab(string lab, int page = 1)
|
||||
{
|
||||
return RedirectToActionPermanent("viewLab", "front", new { lab = lab });
|
||||
}
|
||||
|
||||
public ActionResult version(int major, int minor, int page = 1)
|
||||
{
|
||||
var builds = Build.SelectInBuildOrder().Where(b => b.MajorVersion == major && b.MinorVersion == minor);
|
||||
var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize);
|
||||
|
||||
ViewBag.PageNumber = page;
|
||||
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(pageSize));
|
||||
|
||||
return View("index", pageBuilds);
|
||||
}
|
||||
|
||||
public ActionResult source(TypeOfSource source, int page = 1)
|
||||
{
|
||||
var builds = Build.SelectInBuildOrder().Where(b => b.SourceType == source);
|
||||
var pageBuilds = builds.Skip((page - 1) * pageSize).Take(pageSize);
|
||||
|
||||
ViewBag.PageNumber = page;
|
||||
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(pageSize));
|
||||
|
||||
return View("index", pageBuilds);
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /build/Info/5
|
||||
|
||||
public ActionResult info(int id)
|
||||
{
|
||||
return RedirectToActionPermanent("viewBuild", "front", new { id = id });
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ namespace BuildFeed.Controllers
|
|||
{
|
||||
public class frontController : Controller
|
||||
{
|
||||
private const int _pageSize = 84;
|
||||
public const int _pageSize = 84;
|
||||
|
||||
[Route("", Order = 1)]
|
||||
#if !DEBUG
|
||||
|
@ -114,6 +114,33 @@ public ActionResult viewSource(TypeOfSource source)
|
|||
return View(builds);
|
||||
}
|
||||
|
||||
[Route("year/{year}/")]
|
||||
#if !DEBUG
|
||||
[OutputCache(Duration = 600, VaryByParam = "none")]
|
||||
#endif
|
||||
public ActionResult viewYear(int year)
|
||||
{
|
||||
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);
|
||||
return View(builds);
|
||||
}
|
||||
|
||||
[Route("version/{major}.{minor}/")]
|
||||
#if !DEBUG
|
||||
[OutputCache(Duration = 600, VaryByParam = "none")]
|
||||
#endif
|
||||
public ActionResult viewVersion(int major, int minor)
|
||||
{
|
||||
string valueString = string.Format("{0}.{1}", major, minor);
|
||||
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);
|
||||
return View(builds);
|
||||
}
|
||||
|
||||
[Route("add/"), Authorize]
|
||||
public ActionResult addBuild()
|
||||
{
|
||||
|
|
|
@ -145,7 +145,7 @@ public ActionResult sitemap()
|
|||
action = "index",
|
||||
page = 1
|
||||
}),
|
||||
Pages = (builds.Count() + (buildController.pageSize - 1)) / buildController.pageSize
|
||||
Pages = (builds.Count() + (frontController._pageSize - 1)) / frontController._pageSize
|
||||
} });
|
||||
|
||||
actions.Add("Versions", (from b in builds
|
||||
|
@ -163,7 +163,7 @@ bv.Key.Minor descending
|
|||
minor = bv.Key.Minor,
|
||||
page = 1
|
||||
}),
|
||||
Pages = (bv.Count() + (buildController.pageSize - 1)) / buildController.pageSize
|
||||
Pages = (bv.Count() + (frontController._pageSize - 1)) / frontController._pageSize
|
||||
}).ToArray());
|
||||
|
||||
actions.Add("Labs", (from b in builds
|
||||
|
@ -180,7 +180,7 @@ orderby bv.Key
|
|||
lab = bv.Key,
|
||||
page = 1
|
||||
}),
|
||||
Pages = (bv.Count() + (buildController.pageSize - 1)) / buildController.pageSize
|
||||
Pages = (bv.Count() + (frontController._pageSize - 1)) / frontController._pageSize
|
||||
}).ToArray());
|
||||
|
||||
actions.Add("Years", (from b in builds
|
||||
|
@ -197,7 +197,7 @@ orderby bv.Key
|
|||
year = bv.Key,
|
||||
page = 1
|
||||
}),
|
||||
Pages = (bv.Count() + (buildController.pageSize - 1)) / buildController.pageSize
|
||||
Pages = (bv.Count() + (frontController._pageSize - 1)) / frontController._pageSize
|
||||
}).ToArray());
|
||||
|
||||
actions.Add("Sources", (from b in builds
|
||||
|
@ -213,7 +213,7 @@ orderby bv.Key
|
|||
source = bv.Key,
|
||||
page = 1
|
||||
}),
|
||||
Pages = (bv.Count() + (buildController.pageSize - 1)) / buildController.pageSize
|
||||
Pages = (bv.Count() + (frontController._pageSize - 1)) / frontController._pageSize
|
||||
}).ToArray());
|
||||
|
||||
SitemapData model = new SitemapData()
|
||||
|
|
|
@ -98,6 +98,25 @@ public static IEnumerable<string> SelectUnusedVersions()
|
|||
}
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select, false)]
|
||||
public static IEnumerable<string> SelectUnusedYears()
|
||||
{
|
||||
|
||||
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
||||
{
|
||||
var client = rClient.As<MetaItem>();
|
||||
var years = Build.SelectBuildYears();
|
||||
|
||||
var usedYears = from u in client.GetAll()
|
||||
where u.Id.Type == MetaType.Year
|
||||
select u;
|
||||
|
||||
return from y in years
|
||||
where !usedYears.Any(ul => ul.Id.Value == y.ToString())
|
||||
select y.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Insert, true)]
|
||||
public static void Insert(MetaItem item)
|
||||
{
|
||||
|
@ -161,6 +180,7 @@ public enum MetaType
|
|||
{
|
||||
Lab,
|
||||
Version,
|
||||
Source
|
||||
Source,
|
||||
Year
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("BuildFeed")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015, Thomas Hounsell")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
{
|
||||
<time datetime="@Model.BuildTime.Value.ToString("yyyy-MM-dd HH:mm")" title="@Model.BuildTime.Value.ToString("h:mm tt on dddd, d MMMM yyyy")">@Html.DisplayFor(model => model.BuildTime, "{0:yyMMdd-HHmm}")</time>
|
||||
<br />
|
||||
<a href="@Url.Action("year", new { year = Model.BuildTime.Value.Year })" class="more-link"><i class="fa fa-plus-square-o fa-sm"></i> Find more builds compiled in @Model.BuildTime.Value.Year</a>
|
||||
<a href="@Url.Action("viewYear", new { year = Model.BuildTime.Value.Year })" class="more-link"><i class="fa fa-plus-square-o fa-sm"></i> Find more builds compiled in @Model.BuildTime.Value.Year</a>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
|
|
68
Views/front/viewVersion.cshtml
Normal file
68
Views/front/viewVersion.cshtml
Normal file
|
@ -0,0 +1,68 @@
|
|||
@model IEnumerable<BuildFeed.Models.Build>
|
||||
@using Humanizer;
|
||||
@{
|
||||
ViewBag.Title = string.Format("Windows NT {0} | BuildFeed", ViewBag.ItemId);
|
||||
}
|
||||
|
||||
@section head
|
||||
{
|
||||
@if (ViewBag.MetaItem != null)
|
||||
{
|
||||
<meta name="description" content="@ViewBag.MetaItem.MetaDescription" />
|
||||
<meta property="og:description" content="@ViewBag.MetaItem.MetaDescription" />
|
||||
}
|
||||
}
|
||||
|
||||
<h2>@string.Format("Windows NT {0}", ViewBag.ItemId)</h2>
|
||||
@if (ViewBag.MetaItem != null && !string.IsNullOrWhiteSpace(ViewBag.MetaItem.PageContent))
|
||||
{
|
||||
<h3>About</h3>
|
||||
@Html.Raw(ViewBag.MetaItem.PageContent)
|
||||
}
|
||||
<h3>Share</h3>
|
||||
<div class="addthis_sharing_toolbox"></div>
|
||||
<h3>Listing</h3>
|
||||
<div class="row">
|
||||
@foreach (var build in Model)
|
||||
{
|
||||
<div class="col-sm-3">
|
||||
<h3 class="build-group-title">@string.Format("{0}.{1}.{2}.{3}", build.MajorVersion, build.MinorVersion, build.Number, build.Revision)</h3>
|
||||
<p>
|
||||
<a href="@Url.Action("viewBuild", new { id = build.Id })" class="btn btn-info btn-xs">Info</a>
|
||||
@if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
<a href="@Url.Action("editBuild", new { id = build.Id })" class="btn btn-primary btn-xs">Edit</a>
|
||||
if (Roles.IsUserInRole("Administrators"))
|
||||
{
|
||||
<a href="@Url.Action("deleteBuild", new { id = build.Id })" class="btn btn-danger btn-xs">Delete</a>
|
||||
}
|
||||
}
|
||||
</p>
|
||||
<p>
|
||||
@if (!string.IsNullOrEmpty(build.Lab))
|
||||
{
|
||||
<span><i class="fa fa-code-fork fa-fw"></i> @build.Lab</span><br />
|
||||
}
|
||||
@if (build.BuildTime.HasValue)
|
||||
{
|
||||
<span title="@build.BuildTime.Value.Humanize()"><i class="fa fa-calendar fa-fw"></i> @build.BuildTime.Value.ToString("d MMMM yyyy")</span><br />
|
||||
<span title="@build.BuildTime.Value.Humanize()"><i class="fa fa-clock-o fa-fw"></i> @build.BuildTime.Value.ToString("h:mm tt")</span><br />
|
||||
}
|
||||
</p>
|
||||
<p>
|
||||
@if (build.IsLeaked)
|
||||
{
|
||||
<span class="label label-success label-build-status">Leaked</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="label label-danger label-build-status">Unleaked</span>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@section scripts
|
||||
{
|
||||
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5431719a661cbfd0" async="async"></script>
|
||||
}
|
73
Views/front/viewYear.cshtml
Normal file
73
Views/front/viewYear.cshtml
Normal file
|
@ -0,0 +1,73 @@
|
|||
@model IEnumerable<BuildFeed.Models.Build>
|
||||
@using Humanizer;
|
||||
@{
|
||||
ViewBag.Title = string.Format("Builds from {0} | BuildFeed", ViewBag.ItemId);
|
||||
}
|
||||
|
||||
@section head
|
||||
{
|
||||
@if (ViewBag.MetaItem != null)
|
||||
{
|
||||
<meta name="description" content="@ViewBag.MetaItem.MetaDescription" />
|
||||
<meta property="og:description" content="@ViewBag.MetaItem.MetaDescription" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<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" />
|
||||
}
|
||||
}
|
||||
|
||||
<h2>@string.Format("Builds from {0}", ViewBag.ItemId)</h2>
|
||||
@if (ViewBag.MetaItem != null && !string.IsNullOrWhiteSpace(ViewBag.MetaItem.PageContent))
|
||||
{
|
||||
<h3>About</h3>
|
||||
@Html.Raw(ViewBag.MetaItem.PageContent)
|
||||
}
|
||||
<h3>Share</h3>
|
||||
<div class="addthis_sharing_toolbox"></div>
|
||||
<h3>Listing</h3>
|
||||
<div class="row">
|
||||
@foreach (var build in Model)
|
||||
{
|
||||
<div class="col-sm-3">
|
||||
<h3 class="build-group-title">@string.Format("{0}.{1}.{2}.{3}", build.MajorVersion, build.MinorVersion, build.Number, build.Revision)</h3>
|
||||
<p>
|
||||
<a href="@Url.Action("viewBuild", new { id = build.Id })" class="btn btn-info btn-xs">Info</a>
|
||||
@if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
<a href="@Url.Action("editBuild", new { id = build.Id })" class="btn btn-primary btn-xs">Edit</a>
|
||||
if (Roles.IsUserInRole("Administrators"))
|
||||
{
|
||||
<a href="@Url.Action("deleteBuild", new { id = build.Id })" class="btn btn-danger btn-xs">Delete</a>
|
||||
}
|
||||
}
|
||||
</p>
|
||||
<p>
|
||||
@if (!string.IsNullOrEmpty(build.Lab))
|
||||
{
|
||||
<span><i class="fa fa-code-fork fa-fw"></i> @build.Lab</span><br />
|
||||
}
|
||||
@if (build.BuildTime.HasValue)
|
||||
{
|
||||
<span title="@build.BuildTime.Value.Humanize()"><i class="fa fa-calendar fa-fw"></i> @build.BuildTime.Value.ToString("d MMMM yyyy")</span><br />
|
||||
<span title="@build.BuildTime.Value.Humanize()"><i class="fa fa-clock-o fa-fw"></i> @build.BuildTime.Value.ToString("h:mm tt")</span><br />
|
||||
}
|
||||
</p>
|
||||
<p>
|
||||
@if (build.IsLeaked)
|
||||
{
|
||||
<span class="label label-success label-build-status">Leaked</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="label label-danger label-build-status">Unleaked</span>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@section scripts
|
||||
{
|
||||
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5431719a661cbfd0" async="async"></script>
|
||||
}
|
|
@ -47,6 +47,18 @@
|
|||
<div class="container">
|
||||
@Html.ActionLink("BuildFeed", "index", new { controller = "front", area = "" }, new { @class = "navbar-brand" })
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
@if (!User.Identity.IsAuthenticated)
|
||||
{
|
||||
<li><a href="@Url.Action("login", new { controller = "support", area = "" }) " title="Log in"><i class="fa fa-user"></i> Log in</a></li>
|
||||
}
|
||||
else if (Roles.IsUserInRole("Administrators"))
|
||||
{
|
||||
<li><a href="@Url.Action("index", new { controller = "base", area = "admin" }) " title="Admin"><i class="fa fa-cogs"></i> Admin</a></li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li><a href="@Url.Action("logout", new { controller = "support", area = "" }) " title="Log out"><i class="fa fa-user"></i> Log out</a></li>
|
||||
}
|
||||
<li><a href="@Url.Action("stats", new { controller = "support", area = "" }) " title="Statistics"><i class="fa fa-line-chart"></i> Statistics</a></li>
|
||||
<li><a href="@Url.Action("rss", new { controller = "support", area = "" })" title="RSS Feeds"><i class="fa fa-rss"></i> RSS Feeds</a></li>
|
||||
<li><a href="https://twitter.com/buildfeed" title="Twitter" target="_blank"><i class="fa fa-twitter"></i> Twitter</a></li>
|
||||
|
|
Loading…
Reference in New Issue
Block a user