mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 15:32:37 -07:00
More work for #298
This commit is contained in:
parent
0fa42b93f5
commit
05e4c313bf
7 changed files with 108 additions and 13 deletions
44
PlexRequests.UI/Helpers/EmptyViewBase.cs
Normal file
44
PlexRequests.UI/Helpers/EmptyViewBase.cs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: EmptyViewBase.cs
|
||||||
|
// Created By: Jamie Rees
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
// a copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
// ************************************************************************/
|
||||||
|
#endregion
|
||||||
|
using Nancy.ViewEngines.Razor;
|
||||||
|
|
||||||
|
namespace PlexRequests.UI.Helpers
|
||||||
|
{
|
||||||
|
public class EmptyViewBase<T> : NancyRazorViewBase<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
public EmptyViewBase()
|
||||||
|
{
|
||||||
|
Layout = "Shared/Blank.cshtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Execute()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -65,11 +65,7 @@ namespace PlexRequests.UI.Modules
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var claims = Context.CurrentUser.Claims.ToList();
|
var claims = Context.CurrentUser.Claims.ToList();
|
||||||
if (claims.Contains(UserClaims.Admin) || claims.Contains(UserClaims.PowerUser))
|
return claims.Contains(UserClaims.Admin) || claims.Contains(UserClaims.PowerUser);
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +101,7 @@ namespace PlexRequests.UI.Modules
|
||||||
var baseUrl = settings.BaseUrl;
|
var baseUrl = settings.BaseUrl;
|
||||||
|
|
||||||
var redirectPath = string.IsNullOrEmpty(baseUrl) ? "~/userlogin" : $"~/{baseUrl}/userlogin";
|
var redirectPath = string.IsNullOrEmpty(baseUrl) ? "~/userlogin" : $"~/{baseUrl}/userlogin";
|
||||||
|
|
||||||
return Session[SessionKeys.UsernameKey] == null
|
return Session[SessionKeys.UsernameKey] == null
|
||||||
? Context.GetRedirect(redirectPath)
|
? Context.GetRedirect(redirectPath)
|
||||||
: null;
|
: null;
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// ************************************************************************/
|
// ************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
using Nancy;
|
|
||||||
using Nancy.Extensions;
|
using Nancy.Extensions;
|
||||||
|
using Nancy.Responses;
|
||||||
|
|
||||||
using PlexRequests.Core;
|
using PlexRequests.Core;
|
||||||
using PlexRequests.Core.SettingModels;
|
using PlexRequests.Core.SettingModels;
|
||||||
|
@ -36,9 +36,14 @@ namespace PlexRequests.UI.Modules
|
||||||
{
|
{
|
||||||
public IndexModule(ISettingsService<PlexRequestSettings> pr) : base(pr)
|
public IndexModule(ISettingsService<PlexRequestSettings> pr) : base(pr)
|
||||||
{
|
{
|
||||||
Get["/"] = parameters => Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/search" : "~/search");
|
Get["/"] = x => Index();
|
||||||
|
|
||||||
Get["/Index"] = parameters => Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/search" : "~/search");
|
Get["/Index"] = x => Index();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RedirectResponse Index()
|
||||||
|
{
|
||||||
|
return Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/search" : "~/search");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,9 +28,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using Nancy.Extensions;
|
using Nancy.Extensions;
|
||||||
|
using Nancy.Responses;
|
||||||
using Nancy.Responses.Negotiation;
|
using Nancy.Responses.Negotiation;
|
||||||
|
|
||||||
using NLog;
|
using NLog;
|
||||||
|
@ -46,23 +48,30 @@ namespace PlexRequests.UI.Modules
|
||||||
{
|
{
|
||||||
public class UserLoginModule : BaseModule
|
public class UserLoginModule : BaseModule
|
||||||
{
|
{
|
||||||
public UserLoginModule(ISettingsService<AuthenticationSettings> auth, IPlexApi api, ISettingsService<PlexRequestSettings> pr) : base("userlogin", pr)
|
public UserLoginModule(ISettingsService<AuthenticationSettings> auth, IPlexApi api, ISettingsService<PlexRequestSettings> pr, ISettingsService<LandingPageSettings> lp) : base("userlogin", pr)
|
||||||
{
|
{
|
||||||
AuthService = auth;
|
AuthService = auth;
|
||||||
|
LandingPageSettings = lp;
|
||||||
Api = api;
|
Api = api;
|
||||||
Get["/"] = _ => Index();
|
Get["/", true] = async (x, ct) => await Index();
|
||||||
Post["/"] = x => LoginUser();
|
Post["/"] = x => LoginUser();
|
||||||
Get["/logout"] = x => Logout();
|
Get["/logout"] = x => Logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISettingsService<AuthenticationSettings> AuthService { get; }
|
private ISettingsService<AuthenticationSettings> AuthService { get; }
|
||||||
|
private ISettingsService<LandingPageSettings> LandingPageSettings { get; }
|
||||||
private IPlexApi Api { get; }
|
private IPlexApi Api { get; }
|
||||||
|
|
||||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public Negotiator Index()
|
public async Task<Negotiator> Index()
|
||||||
{
|
{
|
||||||
var settings = AuthService.GetSettings();
|
var landingSettings = await LandingPageSettings.GetSettingsAsync();
|
||||||
|
if (landingSettings.Enabled)
|
||||||
|
{
|
||||||
|
return View["Landing/Index",landingSettings];
|
||||||
|
}
|
||||||
|
var settings = await AuthService.GetSettingsAsync();
|
||||||
return View["Index", settings];
|
return View["Index", settings];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,7 @@
|
||||||
<Compile Include="Bootstrapper.cs" />
|
<Compile Include="Bootstrapper.cs" />
|
||||||
<Compile Include="Helpers\BaseUrlHelper.cs" />
|
<Compile Include="Helpers\BaseUrlHelper.cs" />
|
||||||
<Compile Include="Helpers\HeadphonesSender.cs" />
|
<Compile Include="Helpers\HeadphonesSender.cs" />
|
||||||
|
<Compile Include="Helpers\EmptyViewBase.cs" />
|
||||||
<Compile Include="Helpers\ServiceLocator.cs" />
|
<Compile Include="Helpers\ServiceLocator.cs" />
|
||||||
<Compile Include="Helpers\StringHelper.cs" />
|
<Compile Include="Helpers\StringHelper.cs" />
|
||||||
<Compile Include="Helpers\Themes.cs" />
|
<Compile Include="Helpers\Themes.cs" />
|
||||||
|
@ -543,6 +544,12 @@
|
||||||
<Content Include="Views\Admin\LandingPage.cshtml">
|
<Content Include="Views\Admin\LandingPage.cshtml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Views\Landing\Index.cshtml">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Views\Shared\Blank.cshtml">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<None Include="Web.Debug.config">
|
<None Include="Web.Debug.config">
|
||||||
<DependentUpon>web.config</DependentUpon>
|
<DependentUpon>web.config</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
|
|
3
PlexRequests.UI/Views/Landing/Index.cshtml
Normal file
3
PlexRequests.UI/Views/Landing/Index.cshtml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
@inherits PlexRequests.UI.Helpers.EmptyViewBase<PlexRequests.Core.SettingModels.LandingPageSettings>
|
||||||
|
|
||||||
|
|
31
PlexRequests.UI/Views/Shared/Blank.cshtml
Normal file
31
PlexRequests.UI/Views/Shared/Blank.cshtml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
@using Nancy.Security
|
||||||
|
@using Nancy.Session
|
||||||
|
@using PlexRequests.UI.Helpers
|
||||||
|
@using PlexRequests.UI.Models
|
||||||
|
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase
|
||||||
|
@{
|
||||||
|
var baseUrl = Html.GetBaseUrl();
|
||||||
|
var url = string.Empty;
|
||||||
|
if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
|
||||||
|
{
|
||||||
|
url = "/" + baseUrl.ToHtmlString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<html>
|
||||||
|
<div hidden="hidden" id="baseUrl">@baseUrl.ToHtmlString()</div>
|
||||||
|
<head>
|
||||||
|
<title>Plex Requests</title>
|
||||||
|
<!-- Styles -->
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
@Html.LoadAssets()
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
@RenderBody()
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue