Updating Warmup UI++

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-06-09 17:46:21 -07:00
parent 2138cbdddd
commit f782779ccb
3 changed files with 25 additions and 13 deletions

View File

@@ -61,8 +61,11 @@ namespace Orchard.Warmup.Controllers {
using (var urlReader = new StringReader(viewModel.Settings.Urls)) { using (var urlReader = new StringReader(viewModel.Settings.Urls)) {
string relativeUrl; string relativeUrl;
while (null != (relativeUrl = urlReader.ReadLine())) { while (null != (relativeUrl = urlReader.ReadLine())) {
if(String.IsNullOrWhiteSpace(relativeUrl)) {
continue;
}
if (!Uri.IsWellFormedUriString(relativeUrl, UriKind.Relative) || !(relativeUrl.StartsWith("/"))) { 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) { if (ModelState.IsValid) {
_warmupUpdater.Generate(); _warmupUpdater.Generate();
Services.Notifier.Information(T("Warmup updated successfully."));
}
else {
Services.TransactionManager.Cancel();
} }
return RedirectToAction("Index"); return Index();
} }
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) { bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {

View File

@@ -117,6 +117,10 @@ namespace Orchard.Warmup.Services {
using (var urlReader = new StringReader(part.Urls)) { using (var urlReader = new StringReader(part.Urls)) {
string relativeUrl; string relativeUrl;
while (null != (relativeUrl = urlReader.ReadLine())) { while (null != (relativeUrl = urlReader.ReadLine())) {
if (String.IsNullOrWhiteSpace(relativeUrl)) {
continue;
}
string url = null; string url = null;
relativeUrl = relativeUrl.Trim(); relativeUrl = relativeUrl.Trim();

View File

@@ -7,10 +7,12 @@
Layout.Title = T("Performance").ToString(); Layout.Title = T("Performance").ToString();
} }
<p>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" }).</p>
@using (Html.BeginFormAntiForgeryPost()) { @using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary() @Html.ValidationSummary()
<p>@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" }))</p>
<fieldset> <fieldset>
<div> <div>
@Html.TextAreaFor(m => m.Settings.Urls, new { @class = "textMedium" }) @Html.TextAreaFor(m => m.Settings.Urls, new { @class = "textMedium" })
@@ -33,13 +35,10 @@
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Settings.OnPublish)">@T("Generate warmup pages any time some content is published")</label> <label class="forcheckbox" for="@Html.FieldIdFor(m => m.Settings.OnPublish)">@T("Generate warmup pages any time some content is published")</label>
</div> </div>
</fieldset> </fieldset>
<fieldset>
<button class="primaryAction" name="submit" value="@T("Save")" type="submit">@T("Save")</button>
</fieldset>
}
if (Model.ReportEntries.Any()) {
<fieldset> <fieldset>
<label>@T("Report")</label> <h3>@T("Status")</h3>
<table class="items" summary="@T("This is a table of the reports in your application")"> <table class="items" summary="@T("This is a table of the reports in your application")">
<colgroup> <colgroup>
<col id="Col1" /> <col id="Col1" />
@@ -49,9 +48,9 @@
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
<th scope="col">@T("Url")</th> <th scope="col">@T("Path")</th>
<th scope="col">@T("Status")</th> <th scope="col">@T("Status")</th>
<th scope="col">@T("Date")</th> <th scope="col">@T("Date generated")</th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
@@ -70,3 +69,8 @@
} }
</table> </table>
</fieldset> </fieldset>
}
<fieldset>
<button class="primaryAction" name="submit" value="@T("Save")" type="submit">@T("Save")</button>
</fieldset>
}