From 2ad6aafc40ecc94806f35d418fe7b7896eac02fa Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 13 May 2010 19:07:53 -0700 Subject: [PATCH] Move list of default features to SetupService This is so that the "setup" command doesn't require a list of features and can use the default list. Also add back tags, widgets and media as enabled by default. --HG-- branch : dev --- .../Orchard.Setup/Commands/SetupCommand.cs | 21 +++++++----- .../Controllers/SetupController.cs | 21 +----------- .../Orchard.Setup/Services/SetupService.cs | 33 +++++++++++++++++-- 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Commands/SetupCommand.cs b/src/Orchard.Web/Modules/Orchard.Setup/Commands/SetupCommand.cs index 69943779f..8970ccb15 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Commands/SetupCommand.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Commands/SetupCommand.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using Orchard.Commands; using Orchard.Setup.Services; @@ -37,6 +38,14 @@ namespace Orchard.Setup.Commands { [CommandName("setup")] [OrchardSwitches("SiteName,AdminUsername,AdminPassword,DatabaseProvider,DatabaseConnectionString,DatabaseTablePrefix,EnabledFeatures")] public void Setup() { + IEnumerable enabledFeatures = null; + if (!string.IsNullOrEmpty(this.EnabledFeatures)) { + enabledFeatures = this.EnabledFeatures + .Split(',') + .Select(s => s.Trim()) + .Where(s => !string.IsNullOrEmpty(s)); + } + var setupContext = new SetupContext { SiteName = this.SiteName, AdminUsername = this.AdminUsername, @@ -44,19 +53,15 @@ namespace Orchard.Setup.Commands { DatabaseProvider = this.DatabaseProvider, DatabaseConnectionString = this.DatabaseConnectionString, DatabaseTablePrefix = this.DatabaseTablePrefix, - EnabledFeatures = this.EnabledFeatures.Split(',').Select(s => s.Trim()) + EnabledFeatures = enabledFeatures }; _setupService.Setup(setupContext); - Context.Output.WriteLine("Site \"{0}\" setup to run data provider \"{1}\" (with table prefix \"{2}\") with the following features enabled:", + Context.Output.WriteLine(T("Site \"{0}\" sucessfully setup to run data provider \"{1}\" (with table prefix \"{2}\").", setupContext.SiteName, setupContext.DatabaseProvider, - setupContext.DatabaseTablePrefix); - - foreach (var feature in setupContext.EnabledFeatures) { - this.Context.Output.WriteLine("{0}", feature); - } + setupContext.DatabaseTablePrefix)); } } } diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs index 2c148d7c1..3b89d2121 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs @@ -65,25 +65,6 @@ namespace Orchard.Setup.Controllers { } try { - // The vanilla Orchard distibution has the following features enabled. - string[] hardcoded = { - "Orchard.Framework", - "Common", - "Dashboard", - "Feeds", - "HomePage", - "Navigation", - "Scheduling", - "Settings", - "XmlRpc", - "Orchard.Users", - "Orchard.Roles", - "TinyMce", - "Orchard.Modules", - "Orchard.Themes", - "Orchard.Pages", - "Orchard.Blogs", - "Orchard.Comments"}; var setupContext = new SetupContext { SiteName = model.SiteName, @@ -92,7 +73,7 @@ namespace Orchard.Setup.Controllers { DatabaseProvider = model.DatabaseOptions ? "SQLite" : "SqlServer", DatabaseConnectionString = model.DatabaseConnectionString, DatabaseTablePrefix = model.DatabaseTablePrefix, - EnabledFeatures = hardcoded + EnabledFeatures = null // default list }; _setupService.Setup(setupContext); diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs index bc59bb05f..a61e4955a 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs @@ -49,13 +49,40 @@ namespace Orchard.Setup.Services { } public void Setup(SetupContext context) { + // The vanilla Orchard distibution has the following features enabled. + if (context.EnabledFeatures == null || context.EnabledFeatures.Count() == 0) { + string[] hardcoded = { + "Orchard.Framework", + "Common", + "Dashboard", + "Feeds", + "HomePage", + "Navigation", + "Scheduling", + "Settings", + "XmlRpc", + "Orchard.Users", + "Orchard.Roles", + "TinyMce", + "Orchard.Modules", + "Orchard.Themes", + "Orchard.Pages", + "Orchard.Blogs", + "Orchard.Comments", + "Orchard.Tags", + "Orchard.Media", + "Futures.Widgets"}; + + context.EnabledFeatures = hardcoded; + } + var shellSettings = new ShellSettings(_shellSettings); if (string.IsNullOrEmpty(shellSettings.DataProvider)) { shellSettings.DataProvider = context.DatabaseProvider; shellSettings.DataConnectionString = context.DatabaseConnectionString; shellSettings.DataTablePrefix = context.DatabaseTablePrefix; - }; + } var shellDescriptor = new ShellDescriptor { EnabledFeatures = context.EnabledFeatures.Select(name => new ShellFeature { Name = name }) @@ -113,8 +140,10 @@ namespace Orchard.Setup.Services { page.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

"; page.As().Slug = "home"; page.As().Title = T("Home").ToString(); - page.As().CommentsShown = false; page.As().Owner = user; + if (page.Has()) { + page.As().CommentsShown = false; + } contentManager.Publish(page); siteSettings.Record.HomePage = "PageHomePageProvider;" + page.Id;