From 4a606ae6f499f114caa66cd1f33bd09b2c96203f Mon Sep 17 00:00:00 2001 From: Suha Can Date: Tue, 22 Feb 2011 15:31:38 -0800 Subject: [PATCH] Adding a default recipe and making the recipe choice optional in setup. --HG-- branch : recipe --- src/Orchard.Specs/Hosting/WebHost.cs | 4 ++ src/Orchard.Specs/Setup.feature | 1 - src/Orchard.Specs/Setup.feature.cs | 11 ++-- .../Controllers/SetupController.cs | 18 +++---- .../Orchard.Setup/Orchard.Setup.csproj | 1 + .../Orchard.Setup/Recipes/default.recipe.xml | 52 +++++++++++++++++++ .../Orchard.Setup/Views/Setup/Index.cshtml | 2 +- 7 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 src/Orchard.Web/Modules/Orchard.Setup/Recipes/default.recipe.xml diff --git a/src/Orchard.Specs/Hosting/WebHost.cs b/src/Orchard.Specs/Hosting/WebHost.cs index 0ee84fd03..06c776ab3 100644 --- a/src/Orchard.Specs/Hosting/WebHost.cs +++ b/src/Orchard.Specs/Hosting/WebHost.cs @@ -20,6 +20,7 @@ namespace Orchard.Specs.Hosting { private IEnumerable _knownModules; private IEnumerable _knownThemes; private IEnumerable _knownBinAssemblies; + private IEnumerable _knownRecipes; public WebHost(Path orchardTemp) { _orchardTemp = orchardTemp; @@ -97,6 +98,9 @@ namespace Orchard.Specs.Hosting { path => IsSpecFlowTestAssembly(path) && !_tempSite.Combine("bin").Combine(path.FileName).Exists, _tempSite.Combine("bin")); + Log("Copy Orchard recipes"); + _orchardWebPath.Combine("Modules").Combine("Orchard.Setup").Combine("Recipes").DeepCopy("*.xml", _tempSite.Combine("Modules").Combine("Orchard.Setup").Combine("Recipes")); + StartAspNetHost(virtualDirectory); Log("ASP.NET host initialization completed in {0} sec", stopwatch.Elapsed.TotalSeconds); diff --git a/src/Orchard.Specs/Setup.feature b/src/Orchard.Specs/Setup.feature index 092313c61..1cb6d8ab4 100644 --- a/src/Orchard.Specs/Setup.feature +++ b/src/Orchard.Specs/Setup.feature @@ -48,7 +48,6 @@ Scenario: Calling setup on a brand new install | SiteName | My Site | | AdminPassword | 6655321 | | ConfirmPassword | 6655321 | - | Recipe | Minimal | And I hit "Finish Setup" And I go to "/" Then I should see "My Site" diff --git a/src/Orchard.Specs/Setup.feature.cs b/src/Orchard.Specs/Setup.feature.cs index ac5f5f9f8..811f0aeed 100644 --- a/src/Orchard.Specs/Setup.feature.cs +++ b/src/Orchard.Specs/Setup.feature.cs @@ -203,18 +203,15 @@ this.ScenarioSetup(scenarioInfo); table5.AddRow(new string[] { "ConfirmPassword", "6655321"}); - table5.AddRow(new string[] { - "Recipe", - "Minimal"}); #line 46 testRunner.When("I fill in", ((string)(null)), table5); -#line 52 +#line 51 testRunner.And("I hit \"Finish Setup\""); -#line 53 +#line 52 testRunner.And("I go to \"/\""); -#line 54 +#line 53 testRunner.Then("I should see \"My Site\""); -#line 55 +#line 54 testRunner.And("I should see \"Welcome, admin<" + "/strong>!\""); #line hidden diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs index d4d6bb965..c6fdb2321 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs @@ -19,6 +19,7 @@ namespace Orchard.Setup.Controllers { private readonly IViewsBackgroundCompilation _viewsBackgroundCompilation; private readonly INotifier _notifier; private readonly ISetupService _setupService; + private const string DefaultRecipe = "Default"; public SetupController( INotifier notifier, @@ -41,13 +42,13 @@ namespace Orchard.Setup.Controllers { public ActionResult Index() { var initialSettings = _setupService.Prime(); - var recipes = (List)_setupService.Recipes(); + var recipes = _setupService.Recipes().Where(r => r.Name != DefaultRecipe); // On the first time installation of Orchard, the user gets to the setup screen, which // will take a while to finish (user inputting data and the setup process itself). // We use this opportunity to start a background task to "pre-compile" all the known // views in the app folder, so that the application is more reponsive when the user - // hits the homepage and admin screens for the first time. + // hits the homepage and admin screens for the first time.)) if (StringComparer.OrdinalIgnoreCase.Equals(initialSettings.Name, ShellSettings.DefaultName)) { _viewsBackgroundCompilation.Start(); } @@ -77,17 +78,14 @@ namespace Orchard.Setup.Controllers { ModelState.AddModelError("DatabaseTablePrefix", T("The table prefix must begin with a letter").Text); } } - if (String.IsNullOrEmpty(model.Recipe)) { - ModelState.AddModelError("Recipe", T("You must choose a recipe. Recipes come from the Recipes folder of your Setup module.").Text); + if (model.Recipe == null) { + model.Recipe = DefaultRecipe; } - if (!ModelState.IsValid) { - var recipes = (List)_setupService.Recipes(); + var recipes = _setupService.Recipes().Where(r => r.Name != DefaultRecipe); model.Recipes = recipes; - if (!String.IsNullOrEmpty(model.Recipe)) { - foreach (var recipe in recipes.Where(recipe => recipe.Name == model.Recipe)) { - model.RecipeDescription = recipe.Description; - } + foreach (var recipe in recipes.Where(recipe => recipe.Name == model.Recipe)) { + model.RecipeDescription = recipe.Description; } model.DatabaseIsPreconfigured = !string.IsNullOrEmpty(_setupService.Prime().DataProvider); diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj b/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj index 1701df8d9..4cbbda406 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj +++ b/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj @@ -77,6 +77,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Recipes/default.recipe.xml b/src/Orchard.Web/Modules/Orchard.Setup/Recipes/default.recipe.xml new file mode 100644 index 000000000..589d1aa1b --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Setup/Recipes/default.recipe.xml @@ -0,0 +1,52 @@ + + + + Default + A recipe providing a default Orchard installation profile. + The Orchard Team + http://orchardproject.net + + 1.0 + + + + + + + + + + + + + + + + + + + + + + + + + layer create /Name:"Default" /LayerRule:"true" + layer create /Name:"Authenticated" /LayerRule:"authenticated" + layer create /Name:"Anonymous" /LayerRule:"not authenticated" + layer create /Name:"Disabled" /LayerRule:"false" + layer create /Name:"TheHomepage" /LayerRule:"url '~/'" + page create /Slug:"welcome-to-orchard" /Title:"Welcome to Orchard!" /Path:"welcome-to-orchard" /Homepage:true /Publish:true /UseWelcomeText:true + widget create /Type:"HtmlWidget" /Title:"First Leader Aside" /Zone:"TripelFirst" /Position:"5" /Layer:"TheHomepage" /UseLoremIpsumText:true + widget create /Type:"HtmlWidget" /Title:"Second Leader Aside" /Zone:"TripelSecond" /Position:"5" /Layer:"TheHomepage" /UseLoremIpsumText:true + widget create /Type:"HtmlWidget" /Title:"Third Leader Aside" /Zone:"TripelThird" /Position:"5" /Layer:"TheHomepage" /UseLoremIpsumText:true + menuitem create /MenuPosition:"1" /MenuText:"Home" /Url:"" /OnMainMenu:true + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.cshtml b/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.cshtml index 8b172aea0..0a3191cf0 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.cshtml @@ -52,7 +52,7 @@ if (!Model.DatabaseIsPreconfigured) { }
- @T("Choose an Orchard Recipe") + @T("Choose an Orchard Recipe (Optional)")
@T("Orchard Recipes allow you to setup your site with additional pre-configured options, features and settings out of the box")