Skip to content

Commit

Permalink
Merge pull request #39 from valdisiljuconoks/develop
Browse files Browse the repository at this point in the history
Merge from 'develop'
  • Loading branch information
valdisiljuconoks authored Jun 11, 2016
2 parents 9554494 + df91156 commit c0202be
Show file tree
Hide file tree
Showing 157 changed files with 4,742 additions and 898 deletions.
14 changes: 11 additions & 3 deletions .vs/config/applicationhost.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
IIS configuration sections.
Expand Down Expand Up @@ -137,8 +137,8 @@
<add name="Clr2IntegratedAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="Clr2ClassicAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="UnmanagedClassicAppPool" managedRuntimeVersion="" managedPipelineMode="Classic" autoStart="true" />
<applicationPoolDefaults managedRuntimeLoader="v4.0" >
<processModel/>
<applicationPoolDefaults managedRuntimeLoader="v4.0">
<processModel />
</applicationPoolDefaults>
</applicationPools>

Expand All @@ -161,6 +161,14 @@
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
<site name="DbLocalizationProvider.MvcSample" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\valdis\Documents\GitHubVisualStudio\DbLocalizationProvider\DbLocalizationProvider.MvcSample" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:14791:localhost" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
Expand Down
24 changes: 24 additions & 0 deletions DbLocalizationProvider.AdminUI.EPiServer/AdminUISetupModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using InitializationModule = EPiServer.Web.InitializationModule;

namespace DbLocalizationProvider.AdminUI.EPiServer
{
[InitializableModule]
[ModuleDependency(typeof(InitializationModule))]
public class AdminUISetupModule : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
foreach (var role in new[] { "CmsAdmins", "WebAdmins", "LocalizationAdmins" })
UiConfigurationContext.Current.AuthorizedAdminRoles.Add(role);

foreach (var role in new[] { "CmsEditors", "WebEditors", "LocalizationEditors" })
UiConfigurationContext.Current.AuthorizedEditorRoles.Add(role);

// set default implementations
}

public void Uninitialize(InitializationEngine context) { }
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" ?>

<package>
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>https://github.com/valdisiljuconoks/LocalizationProvider/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/valdisiljuconoks/LocalizationProvider/</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Inital version of DbLocalizationProvider AdminUI package for EPiServer</releaseNotes>
<copyright>Copyright 2016 (c) Valdis Iljuconoks, Tech Fellow</copyright>
<tags>Localization EPiServer Provider DbLocalization DbLocalizationProvider LocalizationProvider AdminUI UI</tags>
<dependencies>
<dependency id="DbLocalizationProvider.EPiServer" version="2.0.0" />
</dependencies>
</metadata>
<files>
<file src="DbLocalizationProvider.AdminUI.EPiServer.zip" target="content\modules\_protected\DbLocalizationProvider.AdminUI.EPiServer" />
</files>
</package>
Binary file not shown.
27 changes: 27 additions & 0 deletions DbLocalizationProvider.AdminUI.EPiServer/MenuItemRegistration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.Linq;
using EPiServer.PlugIn;
using EPiServer.Shell;
using EPiServer.Shell.Navigation;
using PlugInArea = EPiServer.PlugIn.PlugInArea;

