mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Implementing the Warmup module
- Global.asax.cs looks for static pages in ~\App_Data\Warmup - Orchard.Warmup module contains methods to generate those pages based on scheduled times, and content publishing --HG-- branch : dev
This commit is contained in:
@@ -64,27 +64,26 @@ namespace Orchard.Core.Settings.Controllers {
|
||||
var site = _siteService.GetSiteSettings();
|
||||
dynamic model = Services.ContentManager.UpdateEditor(site, this, groupInfoId);
|
||||
|
||||
GroupInfo groupInfo = null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(groupInfoId)) {
|
||||
if (model == null) {
|
||||
Services.TransactionManager.Cancel();
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
var groupInfo = Services.ContentManager.GetEditorGroupInfo(site, groupInfoId);
|
||||
groupInfo = Services.ContentManager.GetEditorGroupInfo(site, groupInfoId);
|
||||
if (groupInfo == null) {
|
||||
Services.TransactionManager.Cancel();
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
Services.TransactionManager.Cancel();
|
||||
model.GroupInfo = groupInfo;
|
||||
|
||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||
return View((object) model);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
Services.TransactionManager.Cancel();
|
||||
model.GroupInfo = groupInfo;
|
||||
|
||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||
return View((object)model);
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,11 @@
|
||||
using JetBrains.Annotations;
|
||||
using System.Net;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Core.Settings.ViewModels;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Settings;
|
||||
using System;
|
||||
using Orchard.Security;
|
||||
@@ -16,16 +18,24 @@ namespace Orchard.Core.Settings.Drivers {
|
||||
private readonly ISiteService _siteService;
|
||||
private readonly ICultureManager _cultureManager;
|
||||
private readonly IMembershipService _membershipService;
|
||||
private readonly INotifier _notifier;
|
||||
|
||||
public SiteSettingsPartDriver(ISiteService siteService, ICultureManager cultureManager, IMembershipService membershipService, INotifier notifier) {
|
||||
public SiteSettingsPartDriver(
|
||||
ISiteService siteService,
|
||||
ICultureManager cultureManager,
|
||||
IMembershipService membershipService,
|
||||
INotifier notifier) {
|
||||
_siteService = siteService;
|
||||
_cultureManager = cultureManager;
|
||||
_membershipService = membershipService;
|
||||
_notifier = notifier;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
protected override string Prefix { get { return "SiteSettings"; } }
|
||||
|
||||
@@ -48,6 +58,8 @@ namespace Orchard.Core.Settings.Drivers {
|
||||
SiteCultures = _cultureManager.ListCultures()
|
||||
};
|
||||
|
||||
var previousBaseUrl = model.Site.BaseUrl;
|
||||
|
||||
updater.TryUpdateModel(model, Prefix, null, null);
|
||||
|
||||
// ensures the super user is fully empty
|
||||
@@ -62,6 +74,27 @@ namespace Orchard.Core.Settings.Drivers {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ensure the base url is absolute if provided
|
||||
if (!String.IsNullOrWhiteSpace(model.Site.BaseUrl)) {
|
||||
if (!model.Site.BaseUrl.ToLower().StartsWith("http")) {
|
||||
updater.AddModelError("BaseUrl", T("The base url must be absolute."));
|
||||
}
|
||||
// if the base url has been modified, try to ping it
|
||||
else if (!String.Equals(previousBaseUrl, model.Site.BaseUrl, StringComparison.OrdinalIgnoreCase)) {
|
||||
try {
|
||||
var request = WebRequest.Create(model.Site.BaseUrl) as HttpWebRequest;
|
||||
if (request != null) {
|
||||
using (request.GetResponse() as HttpWebResponse) {}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
_notifier.Warning(T("The base url you entered could not be requested from current location."));
|
||||
Logger.Warning(e, "Could not query base url: {0}", model.Site.BaseUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ContentShape("Parts_Settings_SiteSettingsPart",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Settings.SiteSettingsPart", Model: model, Prefix: Prefix));
|
||||
}
|
||||
|
@@ -95,5 +95,14 @@ namespace Orchard.Core.Settings {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int UpdateFrom1() {
|
||||
SchemaBuilder.AlterTable("SiteSettingsPartRecord",
|
||||
table => table
|
||||
.AddColumn<string>("BaseUrl", c => c.WithLength(255))
|
||||
);
|
||||
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Core.Settings.Models {
|
||||
@@ -42,5 +43,11 @@ namespace Orchard.Core.Settings.Models {
|
||||
get { return Record.PageSize; }
|
||||
set { Record.PageSize = value; }
|
||||
}
|
||||
|
||||
[StringLength(255)]
|
||||
public string BaseUrl {
|
||||
get { return Record.BaseUrl; }
|
||||
set { Record.BaseUrl = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Core.Settings.Models {
|
||||
@@ -24,5 +25,8 @@ namespace Orchard.Core.Settings.Models {
|
||||
public virtual ResourceDebugMode ResourceDebugMode { get; set; }
|
||||
|
||||
public virtual int PageSize { get; set; }
|
||||
|
||||
[StringLength(255)]
|
||||
public virtual string BaseUrl { get; set; }
|
||||
}
|
||||
}
|
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Settings;
|
||||
|
||||
@@ -8,7 +7,6 @@ namespace Orchard.Core.Settings.ViewModels {
|
||||
public class SiteSettingsPartViewModel {
|
||||
public SiteSettingsPart Site { get; set; }
|
||||
public IEnumerable<string> SiteCultures { get; set; }
|
||||
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public int Id {
|
||||
@@ -16,33 +14,38 @@ namespace Orchard.Core.Settings.ViewModels {
|
||||
}
|
||||
|
||||
public string PageTitleSeparator {
|
||||
get { return Site.Record.PageTitleSeparator; }
|
||||
set { Site.Record.PageTitleSeparator = value; }
|
||||
get { return Site.PageTitleSeparator; }
|
||||
set { Site.PageTitleSeparator = value; }
|
||||
}
|
||||
|
||||
public string SiteName {
|
||||
get { return Site.Record.SiteName; }
|
||||
set { Site.Record.SiteName = value; }
|
||||
get { return Site.SiteName; }
|
||||
set { Site.SiteName = value; }
|
||||
}
|
||||
|
||||
public string SiteCulture {
|
||||
get { return Site.Record.SiteCulture; }
|
||||
set { Site.Record.SiteCulture = value; }
|
||||
get { return Site.SiteCulture; }
|
||||
set { Site.SiteCulture = value; }
|
||||
}
|
||||
|
||||
public string SuperUser {
|
||||
get { return Site.As<SiteSettingsPart>().Record.SuperUser; }
|
||||
set { Site.As<SiteSettingsPart>().Record.SuperUser = value; }
|
||||
get { return Site.SuperUser; }
|
||||
set { Site.SuperUser = value; }
|
||||
}
|
||||
|
||||
public ResourceDebugMode ResourceDebugMode {
|
||||
get { return Site.As<SiteSettingsPart>().ResourceDebugMode; }
|
||||
set { Site.As<SiteSettingsPart>().ResourceDebugMode = value; }
|
||||
get { return Site.ResourceDebugMode; }
|
||||
set { Site.ResourceDebugMode = value; }
|
||||
}
|
||||
|
||||
public int PageSize {
|
||||
get { return Site.As<SiteSettingsPart>().PageSize; }
|
||||
set { Site.As<SiteSettingsPart>().PageSize = value; }
|
||||
get { return Site.PageSize; }
|
||||
set { Site.PageSize = value; }
|
||||
}
|
||||
|
||||
public string BaseUrl {
|
||||
get { return Site.BaseUrl; }
|
||||
set { Site.BaseUrl = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -38,7 +38,13 @@
|
||||
</div>
|
||||
<div>
|
||||
<label for="DefaultPageSize">@T("Default number of items per page")</label>
|
||||
@Html.TextBoxFor(m => m.PageSize, new { @class = "textMedium" })
|
||||
@Html.TextBoxFor(m => m.PageSize, new { @class = "text-small" })
|
||||
<span class="hint">@T("Determines the default number of items that are shown per page.")</span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="@Html.FieldIdFor(m => m.BaseUrl)">@T("Base url ")</label>
|
||||
@Html.TextBoxFor(m => m.BaseUrl, new { @class = "textMedium" })
|
||||
<span class="hint">@T("Enter the fully qualified base url of your website.")</span>
|
||||
<span class="hint">@T("e.g., http://localhost:30320/orchardlocal, http://www.yourdomain.com")</span>
|
||||
</div>
|
||||
</fieldset>
|
Reference in New Issue
Block a user