Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

Remove Light and E-Ink theme (#1263)

Joseph Milazzof2b1cd55f0e5
diff --git a/API.Tests/Services/SiteThemeServiceTests.cs b/API.Tests/Services/SiteThemeServiceTests.cs
index 9c4bbc7cf..246461fc8 100644
--- a/API.Tests/Services/SiteThemeServiceTests.cs
+++ b/API.Tests/Services/SiteThemeServiceTests.cs
@@ -87,7 +87,7 @@ public class SiteThemeServiceTests
UserName = "Joe",
UserPreferences = new AppUserPreferences
{
- Theme = Seed.DefaultThemes[1]
+ Theme = Seed.DefaultThemes[0]
}
});
diff --git a/API/Data/MigrateRemoveExtraThemes.cs b/API/Data/MigrateRemoveExtraThemes.cs
new file mode 100644
index 000000000..1c9a1e9b0
--- /dev/null
+++ b/API/Data/MigrateRemoveExtraThemes.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using API.Services.Tasks;
+
+namespace API.Data;
+
+/// <summary>
+/// In v0.5.3, we removed Light and E-Ink themes. This migration will remove the themes from the DB and default anyone on
+/// null, E-Ink, or Light to Dark.
+/// </summary>
+public static class MigrateRemoveExtraThemes
+{
+ public static async Task Migrate(IUnitOfWork unitOfWork, IThemeService themeService)
+ {
+ Console.WriteLine("Removing Dark and E-Ink themes");
+
+ var themes = (await unitOfWork.SiteThemeRepository.GetThemes()).ToList();
+
+ if (themes.FirstOrDefault(t => t.Name.Equals("Light")) == null)
+ {
+ Console.WriteLine("Done. Nothing to do");
+ return;
+ }
+
+ var darkTheme = themes.Single(t => t.Name.Equals("Dark"));
+ var lightTheme = themes.Single(t => t.Name.Equals("Light"));
+ var eInkTheme = themes.Single(t => t.Name.Equals("E-Ink"));
+
+
+
+ // Update default theme if it's not Dark or a custom theme
+ await themeService.UpdateDefault(darkTheme.Id);
+
+ // Update all users to Dark theme if they are on Light/E-Ink
+ foreach (var pref in await unitOfWork.UserRepository.GetAllPreferencesByThemeAsync(lightTheme.Id))
+ {
+ pref.Theme = darkTheme;
+ }
+ foreach (var pref in await unitOfWork.UserRepository.GetAllPreferencesByThemeAsync(eInkTheme.Id))
+ {
+ pref.Theme = darkTheme;
+ }
+
+ // Remove Light/E-Ink themes
+ foreach (var siteTheme in themes.Where(t => t.Name.Equals("Light") || t.Name.Equals("E-Ink")))
+ {
+ unitOfWork.SiteThemeRepository.Remove(siteTheme);
+ }
+ // Commit and call it a day
+ await unitOfWork.CommitAsync();
+
+ Console.WriteLine("Completed removing Dark and E-Ink themes");
+ }
+
+}
diff --git a/API/Data/Seed.cs b/API/Data/Seed.cs
index 63e6cbdd5..4ecd27da5 100644
--- a/API/Data/Seed.cs
+++ b/API/Data/Seed.cs
@@ -33,23 +33,7 @@ namespace API.Data
Provider = ThemeProvider.System,
FileName = "dark.scss",
IsDefault = true,
- },
- new()
- {
- Name = "Light",
- NormalizedName = Parser.Parser.Normalize("Light"),
- Provider = ThemeProvider.System,
- FileName = "light.scss",
- IsDefault = false,
- },
- new()
- {
- Name = "E-Ink",
- NormalizedName = Parser.Parser.Normalize("E-Ink"),
- Provider = ThemeProvider.System,
- FileName = "e-ink.scss",
- IsDefault = false,
- },
+ }
}.ToArray());
public static async Task SeedRoles(RoleManager<AppRole> roleManager)
diff --git a/API/Startup.cs b/API/Startup.cs
index e1dd28a81..66f704489 100644
--- a/API/Startup.cs
+++ b/API/Startup.cs
@@ -147,6 +147,7 @@ namespace API
// Apply all migrations on startup
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
var userManager = serviceProvider.GetRequiredService<UserManager<AppUser>>();
+ var themeService = serviceProvider.GetRequiredService<IThemeService>();
await MigrateBookmarks.Migrate(directoryService, unitOfWork,
logger, cacheService);
@@ -154,6 +155,8 @@ namespace API
// Only run this if we are upgrading
await MigrateChangePasswordRoles.Migrate(unitOfWork, userManager);
+ await MigrateRemoveExtraThemes.Migrate(unitOfWork, themeService);
+
// Update the version in the DB after all migrations are run
var installVersion = await unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.InstallVersion);
installVersion.Value = BuildInfo.Version.ToString();
diff --git a/UI/Web/src/app/admin/invite-user/invite-user.component.html b/UI/Web/src/app/admin/invite-user/invite-user.component.html
index e8c56e484..1164627a7 100644
--- a/UI/Web/src/app/admin/invite-user/invite-user.component.html
+++ b/UI/Web/src/app/admin/invite-user/invite-user.component.html
@@ -6,7 +6,7 @@
</div>
<div class="modal-body">
<p>
- Invite a user to your server. Enter their email in and we will send them an email to create an account. If you do not want to use our email service, you can <a href="https://wiki.kavitareader.com/en/guides/misc/email" target="_blank" rel="noreferrer">host your own</a>
+ Invite a user to your server. Enter their email in and we will send them an email to create an account. If you do not want to use our email service, you can <a href="https://wiki.kavitareader.com/en/guides/misc/email" target="_blank" rel="noopener noreferrer">host your own</a>
email service or use a fake email (Forgot User will not work). A link will be presented regardless and can be used to setup the email account manually.
</p>
diff --git a/UI/Web/src/app/nav/nav-header/nav-header.component.html b/UI/Web/src/app/nav/nav-header/nav-header.component.html
index e5c64466a..8ecae4267 100644
--- a/UI/Web/src/app/nav/nav-header/nav-header.component.html
+++ b/UI/Web/src/app/nav/nav-header/nav-header.component.html
@@ -155,7 +155,7 @@
<div ngbDropdownMenu>
<a class="xs-only" ngbDropdownItem routerLink="/admin/dashboard" *ngIf="user.roles.includes('Admin')">Server Settings</a>
<a ngbDropdownItem routerLink="/preferences/">Settings</a>
- <a ngbDropdownItem href="https://wiki.kavitareader.com" rel="noreferrer" target="_blank">Help</a>
+ <a ngbDropdownItem href="https://wiki.kavitareader.com" rel="noopener noreferrer" target="_blank">Help</a>
<a ngbDropdownItem routerLink="/announcements/" *ngIf="accountService.hasAdminRole(user)">Annoucements</a>
<a ngbDropdownItem (click)="logout()">Logout</a>
</div>
diff --git a/UI/Web/src/app/user-settings/theme-manager/theme-manager.component.html b/UI/Web/src/app/user-settings/theme-manager/theme-manager.component.html
index fdaf7a3fb..62cfde1ca 100644
--- a/UI/Web/src/app/user-settings/theme-manager/theme-manager.component.html
+++ b/UI/Web/src/app/user-settings/theme-manager/theme-manager.component.html
@@ -8,6 +8,10 @@
</div>
</div>
+ <p *ngIf="isAdmin">
+ Looking for a light or e-ink theme? We have some custom themes you can use on our <a href="https://wiki.kavitareader.com/en/guides/settings/themes" target="_blank" rel="noopener noreferrer">wiki</a>.
+ </p>
+
<div class="row g-0">
<h4>Site Themes</h4>
<ng-container *ngFor="let theme of (themeService.themes$ | async)">