diff --git a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs index 078798b3e..65afd1559 100644 --- a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs +++ b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs @@ -60,6 +60,9 @@ namespace PlexRequests.Core.SettingModels public bool DisableTvRequestsBySeason { get; set; } public bool SendRecentlyAddedEmail { get; set; } + public string CustomDonationUrl { get; set; } + public bool EnableCustomDonationUrl { get; set; } + public string CustomDonationMessage { get; set; } /// /// The CSS name of the theme we want /// diff --git a/PlexRequests.UI/Modules/DonationLinkModule.cs b/PlexRequests.UI/Modules/DonationLinkModule.cs new file mode 100644 index 000000000..9ede62e41 --- /dev/null +++ b/PlexRequests.UI/Modules/DonationLinkModule.cs @@ -0,0 +1,52 @@ +using System; +using System.Threading.Tasks; + +using Nancy; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using NLog; + +using PlexRequests.Core; +using PlexRequests.Core.SettingModels; +using PlexRequests.Helpers; +using PlexRequests.UI.Models; + +namespace PlexRequests.UI.Modules +{ + public class DonationLinkModule : BaseAuthModule + { + public DonationLinkModule(ICacheProvider provider, ISettingsService pr) : base("customDonation", pr) + { + Cache = provider; + + Get["/", true] = async (x, ct) => await GetCustomDonationUrl(pr); + } + + private ICacheProvider Cache { get; } + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + private async Task GetCustomDonationUrl(ISettingsService pr) + { + PlexRequestSettings settings = await pr.GetSettingsAsync(); + try + { + if (settings.EnableCustomDonationUrl) + { + return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage }); + } + else + { + return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage }); + } + } + catch (Exception e) + { + Log.Warn("Exception Thrown when attempting to check the custom donation url"); + Log.Warn(e); + return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage }); + } + } + } + +} diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj index 1df11b208..bd88121f2 100644 --- a/PlexRequests.UI/PlexRequests.UI.csproj +++ b/PlexRequests.UI/PlexRequests.UI.csproj @@ -248,6 +248,7 @@ + diff --git a/PlexRequests.UI/Resources/UI.resx b/PlexRequests.UI/Resources/UI.resx index 4f23fce97..883e20be1 100644 --- a/PlexRequests.UI/Resources/UI.resx +++ b/PlexRequests.UI/Resources/UI.resx @@ -443,4 +443,7 @@ View In Plex + + Donate to Library Maintainer + \ No newline at end of file diff --git a/PlexRequests.UI/Resources/UI1.Designer.cs b/PlexRequests.UI/Resources/UI1.Designer.cs index 6cd282c32..acb53c9bb 100644 --- a/PlexRequests.UI/Resources/UI1.Designer.cs +++ b/PlexRequests.UI/Resources/UI1.Designer.cs @@ -114,6 +114,15 @@ namespace PlexRequests.UI.Resources { } } + /// + /// Looks up a localized string similar to Donate to Library Maintainer. + /// + public static string Custom_Donation_Default { + get { + return ResourceManager.GetString("Custom_Donation_Default", resourceCulture); + } + } + /// /// Looks up a localized string similar to Issue. /// diff --git a/PlexRequests.UI/Views/Admin/Settings.cshtml b/PlexRequests.UI/Views/Admin/Settings.cshtml index 386b209c8..8ed022ee8 100644 --- a/PlexRequests.UI/Views/Admin/Settings.cshtml +++ b/PlexRequests.UI/Views/Admin/Settings.cshtml @@ -273,10 +273,38 @@ } +
+
+ + @if (Model.EnableCustomDonationUrl) + { + + + } + else + { + + } +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + -

A comma separated list of users whose requests do not require approval (These users also do not have a request limit).

+

A comma separated list of users whose requests do not require approval (These users also do not have a request limit).

diff --git a/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml b/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml index 6692f6f74..8a1826a07 100644 --- a/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml +++ b/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml @@ -1,6 +1,7 @@ @using Nancy.Security @using Nancy.Session @using Nancy; +@using PlexRequests.Core.SettingModels @using PlexRequests.UI.Helpers @using PlexRequests.UI.Models @using PlexRequests.UI.Resources @@ -38,10 +39,11 @@ {
  • } +
    + \ No newline at end of file