mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-18 17:47:54 +08:00
Expand packages to the "live" ~/Themes, ~/Modules folders
--HG-- branch : dev
This commit is contained in:
@@ -39,7 +39,7 @@ namespace Orchard.Packaging {
|
|||||||
|
|
||||||
var projectFile = extensionDescriptor.Name + ".csproj";
|
var projectFile = extensionDescriptor.Name + ".csproj";
|
||||||
if (LoadProject(context, projectFile)) {
|
if (LoadProject(context, projectFile)) {
|
||||||
EmbedVirtualFile(context, projectFile, System.Net.Mime.MediaTypeNames.Text.Xml);
|
EmbedVirtualFile(context, projectFile, MediaTypeNames.Text.Xml);
|
||||||
EmbedProjectFiles(context, "Compile", "Content", "None", "EmbeddedResource");
|
EmbedProjectFiles(context, "Compile", "Content", "None", "EmbeddedResource");
|
||||||
EmbedReferenceFiles(context);
|
EmbedReferenceFiles(context);
|
||||||
}
|
}
|
||||||
|
@@ -5,17 +5,21 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Orchard.FileSystems.VirtualPath;
|
using Orchard.FileSystems.VirtualPath;
|
||||||
|
using Orchard.Localization;
|
||||||
|
|
||||||
namespace Orchard.Packaging {
|
namespace Orchard.Packaging {
|
||||||
public class PackageExpander : IPackageExpander {
|
public class PackageExpander : IPackageExpander {
|
||||||
private const string ContentTypePrefix = "Orchard ";
|
private const string ContentTypePrefix = "Orchard ";
|
||||||
private readonly IVirtualPathProvider _virtualPathProvider;
|
private readonly IVirtualPathProvider _virtualPathProvider;
|
||||||
|
|
||||||
public PackageExpander(
|
public PackageExpander(IVirtualPathProvider virtualPathProvider) {
|
||||||
IVirtualPathProvider virtualPathProvider) {
|
|
||||||
_virtualPathProvider = virtualPathProvider;
|
_virtualPathProvider = virtualPathProvider;
|
||||||
|
|
||||||
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
class ExpandContext {
|
class ExpandContext {
|
||||||
public Stream Stream { get; set; }
|
public Stream Stream { get; set; }
|
||||||
public Package Package { get; set; }
|
public Package Package { get; set; }
|
||||||
@@ -61,12 +65,12 @@ namespace Orchard.Packaging {
|
|||||||
var partUri = PackUriHelper.CreatePartUri(new Uri(context.SourcePath + relativePath, UriKind.Relative));
|
var partUri = PackUriHelper.CreatePartUri(new Uri(context.SourcePath + relativePath, UriKind.Relative));
|
||||||
var packagePart = context.Package.GetPart(partUri);
|
var packagePart = context.Package.GetPart(partUri);
|
||||||
using (var packageStream = packagePart.GetStream(FileMode.Open, FileAccess.Read)) {
|
using (var packageStream = packagePart.GetStream(FileMode.Open, FileAccess.Read)) {
|
||||||
var filePath = Path.Combine(context.TargetPath, relativePath);
|
var filePath = _virtualPathProvider.Combine(context.TargetPath, relativePath);
|
||||||
var folderPath = Path.GetDirectoryName(filePath);
|
var folderPath = _virtualPathProvider.GetDirectoryName(filePath);
|
||||||
if (!Directory.Exists(folderPath))
|
if (!_virtualPathProvider.DirectoryExists(folderPath))
|
||||||
Directory.CreateDirectory(folderPath);
|
_virtualPathProvider.CreateDirectory(folderPath);
|
||||||
|
|
||||||
using (var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read)) {
|
using (var fileStream = _virtualPathProvider.CreateFile(filePath)) {
|
||||||
packageStream.CopyTo(fileStream);
|
packageStream.CopyTo(fileStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,14 +162,15 @@ namespace Orchard.Packaging {
|
|||||||
|
|
||||||
private void EstablishPaths(ExpandContext context, IVirtualPathProvider virtualPathProvider) {
|
private void EstablishPaths(ExpandContext context, IVirtualPathProvider virtualPathProvider) {
|
||||||
context.SourcePath = "\\" + context.ExtensionName + "\\";
|
context.SourcePath = "\\" + context.ExtensionName + "\\";
|
||||||
if (context.ExtensionType == "Theme") {
|
switch (context.ExtensionType) {
|
||||||
context.TargetPath = virtualPathProvider.MapPath("~/Themes-temp/" + context.ExtensionName);
|
case "Theme":
|
||||||
}
|
context.TargetPath = virtualPathProvider.Combine("~/Themes/" + context.ExtensionName);
|
||||||
else if (context.ExtensionType == "Module") {
|
break;
|
||||||
context.TargetPath = virtualPathProvider.MapPath("~/Modules-temp/" + context.ExtensionName);
|
case "Module":
|
||||||
}
|
context.TargetPath = virtualPathProvider.Combine("~/Modules/" + context.ExtensionName);
|
||||||
else {
|
break;
|
||||||
throw new ApplicationException("Unknown extension type");
|
default:
|
||||||
|
throw new OrchardCoreException(T("Unknown extension type \"{0}\"", context.ExtensionType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user