Injecting RecipeHarvester impl into the safe mode shell

Setup to call the harvester for the recipes list
SetupContext now contains the recipe for the site, which will be executed
Updated minimal,blog and cms recipe files
Added recipe description to the setup view model to keep it between posts in case of errors

--HG--
branch : recipe
This commit is contained in:
Suha Can
2011-02-12 14:57:11 -08:00
parent 578c107da3
commit e5c821dab3
11 changed files with 81 additions and 35 deletions

View File

@@ -1,8 +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;
@@ -17,7 +20,10 @@ namespace Orchard.Setup.Controllers {
private readonly INotifier _notifier;
private readonly ISetupService _setupService;
public SetupController(INotifier notifier, ISetupService setupService, IViewsBackgroundCompilation viewsBackgroundCompilation) {
public SetupController(
INotifier notifier,
ISetupService setupService,
IViewsBackgroundCompilation viewsBackgroundCompilation) {
_viewsBackgroundCompilation = viewsBackgroundCompilation;
_notifier = notifier;
_setupService = setupService;
@@ -35,12 +41,13 @@ namespace Orchard.Setup.Controllers {
public ActionResult Index() {
var initialSettings = _setupService.Prime();
var recipes = (List<Recipe>)_setupService.Recipes();
// 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();
}
@@ -48,8 +55,10 @@ namespace Orchard.Setup.Controllers {
//
return IndexViewResult(new SetupViewModel {
AdminUsername = "admin",
AdminUsername = "admin",
DatabaseIsPreconfigured = !string.IsNullOrEmpty(initialSettings.DataProvider),
HasRecipes = recipes.Count > 0,
Recipes = recipes
});
}
@@ -71,13 +80,20 @@ namespace Orchard.Setup.Controllers {
}
if (!ModelState.IsValid) {
var recipes = (List<Recipe>)_setupService.Recipes();
model.HasRecipes = recipes.Count > 0;
model.Recipes = recipes;
if (!String.IsNullOrEmpty(model.Recipe)) {
foreach (var recipe in recipes.Where(recipe => recipe.Name == model.Recipe)) {
model.RecipeDescription = recipe.Description;
}
}
model.DatabaseIsPreconfigured = !string.IsNullOrEmpty(_setupService.Prime().DataProvider);
//TODO: set HasRecipes flag and recipedescription
return IndexViewResult(model);
}
try {
var setupContext = new SetupContext {
SiteName = model.SiteName,
AdminUsername = model.AdminUsername,
@@ -85,7 +101,8 @@ namespace Orchard.Setup.Controllers {
DatabaseProvider = model.DatabaseOptions ? "SqlCe" : "SqlServer",
DatabaseConnectionString = model.DatabaseConnectionString,
DatabaseTablePrefix = model.DatabaseTablePrefix,
EnabledFeatures = null // default list
EnabledFeatures = null, // default list
Recipe = model.Recipe
};
_setupService.Setup(setupContext);

View File

@@ -91,6 +91,10 @@
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Recipes\Orchard.Recipes.csproj">
<Project>{FC1D74E8-7A4D-48F4-83DE-95C6173780C4}</Project>
<Name>Orchard.Recipes</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Themes\Orchard.Themes.csproj">
<Project>{CDE24A24-01D3-403C-84B9-37722E18DFB7}</Project>
<Name>Orchard.Themes</Name>

View File

@@ -1,9 +1,11 @@
<?xml version="1.0"?>
<Recipe>
<Name>blog</Name>
<Description>Orchard Blog Recipe</Description>
<Author>The Orchard Team</Author>
<WebSite>http://orchardproject.net</WebSite>
<Tags></Tags>
<Version>1.0</Version>
</Recipe>
<Orchard>
<Recipe>
<Name>blog</Name>
<Description>Orchard Blog Recipe</Description>
<Author>The Orchard Team</Author>
<WebSite>http://orchardproject.net</WebSite>
<Tags></Tags>
<Version>1.0</Version>
</Recipe>
</Orchard>

View File

@@ -1,9 +1,11 @@
<?xml version="1.0"?>
<Recipe>
<Name>cms</Name>
<Description>Orchard CMS Recipe</Description>
<Author>The Orchard Team</Author>
<WebSite>http://orchardproject.net</WebSite>
<Tags></Tags>
<Version>1.0</Version>
</Recipe>
<Orchard>
<Recipe>
<Name>cms</Name>
<Description>Orchard CMS Recipe</Description>
<Author>The Orchard Team</Author>
<WebSite>http://orchardproject.net</WebSite>
<Tags></Tags>
<Version>1.0</Version>
</Recipe>
</Orchard>

View File

@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<Recipe>
<Name>minimal</Name>
<Description>A minimal recipe for Orchard devs</Description>
<Author>The Orchard Team</Author>
<WebSite>http://orchardproject.net</WebSite>
<Tags>developer</Tags>
<Version>1.0</Version>
<Orchard>
<Recipe>
<Name>minimal</Name>
<Description>A minimal recipe for Orchard devs</Description>
<Author>The Orchard Team</Author>
<WebSite>http://orchardproject.net</WebSite>
<Tags>developer</Tags>
<Version>1.0</Version>
</Recipe>
<!-- Steps -->
<CleanUpInactive />
</Recipe>
</Orchard>

View File

@@ -1,8 +1,11 @@
using Orchard.Environment.Configuration;
using System.Collections.Generic;
using Orchard.Environment.Configuration;
using Orchard.Recipes.Models;
namespace Orchard.Setup.Services {
public interface ISetupService : IDependency {
ShellSettings Prime();
IEnumerable<Recipe> Recipes();
void Setup(SetupContext context);
}
}

View File

@@ -9,5 +9,6 @@ namespace Orchard.Setup.Services {
public string DatabaseConnectionString { get; set; }
public string DatabaseTablePrefix { get; set; }
public IEnumerable<string> EnabledFeatures { get; set; }
public string Recipe { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Web;
@@ -23,6 +24,8 @@ using Orchard.Environment.Descriptor.Models;
using Orchard.Indexing;
using Orchard.Localization;
using Orchard.Localization.Services;
using Orchard.Recipes.Models;
using Orchard.Recipes.Services;
using Orchard.Reports.Services;
using Orchard.Security;
using Orchard.Settings;
@@ -41,6 +44,8 @@ namespace Orchard.Setup.Services {
private readonly IShellContainerFactory _shellContainerFactory;
private readonly ICompositionStrategy _compositionStrategy;
private readonly IProcessingEngine _processingEngine;
private readonly IRecipeHarvester _recipeHarvester;
private readonly IEnumerable<Recipe> _recipes;
public SetupService(
ShellSettings shellSettings,
@@ -48,13 +53,16 @@ namespace Orchard.Setup.Services {
IShellSettingsManager shellSettingsManager,
IShellContainerFactory shellContainerFactory,
ICompositionStrategy compositionStrategy,
IProcessingEngine processingEngine) {
IProcessingEngine processingEngine,
IRecipeHarvester recipeHarvester) {
_shellSettings = shellSettings;
_orchardHost = orchardHost;
_shellSettingsManager = shellSettingsManager;
_shellContainerFactory = shellContainerFactory;
_compositionStrategy = compositionStrategy;
_processingEngine = processingEngine;
_recipeHarvester = recipeHarvester;
_recipes = _recipeHarvester.HarvestRecipes("Orchard.Setup");
T = NullLocalizer.Instance;
}
@@ -64,6 +72,10 @@ namespace Orchard.Setup.Services {
return _shellSettings;
}
public IEnumerable<Recipe> Recipes() {
return _recipes;
}
public void Setup(SetupContext context) {
// The vanilla Orchard distibution has the following features enabled.
if (context.EnabledFeatures == null || context.EnabledFeatures.Count() == 0) {

View File

@@ -27,6 +27,7 @@ using Orchard.Mvc.ViewEngines;
using Orchard.Mvc.ViewEngines.Razor;
using Orchard.Mvc.ViewEngines.ThemeAwareness;
using Orchard.Mvc.ViewEngines.WebForms;
using Orchard.Recipes.Services;
using Orchard.Settings;
using Orchard.Themes;
using Orchard.UI.Notify;
@@ -75,6 +76,9 @@ namespace Orchard.Setup {
builder.RegisterType<DefaultDataMigrationInterpreter>().As<IDataMigrationInterpreter>().InstancePerLifetimeScope();
builder.RegisterType<DataMigrationManager>().As<IDataMigrationManager>().InstancePerLifetimeScope();
builder.RegisterType<RecipeHarvester>().As<IRecipeHarvester>().InstancePerLifetimeScope();
builder.RegisterType<RecipeParser>().As<IRecipeParser>().InstancePerLifetimeScope();
// in progress - adding services for display/shape support in setup
builder.RegisterType<DisplayHelperFactory>().As<IDisplayHelperFactory>();
builder.RegisterType<DefaultDisplayManager>().As<IDisplayManager>();

View File

@@ -25,5 +25,6 @@ namespace Orchard.Setup.ViewModels {
public bool HasRecipes { get; set; }
public IEnumerable<Recipe> Recipes { get; set; }
public string Recipe { get; set; }
public string RecipeDescription { get; set; }
}
}

View File

@@ -64,7 +64,7 @@ if (Model.HasRecipes) {
}
</select>
</div>
<div id="recipedescription"></div>
<div id="recipedescription">@Model.RecipeDescription</div>
</fieldset>
}
<div id="throbber">