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