diff --git a/BuildFeed.Local/InvariantTerms.cs b/BuildFeed.Local/InvariantTerms.cs index 8709c74..ecac936 100644 --- a/BuildFeed.Local/InvariantTerms.cs +++ b/BuildFeed.Local/InvariantTerms.cs @@ -1,11 +1,11 @@ - // ReSharper disable InconsistentNaming +// ReSharper disable InconsistentNaming namespace BuildFeed.Local { public class InvariantTerms { - public const string SiteName = "BuildFeed"; public const string DeveloperName = "Thomas Hounsell"; public const string ProductName = "Windows NT"; + public const string SiteName = "BuildFeed"; } } \ No newline at end of file diff --git a/BuildFeed.Model/Build.cs b/BuildFeed.Model/Build.cs index 92decb3..721438d 100644 --- a/BuildFeed.Model/Build.cs +++ b/BuildFeed.Model/Build.cs @@ -11,10 +11,12 @@ namespace BuildFeed.Model { - [DataObject, BsonIgnoreExtraElements] + [DataObject] + [BsonIgnoreExtraElements] public class Build { - [Key, BsonId] + [Key] + [BsonId] public Guid Id { get; set; } public long? LegacyId { get; set; } @@ -66,7 +68,7 @@ public class Build public string LabUrl { get; set; } - public bool IsLeaked => SourceType == TypeOfSource.PublicRelease || SourceType == TypeOfSource.InternalLeak || SourceType == TypeOfSource.UpdateGDR || SourceType == TypeOfSource.UpdateLDR; + public bool IsLeaked => (SourceType == TypeOfSource.PublicRelease) || (SourceType == TypeOfSource.InternalLeak) || (SourceType == TypeOfSource.UpdateGDR) || (SourceType == TypeOfSource.UpdateLDR); public string FullBuildString { @@ -154,8 +156,8 @@ public ProjectFamily Family { return ProjectFamily.Windows7; } - if (MajorVersion == 6 - && Number >= 5000) + if ((MajorVersion == 6) + && (Number >= 5000)) { return ProjectFamily.WindowsVista; } @@ -163,18 +165,18 @@ public ProjectFamily Family { return ProjectFamily.Longhorn; } - if (MajorVersion == 5 - && Number >= 3000) + if ((MajorVersion == 5) + && (Number >= 3000)) { return ProjectFamily.Server2003; } - if (MajorVersion == 5 - && Number >= 2205) + if ((MajorVersion == 5) + && (Number >= 2205)) { return ProjectFamily.WindowsXP; } - if (MajorVersion == 5 - && MinorVersion == 50) + if ((MajorVersion == 5) + && (MinorVersion == 50)) { return ProjectFamily.Neptune; } diff --git a/BuildFeed.Model/BuildRepository-Version.cs b/BuildFeed.Model/BuildRepository-Version.cs index 3d44b98..71474c7 100644 --- a/BuildFeed.Model/BuildRepository-Version.cs +++ b/BuildFeed.Model/BuildRepository-Version.cs @@ -16,10 +16,10 @@ public async Task SelectAllVersions(int limit = -1, int skip = 0 new BsonElement(nameof(BuildVersion.Major), $"${nameof(Build.MajorVersion)}"), new BsonElement(nameof(BuildVersion.Minor), $"${nameof(Build.MinorVersion)}") })).Sort(new BsonDocument - { - new BsonElement($"_id.{nameof(BuildVersion.Major)}", -1), - new BsonElement($"_id.{nameof(BuildVersion.Minor)}", -1) - }).Skip(skip); + { + new BsonElement($"_id.{nameof(BuildVersion.Major)}", -1), + new BsonElement($"_id.{nameof(BuildVersion.Minor)}", -1) + }).Skip(skip); if (limit > 0) { diff --git a/BuildFeed.Model/BuildRepository-Year.cs b/BuildFeed.Model/BuildRepository-Year.cs index 3b1b4c3..0ebd77d 100644 --- a/BuildFeed.Model/BuildRepository-Year.cs +++ b/BuildFeed.Model/BuildRepository-Year.cs @@ -53,8 +53,8 @@ public async Task> SelectYear(int year, int limit = -1, int skip = 0 public async Task SelectYearCount(int year) => - await - _buildCollection.CountAsync(Builders.Filter.And(Builders.Filter.Gte(b => b.BuildTime, new DateTime(year, 1, 1, 0, 0, 0, DateTimeKind.Utc)), - Builders.Filter.Lte(b => b.BuildTime, new DateTime(year, 12, 31, 23, 59, 59, DateTimeKind.Utc)))); + await + _buildCollection.CountAsync(Builders.Filter.And(Builders.Filter.Gte(b => b.BuildTime, new DateTime(year, 1, 1, 0, 0, 0, DateTimeKind.Utc)), + Builders.Filter.Lte(b => b.BuildTime, new DateTime(year, 12, 31, 23, 59, 59, DateTimeKind.Utc)))); } } \ No newline at end of file diff --git a/BuildFeed.Model/BuildRepository.cs b/BuildFeed.Model/BuildRepository.cs index 5125b43..6f2fdee 100644 --- a/BuildFeed.Model/BuildRepository.cs +++ b/BuildFeed.Model/BuildRepository.cs @@ -232,7 +232,7 @@ public async Task Insert(Build item) [DataObjectMethod(DataObjectMethodType.Insert, false)] public async Task InsertAll(IEnumerable items) { - List generatedItems = new List(); + var generatedItems = new List(); foreach (Build item in items) { item.Id = Guid.NewGuid(); diff --git a/BuildFeed.Model/MetaItem.cs b/BuildFeed.Model/MetaItem.cs index 378e77f..faac284 100644 --- a/BuildFeed.Model/MetaItem.cs +++ b/BuildFeed.Model/MetaItem.cs @@ -31,9 +31,9 @@ public class MetaItemModel public class MetaItem { private const string META_COLLECTION_NAME = "metaitem"; + private readonly BuildRepository _bModel; private readonly IMongoCollection _metaCollection; - private readonly BuildRepository _bModel; public MetaItem() { @@ -57,13 +57,22 @@ public MetaItem() } [DataObjectMethod(DataObjectMethodType.Select, false)] - public async Task> Select() { return await _metaCollection.Find(new BsonDocument()).ToListAsync(); } + public async Task> Select() + { + return await _metaCollection.Find(new BsonDocument()).ToListAsync(); + } [DataObjectMethod(DataObjectMethodType.Select, true)] - public async Task> SelectByType(MetaType type) { return await _metaCollection.Find(f => f.Id.Type == type).ToListAsync(); } + public async Task> SelectByType(MetaType type) + { + return await _metaCollection.Find(f => f.Id.Type == type).ToListAsync(); + } [DataObjectMethod(DataObjectMethodType.Select, false)] - public async Task SelectById(MetaItemKey id) { return await _metaCollection.Find(f => f.Id.Type == id.Type && f.Id.Value == id.Value).SingleOrDefaultAsync(); } + public async Task SelectById(MetaItemKey id) + { + return await _metaCollection.Find(f => (f.Id.Type == id.Type) && (f.Id.Value == id.Value)).SingleOrDefaultAsync(); + } [DataObjectMethod(DataObjectMethodType.Select, false)] public async Task> SelectUnusedLabs() @@ -102,16 +111,28 @@ where usedYears.All(ul => ul.Id.Value != y.ToString()) } [DataObjectMethod(DataObjectMethodType.Insert, true)] - public async Task Insert(MetaItemModel item) { await _metaCollection.InsertOneAsync(item); } + public async Task Insert(MetaItemModel item) + { + await _metaCollection.InsertOneAsync(item); + } [DataObjectMethod(DataObjectMethodType.Update, true)] - public async Task Update(MetaItemModel item) { await _metaCollection.ReplaceOneAsync(f => f.Id.Type == item.Id.Type && f.Id.Value == item.Id.Value, item); } + public async Task Update(MetaItemModel item) + { + await _metaCollection.ReplaceOneAsync(f => (f.Id.Type == item.Id.Type) && (f.Id.Value == item.Id.Value), item); + } [DataObjectMethod(DataObjectMethodType.Insert, false)] - public async Task InsertAll(IEnumerable items) { await _metaCollection.InsertManyAsync(items); } + public async Task InsertAll(IEnumerable items) + { + await _metaCollection.InsertManyAsync(items); + } [DataObjectMethod(DataObjectMethodType.Delete, true)] - public async Task DeleteById(MetaItemKey id) { await _metaCollection.DeleteOneAsync(f => f.Id.Type == id.Type && f.Id.Value == id.Value); } + public async Task DeleteById(MetaItemKey id) + { + await _metaCollection.DeleteOneAsync(f => (f.Id.Type == id.Type) && (f.Id.Value == id.Value)); + } } public class MetaItemKey @@ -119,7 +140,9 @@ public class MetaItemKey public MetaType Type { get; set; } public string Value { get; set; } - public MetaItemKey() { } + public MetaItemKey() + { + } public MetaItemKey(string id) { @@ -128,7 +151,10 @@ public MetaItemKey(string id) Value = items[1]; } - public override string ToString() { return $"{Type}:{Value}"; } + public override string ToString() + { + return $"{Type}:{Value}"; + } } public enum MetaType diff --git a/BuildFeed/App_Code/PaginationHelpers.cshtml b/BuildFeed/App_Code/PaginationHelpers.cshtml index 7f7e8d8..1a6debd 100644 --- a/BuildFeed/App_Code/PaginationHelpers.cshtml +++ b/BuildFeed/App_Code/PaginationHelpers.cshtml @@ -3,10 +3,10 @@ @using BuildFeed.Code @helper PaginationBlock(int currentPage, int totalPages, string view, RouteValueDictionary rd) { -string multiView = view + "Page"; + string multiView = view + "Page"; -if (totalPages > 1) -{ + if (totalPages > 1) + {
    @if (currentPage == 2) @@ -69,7 +69,10 @@ if (totalPages > 1) ["page"] = i }; -
  • @MvcIntrinsics.Html.ActionLink(i.ToString(), multiView, rvd)
  • +
  • + @MvcIntrinsics.Html.ActionLink(i.ToString(), multiView, rvd)
  • } @@ -99,5 +102,5 @@ if (totalPages > 1) }
