Remove Base Url Support (#652)

* Fixed some issues with base url. All Scheduled jobs are now in user's timezone

* Hide Base Url support from UI and removed some code around it on the backend to prevent it from interfering. Patched back in changes from base-href branch like Timezone on scheduled jobs and enhanced logging.

* Added parser support for "2000 AD 0366 [1984-04-28] (flopbie)" and removed for "01 Spiderman 01".
This commit is contained in:
Joseph Milazzo 2021-10-11 06:57:50 -07:00 committed by GitHub
parent ec3fe7fd8a
commit 06508fd909
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 63 additions and 120 deletions

View file

@ -8,7 +8,7 @@ namespace Kavita.Common
{
public static class Configuration
{
private static string AppSettingsFilename = GetAppSettingFilename();
private static readonly string AppSettingsFilename = GetAppSettingFilename();
public static string Branch
{
get => GetBranch(GetAppSettingFilename());
@ -33,12 +33,6 @@ namespace Kavita.Common
set => SetLogLevel(GetAppSettingFilename(), value);
}
public static string BaseUrl
{
get => GetBaseUrl(GetAppSettingFilename());
set => SetBaseUrl(GetAppSettingFilename(), value);
}
private static string GetAppSettingFilename()
{
if (!string.IsNullOrEmpty(AppSettingsFilename))
@ -157,55 +151,6 @@ namespace Kavita.Common
#endregion
#region BaseUrl
private static string GetBaseUrl(string filePath)
{
if (new OsInfo(Array.Empty<IOsVersionAdapter>()).IsDocker)
{
return "/";
}
try
{
var json = File.ReadAllText(filePath);
var jsonObj = JsonSerializer.Deserialize<dynamic>(json);
const string key = "BaseUrl";
if (jsonObj.TryGetProperty(key, out JsonElement tokenElement))
{
return tokenElement.GetString();
}
}
catch (Exception ex)
{
Console.WriteLine("Error reading app settings: " + ex.Message);
}
return "/";
}
private static void SetBaseUrl(string filePath, string value)
{
if (new OsInfo(Array.Empty<IOsVersionAdapter>()).IsDocker)
{
return;
}
var currentBaseUrl = GetBaseUrl(filePath);
var json = File.ReadAllText(filePath);
if (!json.Contains("BaseUrl"))
{
var lastBracket = json.LastIndexOf("}", StringComparison.Ordinal) - 1;
json = (json.Substring(0, lastBracket) + (",\n \"BaseUrl\": " + currentBaseUrl) + "}");
}
else
{
json = json.Replace("\"BaseUrl\": " + currentBaseUrl, "\"BaseUrl\": " + value);
}
File.WriteAllText(filePath, json);
}
#endregion
#region LogLevel
private static void SetLogLevel(string filePath, string logLevel)