Removing customcontentsite recipe.

Making Default the default option on the recipe dropdown.
Few related changes.

--HG--
branch : dev
This commit is contained in:
Suha Can
2011-02-23 17:00:31 -08:00
parent 384cc5758b
commit fd6f994143
5 changed files with 33 additions and 44 deletions

View File

@@ -1,9 +1,11 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web.Mvc; using System.Web.Mvc;
using Orchard.Environment; using Orchard.Environment;
using Orchard.Environment.Configuration; using Orchard.Environment.Configuration;
using Orchard.Logging; using Orchard.Logging;
using Orchard.Recipes.Models;
using Orchard.Setup.Services; using Orchard.Setup.Services;
using Orchard.Setup.ViewModels; using Orchard.Setup.ViewModels;
using Orchard.Localization; using Orchard.Localization;
@@ -40,7 +42,11 @@ namespace Orchard.Setup.Controllers {
public ActionResult Index() { public ActionResult Index() {
var initialSettings = _setupService.Prime(); 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 // 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). // 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 { return IndexViewResult(new SetupViewModel {
AdminUsername = "admin", AdminUsername = "admin",
DatabaseIsPreconfigured = !string.IsNullOrEmpty(initialSettings.DataProvider), DatabaseIsPreconfigured = !string.IsNullOrEmpty(initialSettings.DataProvider),
Recipes = recipes Recipes = recipes,
RecipeDescription = recipeDescription
}); });
} }
[HttpPost, ActionName("Index")] [HttpPost, ActionName("Index")]
public ActionResult IndexPOST(SetupViewModel model) { public ActionResult IndexPOST(SetupViewModel model) {
var recipes = OrderRecipes(_setupService.Recipes());
//TODO: Couldn't get a custom ValidationAttribute to validate two properties //TODO: Couldn't get a custom ValidationAttribute to validate two properties
if (!model.DatabaseOptions && string.IsNullOrEmpty(model.DatabaseConnectionString)) if (!model.DatabaseOptions && string.IsNullOrEmpty(model.DatabaseConnectionString))
ModelState.AddModelError("DatabaseConnectionString", T("A SQL connection string is required").Text); ModelState.AddModelError("DatabaseConnectionString", T("A SQL connection string is required").Text);
@@ -77,10 +86,14 @@ namespace Orchard.Setup.Controllers {
} }
} }
if (model.Recipe == null) { 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) { if (!ModelState.IsValid) {
var recipes = _setupService.Recipes().Where(r => r.Name != DefaultRecipe);
model.Recipes = recipes; model.Recipes = recipes;
foreach (var recipe in recipes.Where(recipe => recipe.Name == model.Recipe)) { foreach (var recipe in recipes.Where(recipe => recipe.Name == model.Recipe)) {
model.RecipeDescription = recipe.Description; model.RecipeDescription = recipe.Description;
@@ -117,5 +130,19 @@ namespace Orchard.Setup.Controllers {
return IndexViewResult(model); return IndexViewResult(model);
} }
} }
private static List<Recipe> OrderRecipes(IEnumerable<Recipe> recipes) {
var recipeList = new List<Recipe>();
var tempList = new List<Recipe>();
foreach (var recipe in recipes) {
if (recipe.Name == DefaultRecipe) {
recipeList.Add(recipe);
}
else {
tempList.Add(recipe);
}
}
return recipeList.Concat(tempList).ToList();
}
} }
} }

View File

@@ -78,7 +78,6 @@
<Content Include="Content\synchronizing.gif" /> <Content Include="Content\synchronizing.gif" />
<Content Include="Recipes\blog.recipe.xml" /> <Content Include="Recipes\blog.recipe.xml" />
<Content Include="Recipes\default.recipe.xml" /> <Content Include="Recipes\default.recipe.xml" />
<Content Include="Recipes\customcontentsite.recipe.xml" />
<Content Include="Recipes\minimal.recipe.xml" /> <Content Include="Recipes\minimal.recipe.xml" />
<Content Include="Scripts\setup.js" /> <Content Include="Scripts\setup.js" />
<Content Include="Views\Setup\Index.cshtml" /> <Content Include="Views\Setup\Index.cshtml" />

View File

@@ -1,35 +0,0 @@
<?xml version="1.0"?>
<Orchard>
<Recipe>
<Name>Custom Content Site</Name>
<Description>A recipe providing an installation profile with the functionality needed to create content-based custom sites.</Description>
<Author>The Orchard Team</Author>
<WebSite>http://orchardproject.net</WebSite>
<Tags></Tags>
<Version>1.0</Version>
</Recipe>
<Feature enable="Orchard.ContentTypes,Orchard.Lists,Orchard.PublishLater,
Orchard.jQuery,TinyMce,Orchard.Media,Orchard.MediaPicker,
PackagingServices,Orchard.Packaging,Gallery,TheThemeMachine" />
<Metadata>
<Types>
<Page ContentTypeSettings.Draftable="True" TypeIndexing.Included="true" />
</Types>
<Parts>
<BodyPart BodyPartSettings.FlavorDefault="html" />
<!-- Dynamic parts -->
</Parts>
</Metadata>
<Settings>
</Settings>
<Command>
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
</Command>
<Migration features="*" />
</Orchard>

View File

@@ -2,7 +2,7 @@
<Orchard> <Orchard>
<Recipe> <Recipe>
<Name>Default</Name> <Name>Default</Name>
<Description>A recipe providing a default Orchard installation profile.</Description> <Description>The default recipe for an Orchard site that includes pages, blogs, custom content types, comments, tags, widgets and basic navigation.</Description>
<Author>The Orchard Team</Author> <Author>The Orchard Team</Author>
<WebSite>http://orchardproject.net</WebSite> <WebSite>http://orchardproject.net</WebSite>
<Tags></Tags> <Tags></Tags>

View File

@@ -52,12 +52,10 @@ if (!Model.DatabaseIsPreconfigured) {
</fieldset> </fieldset>
} }
<fieldset> <fieldset>
<legend>@T("Choose an Orchard Recipe (Optional)")</legend> <legend>@T("Choose an Orchard Recipe")</legend>
<div>@T("Orchard Recipes allow you to setup your site with additional pre-configured options, features and settings out of the box")</div> <div>@T("Orchard Recipes allow you to setup your site with additional pre-configured options, features and settings out of the box")</div>
<div> <div>
<select id="@Html.FieldIdFor(m => m.Recipe)" name="@Html.FieldNameFor(m => m.Recipe)" class="recipe"> <select id="@Html.FieldIdFor(m => m.Recipe)" name="@Html.FieldNameFor(m => m.Recipe)" class="recipe">
@Html.SelectOption("", false, T("Choose").ToString(), new { recipedescription = "" })
@Html.SelectOption("", false, T("-------------------").ToString(), new { recipedescription = "" })
@foreach(var recipe in Model.Recipes) { @foreach(var recipe in Model.Recipes) {
@Html.SelectOption(Model.Recipe, recipe.Name, recipe.Name, new { recipedescription = recipe.Description }) @Html.SelectOption(Model.Recipe, recipe.Name, recipe.Name, new { recipedescription = recipe.Description })
} }