mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding option to process recipes when installing modules. Adding detailed installation page to local installation. Moving installation processes to PackagingServices feature. Correcting dependencies between features.
--HG-- branch : dev
This commit is contained in:
@@ -157,7 +157,7 @@ Features:
|
||||
public void Uninstall(string packageId, string applicationPath) {
|
||||
}
|
||||
|
||||
public ExtensionDescriptor GetExtensionDescriptor(IPackage package) {
|
||||
public ExtensionDescriptor GetExtensionDescriptor(IPackage package, string extensionType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
@@ -3,12 +3,10 @@ using System.IO;
|
||||
using System.Web;
|
||||
using System.Web.Hosting;
|
||||
using Orchard.Commands;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Packaging.Services;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Packaging.Commands {
|
||||
[OrchardFeature("Orchard.Packaging")]
|
||||
public class PackagingCommands : DefaultOrchardCommandHandler {
|
||||
private static readonly string ApplicationPath = HostingEnvironment.MapPath("~/");
|
||||
|
||||
|
@@ -2,19 +2,13 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Hosting;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Xml.Linq;
|
||||
using NuGet;
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Modules.Services;
|
||||
using Orchard.Packaging.Models;
|
||||
using Orchard.Packaging.Services;
|
||||
using Orchard.Packaging.ViewModels;
|
||||
@@ -33,20 +27,16 @@ namespace Orchard.Packaging.Controllers {
|
||||
[Themed, Admin]
|
||||
public class GalleryController : Controller {
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly IPackageManager _packageManager;
|
||||
private readonly IPackagingSourceManager _packagingSourceManager;
|
||||
private readonly IModuleService _moduleService;
|
||||
|
||||
public GalleryController(
|
||||
ShellSettings shellSettings,
|
||||
IPackageManager packageManager,
|
||||
IPackagingSourceManager packagingSourceManager,
|
||||
IModuleService moduleService,
|
||||
IOrchardServices services) {
|
||||
|
||||
_shellSettings = shellSettings;
|
||||
_packageManager = packageManager;
|
||||
_packagingSourceManager = packagingSourceManager;
|
||||
_moduleService = moduleService;
|
||||
Services = services;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
@@ -232,78 +222,5 @@ namespace Orchard.Packaging.Controllers {
|
||||
Options = options
|
||||
});
|
||||
}
|
||||
|
||||
public ActionResult Install(string packageId, string version, int sourceId, string redirectTo) {
|
||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var source = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
|
||||
if (source == null) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
PackageInfo packageInfo = InstallPackage(packageId, version, source);
|
||||
if (DefaultExtensionTypes.IsModule(packageInfo.ExtensionType)) {
|
||||
IPackageRepository packageRepository = PackageRepositoryFactory.Default.CreateRepository(new PackageSource(source.FeedUrl, "Default"));
|
||||
|
||||
IPackage package = packageRepository.FindPackage(packageId);
|
||||
ExtensionDescriptor extensionDescriptor = _packageManager.GetExtensionDescriptor(package);
|
||||
|
||||
List<PackagingInstallFeatureViewModel> features = extensionDescriptor.Features
|
||||
.Where(featureDescriptor => !DefaultExtensionTypes.IsTheme(featureDescriptor.Extension.ExtensionType))
|
||||
.Select(featureDescriptor => new PackagingInstallFeatureViewModel {
|
||||
Enable = true, // by default all features are enabled
|
||||
FeatureDescriptor = featureDescriptor
|
||||
}).ToList();
|
||||
|
||||
if (features.Count > 0) {
|
||||
return View("InstallModule", new PackagingInstallViewModel {
|
||||
Features = features,
|
||||
ExtensionDescriptor = extensionDescriptor
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToAction(redirectTo);
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("InstallModule")]
|
||||
public ActionResult InstallModulePOST(PackagingInstallViewModel packagingInstallViewModel, string packageId, string version, int sourceId, string redirectTo) {
|
||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var source = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
|
||||
|
||||
if (source == null) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
// Enable selected features
|
||||
if (packagingInstallViewModel.Features.Count > 0) {
|
||||
IEnumerable<string> featureIds = packagingInstallViewModel.Features.Select(feature => feature.FeatureDescriptor.Id);
|
||||
|
||||
// Enable the features and its dependencies
|
||||
_moduleService.EnableFeatures(featureIds, true);
|
||||
}
|
||||
|
||||
return RedirectToAction(redirectTo);
|
||||
}
|
||||
|
||||
private PackageInfo InstallPackage(string packageId, string version, PackagingSource source) {
|
||||
PackageInfo packageInfo = null;
|
||||
try {
|
||||
packageInfo = _packageManager.Install(packageId, version, source.FeedUrl, HostingEnvironment.MapPath("~/"));
|
||||
|
||||
if (DefaultExtensionTypes.IsTheme(packageInfo.ExtensionType)) {
|
||||
Services.Notifier.Information(T("The theme has been successfully installed. It can be enabled in the \"Themes\" page accessible from the menu."));
|
||||
} else if (DefaultExtensionTypes.IsModule(packageInfo.ExtensionType)) {
|
||||
Services.Notifier.Information(T("The module has been successfully installed."));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
this.Error(exception, T("Package installation failed."), Logger, Services.Notifier);
|
||||
}
|
||||
|
||||
return packageInfo;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Hosting;
|
||||
using System.Web.Mvc;
|
||||
@@ -9,8 +11,13 @@ using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Modules.Services;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Packaging.Models;
|
||||
using Orchard.Packaging.Services;
|
||||
using Orchard.Packaging.ViewModels;
|
||||
using Orchard.Recipes.Models;
|
||||
using Orchard.Recipes.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Themes;
|
||||
using Orchard.UI.Admin;
|
||||
@@ -20,26 +27,37 @@ using IPackageManager = Orchard.Packaging.Services.IPackageManager;
|
||||
using PackageBuilder = Orchard.Packaging.Services.PackageBuilder;
|
||||
|
||||
namespace Orchard.Packaging.Controllers {
|
||||
[OrchardFeature("PackagingServices")]
|
||||
[Themed, Admin]
|
||||
public class PackagingServicesController : Controller {
|
||||
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly IPackageManager _packageManager;
|
||||
private readonly IPackagingSourceManager _packagingSourceManager;
|
||||
private readonly IAppDataFolderRoot _appDataFolderRoot;
|
||||
private readonly INotifier _notifier;
|
||||
private readonly IModuleService _moduleService;
|
||||
private readonly IRecipeHarvester _recipeHarvester;
|
||||
private readonly IRecipeManager _recipeManager;
|
||||
|
||||
public PackagingServicesController(
|
||||
ShellSettings shellSettings,
|
||||
IPackageManager packageManager,
|
||||
IPackagingSourceManager packagingSourceManager,
|
||||
INotifier notifier,
|
||||
IAppDataFolderRoot appDataFolderRoot,
|
||||
IOrchardServices services) {
|
||||
IOrchardServices services,
|
||||
IModuleService moduleService,
|
||||
IRecipeHarvester recipeHarvester,
|
||||
IRecipeManager recipeManager) {
|
||||
|
||||
_shellSettings = shellSettings;
|
||||
_packageManager = packageManager;
|
||||
_notifier = notifier;
|
||||
_appDataFolderRoot = appDataFolderRoot;
|
||||
_moduleService = moduleService;
|
||||
_recipeHarvester = recipeHarvester;
|
||||
_recipeManager = recipeManager;
|
||||
_packagingSourceManager = packagingSourceManager;
|
||||
Services = services;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
@@ -57,14 +75,6 @@ namespace Orchard.Packaging.Controllers {
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("AddTheme")]
|
||||
public ActionResult AddThemePOST(string returnUrl) {
|
||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add themes")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
return InstallPackage(returnUrl, Request.RawUrl);
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("RemoveTheme")]
|
||||
public ActionResult RemoveThemePOST(string themeId, string returnUrl, string retryUrl) {
|
||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to remove themes")))
|
||||
@@ -80,41 +90,129 @@ namespace Orchard.Packaging.Controllers {
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("AddModule")]
|
||||
public ActionResult AddModulePOST(string returnUrl) {
|
||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add modules")))
|
||||
public ActionResult InstallGallery(string packageId, string version, int sourceId, string redirectUrl) {
|
||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
return InstallPackage(returnUrl, Request.RawUrl);
|
||||
try {
|
||||
var source = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
|
||||
if (source == null) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
PackageInfo packageInfo = _packageManager.Install(packageId, version, source.FeedUrl, HostingEnvironment.MapPath("~/"));
|
||||
|
||||
if (DefaultExtensionTypes.IsTheme(packageInfo.ExtensionType)) {
|
||||
Services.Notifier.Information(T("The theme has been successfully installed. It can be enabled in the \"Themes\" page accessible from the menu."));
|
||||
} else if (DefaultExtensionTypes.IsModule(packageInfo.ExtensionType)) {
|
||||
Services.Notifier.Information(T("The module has been successfully installed."));
|
||||
|
||||
IPackageRepository packageRepository = PackageRepositoryFactory.Default.CreateRepository(new PackageSource(source.FeedUrl, "Default"));
|
||||
IPackage package = packageRepository.FindPackage(packageId);
|
||||
ExtensionDescriptor extensionDescriptor = _packageManager.GetExtensionDescriptor(package, packageInfo.ExtensionType);
|
||||
|
||||
return InstallPackageDetails(extensionDescriptor, redirectUrl);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
this.Error(exception, T("Package installation failed."), Logger, Services.Notifier);
|
||||
}
|
||||
|
||||
return Redirect(redirectUrl);
|
||||
}
|
||||
|
||||
public ActionResult InstallPackage(string returnUrl, string retryUrl) {
|
||||
public ActionResult InstallLocally(string redirectUrl) {
|
||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to install packages")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
try {
|
||||
if (Request.Files != null &&
|
||||
Request.Files.Count > 0 &&
|
||||
!string.IsNullOrWhiteSpace(Request.Files[0].FileName)) {
|
||||
ModelState.AddModelError("File", T("Select a file to upload.").ToString());
|
||||
if (Request.Files == null ||
|
||||
Request.Files.Count == 0 ||
|
||||
string.IsNullOrWhiteSpace(Request.Files.Get(0).FileName)) {
|
||||
|
||||
throw new OrchardException(T("Select a file to upload."));
|
||||
}
|
||||
|
||||
foreach (string fileName in Request.Files) {
|
||||
HttpPostedFileBase file = Request.Files[fileName];
|
||||
if (file != null) {
|
||||
string fullFileName = Path.Combine(_appDataFolderRoot.RootFolder, fileName + ".nupkg").Replace(Path.DirectorySeparatorChar, '/');
|
||||
file.SaveAs(fullFileName);
|
||||
PackageInfo info = _packageManager.Install(new ZipPackage(fullFileName), _appDataFolderRoot.RootFolder, HostingEnvironment.MapPath("~/"));
|
||||
System.IO.File.Delete(fullFileName);
|
||||
HttpPostedFileBase file = Request.Files.Get(0);
|
||||
string fullFileName = Path.Combine(_appDataFolderRoot.RootFolder, file.FileName + ".nupkg").Replace(Path.DirectorySeparatorChar, '/');
|
||||
file.SaveAs(fullFileName);
|
||||
ZipPackage package = new ZipPackage(fullFileName);
|
||||
PackageInfo packageInfo = _packageManager.Install(package, _appDataFolderRoot.RootFolder, HostingEnvironment.MapPath("~/"));
|
||||
ExtensionDescriptor extensionDescriptor = _packageManager.GetExtensionDescriptor(package, packageInfo.ExtensionType);
|
||||
System.IO.File.Delete(fullFileName);
|
||||
|
||||
if (DefaultExtensionTypes.IsTheme(extensionDescriptor.ExtensionType)) {
|
||||
Services.Notifier.Information(T("The theme has been successfully installed. It can be enabled in the \"Themes\" page accessible from the menu."));
|
||||
} else if (DefaultExtensionTypes.IsModule(extensionDescriptor.ExtensionType)) {
|
||||
Services.Notifier.Information(T("The module has been successfully installed."));
|
||||
|
||||
return InstallPackageDetails(extensionDescriptor, redirectUrl);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
this.Error(exception, T("Package uploading and installation failed."), Logger, Services.Notifier);
|
||||
}
|
||||
|
||||
return Redirect(redirectUrl);
|
||||
}
|
||||
|
||||
private ActionResult InstallPackageDetails(ExtensionDescriptor extensionDescriptor, string redirectUrl) {
|
||||
if (DefaultExtensionTypes.IsModule(extensionDescriptor.ExtensionType)) {
|
||||
List<PackagingInstallFeatureViewModel> features = extensionDescriptor.Features
|
||||
.Where(featureDescriptor => !DefaultExtensionTypes.IsTheme(featureDescriptor.Extension.ExtensionType))
|
||||
.Select(featureDescriptor => new PackagingInstallFeatureViewModel {
|
||||
Enable = true, // by default all features are enabled
|
||||
FeatureDescriptor = featureDescriptor
|
||||
}).ToList();
|
||||
|
||||
List<PackagingInstallRecipeViewModel> recipes = _recipeHarvester.HarvestRecipes(extensionDescriptor.Id)
|
||||
.Select(recipe => new PackagingInstallRecipeViewModel {
|
||||
Execute = false, // by default no recipes are executed
|
||||
Recipe = recipe
|
||||
}).ToList();
|
||||
|
||||
if (features.Count > 0) {
|
||||
return View("InstallModuleDetails", new PackagingInstallViewModel {
|
||||
Features = features,
|
||||
Recipes = recipes,
|
||||
ExtensionDescriptor = extensionDescriptor
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect(redirectUrl);
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("InstallPackageDetails")]
|
||||
public ActionResult InstallPackageDetailsPOST(PackagingInstallViewModel packagingInstallViewModel, string redirectUrl) {
|
||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
try {
|
||||
IEnumerable<Recipe> recipes = _recipeHarvester.HarvestRecipes(packagingInstallViewModel.ExtensionDescriptor.Id)
|
||||
.Where(loadedRecipe => packagingInstallViewModel.Recipes.FirstOrDefault(recipeViewModel => recipeViewModel.Execute && recipeViewModel.Recipe.Name.Equals(loadedRecipe.Name)) != null);
|
||||
|
||||
foreach (Recipe recipe in recipes) {
|
||||
try {
|
||||
_recipeManager.Execute(recipe);
|
||||
}
|
||||
catch {
|
||||
Services.Notifier.Error(T("Recipes contains {0} unsuported module installation steps.", recipe.Name));
|
||||
}
|
||||
}
|
||||
|
||||
return this.RedirectLocal(returnUrl, "~/");
|
||||
} catch (Exception exception) {
|
||||
this.Error(exception, T("Package uploading and installation failed."), Logger, Services.Notifier);
|
||||
// Enable selected features
|
||||
if (packagingInstallViewModel.Features.Count > 0) {
|
||||
IEnumerable<string> featureIds = packagingInstallViewModel.Features.Select(feature => feature.FeatureDescriptor.Id);
|
||||
|
||||
return Redirect(retryUrl);
|
||||
// Enable the features and its dependencies
|
||||
_moduleService.EnableFeatures(featureIds, true);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
Services.Notifier.Error(T("Post installation steps failed with error: {0}", exception.Message));
|
||||
}
|
||||
|
||||
return Redirect(redirectUrl);
|
||||
}
|
||||
|
||||
public ActionResult UninstallPackage(string id, string returnUrl, string retryUrl) {
|
||||
|
@@ -7,19 +7,19 @@ OrchardVersion: 1.0.20
|
||||
Description: The packaging module enables packaging modules using the OPC format.
|
||||
FeatureDescription: Commands for creating/installing local modules.
|
||||
Category: Packaging
|
||||
Dependencies: PackagingServices
|
||||
Features:
|
||||
PackagingServices:
|
||||
Name: Packaging Services
|
||||
Name: Packaging commands
|
||||
Description: Core services for packaging using the OPC format.
|
||||
Category: Packaging
|
||||
Dependencies: Orchard.Packaging
|
||||
Gallery:
|
||||
Name: Gallery
|
||||
Description: Module gallery management.
|
||||
Category: Packaging
|
||||
Dependencies: Orchard.Packaging
|
||||
Gallery.Updates
|
||||
Name: Gallery Updates
|
||||
Dependencies: PackagingServices
|
||||
Gallery.Updates:
|
||||
Name: Package Updates
|
||||
Description: Manages updates for packages.
|
||||
Category: Packaging
|
||||
Dependencies: Gallery
|
||||
|
@@ -167,7 +167,7 @@
|
||||
<Content Include="Views\GalleryUpdates\ModulesUpdates.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Gallery\InstallModule.cshtml" />
|
||||
<Content Include="Views\PackagingServices\InstallModuleDetails.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -1,4 +1,3 @@
|
||||
using System.Collections.Generic;
|
||||
using NuGet;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Packaging.Models;
|
||||
@@ -10,6 +9,6 @@ namespace Orchard.Packaging.Services {
|
||||
PackageInfo Install(string packageId, string version, string location, string applicationPath);
|
||||
void Uninstall(string packageId, string applicationPath);
|
||||
|
||||
ExtensionDescriptor GetExtensionDescriptor(IPackage package);
|
||||
ExtensionDescriptor GetExtensionDescriptor(IPackage package, string extensionType);
|
||||
}
|
||||
}
|
@@ -1,14 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NuGet;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Folders;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Features;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Packaging.Models;
|
||||
|
||||
@@ -73,12 +69,16 @@ namespace Orchard.Packaging.Services {
|
||||
_packageExpander.Uninstall(packageId, applicationPath);
|
||||
}
|
||||
|
||||
public ExtensionDescriptor GetExtensionDescriptor(IPackage package) {
|
||||
IPackageFile packageFile = package.GetFiles().FirstOrDefault(file => Path.GetFileName(file.Path).Equals("module.txt", StringComparison.OrdinalIgnoreCase));
|
||||
public ExtensionDescriptor GetExtensionDescriptor(IPackage package, string extensionType) {
|
||||
IPackageFile packageFile = package.GetFiles().FirstOrDefault(file =>
|
||||
Path.GetFileName(file.Path).Equals(
|
||||
DefaultExtensionTypes.IsModule(extensionType) ? "module.txt" : "theme.txt",
|
||||
StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (packageFile != null) {
|
||||
string extensionId = Path.GetFileName(Path.GetDirectoryName(packageFile.Path).TrimEnd('/', '\\'));
|
||||
using (StreamReader streamReader = new StreamReader(packageFile.GetStream())) {
|
||||
return ExtensionFolders.GetDescriptorForExtension("", extensionId, DefaultExtensionTypes.Module, streamReader.ReadToEnd());
|
||||
return ExtensionFolders.GetDescriptorForExtension("", extensionId, extensionType, streamReader.ReadToEnd());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,7 @@ using Orchard.Packaging.GalleryServer;
|
||||
using Orchard.Packaging.Models;
|
||||
|
||||
namespace Orchard.Packaging.Services {
|
||||
[OrchardFeature("Gallery")]
|
||||
[OrchardFeature("PackagingServices")]
|
||||
public class PackagingSourceManager : IPackagingSourceManager {
|
||||
public static string GetExtensionPrefix(string extensionType) {
|
||||
return string.Format("Orchard.{0}.", extensionType);
|
||||
|
@@ -1,9 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.Packaging.ViewModels {
|
||||
public class PackagingInstallViewModel {
|
||||
public List<PackagingInstallFeatureViewModel> Features { get; set; }
|
||||
public List<PackagingInstallRecipeViewModel> Recipes { get; set; }
|
||||
|
||||
public ExtensionDescriptor ExtensionDescriptor { get; set; }
|
||||
}
|
||||
|
||||
@@ -11,4 +14,9 @@ namespace Orchard.Packaging.ViewModels {
|
||||
public FeatureDescriptor FeatureDescriptor { get; set; }
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
|
||||
public class PackagingInstallRecipeViewModel {
|
||||
public Recipe Recipe { get; set; }
|
||||
public bool Execute { get; set; }
|
||||
}
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
@model Orchard.Packaging.ViewModels.PackagingInstallViewModel
|
||||
@using Orchard.Environment.Extensions.Models;
|
||||
@using Orchard.Packaging.ViewModels;
|
||||
@using System.Linq;
|
||||
|
||||
@{
|
||||
Style.Require("PackagingAdmin");
|
||||
|
||||
Layout.Title = T("{0} - {1} Details", Model.ExtensionDescriptor.Name, Model.ExtensionDescriptor.Version).ToString();
|
||||
}
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("InstallModule", "Gallery", new { packageId = Request.QueryString["packageId"], version = Request.QueryString["version"], sourceId = Request.QueryString["sourceId"], redirectTo = Request.QueryString["redirectTo"] }))) {
|
||||
<h3>@T("Pick the features you want enabled").ToString()</h3>
|
||||
|
||||
<fieldset>
|
||||
@{ var index = 0; }
|
||||
@foreach (PackagingInstallFeatureViewModel feature in Model.Features) {
|
||||
<div>
|
||||
@Html.HiddenFor(m => m.Features[index].FeatureDescriptor.Id)
|
||||
@Html.HiddenFor(m => m.Features[index].FeatureDescriptor.Name)
|
||||
|
||||
@Html.EditorFor(m => m.Features[index].Enable)
|
||||
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Features[index].Enable)">
|
||||
@if (!string.IsNullOrEmpty(@feature.FeatureDescriptor.Name)) {
|
||||
@feature.FeatureDescriptor.Name
|
||||
} else {
|
||||
@feature.FeatureDescriptor.Id
|
||||
}
|
||||
</label>
|
||||
@{ index++; }
|
||||
</div>
|
||||
}
|
||||
</fieldset>
|
||||
|
||||
<button class="primaryAction" type="submit">@T("Ok")</button>
|
||||
}
|
@@ -60,7 +60,7 @@
|
||||
</div>
|
||||
|
||||
<div class="related">
|
||||
@Html.ActionLink(T("Install").ToString(), "Install", new RouteValueDictionary { { "packageId", item.PackageId }, { "version", item.Version }, { "sourceId", item.Source.Id }, { "redirectTo", "Modules" } })@T(" | ")
|
||||
@Html.ActionLink(T("Install").ToString(), "InstallGallery", "PackagingServices", new RouteValueDictionary { { "packageId", item.PackageId }, { "version", item.Version }, { "sourceId", item.Source.Id }, { "redirectUrl", HttpContext.Current.Request.RawUrl } }, null)@T(" | ")
|
||||
<a href="@item.PackageStreamUri">@T("Download")</a>
|
||||
</div>
|
||||
|
||||
|
@@ -65,7 +65,7 @@
|
||||
</div>
|
||||
|
||||
<div class="related">
|
||||
@Html.ActionLink(T("Install").ToString(), "Install", new RouteValueDictionary { { "packageId", item.PackageId }, { "version", item.Version }, { "sourceId", item.Source.Id }, { "redirectTo", "Themes" } })@T(" | ")
|
||||
@Html.ActionLink(T("Install").ToString(), "InstallGallery", "PackagingServices", new RouteValueDictionary { { "packageId", item.PackageId }, { "version", item.Version }, { "sourceId", item.Source.Id }, { "redirectUrl", HttpContext.Current.Request.RawUrl } }, null)@T(" | ")
|
||||
<a href="@item.PackageStreamUri">@T("Download")</a>
|
||||
</div>
|
||||
|
||||
|
@@ -1,12 +1,10 @@
|
||||
@{
|
||||
Layout.Title = T("Install a Module").ToString();
|
||||
@{ Layout.Title = T("Install a Module").ToString(); }
|
||||
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("AddModule", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request["returnUrl"] }), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
||||
Html.ValidationSummary();
|
||||
<fieldset>
|
||||
<label for="ModulePackage">@T("Module Package")</label>
|
||||
<input type="file" id="ModulePackage" size="64" name="ModulePackage" />
|
||||
</fieldset>
|
||||
<button type="submit" class="primaryAction">@T("Install")</button>
|
||||
}
|
||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("InstallLocally", "PackagingServices", new { redirectUrl = HttpContext.Current.Request["returnUrl"] }), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
||||
Html.ValidationSummary();
|
||||
<fieldset>
|
||||
<label for="ModulePackage">@T("Module Package")</label>
|
||||
<input type="file" id="ModulePackage" size="64" name="ModulePackage" />
|
||||
</fieldset>
|
||||
<button type="submit" class="primaryAction">@T("Install")</button>
|
||||
}
|
@@ -1,12 +1,10 @@
|
||||
@{
|
||||
Layout.Title = T("Install a Theme").ToString();
|
||||
@{ Layout.Title = T("Install a Theme").ToString(); }
|
||||
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("AddTheme", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request["returnUrl"] }), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
||||
Html.ValidationSummary();
|
||||
<fieldset>
|
||||
<label for="ModulePackage">@T("Theme Package")</label>
|
||||
<input type="file" id="ThemePackage" size="64" name="ThemePackage" />
|
||||
</fieldset>
|
||||
<button type="submit" class="primaryAction">@T("Install")</button>
|
||||
}
|
||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("InstallLocally", "PackagingServices", new { redirectUrl = HttpContext.Current.Request["returnUrl"] }), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
||||
Html.ValidationSummary();
|
||||
<fieldset>
|
||||
<label for="ModulePackage">@T("Theme Package")</label>
|
||||
<input type="file" id="ThemePackage" size="64" name="ThemePackage" />
|
||||
</fieldset>
|
||||
<button type="submit" class="primaryAction">@T("Install")</button>
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
@model Orchard.Packaging.ViewModels.PackagingInstallViewModel
|
||||
@using Orchard.Environment.Extensions.Models;
|
||||
@using Orchard.Packaging.ViewModels;
|
||||
@using System.Linq;
|
||||
|
||||
@{
|
||||
Style.Require("PackagingAdmin");
|
||||
|
||||
Layout.Title = T("{0} - {1} Details", Model.ExtensionDescriptor.Name, Model.ExtensionDescriptor.Version).ToString();
|
||||
}
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("InstallPackageDetails", "PackagingServices", new { packageId = Request.QueryString["packageId"], version = Request.QueryString["version"], sourceId = Request.QueryString["sourceId"], redirectUrl = Request.QueryString["redirectUrl"] }))) {
|
||||
<h3>@T("Installation details").ToString()</h3>
|
||||
|
||||
@Html.HiddenFor(m => m.ExtensionDescriptor.Id)
|
||||
|
||||
if (Model.Recipes.Count > 0) {
|
||||
<fieldset>
|
||||
<legend>@T("Pick the recipes you want to run").ToString()</legend>
|
||||
|
||||
@{ var recipeIndex = 0; }
|
||||
@foreach (PackagingInstallRecipeViewModel recipe in Model.Recipes) {
|
||||
<div>
|
||||
@Html.HiddenFor(m => m.Recipes[recipeIndex].Recipe.Name)
|
||||
|
||||
@Html.EditorFor(m => m.Recipes[recipeIndex].Execute)
|
||||
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Recipes[recipeIndex].Execute)">@recipe.Recipe.Name</label>
|
||||
|
||||
@{ recipeIndex++; }
|
||||
</div>
|
||||
}
|
||||
</fieldset>
|
||||
}
|
||||
|
||||
<fieldset>
|
||||
<legend>@T("Pick the features you want enabled").ToString()</legend>
|
||||
|
||||
@{ var featureIndex = 0; }
|
||||
@foreach (PackagingInstallFeatureViewModel feature in Model.Features) {
|
||||
<div>
|
||||
@Html.HiddenFor(m => m.Features[featureIndex].FeatureDescriptor.Id)
|
||||
@Html.HiddenFor(m => m.Features[featureIndex].FeatureDescriptor.Name)
|
||||
|
||||
@Html.EditorFor(m => m.Features[featureIndex].Enable)
|
||||
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Features[featureIndex].Enable)">
|
||||
@if (!string.IsNullOrEmpty(@feature.FeatureDescriptor.Name)) {
|
||||
@feature.FeatureDescriptor.Name
|
||||
} else {
|
||||
@feature.FeatureDescriptor.Id
|
||||
}
|
||||
</label>
|
||||
|
||||
@{ featureIndex++; }
|
||||
</div>
|
||||
}
|
||||
</fieldset>
|
||||
|
||||
<button class="primaryAction" type="submit">@T("Ok")</button>
|
||||
}
|
@@ -29,11 +29,11 @@ namespace Orchard.Recipes.Services {
|
||||
public Localizer T { get; set; }
|
||||
ILogger Logger { get; set; }
|
||||
|
||||
public IEnumerable<Recipe> HarvestRecipes(string extensionName) {
|
||||
public IEnumerable<Recipe> HarvestRecipes(string extensionId) {
|
||||
var recipes = new List<Recipe>();
|
||||
var extension = _extensionManager.GetExtension(extensionName);
|
||||
var extension = _extensionManager.GetExtension(extensionId);
|
||||
if (extension != null) {
|
||||
var recipeLocation = Path.Combine(extension.Location, extensionName, "Recipes");
|
||||
var recipeLocation = Path.Combine(extension.Location, extensionId, "Recipes");
|
||||
var recipeFiles = _webSiteFolder.ListFiles(recipeLocation, true);
|
||||
recipes.AddRange(
|
||||
from recipeFile in recipeFiles
|
||||
@@ -41,7 +41,7 @@ namespace Orchard.Recipes.Services {
|
||||
select _recipeParser.ParseRecipe(_webSiteFolder.ReadFile(recipeFile)));
|
||||
}
|
||||
else {
|
||||
Logger.Error("Could not discover recipes because module '{0}' was not found.", extensionName);
|
||||
Logger.Error("Could not discover recipes because module '{0}' was not found.", extensionId);
|
||||
}
|
||||
|
||||
return recipes;
|
||||
|
@@ -3,6 +3,6 @@ using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.Recipes.Services {
|
||||
public interface IRecipeHarvester : IDependency {
|
||||
IEnumerable<Recipe> HarvestRecipes(string extensionName);
|
||||
IEnumerable<Recipe> HarvestRecipes(string extensionId);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user