-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
570c566
commit 98c3870
Showing
27 changed files
with
367 additions
and
46 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using XCore.DisplayManagement.Theming; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace XCore.Admin | ||
{ | ||
/// <summary> | ||
/// Provides the theme defined in the site configuration for the current scope (request). | ||
/// The same <see cref="ThemeSelectorResult"/> is returned if called multiple times | ||
/// during the same scope. | ||
/// </summary> | ||
public class AdminThemeSelector : IThemeSelector | ||
{ | ||
private readonly IAdminThemeService _adminThemeService; | ||
private readonly IHttpContextAccessor _httpContextAccessor; | ||
|
||
public AdminThemeSelector( | ||
IAdminThemeService adminThemeService, | ||
IHttpContextAccessor httpContextAccessor | ||
) | ||
{ | ||
_adminThemeService = adminThemeService; | ||
_httpContextAccessor = httpContextAccessor; | ||
} | ||
|
||
public async Task<ThemeSelectorResult> GetThemeAsync() | ||
{ | ||
if (AdminAttribute.IsApplied(_httpContextAccessor.HttpContext)) | ||
{ | ||
string adminThemeName = "TheAdmin";//await _adminThemeService.GetAdminThemeNameAsync(); | ||
if (String.IsNullOrEmpty(adminThemeName)) | ||
{ | ||
return null; | ||
} | ||
|
||
return new ThemeSelectorResult | ||
{ | ||
Priority = 100, | ||
ThemeName = adminThemeName | ||
}; | ||
} | ||
await Task.Run(()=> { }); | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Microsoft.Extensions.Caching.Memory; | ||
using XCore.Settings; | ||
using XCore.Environment.Extensions; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace XCore.Admin | ||
{ | ||
public class AdminThemeService : IAdminThemeService | ||
{ | ||
private const string CacheKey = "AdminThemeName"; | ||
|
||
private readonly IExtensionManager _extensionManager; | ||
private readonly ISiteService _siteService; | ||
private readonly IMemoryCache _memoryCache; | ||
|
||
public AdminThemeService( | ||
ISiteService siteService, | ||
IExtensionManager extensionManager, | ||
IMemoryCache memoryCache | ||
) | ||
{ | ||
_siteService = siteService; | ||
_extensionManager = extensionManager; | ||
_memoryCache = memoryCache; | ||
} | ||
|
||
public async Task<IExtensionInfo> GetAdminThemeAsync() | ||
{ | ||
string currentThemeName = await GetAdminThemeNameAsync(); | ||
if (String.IsNullOrEmpty(currentThemeName)) | ||
{ | ||
return null; | ||
} | ||
|
||
return _extensionManager.GetExtension(currentThemeName); | ||
} | ||
|
||
public async Task SetAdminThemeAsync(string themeName) | ||
{ | ||
var site = await _siteService.GetSiteSettingsAsync(); | ||
site.Properties["CurrentAdminThemeName"] = themeName; | ||
//(site as IContent).ContentItem.Content.CurrentAdminThemeName = themeName; | ||
_memoryCache.Set(CacheKey, themeName); | ||
await _siteService.UpdateSiteSettingsAsync(site); | ||
} | ||
|
||
public async Task<string> GetAdminThemeNameAsync() | ||
{ | ||
string themeName; | ||
if (!_memoryCache.TryGetValue(CacheKey, out themeName)) | ||
{ | ||
var site = await _siteService.GetSiteSettingsAsync(); | ||
themeName = (string)site.Properties["CurrentAdminThemeName"]; | ||
// themeName = (string)(site as IContent).ContentItem.Content.CurrentAdminThemeName; | ||
_memoryCache.Set(CacheKey, themeName); | ||
} | ||
|
||
return themeName; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Name: Admin | ||
AntiForgery: enabled | ||
Author: The Orchard Team | ||
Website: http://orchardproject.net | ||
Version: 2.0.x | ||
OrchardVersion: 2.0.x | ||
Description: Creates an admin section for the site. | ||
Dependencies: XCore.Settings | ||
Category: Infrastructure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Routing; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
using XCore.DisplayManagement.Theming; | ||
using XCore.Modules; | ||
|
||
namespace XCore.Admin | ||
{ | ||
public class Startup : StartupBase | ||
{ | ||
public override void ConfigureServices(IServiceCollection services) | ||
{ | ||
//services.AddNavigation(); | ||
|
||
//services.Configure<MvcOptions>((options) => | ||
//{ | ||
// options.Filters.Add(typeof(AdminZoneFilter)); | ||
// options.Filters.Add(typeof(AdminFilter)); | ||
// options.Filters.Add(typeof(AdminMenuFilter)); | ||
//}); | ||
|
||
//services.AddScoped<IPermissionProvider, Permissions>(); | ||
services.AddScoped<IThemeSelector, AdminThemeSelector>(); | ||
//services.AddScoped<IAdminThemeService, AdminThemeService>(); | ||
} | ||
|
||
public override void Configure(IApplicationBuilder builder, IRouteBuilder routes, IServiceProvider serviceProvider) | ||
{ | ||
routes.MapAreaRoute( | ||
name: "Adming", | ||
areaName: "XCore.Admin", | ||
template: "adming", | ||
defaults: new { controller = "Admin", action = "Index" } | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Remove="AdminThemeService.cs" /> | ||
</ItemGroup> | ||
|
||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\XCore\XCore.Admin.Abstractions\XCore.Admin.Abstractions.csproj" /> | ||
<ProjectReference Include="..\..\XCore\XCore.DisplayManagement\XCore.DisplayManagement.csproj" /> | ||
<ProjectReference Include="..\..\XCore\XCore.Module.Targets\XCore.Module.Targets.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="..\XCore.Build\XCore.Commons.props" /> | ||
<Import Project="..\XCore\XCore.Theme.Targets\XCore.Theme.Targets.props" /> | ||
<Import Project="..\XCore\XCore.Module.Targets\XCore.Module.Targets.props" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace TheAdmin | ||
{ | ||
// Just a class so that an assembly gets created | ||
public class Placeholder | ||
{ | ||
} | ||
} |
Oops, something went wrong.