Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added AlloyTech sandbox site #44

Merged
merged 2 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nuget/build-packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ If(Test-path $destination) {Remove-item $destination}
[io.compression.zipfile]::CreateFromDirectory($Source, $destination)

.\nuget.exe pack ..\DeveloperTools\DeveloperTools.csproj -Properties Configuration=Release

17 changes: 15 additions & 2 deletions DeveloperTools.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.3
# Visual Studio Version 16
VisualStudioVersion = 16.0.29424.173
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{6C682E10-C007-4377-9E2D-467B9189B8C3}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -16,10 +16,15 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{20EA47CF-F94E-455C-B82B-928FAEB8EF41}"
ProjectSection(SolutionItems) = preProject
.nuget\build-packages.ps1 = .nuget\build-packages.ps1
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeveloperTools.Tests", "tests\DeveloperTools.Tests\DeveloperTools.Tests.csproj", "{C5E53838-AD6F-4482-B3C0-2ECC25007D42}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeveloperTools.SandboxSite", "Tests\DeveloperTools.SandboxSite\DeveloperTools.SandboxSite.csproj", "{FB425711-A454-4807-972A-6A43D1867E0A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{D10CB333-5340-4E93-B7BC-15E3AB1B3335}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -34,10 +39,18 @@ Global
{C5E53838-AD6F-4482-B3C0-2ECC25007D42}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5E53838-AD6F-4482-B3C0-2ECC25007D42}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5E53838-AD6F-4482-B3C0-2ECC25007D42}.Release|Any CPU.Build.0 = Release|Any CPU
{FB425711-A454-4807-972A-6A43D1867E0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB425711-A454-4807-972A-6A43D1867E0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB425711-A454-4807-972A-6A43D1867E0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB425711-A454-4807-972A-6A43D1867E0A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C5E53838-AD6F-4482-B3C0-2ECC25007D42} = {D10CB333-5340-4E93-B7BC-15E3AB1B3335}
{FB425711-A454-4807-972A-6A43D1867E0A} = {D10CB333-5340-4E93-B7BC-15E3AB1B3335}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A45183A0-ADC9-4F14-9709-09BFEDC8263F}
EndGlobalSection
Expand Down
Binary file modified DeveloperTools/EPiServer.DeveloperTools.zip
Binary file not shown.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Developer Tools project
==============

