From f782779ccbca13d49fe1bd481f96a106e031eef4 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 9 Jun 2011 17:46:21 -0700 Subject: [PATCH] Updating Warmup UI++ --HG-- branch : 1.x --- .../Controllers/AdminController.cs | 14 ++++++++----- .../Orchard.Warmup/Services/WarmupUpdater.cs | 4 ++++ .../Orchard.Warmup/Views/Admin/Index.cshtml | 20 +++++++++++-------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Warmup/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Warmup/Controllers/AdminController.cs index 89b6d2c95..e350f92bb 100644 --- a/src/Orchard.Web/Modules/Orchard.Warmup/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Warmup/Controllers/AdminController.cs @@ -61,8 +61,11 @@ namespace Orchard.Warmup.Controllers { using (var urlReader = new StringReader(viewModel.Settings.Urls)) { string relativeUrl; while (null != (relativeUrl = urlReader.ReadLine())) { + if(String.IsNullOrWhiteSpace(relativeUrl)) { + continue; + } if (!Uri.IsWellFormedUriString(relativeUrl, UriKind.Relative) || !(relativeUrl.StartsWith("/"))) { - AddModelError("Urls", T("{0} is an invalid warmup url.", relativeUrl)); + AddModelError("Urls", T("\"{0}\" is an invalid warmup url.", relativeUrl)); } } } @@ -75,14 +78,15 @@ namespace Orchard.Warmup.Controllers { } } - if (ModelState.IsValid) { - Services.Notifier.Information(T("Warmup updated successfully.")); - } if (ModelState.IsValid) { _warmupUpdater.Generate(); + Services.Notifier.Information(T("Warmup updated successfully.")); + } + else { + Services.TransactionManager.Cancel(); } - return RedirectToAction("Index"); + return Index(); } bool IUpdateModel.TryUpdateModel(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) { diff --git a/src/Orchard.Web/Modules/Orchard.Warmup/Services/WarmupUpdater.cs b/src/Orchard.Web/Modules/Orchard.Warmup/Services/WarmupUpdater.cs index 486abe97e..3f69106e4 100644 --- a/src/Orchard.Web/Modules/Orchard.Warmup/Services/WarmupUpdater.cs +++ b/src/Orchard.Web/Modules/Orchard.Warmup/Services/WarmupUpdater.cs @@ -117,6 +117,10 @@ namespace Orchard.Warmup.Services { using (var urlReader = new StringReader(part.Urls)) { string relativeUrl; while (null != (relativeUrl = urlReader.ReadLine())) { + if (String.IsNullOrWhiteSpace(relativeUrl)) { + continue; + } + string url = null; relativeUrl = relativeUrl.Trim(); diff --git a/src/Orchard.Web/Modules/Orchard.Warmup/Views/Admin/Index.cshtml b/src/Orchard.Web/Modules/Orchard.Warmup/Views/Admin/Index.cshtml index 9b6c8d2f9..504c3cb6c 100644 --- a/src/Orchard.Web/Modules/Orchard.Warmup/Views/Admin/Index.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Warmup/Views/Admin/Index.cshtml @@ -7,10 +7,12 @@ Layout.Title = T("Performance").ToString(); } -

The urls below will be requested using @Html.Link(WorkContext.CurrentSite.BaseUrl, WorkContext.CurrentSite.BaseUrl) as a base url. You can change it on the @Html.ActionLink(T("General Settings page").Text, "Index", new { controller = "Admin", area = "Settings" }).

@using (Html.BeginFormAntiForgeryPost()) { @Html.ValidationSummary() + +

@T("The paths below will be requested using {0} as a base url. You can change the base url on the {0}. ", @Html.Link(WorkContext.CurrentSite.BaseUrl, WorkContext.CurrentSite.BaseUrl), @Html.ActionLink(T("General Settings page").Text, "Index", new { controller = "Admin", area = "Settings" }))

+
@Html.TextAreaFor(m => m.Settings.Urls, new { @class = "textMedium" }) @@ -33,13 +35,10 @@
-
- -
-} + if (Model.ReportEntries.Any()) {
- +

@T("Status")

@@ -49,9 +48,9 @@ - + - + @@ -70,3 +69,8 @@ }
@T("Url")@T("Path") @T("Status")@T("Date")@T("Date generated")
+ } +
+ +
+}