mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +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:
@@ -85,8 +85,10 @@
|
||||
<Compile Include="Settings\ViewModels\SettingsIndexViewModel.cs" />
|
||||
<Compile Include="Themes\AdminMenu.cs" />
|
||||
<Compile Include="Themes\Controllers\AdminController.cs" />
|
||||
<Compile Include="Themes\Models\Theme.cs" />
|
||||
<Compile Include="Themes\Models\ThemeSiteSettings.cs" />
|
||||
<Compile Include="Themes\Models\ThemeSiteSettingsHandler.cs" />
|
||||
<Compile Include="Themes\Records\ThemeRecord.cs" />
|
||||
<Compile Include="Themes\Records\ThemeSiteSettingsRecord.cs" />
|
||||
<Compile Include="Themes\Services\ThemeService.cs" />
|
||||
<Compile Include="Themes\ViewModels\ThemesIndexViewModel.cs" />
|
||||
|
@@ -7,8 +7,7 @@ namespace Orchard.Core.Themes {
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
builder.Add("Themes", "11",
|
||||
menu => menu
|
||||
.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" })));
|
||||
.Add("Manage Themes", "2.0", 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.Localization;
|
||||
using Orchard.Themes;
|
||||
@@ -19,7 +20,16 @@ namespace Orchard.Core.Themes.Controllers {
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ActionResult Index() {
|
||||
return View(new ThemesIndexViewModel());
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
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.Collections.Generic;
|
||||
using Orchard.Extensions;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Models;
|
||||
using Orchard.Settings;
|
||||
@@ -8,7 +9,10 @@ using Orchard.Core.Themes.Models;
|
||||
|
||||
namespace Orchard.Core.Themes.Services {
|
||||
public class ThemeService : IThemeService {
|
||||
public ThemeService() {
|
||||
private readonly IExtensionManager _extensionManager;
|
||||
|
||||
public ThemeService(IExtensionManager extensionManager) {
|
||||
_extensionManager = extensionManager;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
@@ -28,11 +32,37 @@ namespace Orchard.Core.Themes.Services {
|
||||
}
|
||||
|
||||
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() {
|
||||
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
|
||||
|
@@ -1,6 +1,10 @@
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Themes;
|
||||
|
||||
namespace Orchard.Core.Themes.ViewModels {
|
||||
public class ThemesIndexViewModel : AdminViewModel {
|
||||
public ITheme CurrentTheme { get; set; }
|
||||
public IEnumerable<ITheme> Themes { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,14 @@
|
||||
Themes</h2>
|
||||
</div>
|
||||
<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>
|
||||
<% Html.Include("AdminFoot"); %>
|
Reference in New Issue
Block a user