Theme Viewer + Theme Updater (#2952)

This commit is contained in:
Joe Milazzo 2024-05-13 17:00:13 -05:00 committed by GitHub
parent 24302d4fcc
commit 38e7c1c131
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 4563 additions and 284 deletions

View file

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
namespace API.DTOs.Theme;
public class DownloadableSiteThemeDto
{
/// <summary>
/// Theme Name
/// </summary>
public string Name { get; set; }
/// <summary>
/// Url to download css file
/// </summary>
public string CssUrl { get; set; }
public string CssFile { get; set; }
/// <summary>
/// Url to preview image
/// </summary>
public IList<string> PreviewUrls { get; set; }
/// <summary>
/// If Already downloaded
/// </summary>
public bool AlreadyDownloaded { get; set; }
/// <summary>
/// Sha of the file
/// </summary>
public string Sha { get; set; }
/// <summary>
/// Path of the Folder the files reside in
/// </summary>
public string Path { get; set; }
/// <summary>
/// Author of the theme
/// </summary>
/// <remarks>Derived from Readme</remarks>
public string Author { get; set; }
/// <summary>
/// Last version tested against
/// </summary>
/// <remarks>Derived from Readme</remarks>
public string LastCompatibleVersion { get; set; }
/// <summary>
/// If version compatible with version
/// </summary>
public bool IsCompatible { get; set; }
/// <summary>
/// Small blurb about the Theme
/// </summary>
public string Description { get; set; }
}

View file

@ -1,3 +1,4 @@
using System.Collections.Generic;
using API.Entities.Enums.Theme;
using API.Services;
@ -30,5 +31,21 @@ public class SiteThemeDto
/// Where did the theme come from
/// </summary>
public ThemeProvider Provider { get; set; }
public IList<string> PreviewUrls { get; set; }
/// <summary>
/// Information about the theme
/// </summary>
public string Description { get; set; }
/// <summary>
/// Author of the Theme (only applies to non-system provided themes)
/// </summary>
public string Author { get; set; }
/// <summary>
/// Last compatible version. System provided will always be most current
/// </summary>
public string CompatibleVersion { get; set; }
public string Selector => "bg-" + Name.ToLower();
}

View file

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using API.DTOs.Theme;
using API.Entities;
using API.Entities.Enums;
using API.Entities.Enums.UserPreferences;
@ -104,7 +105,7 @@ public class UserPreferencesDto
/// </summary>
/// <remarks>Should default to Dark</remarks>
[Required]
public SiteTheme? Theme { get; set; }
public SiteThemeDto? Theme { get; set; }
[Required] public string BookReaderThemeName { get; set; } = null!;
[Required]