Tweak admin theme changes

- Fix SQLite posts-by-tag query
- Fix "on disk" check for default theme
This commit is contained in:
Daniel J. Summers 2024-01-20 17:58:24 -05:00
parent 5ce84e18ca
commit d1a9606c5c
5 changed files with 24 additions and 10 deletions

View File

@ -145,7 +145,7 @@ type SQLitePostData(conn: SqliteConnection, log: ILogger) =
let tagSql, tagParams = inJsonArray Table.Post (nameof Post.Empty.Tags) "tag" [ tag ]
conn.customList
$"{publishedPostByWebLog} AND {tagSql}
ORDER BY p.published_on DESC
ORDER BY {publishField} DESC
LIMIT {postsPerPage + 1} OFFSET {(pageNbr - 1) * postsPerPage}"
(webLogParam webLogId :: tagParams)
fromData<Post>

View File

@ -205,12 +205,13 @@ type DisplayTheme = {
/// Create a display theme from a theme
static member FromTheme inUseFunc (theme: Theme) =
let fileName = if string theme.Id = "default" then "default-theme.zip" else $"./themes/{theme.Id}-theme.zip"
{ Id = string theme.Id
Name = theme.Name
Version = theme.Version
TemplateCount = List.length theme.Templates
IsInUse = inUseFunc theme.Id
IsOnDisk = File.Exists $"{theme.Id}-theme.zip" }
IsOnDisk = File.Exists fileName }
/// Information about an uploaded file used for display

View File

@ -175,8 +175,9 @@ let displayThemeTests = testList "DisplayTheme.FromTheme" [
Expect.isTrue model.IsInUse "IsInUse should have been set"
Expect.isFalse model.IsOnDisk "IsOnDisk should not have been set"
}
test "succeeds when the theme is not in use as is on disk" {
let file = File.Create "another-theme.zip"
test "succeeds when a non-default theme is not in use and is on disk" {
let dir = Directory.CreateDirectory "themes"
let file = File.Create "./themes/another-theme.zip"
try
let model = DisplayTheme.FromTheme (fun _ -> false) { theme with Id = ThemeId "another" }
Expect.isFalse model.IsInUse "IsInUse should not have been set"
@ -184,7 +185,19 @@ let displayThemeTests = testList "DisplayTheme.FromTheme" [
finally
file.Close()
file.Dispose()
File.Delete "another-theme.zip"
File.Delete "./themes/another-theme.zip"
dir.Delete()
}
test "succeeds when the default theme is on disk" {
let file = File.Create "./default-theme.zip"
try
Expect.isTrue
(DisplayTheme.FromTheme (fun _ -> false) { theme with Id = ThemeId "default" }).IsOnDisk
"IsOnDisk should have been set"
finally
file.Close()
file.Dispose()
File.Delete "./default-theme.zip"
}
]

View File

@ -42,7 +42,7 @@
<div class="col-1 d-flex justify-content-end pb-3">
<div class="form-check form-check-inline me-0">
<input type=radio name=SourceType id=sourceTypeCat class=form-check-input value=category
{%- unless typ == "tag" %} checked {% endunless -%}onclick="Admin.customFeedBy('category')">
{%- unless typ == "tag" %} checked{% endunless %} onclick="Admin.customFeedBy('category')">
<label for=sourceTypeCat class="form-check-label d-none">Category</label>
</div>
</div>

View File

@ -145,7 +145,7 @@
</div>
<div class="form-check form-switch pb-2">
<input type=checkbox name=IsTagEnabled id=tagEnabled class=form-check-input value=true
{%- if rss_model.tag_enabled %} checked{% endif %}>
{%- if rss_model.is_tag_enabled %} checked{% endif %}>
<label for=tagEnabled class=form-check-label>Posts by Tag</label>
</div>
</fieldset>