- } + } } \ No newline at end of file diff --git a/BuildFeed/App_Start/FilterConfig.cs b/BuildFeed/App_Start/FilterConfig.cs index b4f34d4..f668540 100644 --- a/BuildFeed/App_Start/FilterConfig.cs +++ b/BuildFeed/App_Start/FilterConfig.cs @@ -4,6 +4,9 @@ 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()); + } } } \ No newline at end of file diff --git a/BuildFeed/Areas/admin/Controllers/baseController.cs b/BuildFeed/Areas/admin/Controllers/baseController.cs index 131b381..5f732a7 100644 --- a/BuildFeed/Areas/admin/Controllers/baseController.cs +++ b/BuildFeed/Areas/admin/Controllers/baseController.cs @@ -9,7 +9,10 @@ public class baseController : BaseController { [Authorize(Roles = "Administrators")] // GET: admin/base - public ActionResult index() { return View(); } + public ActionResult index() + { + return View(); + } [Authorize(Users = "hounsell")] public ActionResult setup() @@ -27,6 +30,9 @@ public ActionResult setup() } [Authorize(Users = "hounsell")] - public ActionResult exception() { throw new Exception("This is a test exception"); } + public ActionResult exception() + { + throw new Exception("This is a test exception"); + } } } \ No newline at end of file diff --git a/BuildFeed/Areas/admin/Controllers/metaController.cs b/BuildFeed/Areas/admin/Controllers/metaController.cs index 84713b9..ad73c23 100644 --- a/BuildFeed/Areas/admin/Controllers/metaController.cs +++ b/BuildFeed/Areas/admin/Controllers/metaController.cs @@ -12,7 +12,10 @@ public class metaController : BaseController { private readonly MetaItem _mModel; - public metaController() { _mModel = new MetaItem(); } + public metaController() + { + _mModel = new MetaItem(); + } // GET: admin/meta public async Task index() diff --git a/BuildFeed/Areas/admin/Views/meta/create.cshtml b/BuildFeed/Areas/admin/Views/meta/create.cshtml index 88f1d36..eaf5d4b 100644 --- a/BuildFeed/Areas/admin/Views/meta/create.cshtml +++ b/BuildFeed/Areas/admin/Views/meta/create.cshtml @@ -84,7 +84,8 @@ } } - $(function() { + $(function() + { var btnsGrps = $.trumbowyg.btnsGrps; $("#@Html.IdFor(model => model.PageContent)") @@ -101,7 +102,8 @@ }); $("#@Html.IdFor(model => model.MetaDescription)") - .keyup(function() { + .keyup(function() + { updateMetaCount(); }); diff --git a/BuildFeed/Areas/admin/Views/users/index.cshtml b/BuildFeed/Areas/admin/Views/users/index.cshtml index b1ce6d1..405b54a 100644 --- a/BuildFeed/Areas/admin/Views/users/index.cshtml +++ b/BuildFeed/Areas/admin/Views/users/index.cshtml @@ -61,46 +61,42 @@ : mu.LastLockoutDate.Humanize()) - @( - mu.IsApproved - ? Html.ActionLink("Unapprove", "unapprove", new - { - id = mu.ProviderUserKey - }, new - { - @class = "button delete-button", - style = "width:70px;" - }) - : Html.ActionLink("Approve", "approve", new - { - id = mu.ProviderUserKey - }, new - { - @class = "button add-button", - style = "width:70px;" - }) - ) + @(mu.IsApproved + ? Html.ActionLink("Unapprove", "unapprove", new + { + id = mu.ProviderUserKey + }, new + { + @class = "button delete-button", + style = "width:70px;" + }) + : Html.ActionLink("Approve", "approve", new + { + id = mu.ProviderUserKey + }, new + { + @class = "button add-button", + style = "width:70px;" + })) - @( - !mu.IsLockedOut - ? Html.ActionLink("Lock", "lock", new - { - id = mu.ProviderUserKey - }, new - { - @class = "button delete-button", - style = "width:70px;" - }) - : Html.ActionLink("Unlock", "unlock", new - { - id = mu.ProviderUserKey - }, new - { - @class = "button add-button", - style = "width:70px;" - }) - ) + @(!mu.IsLockedOut + ? Html.ActionLink("Lock", "lock", new + { + id = mu.ProviderUserKey + }, new + { + @class = "button delete-button", + style = "width:70px;" + }) + : Html.ActionLink("Unlock", "unlock", new + { + id = mu.ProviderUserKey + }, new + { + @class = "button add-button", + style = "width:70px;" + })) } diff --git a/BuildFeed/Areas/admin/Views/web.config b/BuildFeed/Areas/admin/Views/web.config index 15a9aa7..c1814a1 100644 --- a/BuildFeed/Areas/admin/Views/web.config +++ b/BuildFeed/Areas/admin/Views/web.config @@ -27,7 +27,7 @@ - + diff --git a/BuildFeed/BingSiteAuth.xml b/BuildFeed/BingSiteAuth.xml index 2a677a2..c52eb23 100644 --- a/BuildFeed/BingSiteAuth.xml +++ b/BuildFeed/BingSiteAuth.xml @@ -1,4 +1,5 @@ + - 77FAD24B9B2579631630796D246267C3 + 77FAD24B9B2579631630796D246267C3 \ No newline at end of file diff --git a/BuildFeed/BuildFeed.csproj b/BuildFeed/BuildFeed.csproj index 1a09a20..98cf424 100644 --- a/BuildFeed/BuildFeed.csproj +++ b/BuildFeed/BuildFeed.csproj @@ -46,6 +46,19 @@ TRACE prompt 4 + ES6 + None + True + False + ES6 + False + + + False + True + True + + @@ -206,6 +219,7 @@ + @@ -213,32 +227,8 @@ - - dark.scss - - - dark.css - - - default.scss - - - default.css - - - light.scss - - - light.css - - - rtl.scss - - - rtl.css - @@ -257,16 +247,37 @@ + + dark.scss + + + dark.css + + + default.scss + + + default.css + + + light.scss + + + light.css + + + rtl.scss + + + rtl.css + - - - compilerconfig.json - + bfs.ts @@ -445,12 +456,11 @@ - ES5 + ES6 None True False - - + ES6 True diff --git a/BuildFeed/Code/CustomContentTypeAttribute.cs b/BuildFeed/Code/CustomContentTypeAttribute.cs index 1fcc17a..12c8660 100644 --- a/BuildFeed/Code/CustomContentTypeAttribute.cs +++ b/BuildFeed/Code/CustomContentTypeAttribute.cs @@ -7,6 +7,9 @@ public class CustomContentTypeAttribute : ActionFilterAttribute { public string ContentType { get; set; } - public override void OnResultExecuted(ResultExecutedContext filterContext) { filterContext.HttpContext.Response.ContentType = ContentType; } + public override void OnResultExecuted(ResultExecutedContext filterContext) + { + filterContext.HttpContext.Response.ContentType = ContentType; + } } } \ No newline at end of file diff --git a/BuildFeed/Code/Options/Locale.cs b/BuildFeed/Code/Options/Locale.cs index f9fec3a..8cf13fc 100644 --- a/BuildFeed/Code/Options/Locale.cs +++ b/BuildFeed/Code/Options/Locale.cs @@ -6,7 +6,10 @@ namespace BuildFeed.Code.Options { public class Locale { - public static readonly Locale[] AvailableLocales = { + private const string LANG_COOKIE_NAME = "bf_lang"; + + public static readonly Locale[] AvailableLocales = + { new Locale("ar"), //new Locale("bn"), new Locale("cs"), @@ -41,8 +44,6 @@ public class Locale new Locale("zh-hant") }; - private const string LANG_COOKIE_NAME = "bf_lang"; - public string DisplayName => Info.NativeName; public CultureInfo Info { get; set; } @@ -65,7 +66,7 @@ public static CultureInfo DetectCulture(HttpContextBase context) CultureInfo ci = (CultureInfo)CultureInfo.GetCultureInfo(langCookie).Clone(); // Get Gregorian Calendar in locale if available - Calendar gc = ci.OptionalCalendars.FirstOrDefault(c => c is GregorianCalendar && ((GregorianCalendar)c).CalendarType == GregorianCalendarTypes.Localized); + Calendar gc = ci.OptionalCalendars.FirstOrDefault(c => c is GregorianCalendar && (((GregorianCalendar)c).CalendarType == GregorianCalendarTypes.Localized)); if (gc != null) { ci.DateTimeFormat.Calendar = gc; @@ -74,7 +75,9 @@ public static CultureInfo DetectCulture(HttpContextBase context) return ci; } - catch (CultureNotFoundException) { } + catch (CultureNotFoundException) + { + } } return CultureInfo.CurrentCulture; diff --git a/BuildFeed/Code/Options/Theme.cs b/BuildFeed/Code/Options/Theme.cs index 812bf58..e2b1261 100644 --- a/BuildFeed/Code/Options/Theme.cs +++ b/BuildFeed/Code/Options/Theme.cs @@ -16,10 +16,13 @@ public class Theme private readonly SiteTheme _siteTheme; public string CookieValue => _siteTheme.ToString(); - public string CssPath => $"~/res/css/{_siteTheme.ToString().ToLower()}.min.css"; + public string CssPath => $"~/res/css/{_siteTheme.ToString().ToLower()}.css"; public string DisplayName => MvcExtensions.GetDisplayTextForEnum(_siteTheme); - public Theme(SiteTheme st) { _siteTheme = st; } + public Theme(SiteTheme st) + { + _siteTheme = st; + } public static SiteTheme DetectTheme(HttpContextBase context) { diff --git a/BuildFeed/Code/OutputCachePushAttribute.cs b/BuildFeed/Code/OutputCachePushAttribute.cs index 1cd1597..af6d7d4 100644 --- a/BuildFeed/Code/OutputCachePushAttribute.cs +++ b/BuildFeed/Code/OutputCachePushAttribute.cs @@ -15,11 +15,11 @@ public override void OnResultExecuted(ResultExecutedContext filterContext) bool isRtl = CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft; Theme theme = new Theme(Theme.DetectTheme(filterContext.HttpContext)); - filterContext.HttpContext.Response.PushPromise("/res/css/default.min.css"); + filterContext.HttpContext.Response.PushPromise("/res/css/default.css"); filterContext.HttpContext.Response.PushPromise(VirtualPathUtility.ToAbsolute(theme.CssPath)); if (isRtl) { - filterContext.HttpContext.Response.PushPromise("/res/css/rtl.min.css"); + filterContext.HttpContext.Response.PushPromise("/res/css/rtl.css"); } filterContext.HttpContext.Response.PushPromise("/res/ts/bfs.min.js"); } diff --git a/BuildFeed/Controllers/BaseController.cs b/BuildFeed/Controllers/BaseController.cs index f500171..1107352 100644 --- a/BuildFeed/Controllers/BaseController.cs +++ b/BuildFeed/Controllers/BaseController.cs @@ -1,6 +1,4 @@ -using System; -using System.Globalization; -using System.Linq; +using System.Globalization; using System.Web.Mvc; using System.Web.Routing; using BuildFeed.Code.Options; diff --git a/BuildFeed/Controllers/apiController.cs b/BuildFeed/Controllers/apiController.cs index 2733b5a..3d31299 100644 --- a/BuildFeed/Controllers/apiController.cs +++ b/BuildFeed/Controllers/apiController.cs @@ -6,8 +6,8 @@ using System.Web.Security; using BuildFeed.Code; using BuildFeed.Local; -using BuildFeed.Model.Api; using BuildFeed.Model; +using BuildFeed.Model.Api; using BuildFeed.Model.View; namespace BuildFeed.Controllers @@ -16,7 +16,10 @@ public class ApiController : System.Web.Http.ApiController { private readonly BuildRepository _bModel; - public ApiController() { _bModel = new BuildRepository(); } + public ApiController() + { + _bModel = new BuildRepository(); + } public async Task GetBuilds(int limit = 20, int skip = 0) { @@ -51,7 +54,7 @@ public async Task GetBuildsByLab(string lab, int limit = 20, int skip = public async Task> GetWin10Labs() { - List labs = new List(); + var labs = new List(); labs.AddRange(await _bModel.SelectLabsForVersion(6, 4)); labs.AddRange(await _bModel.SelectLabsForVersion(10, 0)); @@ -94,7 +97,7 @@ public async Task> GetSearchResult(string id) } const int maxResults = 16; - List results = new List(); + var results = new List(); results.AddRange(from s in (from c in Enum.GetValues(typeof(TypeOfSource)).Cast() select new @@ -118,7 +121,10 @@ orderby s.Text.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascendi Group = VariantTerms.Search_Source }); - if (results.Count >= maxResults) return results.Take(maxResults); + if (results.Count >= maxResults) + { + return results.Take(maxResults); + } results.AddRange(from v in await _bModel.SelectAllVersions() where $"{v.Major}.{v.Minor}".StartsWith(id) @@ -138,7 +144,10 @@ orderby s.Text.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascendi Group = VariantTerms.Search_Version }); - if (results.Count >= maxResults) return results.Take(maxResults); + if (results.Count >= maxResults) + { + return results.Take(maxResults); + } results.AddRange(from y in await _bModel.SelectAllYears() where y.ToString().Contains(id) @@ -157,7 +166,10 @@ orderby y descending Group = VariantTerms.Search_Year }); - if (results.Count >= maxResults) return results.Take(maxResults); + if (results.Count >= maxResults) + { + return results.Take(maxResults); + } results.AddRange(from l in await _bModel.SearchLabs(id) select new SearchResult @@ -174,7 +186,10 @@ orderby y descending Group = VariantTerms.Search_Lab }); - if (results.Count >= maxResults) return results.Take(maxResults); + if (results.Count >= maxResults) + { + return results.Take(maxResults); + } results.AddRange(from b in await _bModel.Select() where b.FullBuildString.ToLower().Contains(id.ToLower()) diff --git a/BuildFeed/Controllers/frontController.cs b/BuildFeed/Controllers/frontController.cs index 2235c1f..c18a66b 100644 --- a/BuildFeed/Controllers/frontController.cs +++ b/BuildFeed/Controllers/frontController.cs @@ -29,7 +29,8 @@ public FrontController() [Route("", Order = 1)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task Index() { @@ -39,7 +40,8 @@ public async Task Index() [Route("page-{page:int:min(1)}/", Order = 0)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task IndexPage(int page) { @@ -48,15 +50,20 @@ public async Task IndexPage(int page) ViewBag.PageNumber = page; ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await _bModel.SelectAllGroupsCount()) / Convert.ToDouble(PAGE_SIZE)); - if (ViewBag.PageNumber > ViewBag.PageCount) return new HttpNotFoundResult(); + if (ViewBag.PageNumber > ViewBag.PageCount) + { + return new HttpNotFoundResult(); + } return View("Pages", buildGroups); } - [Route("group/{major}.{minor}.{number}.{revision}/", Order = 1), Route("group/{major}.{minor}.{number}/", Order = 5)] + [Route("group/{major}.{minor}.{number}.{revision}/", Order = 1)] + [Route("group/{major}.{minor}.{number}/", Order = 5)] // for when there is no revision #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task ViewGroup(uint major, uint minor, uint number, uint? revision = null) { @@ -81,12 +88,17 @@ public async Task ViewGroup(uint major, uint minor, uint number, u [Route("build/{id:guid}/", Name = "Build")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task ViewBuild(Guid id) { Build b = await _bModel.SelectById(id); - if (b == null) return new HttpNotFoundResult(); + if (b == null) + { + return new HttpNotFoundResult(); + } + return View(b); } @@ -94,7 +106,11 @@ public async Task ViewBuild(Guid id) public async Task ViewBuild(long id) { Build b = await _bModel.SelectByLegacyId(id); - if (b == null) return new HttpNotFoundResult(); + if (b == null) + { + return new HttpNotFoundResult(); + } + return RedirectToAction(nameof(ViewBuild), new { @@ -104,13 +120,16 @@ public async Task ViewBuild(long id) [Route("twitter/{id:guid}/", Name = "Twitter")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none")] + [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")] [CustomContentType(ContentType = "image/png", Order = 2)] #endif public async Task TwitterCard(Guid id) { Build b = await _bModel.SelectById(id); - if (b == null) return new HttpNotFoundResult(); + if (b == null) + { + return new HttpNotFoundResult(); + } string path = Path.Combine(Server.MapPath("~/res/card/"), $"{b.Family}.png"); bool backExists = System.IO.File.Exists(path); @@ -128,7 +147,10 @@ public async Task TwitterCard(Guid id) gr.SmoothingMode = SmoothingMode.HighQuality; gr.PixelOffsetMode = PixelOffsetMode.HighQuality; - if (!backExists) gr.FillRectangle(new SolidBrush(Color.FromArgb(0x24, 0x24, 0x23)), 0, 0, 1120, 600); + if (!backExists) + { + gr.FillRectangle(new SolidBrush(Color.FromArgb(0x24, 0x24, 0x23)), 0, 0, 1120, 600); + } int left = 40; using (GraphicsPath gp = new GraphicsPath()) @@ -153,7 +175,10 @@ public async Task TwitterCard(Guid id) left = Convert.ToInt32(bounds.Width); left += 44; - if (b.Revision.HasValue) gp.AddString($".{b.Revision}", new FontFamily("Segoe UI Light"), 0, 160, new Point(left, 220), StringFormat.GenericTypographic); + if (b.Revision.HasValue) + { + gp.AddString($".{b.Revision}", new FontFamily("Segoe UI Light"), 0, 160, new Point(left, 220), StringFormat.GenericTypographic); + } gr.DrawPath(new Pen(new SolidBrush(Color.FromArgb(0x24, 0x24, 0x23)), 4), gp); gr.FillPath(Brushes.White, gp); @@ -187,7 +212,11 @@ public async Task TwitterCard(Guid id) public async Task TwitterCard(long id) { Build b = await _bModel.SelectByLegacyId(id); - if (b == null) return new HttpNotFoundResult(); + if (b == null) + { + return new HttpNotFoundResult(); + } + return RedirectToAction(nameof(TwitterCard), new { @@ -197,7 +226,8 @@ public async Task TwitterCard(long id) [Route("lab/{lab}/", Order = 1, Name = "Lab Root")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task ViewLab(string lab) { @@ -206,7 +236,8 @@ public async Task ViewLab(string lab) [Route("lab/{lab}/page-{page:int:min(2)}/", Order = 0)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task ViewLabPage(string lab, int page) { @@ -222,14 +253,18 @@ public async Task ViewLabPage(string lab, int page) ViewBag.PageNumber = page; ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await _bModel.SelectLabCount(lab)) / Convert.ToDouble(PAGE_SIZE)); - if (ViewBag.PageNumber > ViewBag.PageCount) return new HttpNotFoundResult(); + if (ViewBag.PageNumber > ViewBag.PageCount) + { + return new HttpNotFoundResult(); + } return View("viewLab", builds); } [Route("source/{source}/", Order = 1, Name = "Source Root")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task ViewSource(TypeOfSource source) { @@ -238,7 +273,8 @@ public async Task ViewSource(TypeOfSource source) [Route("source/{source}/page-{page:int:min(2)}/", Order = 0)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task ViewSourcePage(TypeOfSource source, int page) { @@ -254,14 +290,18 @@ public async Task ViewSourcePage(TypeOfSource source, int page) ViewBag.PageNumber = page; ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await _bModel.SelectSourceCount(source)) / Convert.ToDouble(PAGE_SIZE)); - if (ViewBag.PageNumber > ViewBag.PageCount) return new HttpNotFoundResult(); + if (ViewBag.PageNumber > ViewBag.PageCount) + { + return new HttpNotFoundResult(); + } return View("viewSource", builds); } [Route("year/{year}/", Order = 1, Name = "Year Root")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task ViewYear(int year) { @@ -270,7 +310,8 @@ public async Task ViewYear(int year) [Route("year/{year}/page-{page:int:min(2)}/", Order = 0)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task ViewYearPage(int year, int page) { @@ -286,14 +327,18 @@ public async Task ViewYearPage(int year, int page) ViewBag.PageNumber = page; ViewBag.PageCount = Math.Ceiling(await _bModel.SelectYearCount(year) / Convert.ToDouble(PAGE_SIZE)); - if (ViewBag.PageNumber > ViewBag.PageCount) return new HttpNotFoundResult(); + if (ViewBag.PageNumber > ViewBag.PageCount) + { + return new HttpNotFoundResult(); + } return View("viewYear", builds); } [Route("version/{major}.{minor}/", Order = 1, Name = "Version Root")] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task ViewVersion(uint major, uint minor) { @@ -302,7 +347,8 @@ public async Task ViewVersion(uint major, uint minor) [Route("version/{major}.{minor}/page-{page:int:min(2)}/", Order = 0)] #if !DEBUG - [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)] + [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")] + [OutputCachePush(Order = 2)] #endif public async Task ViewVersionPage(uint major, uint minor, int page) { @@ -319,12 +365,16 @@ public async Task ViewVersionPage(uint major, uint minor, int page ViewBag.PageNumber = page; ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await _bModel.SelectVersionCount(major, minor)) / Convert.ToDouble(PAGE_SIZE)); - if (ViewBag.PageNumber > ViewBag.PageCount) return new HttpNotFoundResult(); + if (ViewBag.PageNumber > ViewBag.PageCount) + { + return new HttpNotFoundResult(); + } return View("viewVersion", builds); } - [Route("add/"), Authorize] + [Route("add/")] + [Authorize] public ActionResult AddBuild() { Build b = new Build @@ -334,7 +384,9 @@ public ActionResult AddBuild() return View("EditBuild", b); } - [Route("add/"), Authorize, HttpPost] + [Route("add/")] + [Authorize] + [HttpPost] public async Task AddBuild(Build build) { if (ModelState.IsValid) @@ -343,8 +395,16 @@ public async Task AddBuild(Build build) { build.Added = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); build.Modified = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); - if (build.BuildTime.HasValue) build.BuildTime = DateTime.SpecifyKind(build.BuildTime.Value, DateTimeKind.Utc); - if (build.LeakDate.HasValue) build.LeakDate = DateTime.SpecifyKind(build.LeakDate.Value, DateTimeKind.Utc); + if (build.BuildTime.HasValue) + { + build.BuildTime = DateTime.SpecifyKind(build.BuildTime.Value, DateTimeKind.Utc); + } + + if (build.LeakDate.HasValue) + { + build.LeakDate = DateTime.SpecifyKind(build.LeakDate.Value, DateTimeKind.Utc); + } + await _bModel.Insert(build); } catch @@ -360,22 +420,33 @@ public async Task AddBuild(Build build) return View("EditBuild", build); } - [Route("edit/{id}/"), Authorize] + [Route("edit/{id}/")] + [Authorize] public async Task EditBuild(Guid id) { Build b = await _bModel.SelectById(id); return View(b); } - [Route("edit/{id}/"), Authorize, HttpPost] + [Route("edit/{id}/")] + [Authorize] + [HttpPost] public async Task EditBuild(Guid id, Build build) { if (ModelState.IsValid) { try { - if (build.BuildTime.HasValue) build.BuildTime = DateTime.SpecifyKind(build.BuildTime.Value, DateTimeKind.Utc); - if (build.LeakDate.HasValue) build.LeakDate = DateTime.SpecifyKind(build.LeakDate.Value, DateTimeKind.Utc); + if (build.BuildTime.HasValue) + { + build.BuildTime = DateTime.SpecifyKind(build.BuildTime.Value, DateTimeKind.Utc); + } + + if (build.LeakDate.HasValue) + { + build.LeakDate = DateTime.SpecifyKind(build.LeakDate.Value, DateTimeKind.Utc); + } + await _bModel.Update(build); } catch @@ -392,7 +463,8 @@ public async Task EditBuild(Guid id, Build build) return View(build); } - [Route("delete/{id}/"), Authorize(Roles = "Administrators")] + [Route("delete/{id}/")] + [Authorize(Roles = "Administrators")] public async Task DeleteBuild(Guid id) { await _bModel.DeleteById(id); diff --git a/BuildFeed/Controllers/rssController.cs b/BuildFeed/Controllers/rssController.cs index da4e582..775952a 100644 --- a/BuildFeed/Controllers/rssController.cs +++ b/BuildFeed/Controllers/rssController.cs @@ -14,7 +14,10 @@ public class RssController : BaseController private const int RSS_SIZE = 25; private readonly BuildRepository _bModel; - public RssController() { _bModel = new BuildRepository(); } + public RssController() + { + _bModel = new BuildRepository(); + } [Route("rss/compiled")] public async Task Index() @@ -31,7 +34,8 @@ public async Task Index() Title = build.AlternateBuildString, Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"), Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}", - Categories = { + Categories = + { build.Family.ToString() }, PublishDate = DateTime.SpecifyKind(build.BuildTime.GetValueOrDefault(), DateTimeKind.Utc) @@ -61,7 +65,8 @@ public async Task Added() Title = build.AlternateBuildString, Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"), Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}", - Categories = { + Categories = + { build.Family.ToString() }, PublishDate = DateTime.SpecifyKind(build.Added, DateTimeKind.Utc) @@ -91,7 +96,8 @@ public async Task Leaked() Title = build.AlternateBuildString, Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"), Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}", - Categories = { + Categories = + { build.Family.ToString() }, PublishDate = DateTime.SpecifyKind(build.LeakDate.GetValueOrDefault(), DateTimeKind.Utc) @@ -121,7 +127,8 @@ public async Task Version() Title = build.AlternateBuildString, Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"), Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}", - Categories = { + Categories = + { build.Family.ToString() } }).ToList() @@ -150,7 +157,8 @@ public async Task Lab(string lab) Title = build.AlternateBuildString, Link = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}"), Permalink = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}", - Categories = { + Categories = + { build.Family.ToString() } }).ToList() diff --git a/BuildFeed/Controllers/supportController.cs b/BuildFeed/Controllers/supportController.cs index 924362c..0f3ef41 100644 --- a/BuildFeed/Controllers/supportController.cs +++ b/BuildFeed/Controllers/supportController.cs @@ -18,12 +18,16 @@ public class SupportController : BaseController { private readonly BuildRepository _bModel; - public SupportController() { _bModel = new BuildRepository(); } + public SupportController() + { + _bModel = new BuildRepository(); + } [Route("login/")] public ActionResult Login() => View(); - [HttpPost, Route("login/")] + [HttpPost] + [Route("login/")] public ActionResult Login(LoginUser ru) { if (ModelState.IsValid) @@ -57,10 +61,13 @@ public ActionResult Login(LoginUser ru) return View(ru); } - [Authorize, Route("password/")] + [Authorize] + [Route("password/")] public ActionResult Password() => View(); - [HttpPost, Authorize, Route("password/")] + [HttpPost] + [Authorize] + [Route("password/")] public ActionResult Password(ChangePassword cp) { if (ModelState.IsValid) @@ -92,7 +99,8 @@ public ActionResult Logout() [Route("register/")] public ActionResult Register() => View(); - [HttpPost, Route("register/")] + [HttpPost] + [Route("register/")] public ActionResult Register(RegistrationUser ru) { if (ModelState.IsValid) @@ -134,12 +142,12 @@ public async Task Rss() [Route("sitemap/")] #if !DEBUG - // [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")] + [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")] #endif public async Task Sitemap() { List builds = await _bModel.SelectBuildsByOrder(); - Dictionary actions = new Dictionary + var actions = new Dictionary { { "Pages", new[] @@ -278,12 +286,12 @@ into lab [Route("xml-sitemap/")] #if !DEBUG - // [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")] + [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")] #endif public async Task XmlSitemap() { XNamespace xn = XNamespace.Get("http://www.sitemaps.org/schemas/sitemap/0.9"); - List xlist = new List(); + var xlist = new List(); // home page XElement home = new XElement(xn + "url"); diff --git a/BuildFeed/Views/Web.config b/BuildFeed/Views/Web.config index d9730ce..c7363e3 100644 --- a/BuildFeed/Views/Web.config +++ b/BuildFeed/Views/Web.config @@ -25,8 +25,8 @@ - + - + \ No newline at end of file diff --git a/BuildFeed/Views/_ViewStart.cshtml b/BuildFeed/Views/_ViewStart.cshtml index 1906fb1..d599c2d 100644 --- a/BuildFeed/Views/_ViewStart.cshtml +++ b/BuildFeed/Views/_ViewStart.cshtml @@ -1,3 +1,3 @@ @{ Layout = "~/Views/shared/_default.cshtml"; -} +} \ No newline at end of file diff --git a/BuildFeed/Views/shared/_default.cshtml b/BuildFeed/Views/shared/_default.cshtml index e51f307..4d78c4c 100644 --- a/BuildFeed/Views/shared/_default.cshtml +++ b/BuildFeed/Views/shared/_default.cshtml @@ -4,11 +4,11 @@ @{ bool isRtl = CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft; - Response.PushPromise("/res/css/default.min.css"); + Response.PushPromise("/res/css/default.css"); Response.PushPromise(VirtualPathUtility.ToAbsolute(((Theme)ViewBag.Theme).CssPath)); if (isRtl) { - Response.PushPromise("/res/css/rtl.min.css"); + Response.PushPromise("/res/css/rtl.css"); } Response.PushPromise("/res/ts/bfs.min.js"); @@ -29,11 +29,11 @@ - + @if (isRtl) { - + } @ViewBag.Title @RenderSection("head", false) diff --git a/BuildFeed/Views/shared/error.cshtml b/BuildFeed/Views/shared/error.cshtml index 304cc4b..dc28fe8 100644 --- a/BuildFeed/Views/shared/error.cshtml +++ b/BuildFeed/Views/shared/error.cshtml @@ -20,11 +20,11 @@ - + @if (isRtl) { - + } @VariantTerms.Common_Error | @InvariantTerms.SiteName