mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-24 05:42:10 +08:00
#20942: Setup now harvests setup recipes from all modules for the setup screen.
Work Item: 20942
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
<WebSite>http://orchardproject.net</WebSite>
|
||||
<Tags>tag1, tag2</Tags>
|
||||
<Version>1.1</Version>
|
||||
<IsSetupRecipe>true</IsSetupRecipe>
|
||||
</Recipe>
|
||||
|
||||
<!-- Steps -->
|
||||
|
||||
@@ -119,6 +119,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
|
||||
Assert.That(sampleRecipe.Description, Is.EqualTo("a sample Orchard recipe describing a cms"));
|
||||
Assert.That(sampleRecipe.Author, Is.EqualTo("orchard"));
|
||||
Assert.That(sampleRecipe.Version, Is.EqualTo("1.1"));
|
||||
Assert.That(sampleRecipe.IsSetupRecipe, Is.True);
|
||||
Assert.That(sampleRecipe.WebSite, Is.EqualTo("http://orchardproject.net"));
|
||||
Assert.That(sampleRecipe.Tags, Is.EqualTo("tag1, tag2"));
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Orchard.Modules.Controllers {
|
||||
|
||||
IEnumerable<ModuleEntry> modules = _extensionManager.AvailableExtensions()
|
||||
.Where(extensionDescriptor => DefaultExtensionTypes.IsModule(extensionDescriptor.ExtensionType))
|
||||
.Where(extensionDescriptor => extensionDescriptor.Id != "Orchard.Setup" && ModuleIsAllowed(extensionDescriptor))
|
||||
.Where(extensionDescriptor => ModuleIsAllowed(extensionDescriptor))
|
||||
.OrderBy(extensionDescriptor => extensionDescriptor.Name)
|
||||
.Select(extensionDescriptor => new ModuleEntry { Descriptor = extensionDescriptor });
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Orchard.Modules.Controllers {
|
||||
if (_recipeHarvester != null) {
|
||||
viewModel.Modules = modules.Select(x => new ModuleRecipesViewModel {
|
||||
Module = x,
|
||||
Recipes = _recipeHarvester.HarvestRecipes(x.Descriptor.Id).ToList()
|
||||
Recipes = _recipeHarvester.HarvestRecipes(x.Descriptor.Id).Where(recipe => !recipe.IsSetupRecipe).ToList()
|
||||
})
|
||||
.Where(x => x.Recipes.Any());
|
||||
}
|
||||
@@ -148,7 +148,7 @@ namespace Orchard.Modules.Controllers {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Recipe recipe = _recipeHarvester.HarvestRecipes(module.Descriptor.Id).FirstOrDefault(x => x.Name == name);
|
||||
Recipe recipe = _recipeHarvester.HarvestRecipes(module.Descriptor.Id).FirstOrDefault(x => !x.IsSetupRecipe && x.Name == name);
|
||||
|
||||
if (recipe == null) {
|
||||
return HttpNotFound();
|
||||
|
||||
@@ -46,6 +46,9 @@ namespace Orchard.Recipes.Services {
|
||||
case "Version":
|
||||
recipe.Version = metadataElement.Value;
|
||||
break;
|
||||
case "IsSetupRecipe":
|
||||
recipe.IsSetupRecipe = !string.IsNullOrEmpty(metadataElement.Value) ? bool.Parse(metadataElement.Value) : false;
|
||||
break;
|
||||
case "ExportUtc":
|
||||
recipe.ExportUtc = !string.IsNullOrEmpty(metadataElement.Value) ? (DateTime?)XmlConvert.ToDateTime(metadataElement.Value, XmlDateTimeSerializationMode.Utc) : null;
|
||||
break;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<WebSite>http://orchardproject.net</WebSite>
|
||||
<Tags>blog</Tags>
|
||||
<Version>1.0</Version>
|
||||
<IsSetupRecipe>true</IsSetupRecipe>
|
||||
</Recipe>
|
||||
|
||||
<Feature enable="Orchard.Blogs,Orchard.Comments,Orchard.Tags,Orchard.Alias,Orchard.Autoroute,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<WebSite>http://orchardproject.net</WebSite>
|
||||
<Tags>developer</Tags>
|
||||
<Version>1.0</Version>
|
||||
<IsSetupRecipe>true</IsSetupRecipe>
|
||||
</Recipe>
|
||||
|
||||
<Feature disable="Feeds, Containers"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<WebSite>http://orchardproject.net</WebSite>
|
||||
<Tags></Tags>
|
||||
<Version>1.0</Version>
|
||||
<IsSetupRecipe>true</IsSetupRecipe>
|
||||
</Recipe>
|
||||
|
||||
<Feature enable="Orchard.Blogs,Orchard.Comments,Orchard.Tags,Orchard.Alias,Orchard.Autoroute,
|
||||
|
||||
@@ -14,6 +14,8 @@ using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Localization;
|
||||
@@ -33,8 +35,9 @@ namespace Orchard.Setup.Services {
|
||||
private readonly IShellContainerFactory _shellContainerFactory;
|
||||
private readonly ICompositionStrategy _compositionStrategy;
|
||||
private readonly IProcessingEngine _processingEngine;
|
||||
private readonly IExtensionManager _extensionManager;
|
||||
private readonly IRecipeHarvester _recipeHarvester;
|
||||
private readonly IEnumerable<Recipe> _recipes;
|
||||
private IEnumerable<Recipe> _recipes;
|
||||
|
||||
public SetupService(
|
||||
ShellSettings shellSettings,
|
||||
@@ -43,6 +46,7 @@ namespace Orchard.Setup.Services {
|
||||
IShellContainerFactory shellContainerFactory,
|
||||
ICompositionStrategy compositionStrategy,
|
||||
IProcessingEngine processingEngine,
|
||||
IExtensionManager extensionManager,
|
||||
IRecipeHarvester recipeHarvester) {
|
||||
_shellSettings = shellSettings;
|
||||
_orchardHost = orchardHost;
|
||||
@@ -50,8 +54,8 @@ namespace Orchard.Setup.Services {
|
||||
_shellContainerFactory = shellContainerFactory;
|
||||
_compositionStrategy = compositionStrategy;
|
||||
_processingEngine = processingEngine;
|
||||
_extensionManager = extensionManager;
|
||||
_recipeHarvester = recipeHarvester;
|
||||
_recipes = _recipeHarvester.HarvestRecipes("Orchard.Setup");
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
@@ -62,6 +66,16 @@ namespace Orchard.Setup.Services {
|
||||
}
|
||||
|
||||
public IEnumerable<Recipe> Recipes() {
|
||||
if (_recipes == null) {
|
||||
var recipes = new List<Recipe>();
|
||||
|
||||
foreach (var extension in _extensionManager.AvailableExtensions().Where(extension => DefaultExtensionTypes.IsModule(extension.ExtensionType))) {
|
||||
recipes.AddRange(_recipeHarvester.HarvestRecipes(extension.Id).Where(recipe => recipe.IsSetupRecipe));
|
||||
}
|
||||
|
||||
_recipes = recipes;
|
||||
}
|
||||
|
||||
return _recipes;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Orchard.Recipes.Models {
|
||||
public string Author { get; set; }
|
||||
public string WebSite { get; set; }
|
||||
public string Version { get; set; }
|
||||
public bool IsSetupRecipe { get; set; }
|
||||
public DateTime? ExportUtc { get; set; }
|
||||
public string Tags { get; set; }
|
||||
public IEnumerable<RecipeStep> RecipeSteps { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user