namespace DbLocalizationProvider.AdminUI.EPiServer
{
[GuiPlugIn(DisplayName = "Localization Resources", UrlFromModuleFolder = "LocalizationResources", Area = PlugInArea.AdminMenu)]
public class MenuItemRegistration { }

[MenuProvider]
public class AdminUIMenuProvider : IMenuProvider
{
public IEnumerable<MenuItem> GetMenuItems()
{
return new List<MenuItem>
{
new UrlMenuItem("Localization", "/global/cms/localization", Paths.ToResource(typeof(MenuItemRegistration), "LocalizationResources/Main"))
{
IsAvailable = ctx => UiConfigurationContext.Current.AuthorizedEditorRoles.Any(ctx.HttpContext.User.IsInRole)
}
};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("DbLocalizationProvider.AdminUI.EPiServer")]
[assembly: AssemblyDescription("DbLocalizationProvider management user interface for EPServer")]
[assembly: Guid("aa5fcd04-8113-4f0b-8e8e-5cf365b3d245")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<%= Page.ClientResources("DijitWidgets", new[] { ClientResourceType.Style })%>

<%= Html.CssLink(UriSupport.ResolveUrlFromUIBySettings("App_Themes/Default/Styles/ToolButton.css")) %>
<%= Html.CssLink(Paths.ToClientResource("CMS", "ClientResources/Epi/Base/CMS.css"))%>
<%--<%= Html.CssLink(Paths.ToClientResource("CMS", "ClientResources/Epi/Base/CMS.css"))%>--%>
<%= Html.ScriptResource(UriSupport.ResolveUrlFromUtilBySettings("javascript/episerverscriptmanager.js"))%>
<%= Html.ScriptResource(UriSupport.ResolveUrlFromUIBySettings("javascript/system.js")) %>
<%= Html.ScriptResource(UriSupport.ResolveUrlFromUIBySettings("javascript/dialog.js")) %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<module>
<assemblies>
<add assembly="DbLocalizationProvider.AdminUI" />
<add assembly="DbLocalizationProvider.AdminUI.EPiServer" />
</assemblies>
</module>
17 changes: 17 additions & 0 deletions DbLocalizationProvider.AdminUI.EPiServer/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="3.2.0" />
<package id="Castle.Windsor" version="3.2.0" />
<package id="EntityFramework" version="6.1.2" />
<package id="EPiServer.CMS.Core" version="9.0.0" />
<package id="EPiServer.CMS.UI.Core" version="9.0.0" />
<package id="EPiServer.Framework" version="9.0.0" />
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" />
<package id="Microsoft.AspNet.Razor" version="2.0.20710.0" />
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="Newtonsoft.Json" version="5.0.8" />
<package id="Owin" version="1.0" targetFramework="net452" />
<package id="structuremap.web-signed" version="3.1.6.186" />
<package id="structuremap-signed" version="3.1.6.186" />
</packages>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<configuration>
<episerver.shell>
<protectedModules>
<add name="DbLocalizationProvider.AdminUI" />
<add name="DbLocalizationProvider.AdminUI.EPiServer" />
</protectedModules>
</episerver.shell>
</configuration>
15 changes: 15 additions & 0 deletions DbLocalizationProvider.AdminUI/AppBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using Owin;

namespace DbLocalizationProvider.AdminUI
{
public static class AppBuilderExtensions
{
public static void UseDbLocalizationProviderAdminUI(this IAppBuilder builder, Action<UiConfigurationContext> setup = null)
{
// set default implementations

setup?.Invoke(UiConfigurationContext.Current);
}
}
}
23 changes: 23 additions & 0 deletions DbLocalizationProvider.AdminUI/AuthorizeRolesAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,28 @@ public AuthorizeRolesAttribute(params string[] roles)
{
Roles = string.Join(",", roles);
}

public UiContextMode Mode { get; set; } = UiContextMode.None;

public override void OnAuthorization(AuthorizationContext filterContext)
{
// merge both roles into single list
var admins = string.Join(",", UiConfigurationContext.Current.AuthorizedAdminRoles);
var editors = string.Join(",", UiConfigurationContext.Current.AuthorizedEditorRoles);

var rolesToCheck = string.Join(",", string.Join(",", admins, editors));
switch (Mode)
{
case UiContextMode.Admin:
rolesToCheck = admins;
break;
case UiContextMode.Edit:
rolesToCheck = editors;
break;
}

Roles = rolesToCheck;
base.OnAuthorization(filterContext);
}
}
}
Binary file not shown.
Loading

0 comments on commit c0202be

Please sign in to comment.