Download latest build on [NuGet](http://nuget.episerver.com/en/OtherPages/Package/?packageId=EPiServer.DeveloperTools) or [under releases](https://github.com/episerver/DeveloperTools/releases)

Experimental project to build small tools useful for developers. Install as an add-on in EPiServer CMS 7.5 (or later) using the manual upload button under Addons. When installed you must be part of the Administrators group to use the tool, a new menu "Developer" should appear in the top menu. And remember, use at your own risk - this is not a supported product.
Expand All @@ -20,5 +19,7 @@ Current features:
* View local object cache content (with option to remove some items)

## How Risky it is to install on production?

You can read more in depth analysis of toolset and it's side-effects [here](https://blog.tech-fellow.net/2019/02/14/how-risky-are-episerver-developertools-on-production-environment/).

## Contributing?
Sandbox site credentials: admin/P@ssword1!
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using EPiServer.ServiceLocation;
using EPiServer.Shell.Security;
using Owin;
using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace DeveloperTools.SandboxSite
{
public static class AdministratorRegistrationPage
{
private static Func<bool> _isLocalRequest = () => false;

private static Lazy<bool> _isAnyUserRegistered = new Lazy<bool>(() => false);

private static bool? _isEnabled = null;

public static bool IsEnabled
{
get
{
if (_isEnabled.HasValue)
{
return _isEnabled.Value;
}

var showUserRegistration = _isLocalRequest() && !_isAnyUserRegistered.Value;
if (!showUserRegistration)
{
_isEnabled = false;
}

return showUserRegistration;
}
set
{
_isEnabled = value;
}
}

public static void UseAdministratorRegistrationPage(this IAppBuilder app, Func<bool> isLocalRequest)
{
_isLocalRequest = isLocalRequest;
_isAnyUserRegistered = new Lazy<bool>(IsAnyUserRegistered);
GlobalFilters.Filters.Add(new RegistrationActionFilterAttribute());
if (isLocalRequest())
{
AddRoute();
}
}

private static bool IsAnyUserRegistered()
{
var provider = ServiceLocator.Current.GetInstance<UIUserProvider>();
int totalUsers = 0;
var res = provider.GetAllUsers(0, 1, out totalUsers);
return totalUsers > 0;
}

public class RegistrationActionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext context)
{
var registerUrl = VirtualPathUtility.ToAbsolute("~/Register");
if (IsEnabled && !context.RequestContext.HttpContext.Request.Path.StartsWith(registerUrl))
{
context.Result = new RedirectResult(registerUrl);
}
}
}

static void AddRoute()
{
var routeData = new RouteValueDictionary();
routeData.Add("Controller", "Register");
routeData.Add("action", "Index");
routeData.Add("id", " UrlParameter.Optional");
RouteTable.Routes.Add("Register", new Route("{controller}/{action}/{id}", routeData, new MvcRouteHandler()) { RouteExistingFiles = false });
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using EPiServer.Framework.Localization;
using EPiServer.ServiceLocation;
using EPiServer.Web;

namespace DeveloperTools.SandboxSite.Business.Channels
{
/// <summary>
/// Base class for all resolution definitions
/// </summary>
public abstract class DisplayResolutionBase : IDisplayResolution
{
private Injected<LocalizationService> LocalizationService { get; set; }

protected DisplayResolutionBase(string name, int width, int height)
{
Id = GetType().FullName;
Name = Translate(name);
Width = width;
Height = height;
}

/// <summary>
/// Gets the unique ID for this resolution
/// </summary>
public string Id { get; protected set; }

/// <summary>
/// Gets the name of resolution
/// </summary>
public string Name { get; protected set; }

/// <summary>
/// Gets the resolution width in pixels
/// </summary>
public int Width { get; protected set; }

/// <summary>
/// Gets the resolution height in pixels
/// </summary>
public int Height { get; protected set; }

private string Translate(string resurceKey)
{
string value;

if(!LocalizationService.Service.TryGetString(resurceKey, out value))
{
value = resurceKey;
}

return value;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace DeveloperTools.SandboxSite.Business.Channels
{
/// <summary>
/// Defines resolution for desktop displays
/// </summary>
public class StandardResolution : DisplayResolutionBase
{
public StandardResolution() : base("/resolutions/standard", 1366, 768)
{
}
}

/// <summary>
/// Defines resolution for a horizontal iPad
/// </summary>
public class IpadHorizontalResolution : DisplayResolutionBase
{
public IpadHorizontalResolution() : base("/resolutions/ipadhorizontal", 1024, 768)
{
}
}

/// <summary>
/// Defines resolution for a vertical iPhone 5s
/// </summary>
public class IphoneVerticalResolution : DisplayResolutionBase
{
public IphoneVerticalResolution() : base("/resolutions/iphonevertical", 320, 568)
{
}
}

/// <summary>
/// Defines resolution for a vertical Android handheld device
/// </summary>
public class AndroidVerticalResolution : DisplayResolutionBase
{
public AndroidVerticalResolution() : base("/resolutions/androidvertical", 480, 800)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Web;
using System.Web.WebPages;
using EPiServer.Web;

namespace DeveloperTools.SandboxSite.Business.Channels
{
//<summary>
//Defines the 'Mobile' content channel
//</summary>
public class MobileChannel : DisplayChannel
{
public const string Name = "mobile";

public override string ChannelName
{
get
{
return Name;
}
}

public override string ResolutionId
{
get
{
return typeof(IphoneVerticalResolution).FullName;
}
}

public override bool IsActive(HttpContextBase context)
{
return context.GetOverriddenBrowser().IsMobileDevice;
}
}
}
24 changes: 24 additions & 0 deletions tests/DeveloperTools.SandboxSite/Business/Channels/WebChannel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Web;
using EPiServer.Web;

namespace DeveloperTools.SandboxSite.Business.Channels
{
/// <summary>
/// Defines the 'Web' content channel
/// </summary>
public class WebChannel : DisplayChannel
{
public override string ChannelName
{
get
{
return "web";
}
}

public override bool IsActive(HttpContextBase context)
{
return !context.Request.Browser.IsMobileDevice;
}
}
}
48 changes: 48 additions & 0 deletions tests/DeveloperTools.SandboxSite/Business/ContentExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Collections.Generic;
using System.Linq;
using EPiServer.Core;
using EPiServer.Filters;
using EPiServer.Framework.Web;
using EPiServer.ServiceLocation;
using EPiServer;

namespace DeveloperTools.SandboxSite.Business
{
/// <summary>
/// Extension methods for content
/// </summary>
public static class ContentExtensions
{
/// <summary>
/// Filters content which should not be visible to the user.
/// </summary>
public static IEnumerable<T> FilterForDisplay<T>(this IEnumerable<T> contents, bool requirePageTemplate = false, bool requireVisibleInMenu = false)
where T : IContent
{
var accessFilter = new FilterAccess();
var publishedFilter = new FilterPublished();
contents = contents.Where(x => !publishedFilter.ShouldFilter(x) && !accessFilter.ShouldFilter(x));
if (requirePageTemplate)
{
var templateFilter = ServiceLocator.Current.GetInstance<FilterTemplate>();
templateFilter.TemplateTypeCategories = TemplateTypeCategories.Page;
contents = contents.Where(x => !templateFilter.ShouldFilter(x));
}
if (requireVisibleInMenu)
{
contents = contents.Where(x => VisibleInMenu(x));
}
return contents;
}

private static bool VisibleInMenu(IContent content)
{
var page = content as PageData;
if (page == null)
{
return true;
}
return page.VisibleInMenu;
}
}
}
Loading