#17850: Include and enable Orchard.Warmup by default

Also update blog and default recipe to set the site base url
during setup using the current request information.

Work Item: 17850

--HG--
branch : 1.x
This commit is contained in:
Renaud Paquay 2011-05-25 11:59:13 -07:00
parent 73c4f84636
commit 27503d8d1b
5 changed files with 58 additions and 4 deletions

View File

@ -277,7 +277,6 @@
$(StageFolder)\**\Modules\Orchard.MultiTenancy\**;
$(StageFolder)\**\Modules\Orchard.Scripting.Dlr\**;
$(StageFolder)\**\Modules\Orchard.Search\**;
$(StageFolder)\**\Modules\Orchard.Warmup\**;
" />
<MsDeploy-Folder-Input Include="$(StageFolder)\**\*" Exclude="$(StageFolder)\**\bin\**\*.xml;@(MsDeploy-Exclude-Modules)" />
@ -379,7 +378,6 @@
<Exec Command="&quot;$(GalleryFolder)\bin\Orchard.exe&quot; package create Orchard.MultiTenancy &quot;$(GalleryArtifactFolder)&quot;" WorkingDirectory="$(GalleryFolder)"/>
<Exec Command="&quot;$(GalleryFolder)\bin\Orchard.exe&quot; package create Orchard.Scripting.Dlr &quot;$(GalleryArtifactFolder)&quot;" WorkingDirectory="$(GalleryFolder)"/>
<Exec Command="&quot;$(GalleryFolder)\bin\Orchard.exe&quot; package create Orchard.Search &quot;$(GalleryArtifactFolder)&quot;" WorkingDirectory="$(GalleryFolder)"/>
<Exec Command="&quot;$(GalleryFolder)\bin\Orchard.exe&quot; package create Orchard.Warmup &quot;$(GalleryArtifactFolder)&quot;" WorkingDirectory="$(GalleryFolder)"/>
</Target>
<!-- ValidateProjectFiles-->

View File

@ -200,6 +200,7 @@
<Compile Include="Scheduling\Services\ScheduledTaskManager.cs" />
<Compile Include="Scheduling\Services\ScheduledTaskExecutor.cs" />
<Compile Include="Scheduling\Models\Task.cs" />
<Compile Include="Settings\Commands\SiteSettingsCommands.cs" />
<Compile Include="Settings\Models\SiteSettings2Part.cs" />
<Compile Include="Settings\Models\SiteSettings2PartRecord.cs" />
<Compile Include="Settings\ResourceManifest.cs" />

View File

@ -0,0 +1,53 @@
using Orchard.Commands;
using Orchard.ContentManagement;
using Orchard.Core.Settings.Models;
using Orchard.Mvc;
using Orchard.Settings;
using Orchard.Utility.Extensions;
namespace Orchard.Core.Settings.Commands {
public class SiteSettingsCommands : DefaultOrchardCommandHandler {
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISiteService _siteService;
public SiteSettingsCommands(IHttpContextAccessor httpContextAccessor, ISiteService siteService) {
_httpContextAccessor = httpContextAccessor;
_siteService = siteService;
}
[OrchardSwitch]
public string BaseUrl { get; set; }
[OrchardSwitch]
public bool Force { get; set; }
[CommandName("site setting set baseurl")]
[CommandHelp("site setting set baseurl [/BaseUrl:baseUrl] [/Force:true]\r\n\tSet the 'BaseUrl' site settings. If no base url is provided, " +
"use the current request context heuristic to discover the base url. " +
"If 'Force' is true, set the site base url even if it is already set. " +
"The default behavior is to not override the setting.")]
[OrchardSwitches("BaseUrl")]
public string SetBaseUrl() {
// Don't do anything if set and not forcing
if (Force == false && string.IsNullOrEmpty(_siteService.GetSiteSettings().BaseUrl)) {
Context.Output.WriteLine(T("'BaseUrl' site setting is already set. Use the 'Force' flag to override."));
return null;
}
// Retrieve request URL if BaseUrl not provided as a switch value
if (string.IsNullOrEmpty(BaseUrl)) {
if (_httpContextAccessor.Current() == null) {
Context.Output.WriteLine(T("No HTTP request available to determine the base url of the site"));
return null;
}
var request = _httpContextAccessor.Current().Request;
BaseUrl = request.ToApplicationRootUrlString();
}
// Update base url
_siteService.GetSiteSettings().As<SiteSettingsPart>().BaseUrl = BaseUrl;
Context.Output.WriteLine(T("'BaseUrl' site setting set to '{0}'", BaseUrl));
return null;
}
}
}

View File

@ -14,7 +14,7 @@
TinyMce,Orchard.Media,Orchard.MediaPicker,Orchard.PublishLater,
Orchard.jQuery,Orchard.Widgets,Orchard.Widgets.PageLayerHinting,
Orchard.Scripting,Orchard.Scripting.Lightweight,
PackagingServices,Orchard.Packaging,Gallery.Updates,
PackagingServices,Orchard.Packaging,Gallery.Updates,Orchard.Warmup,
TheThemeMachine" />
<Metadata>
@ -52,5 +52,6 @@
widget create HtmlWidget /Title:"Second Leader Aside" /Zone:"TripelSecond" /Position:"5" /Layer:"TheHomepage" /Identity:"SetupHtmlWidget2" /UseLoremIpsumText:true
widget create HtmlWidget /Title:"Third Leader Aside" /Zone:"TripelThird" /Position:"5" /Layer:"TheHomepage" /Identity:"SetupHtmlWidget3" /UseLoremIpsumText:true
menuitem create /MenuPosition:"1" /MenuText:"Home" /Url:"" /OnMainMenu:true
site setting set baseurl
</Command>
</Orchard>

View File

@ -13,7 +13,7 @@
Orchard.Lists,TinyMce,Orchard.Media,Orchard.MediaPicker,Orchard.PublishLater,
Orchard.jQuery,Orchard.Widgets,Orchard.Widgets.PageLayerHinting,Orchard.ContentTypes,
Orchard.Scripting,Orchard.Scripting.Lightweight,
PackagingServices,Orchard.Packaging,Gallery.Updates,
PackagingServices,Orchard.Packaging,Gallery.Updates,Orchard.Warmup,
TheThemeMachine" />
<Metadata>
@ -48,5 +48,6 @@
widget create HtmlWidget /Title:"Second Leader Aside" /Zone:"TripelSecond" /Position:"5" /Layer:"TheHomepage" /Identity:"SetupHtmlWidget2" /UseLoremIpsumText:true
widget create HtmlWidget /Title:"Third Leader Aside" /Zone:"TripelThird" /Position:"5" /Layer:"TheHomepage" /Identity:"SetupHtmlWidget3" /UseLoremIpsumText:true
menuitem create /MenuPosition:"1" /MenuText:"Home" /Url:"" /OnMainMenu:true
site setting set baseurl
</Command>
</Orchard>