mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-11-28 17:32:44 +08:00
- Themes: Theme discovery and related infrastructure work. Theme content item and metadata (Theme.txt). Some initial Theme Admin and a couple skeleton themes.
- Extensions: Theme and Package extensions are now automatically discovered, their metadata parsed and their types loaded by the ExtensionManager. The ExtensionDescriptor now contains an ExtensionType property which will help distinguish extension types. --HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4043750
This commit is contained in:
@@ -49,7 +49,7 @@ namespace Orchard.Tests.Extensions {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void NamesFromFoldersWithPackageTxtShouldBeListed() {
|
public void NamesFromFoldersWithPackageTxtShouldBeListed() {
|
||||||
var folders = new ExtensionFolders(new[] { _tempFolderName });
|
var folders = new PackageFolders(new[] { _tempFolderName });
|
||||||
var names = folders.ListNames();
|
var names = folders.ListNames();
|
||||||
Assert.That(names.Count(), Is.EqualTo(2));
|
Assert.That(names.Count(), Is.EqualTo(2));
|
||||||
Assert.That(names, Has.Some.EqualTo("Sample1"));
|
Assert.That(names, Has.Some.EqualTo("Sample1"));
|
||||||
@@ -58,7 +58,7 @@ namespace Orchard.Tests.Extensions {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PackageTxtShouldBeParsedAndReturnedAsYamlDocument() {
|
public void PackageTxtShouldBeParsedAndReturnedAsYamlDocument() {
|
||||||
var folders = new ExtensionFolders(new[] { _tempFolderName });
|
var folders = new PackageFolders(new[] { _tempFolderName });
|
||||||
var sample1 = folders.ParseManifest("Sample1");
|
var sample1 = folders.ParseManifest("Sample1");
|
||||||
var mapping = (Mapping)sample1.YamlDocument.Root;
|
var mapping = (Mapping)sample1.YamlDocument.Root;
|
||||||
var entities = mapping.Entities
|
var entities = mapping.Entities
|
||||||
|
|||||||
@@ -85,8 +85,10 @@
|
|||||||
<Compile Include="Settings\ViewModels\SettingsIndexViewModel.cs" />
|
<Compile Include="Settings\ViewModels\SettingsIndexViewModel.cs" />
|
||||||
<Compile Include="Themes\AdminMenu.cs" />
|
<Compile Include="Themes\AdminMenu.cs" />
|
||||||
<Compile Include="Themes\Controllers\AdminController.cs" />
|
<Compile Include="Themes\Controllers\AdminController.cs" />
|
||||||
|
<Compile Include="Themes\Models\Theme.cs" />
|
||||||
<Compile Include="Themes\Models\ThemeSiteSettings.cs" />
|
<Compile Include="Themes\Models\ThemeSiteSettings.cs" />
|
||||||
<Compile Include="Themes\Models\ThemeSiteSettingsHandler.cs" />
|
<Compile Include="Themes\Models\ThemeSiteSettingsHandler.cs" />
|
||||||
|
<Compile Include="Themes\Records\ThemeRecord.cs" />
|
||||||
<Compile Include="Themes\Records\ThemeSiteSettingsRecord.cs" />
|
<Compile Include="Themes\Records\ThemeSiteSettingsRecord.cs" />
|
||||||
<Compile Include="Themes\Services\ThemeService.cs" />
|
<Compile Include="Themes\Services\ThemeService.cs" />
|
||||||
<Compile Include="Themes\ViewModels\ThemesIndexViewModel.cs" />
|
<Compile Include="Themes\ViewModels\ThemesIndexViewModel.cs" />
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ namespace Orchard.Core.Themes {
|
|||||||
public void GetNavigation(NavigationBuilder builder) {
|
public void GetNavigation(NavigationBuilder builder) {
|
||||||
builder.Add("Themes", "11",
|
builder.Add("Themes", "11",
|
||||||
menu => menu
|
menu => menu
|
||||||
.Add("Manage Themes", "2.0", item => item.Action("Index", "Admin", new { area = "Themes" }))
|
.Add("Manage Themes", "2.0", item => item.Action("Index", "Admin", new { area = "Themes" })));
|
||||||
.Add("Upload a Theme", "2.1", item => item.Action("Index", "Admin",new { area = "Themes" })));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Web.Mvc;
|
using System;
|
||||||
|
using System.Web.Mvc;
|
||||||
using Orchard.Core.Themes.ViewModels;
|
using Orchard.Core.Themes.ViewModels;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Themes;
|
using Orchard.Themes;
|
||||||
@@ -19,7 +20,16 @@ namespace Orchard.Core.Themes.Controllers {
|
|||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
public ActionResult Index() {
|
public ActionResult Index() {
|
||||||
|
try {
|
||||||
|
var themes = _themeService.GetInstalledThemes();
|
||||||
|
var currentTheme = _themeService.GetCurrentTheme();
|
||||||
|
var model = new ThemesIndexViewModel { CurrentTheme = currentTheme, Themes = themes };
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
|
_notifier.Error(T("Listing themes failed: " + exception.Message));
|
||||||
return View(new ThemesIndexViewModel());
|
return View(new ThemesIndexViewModel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
43
src/Orchard.Web/Core/Themes/Models/Theme.cs
Normal file
43
src/Orchard.Web/Core/Themes/Models/Theme.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using Orchard.Core.Themes.Records;
|
||||||
|
using Orchard.Models;
|
||||||
|
using Orchard.Themes;
|
||||||
|
|
||||||
|
namespace Orchard.Core.Themes.Models {
|
||||||
|
public class Theme : ContentPart<ThemeRecord>, ITheme {
|
||||||
|
public static readonly ContentType ContentType = new ContentType { Name = "theme", DisplayName = "Themes" };
|
||||||
|
|
||||||
|
#region Implementation of ITheme
|
||||||
|
|
||||||
|
public string ThemeName {
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DisplayName {
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description {
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Version {
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Author {
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string HomePage {
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/Orchard.Web/Core/Themes/Records/ThemeRecord.cs
Normal file
12
src/Orchard.Web/Core/Themes/Records/ThemeRecord.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using Orchard.Models.Records;
|
||||||
|
|
||||||
|
namespace Orchard.Core.Themes.Records {
|
||||||
|
public class ThemeRecord : ContentPartRecord {
|
||||||
|
public virtual string ThemeName { get; set; }
|
||||||
|
public virtual string DisplayName { get; set; }
|
||||||
|
public virtual string Description { get; set; }
|
||||||
|
public virtual string Version { get; set; }
|
||||||
|
public virtual string Author { get; set; }
|
||||||
|
public virtual string HomePage { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Orchard.Extensions;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
using Orchard.Models;
|
using Orchard.Models;
|
||||||
using Orchard.Settings;
|
using Orchard.Settings;
|
||||||
@@ -8,7 +9,10 @@ using Orchard.Core.Themes.Models;
|
|||||||
|
|
||||||
namespace Orchard.Core.Themes.Services {
|
namespace Orchard.Core.Themes.Services {
|
||||||
public class ThemeService : IThemeService {
|
public class ThemeService : IThemeService {
|
||||||
public ThemeService() {
|
private readonly IExtensionManager _extensionManager;
|
||||||
|
|
||||||
|
public ThemeService(IExtensionManager extensionManager) {
|
||||||
|
_extensionManager = extensionManager;
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,11 +32,37 @@ namespace Orchard.Core.Themes.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ITheme GetThemeByName(string name) {
|
public ITheme GetThemeByName(string name) {
|
||||||
throw new NotImplementedException();
|
foreach (var descriptor in _extensionManager.AvailableExtensions()) {
|
||||||
|
if (String.Equals(descriptor.Name, name, StringComparison.OrdinalIgnoreCase)) {
|
||||||
|
return new Theme {
|
||||||
|
Author = descriptor.Author ?? String.Empty,
|
||||||
|
Description = descriptor.Description ?? String.Empty,
|
||||||
|
DisplayName = descriptor.DisplayName ?? String.Empty,
|
||||||
|
HomePage = descriptor.HomePage ?? String.Empty,
|
||||||
|
ThemeName = descriptor.Name,
|
||||||
|
Version = descriptor.Version ?? String.Empty
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<ITheme> GetInstalledThemes() {
|
public IEnumerable<ITheme> GetInstalledThemes() {
|
||||||
throw new NotImplementedException();
|
List<ITheme> themes = new List<ITheme>();
|
||||||
|
foreach (var descriptor in _extensionManager.AvailableExtensions()) {
|
||||||
|
if (String.Equals(descriptor.ExtensionType, "Theme", StringComparison.OrdinalIgnoreCase)) {
|
||||||
|
Theme theme = new Theme {
|
||||||
|
Author = descriptor.Author ?? String.Empty,
|
||||||
|
Description = descriptor.Description ?? String.Empty,
|
||||||
|
DisplayName = descriptor.DisplayName ?? String.Empty,
|
||||||
|
HomePage = descriptor.HomePage ?? String.Empty,
|
||||||
|
ThemeName = descriptor.Name,
|
||||||
|
Version = descriptor.Version ?? String.Empty
|
||||||
|
};
|
||||||
|
themes.Add(theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
using Orchard.Mvc.ViewModels;
|
using System.Collections.Generic;
|
||||||
|
using Orchard.Mvc.ViewModels;
|
||||||
|
using Orchard.Themes;
|
||||||
|
|
||||||
namespace Orchard.Core.Themes.ViewModels {
|
namespace Orchard.Core.Themes.ViewModels {
|
||||||
public class ThemesIndexViewModel : AdminViewModel {
|
public class ThemesIndexViewModel : AdminViewModel {
|
||||||
|
public ITheme CurrentTheme { get; set; }
|
||||||
|
public IEnumerable<ITheme> Themes { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,14 @@
|
|||||||
Themes</h2>
|
Themes</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="yui-u">
|
<div class="yui-u">
|
||||||
List of Orchard Themes
|
<% foreach (var theme in Model.Themes) { %>
|
||||||
|
<p>Name: <%= theme.ThemeName %></p>
|
||||||
|
<p>DisplayName: <%= theme.DisplayName %></p>
|
||||||
|
<p>Description: <%= theme.Description %></p>
|
||||||
|
<p>Author: <%= theme.Author %></p>
|
||||||
|
<p>Version: <%= theme.Version %></p>
|
||||||
|
<p>HomePage: <%= theme.HomePage %></p>
|
||||||
|
<% } %>
|
||||||
|
Current Theme: <%= Model.CurrentTheme != null ? Model.CurrentTheme.ThemeName : "None" %>
|
||||||
</div>
|
</div>
|
||||||
<% Html.Include("AdminFoot"); %>
|
<% Html.Include("AdminFoot"); %>
|
||||||
@@ -175,6 +175,10 @@
|
|||||||
<Content Include="Content\Images\title_background.gif" />
|
<Content Include="Content\Images\title_background.gif" />
|
||||||
<Content Include="Content\Site2.css" />
|
<Content Include="Content\Site2.css" />
|
||||||
<Content Include="Content\Site3.css" />
|
<Content Include="Content\Site3.css" />
|
||||||
|
<Content Include="Themes\BlueSky\Theme.gif" />
|
||||||
|
<Content Include="Themes\BlueSky\Theme.txt" />
|
||||||
|
<Content Include="Themes\PinkPretty\Theme.gif" />
|
||||||
|
<Content Include="Themes\PinkPretty\Theme.txt" />
|
||||||
<Content Include="Views\Shared\AdminHead.aspx" />
|
<Content Include="Views\Shared\AdminHead.aspx" />
|
||||||
<Content Include="Views\Shared\AdminFoot.aspx" />
|
<Content Include="Views\Shared\AdminFoot.aspx" />
|
||||||
<Content Include="Views\Shared\Messages.ascx" />
|
<Content Include="Views\Shared\Messages.ascx" />
|
||||||
@@ -187,7 +191,6 @@
|
|||||||
<Folder Include="App_Data\" />
|
<Folder Include="App_Data\" />
|
||||||
<Folder Include="Media\Images\" />
|
<Folder Include="Media\Images\" />
|
||||||
<Folder Include="Media\Videos\" />
|
<Folder Include="Media\Videos\" />
|
||||||
<Folder Include="Themes\" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||||
|
|||||||
BIN
src/Orchard.Web/Themes/BlueSky/Theme.gif
Normal file
BIN
src/Orchard.Web/Themes/BlueSky/Theme.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
6
src/Orchard.Web/Themes/BlueSky/Theme.txt
Normal file
6
src/Orchard.Web/Themes/BlueSky/Theme.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
name: Blue Sky
|
||||||
|
author: Jon Wall
|
||||||
|
description: This theme uses the best of colors Blue.
|
||||||
|
version: 1.0
|
||||||
|
tags: blue
|
||||||
|
homepage: http://www.orchardproject.net
|
||||||
BIN
src/Orchard.Web/Themes/PinkPretty/Theme.gif
Normal file
BIN
src/Orchard.Web/Themes/PinkPretty/Theme.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
6
src/Orchard.Web/Themes/PinkPretty/Theme.txt
Normal file
6
src/Orchard.Web/Themes/PinkPretty/Theme.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
name: Pretty in Pink
|
||||||
|
author: Bertrand Le Roy
|
||||||
|
description: This theme is full of butterflies, hearts and unicorns.
|
||||||
|
version: 1.0
|
||||||
|
tags: pink,butterfly,heart,unicorn
|
||||||
|
homepage: http://weblogs.asp.net/bleroy
|
||||||
@@ -33,13 +33,12 @@ namespace Orchard.Environment {
|
|||||||
builder.Register<PrecompiledExtensionLoader>().As<IExtensionLoader>().SingletonScoped();
|
builder.Register<PrecompiledExtensionLoader>().As<IExtensionLoader>().SingletonScoped();
|
||||||
builder.Register<DynamicExtensionLoader>().As<IExtensionLoader>().SingletonScoped();
|
builder.Register<DynamicExtensionLoader>().As<IExtensionLoader>().SingletonScoped();
|
||||||
|
|
||||||
//builder.Register((ctx, p) => new PackageFolders(MapPaths(p.Named<IEnumerable<string>>("paths"))))
|
builder.Register<PackageFolders>().As<IExtensionFolders>()
|
||||||
// .As<IPackageFolders>()
|
|
||||||
// .WithExtendedProperty("paths", new[] { "~/Packages" })
|
|
||||||
// .SingletonScoped();
|
|
||||||
builder.Register<ExtensionFolders>().As<IExtensionFolders>()
|
|
||||||
.WithArguments(new NamedParameter("paths", new[] { "~/Core", "~/Packages" }))
|
.WithArguments(new NamedParameter("paths", new[] { "~/Core", "~/Packages" }))
|
||||||
.SingletonScoped();
|
.SingletonScoped();
|
||||||
|
builder.Register<ThemeFolders>().As<IExtensionFolders>()
|
||||||
|
.WithArguments(new NamedParameter("paths", new[] { "~/Themes" }))
|
||||||
|
.SingletonScoped();
|
||||||
|
|
||||||
registrations(builder);
|
registrations(builder);
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,13 @@
|
|||||||
public class ExtensionDescriptor {
|
public class ExtensionDescriptor {
|
||||||
public string Location { get; set; }
|
public string Location { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public string ExtensionType { get; set; }
|
||||||
|
|
||||||
|
// extension metadata
|
||||||
public string DisplayName { get; set; }
|
public string DisplayName { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public string Version { get; set; }
|
public string Version { get; set; }
|
||||||
|
public string Author { get; set; }
|
||||||
|
public string HomePage { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Orchard.Extensions.Loaders;
|
using Orchard.Extensions.Loaders;
|
||||||
using Yaml.Grammar;
|
using Yaml.Grammar;
|
||||||
@@ -10,35 +11,45 @@ namespace Orchard.Extensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class ExtensionManager : IExtensionManager {
|
public class ExtensionManager : IExtensionManager {
|
||||||
private readonly IExtensionFolders _folders;
|
private readonly IEnumerable<IExtensionFolders> _folders;
|
||||||
private readonly IEnumerable<IExtensionLoader> _loaders;
|
private readonly IEnumerable<IExtensionLoader> _loaders;
|
||||||
private IEnumerable<ExtensionEntry> _activeExtensions;
|
private IEnumerable<ExtensionEntry> _activeExtensions;
|
||||||
|
|
||||||
public ExtensionManager(IExtensionFolders folders, IEnumerable<IExtensionLoader> loaders) {
|
public ExtensionManager(IEnumerable<IExtensionFolders> folders, IEnumerable<IExtensionLoader> loaders) {
|
||||||
_folders = folders;
|
_folders = folders;
|
||||||
_loaders = loaders.OrderBy(x => x.Order);
|
_loaders = loaders.OrderBy(x => x.Order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IEnumerable<ExtensionDescriptor> AvailableExtensions() {
|
public IEnumerable<ExtensionDescriptor> AvailableExtensions() {
|
||||||
var names = _folders.ListNames();
|
List<ExtensionDescriptor> availableExtensions = new List<ExtensionDescriptor>();
|
||||||
foreach (var name in names) {
|
foreach (var folder in _folders) {
|
||||||
var parseResult = _folders.ParseManifest(name);
|
foreach (var name in folder.ListNames()) {
|
||||||
|
availableExtensions.Add(GetDescriptorForExtension(name, folder));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return availableExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ExtensionDescriptor GetDescriptorForExtension(string name, IExtensionFolders folder) {
|
||||||
|
string extensionType = folder is ThemeFolders ? "Theme" : "Package";
|
||||||
|
var parseResult = folder.ParseManifest(name);
|
||||||
var mapping = (Mapping)parseResult.YamlDocument.Root;
|
var mapping = (Mapping)parseResult.YamlDocument.Root;
|
||||||
var fields = mapping.Entities
|
var fields = mapping.Entities
|
||||||
.Where(x => x.Key is Scalar)
|
.Where(x => x.Key is Scalar)
|
||||||
.ToDictionary(x => ((Scalar)x.Key).Text, x => x.Value);
|
.ToDictionary(x => ((Scalar)x.Key).Text, x => x.Value);
|
||||||
|
|
||||||
|
return new ExtensionDescriptor {
|
||||||
yield return new ExtensionDescriptor {
|
|
||||||
Location = parseResult.Location,
|
Location = parseResult.Location,
|
||||||
Name = name,
|
Name = name,
|
||||||
|
ExtensionType = extensionType,
|
||||||
DisplayName = GetValue(fields, "name"),
|
DisplayName = GetValue(fields, "name"),
|
||||||
Description = GetValue(fields, "description"),
|
Description = GetValue(fields, "description"),
|
||||||
Version = GetValue(fields, "version")
|
Version = GetValue(fields, "version"),
|
||||||
|
Author = GetValue(fields, "author"),
|
||||||
|
HomePage = GetValue(fields, "homepage")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetValue(
|
private static string GetValue(
|
||||||
IDictionary<string, DataItem> fields,
|
IDictionary<string, DataItem> fields,
|
||||||
@@ -56,11 +67,14 @@ namespace Orchard.Extensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<ExtensionEntry> BuildActiveExtensions() {
|
private IEnumerable<ExtensionEntry> BuildActiveExtensions() {
|
||||||
foreach (var descriptor in AvailableExtensions()) {
|
|
||||||
//TODO: this component needs access to some "current settings" to know which are active
|
//TODO: this component needs access to some "current settings" to know which are active
|
||||||
|
foreach (var descriptor in AvailableExtensions()) {
|
||||||
|
// Extensions that are Themes don't have buildable components.
|
||||||
|
if (String.Equals(descriptor.ExtensionType, "Package", StringComparison.OrdinalIgnoreCase)) {
|
||||||
yield return BuildEntry(descriptor);
|
yield return BuildEntry(descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ExtensionEntry BuildEntry(ExtensionDescriptor descriptor) {
|
private ExtensionEntry BuildEntry(ExtensionDescriptor descriptor) {
|
||||||
foreach (var loader in _loaders) {
|
foreach (var loader in _loaders) {
|
||||||
|
|||||||
12
src/Orchard/Extensions/Helpers/PathHelpers.cs
Normal file
12
src/Orchard/Extensions/Helpers/PathHelpers.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System.Web.Hosting;
|
||||||
|
|
||||||
|
namespace Orchard.Extensions.Helpers {
|
||||||
|
public static class PathHelpers {
|
||||||
|
public static string GetPhysicalPath(string path) {
|
||||||
|
if (path.StartsWith("~") && HostingEnvironment.IsHosted) {
|
||||||
|
return HostingEnvironment.MapPath(path);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/Orchard/Extensions/IExtensionFolders.cs
Normal file
15
src/Orchard/Extensions/IExtensionFolders.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Yaml.Grammar;
|
||||||
|
|
||||||
|
namespace Orchard.Extensions {
|
||||||
|
public interface IExtensionFolders {
|
||||||
|
IEnumerable<string> ListNames();
|
||||||
|
ParseResult ParseManifest(string name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ParseResult {
|
||||||
|
public string Location { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public YamlDocument YamlDocument { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,40 +1,20 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Hosting;
|
using Orchard.Extensions.Helpers;
|
||||||
using Yaml.Grammar;
|
using Yaml.Grammar;
|
||||||
|
|
||||||
namespace Orchard.Extensions {
|
namespace Orchard.Extensions {
|
||||||
public interface IExtensionFolders {
|
public class PackageFolders : IExtensionFolders {
|
||||||
IEnumerable<string> ListNames();
|
|
||||||
ParseResult ParseManifest(string name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ParseResult {
|
|
||||||
public string Location { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public YamlDocument YamlDocument { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ExtensionFolders : IExtensionFolders {
|
|
||||||
private readonly IEnumerable<string> _paths;
|
private readonly IEnumerable<string> _paths;
|
||||||
|
|
||||||
public ExtensionFolders(IEnumerable<string> paths) {
|
public PackageFolders(IEnumerable<string> paths) {
|
||||||
_paths = paths;
|
_paths = paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string GetPhysicalPath(string path) {
|
|
||||||
if (path.StartsWith("~") && HostingEnvironment.IsHosted) {
|
|
||||||
return HostingEnvironment.MapPath(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<string> ListNames() {
|
public IEnumerable<string> ListNames() {
|
||||||
foreach (var path in _paths) {
|
foreach (var path in _paths) {
|
||||||
foreach (var directoryName in Directory.GetDirectories(GetPhysicalPath(path))) {
|
foreach (var directoryName in Directory.GetDirectories(PathHelpers.GetPhysicalPath(path))) {
|
||||||
if (File.Exists(Path.Combine(directoryName, "Package.txt")))
|
if (File.Exists(Path.Combine(directoryName, "Package.txt")))
|
||||||
yield return Path.GetFileName(directoryName);
|
yield return Path.GetFileName(directoryName);
|
||||||
}
|
}
|
||||||
@@ -43,7 +23,7 @@ namespace Orchard.Extensions {
|
|||||||
|
|
||||||
public ParseResult ParseManifest(string name) {
|
public ParseResult ParseManifest(string name) {
|
||||||
foreach (var path in _paths) {
|
foreach (var path in _paths) {
|
||||||
var extensionDirectoryPath = Path.Combine(GetPhysicalPath(path), name);
|
var extensionDirectoryPath = Path.Combine(PathHelpers.GetPhysicalPath(path), name);
|
||||||
var extensionManifestPath = Path.Combine(extensionDirectoryPath, "Package.txt");
|
var extensionManifestPath = Path.Combine(extensionDirectoryPath, "Package.txt");
|
||||||
if (!File.Exists(extensionManifestPath)) {
|
if (!File.Exists(extensionManifestPath)) {
|
||||||
continue;
|
continue;
|
||||||
41
src/Orchard/Extensions/ThemeFolders.cs
Normal file
41
src/Orchard/Extensions/ThemeFolders.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Orchard.Extensions.Helpers;
|
||||||
|
using Yaml.Grammar;
|
||||||
|
|
||||||
|
namespace Orchard.Extensions {
|
||||||
|
public class ThemeFolders : IExtensionFolders {
|
||||||
|
private readonly IEnumerable<string> _paths;
|
||||||
|
|
||||||
|
public ThemeFolders(IEnumerable<string> paths) {
|
||||||
|
_paths = paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> ListNames() {
|
||||||
|
foreach (var path in _paths) {
|
||||||
|
foreach (var directoryName in Directory.GetDirectories(PathHelpers.GetPhysicalPath(path))) {
|
||||||
|
if (File.Exists(Path.Combine(directoryName, "Theme.txt")))
|
||||||
|
yield return Path.GetFileName(directoryName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParseResult ParseManifest(string name) {
|
||||||
|
foreach (var path in _paths) {
|
||||||
|
var extensionDirectoryPath = Path.Combine(PathHelpers.GetPhysicalPath(path), name);
|
||||||
|
var extensionManifestPath = Path.Combine(extensionDirectoryPath, "Theme.txt");
|
||||||
|
if (!File.Exists(extensionManifestPath)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var yamlStream = YamlParser.Load(extensionManifestPath);
|
||||||
|
return new ParseResult {
|
||||||
|
Location = path,
|
||||||
|
Name = name,
|
||||||
|
YamlDocument = yamlStream.Documents.Single()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -121,13 +121,16 @@
|
|||||||
<Compile Include="Environment\IOrchardShellEvents.cs" />
|
<Compile Include="Environment\IOrchardShellEvents.cs" />
|
||||||
<Compile Include="Extensions\ExtensionDescriptor.cs" />
|
<Compile Include="Extensions\ExtensionDescriptor.cs" />
|
||||||
<Compile Include="Extensions\ExtensionEntry.cs" />
|
<Compile Include="Extensions\ExtensionEntry.cs" />
|
||||||
<Compile Include="Extensions\ExtensionFolders.cs" />
|
<Compile Include="Extensions\Helpers\PathHelpers.cs" />
|
||||||
|
<Compile Include="Extensions\PackageFolders.cs" />
|
||||||
<Compile Include="Extensions\ExtensionManager.cs" />
|
<Compile Include="Extensions\ExtensionManager.cs" />
|
||||||
|
<Compile Include="Extensions\IExtensionFolders.cs" />
|
||||||
<Compile Include="Extensions\Loaders\CoreExtensionLoader.cs" />
|
<Compile Include="Extensions\Loaders\CoreExtensionLoader.cs" />
|
||||||
<Compile Include="Extensions\Loaders\DynamicExtensionLoader.cs" />
|
<Compile Include="Extensions\Loaders\DynamicExtensionLoader.cs" />
|
||||||
<Compile Include="Extensions\Loaders\IExtensionLoader.cs" />
|
<Compile Include="Extensions\Loaders\IExtensionLoader.cs" />
|
||||||
<Compile Include="Extensions\Loaders\PrecompiledExtensionLoader.cs" />
|
<Compile Include="Extensions\Loaders\PrecompiledExtensionLoader.cs" />
|
||||||
<Compile Include="Extensions\Loaders\ReferencedExtensionLoader.cs" />
|
<Compile Include="Extensions\Loaders\ReferencedExtensionLoader.cs" />
|
||||||
|
<Compile Include="Extensions\ThemeFolders.cs" />
|
||||||
<Compile Include="IEvents.cs" />
|
<Compile Include="IEvents.cs" />
|
||||||
<Compile Include="Localization\IText.cs" />
|
<Compile Include="Localization\IText.cs" />
|
||||||
<Compile Include="Localization\LocalizationModule.cs" />
|
<Compile Include="Localization\LocalizationModule.cs" />
|
||||||
|
|||||||
@@ -6,5 +6,10 @@ namespace Orchard.Themes {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITheme : IContent {
|
public interface ITheme : IContent {
|
||||||
string ThemeName { get; set; }
|
string ThemeName { get; set; }
|
||||||
|
string DisplayName { get; set; }
|
||||||
|
string Description { get; set; }
|
||||||
|
string Version { get; set; }
|
||||||
|
string Author { get; set; }
|
||||||
|
string HomePage { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user