From 1af3c216551291f560619d900e1ccacfd2316e8e Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 8 Apr 2016 14:14:08 +0100 Subject: [PATCH] Added a url base --- .../SettingModels/PlexRequestSettings.cs | 2 +- PlexRequests.Core/Setup.cs | 9 +++---- PlexRequests.UI/Bootstrapper.cs | 16 ++++++++++++- PlexRequests.UI/Content/bootstrap.css | 4 ++-- PlexRequests.UI/Content/font-awesome.css | 4 ++-- PlexRequests.UI/PlexRequests.UI.csproj | 4 ++++ PlexRequests.UI/Program.cs | 14 +++++++---- PlexRequests.UI/Views/Admin/Logs.cshtml | 4 ++-- PlexRequests.UI/Views/Requests/Index.cshtml | 2 +- PlexRequests.UI/Views/Search/Index.cshtml | 2 +- PlexRequests.UI/Views/Shared/_Layout.cshtml | 24 +++++++++---------- 11 files changed, 54 insertions(+), 31 deletions(-) diff --git a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs index 4b4009def..90596ba39 100644 --- a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs +++ b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs @@ -33,7 +33,7 @@ namespace PlexRequests.Core.SettingModels public class PlexRequestSettings : Settings { public int Port { get; set; } - + public string AssetLocation { get; set; } public bool SearchForMovies { get; set; } public bool SearchForTvShows { get; set; } public bool SearchForMusic { get; set; } diff --git a/PlexRequests.Core/Setup.cs b/PlexRequests.Core/Setup.cs index bbf41039e..c59b3556e 100644 --- a/PlexRequests.Core/Setup.cs +++ b/PlexRequests.Core/Setup.cs @@ -44,7 +44,7 @@ namespace PlexRequests.Core { private static Logger Log = LogManager.GetCurrentClassLogger(); private static DbConfiguration Db { get; set; } - public string SetupDb() + public string SetupDb(string assetLocation) { Db = new DbConfiguration(new SqliteFactory()); var created = Db.CheckDb(); @@ -52,7 +52,7 @@ namespace PlexRequests.Core if (created) { - CreateDefaultSettingsPage(); + CreateDefaultSettingsPage(assetLocation); } var version = CheckSchema(); @@ -89,7 +89,7 @@ namespace PlexRequests.Core return version; } - private void CreateDefaultSettingsPage() + private void CreateDefaultSettingsPage(string assetLocation) { var defaultSettings = new PlexRequestSettings { @@ -97,7 +97,8 @@ namespace PlexRequests.Core RequireMovieApproval = true, SearchForMovies = true, SearchForTvShows = true, - WeeklyRequestLimit = 0 + WeeklyRequestLimit = 0, + AssetLocation = assetLocation ?? "assets" }; var s = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider())); s.SaveSettings(defaultSettings); diff --git a/PlexRequests.UI/Bootstrapper.cs b/PlexRequests.UI/Bootstrapper.cs index a3a8bc723..b05b71019 100644 --- a/PlexRequests.UI/Bootstrapper.cs +++ b/PlexRequests.UI/Bootstrapper.cs @@ -32,6 +32,7 @@ using Mono.Data.Sqlite; using Nancy; using Nancy.Authentication.Forms; using Nancy.Bootstrapper; +using Nancy.Conventions; using Nancy.Cryptography; using Nancy.Diagnostics; using Nancy.Session; @@ -60,6 +61,8 @@ namespace PlexRequests.UI // by overriding the various methods and properties. // For more information https://github.com/NancyFx/Nancy/wiki/Bootstrapper + private TinyIoCContainer _container; + protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context) { container.Register(); @@ -108,6 +111,7 @@ namespace PlexRequests.UI TaskManager.TaskFactory = new PlexTaskFactory(); TaskManager.Initialize(new PlexRegistry()); TaskManager.Initialize(new MediaCacheRegistry()); + _container = container; } protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) @@ -132,7 +136,17 @@ namespace PlexRequests.UI (sender, certificate, chain, sslPolicyErrors) => true; } - + + protected override void ConfigureConventions(NancyConventions nancyConventions) + { + base.ConfigureConventions(nancyConventions); + + var settings = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()),new MemoryCacheProvider())); + var assetLocation = settings.GetSettings().AssetLocation; + nancyConventions.StaticContentsConventions.Add( + StaticContentConventionBuilder.AddDirectory("assets", $"{assetLocation}/Content") + ); + } protected override DiagnosticsConfiguration DiagnosticsConfiguration => new DiagnosticsConfiguration { Password = @"password" }; diff --git a/PlexRequests.UI/Content/bootstrap.css b/PlexRequests.UI/Content/bootstrap.css index 83e3b6fa3..0638c1fb9 100644 --- a/PlexRequests.UI/Content/bootstrap.css +++ b/PlexRequests.UI/Content/bootstrap.css @@ -269,8 +269,8 @@ th { } @font-face { font-family: 'Glyphicons Halflings'; - src: url('../Content/fonts/glyphicons-halflings-regular.eot'); - src: url('../Content/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../Content/fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../Content/fonts/glyphicons-halflings-regular.woff') format('woff'), url('../Content/fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../Content/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg'); + src: url('../assets/fonts/glyphicons-halflings-regular.eot'); + src: url('../assets/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../assets/fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../assets/fonts/glyphicons-halflings-regular.woff') format('woff'), url('../assets/fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../assets/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg'); } .glyphicon { position: relative; diff --git a/PlexRequests.UI/Content/font-awesome.css b/PlexRequests.UI/Content/font-awesome.css index 7f747bf2c..b190f2c94 100644 --- a/PlexRequests.UI/Content/font-awesome.css +++ b/PlexRequests.UI/Content/font-awesome.css @@ -6,8 +6,8 @@ * -------------------------- */ @font-face { font-family: 'FontAwesome'; - src: url('../Content/fonts/fontawesome-webfont.eot?v=4.5.0'); - src: url('../Content/fonts/fontawesome-webfont.eot?#iefix&v=4.5.0') format('embedded-opentype'), url('../Content/fonts/fontawesome-webfont.woff2?v=4.5.0') format('woff2'), url('../Content/fonts/fontawesome-webfont.woff?v=4.5.0') format('woff'), url('../Content/fonts/fontawesome-webfont.ttf?v=4.5.0') format('truetype'), url('../Content/fonts/fontawesome-webfont.svg?v=4.5.0#fontawesomeregular') format('svg'); + src: url('../assets/fonts/fontawesome-webfont.eot?v=4.5.0'); + src: url('../assets/fonts/fontawesome-webfont.eot?#iefix&v=4.5.0') format('embedded-opentype'), url('../assets/fonts/fontawesome-webfont.woff2?v=4.5.0') format('woff2'), url('../assets/fonts/fontawesome-webfont.woff?v=4.5.0') format('woff'), url('../assets/fonts/fontawesome-webfont.ttf?v=4.5.0') format('truetype'), url('../assets/fonts/fontawesome-webfont.svg?v=4.5.0#fontawesomeregular') format('svg'); font-weight: normal; font-style: normal; } diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj index c3325ff7d..8fa05a3da 100644 --- a/PlexRequests.UI/PlexRequests.UI.csproj +++ b/PlexRequests.UI/PlexRequests.UI.csproj @@ -462,6 +462,10 @@ + + + + - - - - + + + + - - - - - - - - + + + + + + + +