diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj b/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj index 75c7ea197..bf0578413 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj +++ b/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj @@ -97,6 +97,10 @@ {9916839C-39FC-4CEB-A5AF-89CA7E87119F} Orchard.Core + + {194D3CCC-1153-474D-8176-FDE8D7D0D0BD} + Orchard.Widgets + diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs index a444f745f..4261700a2 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs @@ -27,6 +27,7 @@ using Orchard.Settings; using Orchard.Themes; using Orchard.Environment.State; using Orchard.Data.Migration; +using Orchard.Widgets.Models; namespace Orchard.Setup.Services { public class SetupService : ISetupService { @@ -224,7 +225,22 @@ namespace Orchard.Setup.Services { //contentManager.Publish(page); //siteSettings.Record.HomePage = "RoutableHomePageProvider;" + page.Id; //scratch that - //create the home page as a WidgetPage + + // add a layer for the homepage + var layer = contentManager.Create("Layer"); + layer.As().Name = "TheHomepage"; + layer.As().LayerRule = "url \"~/\""; + contentManager.Publish(layer); + + // create an html widget with the homepage layer as its container + var htmlWidget = contentManager.Create("HtmlWidget"); + htmlWidget.As().LayerPart = layer.As(); + htmlWidget.As().Title = T("Welcome to Orchard!").Text; + htmlWidget.As().Zone = "Content"; + htmlWidget.As().Text = "

Welcome to Orchard!

Congratulations, you've successfully set-up your Orchard site.

This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click Edit to go into edit mode and replace this with whatever you want on your home page to make it your own.

One thing you could do (but you don't have to) is go into Manage Settings (follow the Admin link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.

You probably want to make the site your own. One of the ways you can do that is by clicking Manage Themes in the admin menu. A theme is a packaged look and feel that affects the whole site.

Next, you can start playing with the content types that we installed. For example, go ahead and click Add New Page in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to Manage Menu. You can also click Add New Blog and start posting by clicking \"Add New Post\".

Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to Manage Themes and clicking Install a new Theme. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please consider participating.

--The Orchard Crew

"; + contentManager.Publish(htmlWidget); + + // create the home page as a WidgetPage var page = contentManager.Create("WidgetPage", VersionOptions.Draft); page.As().Title = T("Home").ToString(); contentManager.Publish(page); diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Filters/WidgetFilter.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Filters/WidgetFilter.cs index 27a293744..9612327fd 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Filters/WidgetFilter.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Filters/WidgetFilter.cs @@ -36,6 +36,7 @@ namespace Orchard.Widgets.Filters { List activeLayerIds = new List(); foreach (var activeLayer in activeLayers) { + var context = workContext.HttpContext; if (_ruleManager.Matches(activeLayer.Record.LayerRule)) { activeLayerIds.Add(activeLayer.ContentItem.Id); } diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/RuleEngine/UrlRuleProvider.cs b/src/Orchard.Web/Modules/Orchard.Widgets/RuleEngine/UrlRuleProvider.cs index 46c127403..fd653ab9e 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/RuleEngine/UrlRuleProvider.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/RuleEngine/UrlRuleProvider.cs @@ -1,21 +1,33 @@ using System; +using Orchard.Mvc; using Orchard.UI.Widgets; namespace Orchard.Widgets.RuleEngine { public class UrlRuleProvider : IRuleProvider { - private readonly IWorkContextAccessor _workContextAccessor; + private readonly IHttpContextAccessor _httpContextAccessor; - public UrlRuleProvider(IWorkContextAccessor workContextAccessor) { - _workContextAccessor = workContextAccessor; + public UrlRuleProvider(IHttpContextAccessor httpContextAccessor) { + _httpContextAccessor = httpContextAccessor; } public void Process(RuleContext ruleContext) { - if (!String.Equals(ruleContext.FunctionName, "url", StringComparison.OrdinalIgnoreCase)) { + if (!String.Equals(ruleContext.FunctionName, "url", StringComparison.OrdinalIgnoreCase)) return; - } - var context = _workContextAccessor.GetContext(); - ruleContext.Result = context.HttpContext.Request.RawUrl.StartsWith(Convert.ToString(ruleContext.Arguments[0])); + var context = _httpContextAccessor.Current(); + var url = Convert.ToString(ruleContext.Arguments[0]); + if (url.StartsWith("~/")) { + url = url.Substring(2); + var appPath = context.Request.ApplicationPath; + if (appPath == "/") + appPath = ""; + url = string.Format("{0}/{1}", appPath, url); + } + if (!url.Contains("?") && url.EndsWith("/")) + url = url.TrimEnd('/'); + ruleContext.Result = url.EndsWith("*") + ? context.Request.RawUrl.ToUpperInvariant().StartsWith(url.ToUpperInvariant()) + : context.Request.Path.ToUpperInvariant() == url.ToUpperInvariant(); } } } \ No newline at end of file