From fd6f9941430a261986f722f231956b35156517c6 Mon Sep 17 00:00:00 2001 From: Suha Can Date: Wed, 23 Feb 2011 17:00:31 -0800 Subject: [PATCH] Removing customcontentsite recipe. Making Default the default option on the recipe dropdown. Few related changes. --HG-- branch : dev --- .../Controllers/SetupController.cs | 35 ++++++++++++++++--- .../Orchard.Setup/Orchard.Setup.csproj | 1 - .../Recipes/customcontentsite.recipe.xml | 35 ------------------- .../Orchard.Setup/Recipes/default.recipe.xml | 2 +- .../Orchard.Setup/Views/Setup/Index.cshtml | 4 +-- 5 files changed, 33 insertions(+), 44 deletions(-) delete mode 100644 src/Orchard.Web/Modules/Orchard.Setup/Recipes/customcontentsite.recipe.xml diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs index 82c4efc8c..33f82a2f2 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs @@ -1,9 +1,11 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using Orchard.Environment; using Orchard.Environment.Configuration; using Orchard.Logging; +using Orchard.Recipes.Models; using Orchard.Setup.Services; using Orchard.Setup.ViewModels; using Orchard.Localization; @@ -40,7 +42,11 @@ namespace Orchard.Setup.Controllers { public ActionResult Index() { var initialSettings = _setupService.Prime(); - var recipes = _setupService.Recipes().Where(r => r.Name != DefaultRecipe); + var recipes = OrderRecipes(_setupService.Recipes()); + string recipeDescription = null; + if (recipes.Count > 0) { + recipeDescription = recipes[0].Description; + } // 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). @@ -56,12 +62,15 @@ namespace Orchard.Setup.Controllers { return IndexViewResult(new SetupViewModel { AdminUsername = "admin", DatabaseIsPreconfigured = !string.IsNullOrEmpty(initialSettings.DataProvider), - Recipes = recipes + Recipes = recipes, + RecipeDescription = recipeDescription }); } [HttpPost, ActionName("Index")] public ActionResult IndexPOST(SetupViewModel model) { + var recipes = OrderRecipes(_setupService.Recipes()); + //TODO: Couldn't get a custom ValidationAttribute to validate two properties if (!model.DatabaseOptions && string.IsNullOrEmpty(model.DatabaseConnectionString)) ModelState.AddModelError("DatabaseConnectionString", T("A SQL connection string is required").Text); @@ -77,10 +86,14 @@ namespace Orchard.Setup.Controllers { } } if (model.Recipe == null) { - model.Recipe = DefaultRecipe; + if (!(recipes.Select(r => r.Name).Contains(DefaultRecipe))) { + ModelState.AddModelError("Recipe", T("No recipes were found in the Setup module").Text); + } + else { + model.Recipe = DefaultRecipe; + } } if (!ModelState.IsValid) { - var recipes = _setupService.Recipes().Where(r => r.Name != DefaultRecipe); model.Recipes = recipes; foreach (var recipe in recipes.Where(recipe => recipe.Name == model.Recipe)) { model.RecipeDescription = recipe.Description; @@ -117,5 +130,19 @@ namespace Orchard.Setup.Controllers { return IndexViewResult(model); } } + + private static List OrderRecipes(IEnumerable recipes) { + var recipeList = new List(); + var tempList = new List(); + foreach (var recipe in recipes) { + if (recipe.Name == DefaultRecipe) { + recipeList.Add(recipe); + } + else { + tempList.Add(recipe); + } + } + return recipeList.Concat(tempList).ToList(); + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj b/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj index 4cbbda406..e8e081558 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj +++ b/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj @@ -78,7 +78,6 @@ - diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Recipes/customcontentsite.recipe.xml b/src/Orchard.Web/Modules/Orchard.Setup/Recipes/customcontentsite.recipe.xml deleted file mode 100644 index 9b7f88eb6..000000000 --- a/src/Orchard.Web/Modules/Orchard.Setup/Recipes/customcontentsite.recipe.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - Custom Content Site - A recipe providing an installation profile with the functionality needed to create content-based custom sites. - The Orchard Team - http://orchardproject.net - - 1.0 - - - - - - - - - - - - - - - - - - - page create /Slug:"welcome-to-orchard" /Title:"Welcome to Orchard!" /Path:"welcome-to-orchard" /Homepage:true /Publish:true /UseWelcomeText:true - menuitem create /MenuPosition:"1" /MenuText:"Home" /Url:"" /OnMainMenu:true - - - - diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Recipes/default.recipe.xml b/src/Orchard.Web/Modules/Orchard.Setup/Recipes/default.recipe.xml index a64343c58..62919852a 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Recipes/default.recipe.xml +++ b/src/Orchard.Web/Modules/Orchard.Setup/Recipes/default.recipe.xml @@ -2,7 +2,7 @@ Default - A recipe providing a default Orchard installation profile. + The default recipe for an Orchard site that includes pages, blogs, custom content types, comments, tags, widgets and basic navigation. The Orchard Team http://orchardproject.net 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 0a3191cf0..547c421ce 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.cshtml @@ -52,12 +52,10 @@ if (!Model.DatabaseIsPreconfigured) { }
- @T("Choose an Orchard Recipe (Optional)") + @T("Choose an Orchard Recipe")
@T("Orchard Recipes allow you to setup your site with additional pre-configured options, features and settings out of the box")