Tweak admin theme changes
- Fix SQLite posts-by-tag query - Fix "on disk" check for default theme
This commit is contained in:
parent
5ce84e18ca
commit
d1a9606c5c
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
<div class="col py-3 d-flex align-self-center justify-content-center">
|
||||
<div class="form-check form-switch">
|
||||
<input type=checkbox name=IsPodcast id=isPodcast class=form-check-input value=true
|
||||
{%- if model.is_podcast %} checked {% endif %}onclick="Admin.checkPodcast()">
|
||||
{%- if model.is_podcast %} checked{% endif %} onclick="Admin.checkPodcast()">
|
||||
<label for=isPodcast class=form-check-label>This Is a Podcast Feed</label>
|
||||
</div>
|
||||
</div>
|
||||
@ -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>
|
||||
@ -67,14 +67,14 @@
|
||||
<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=sourceTypeTag class=form-check-input value=tag
|
||||
{%- if typ == "tag" %} checked {% endif %}onclick="Admin.customFeedBy('tag')">
|
||||
{%- if typ == "tag" %} checked{% endif %} onclick="Admin.customFeedBy('tag')">
|
||||
<label for="sourceTypeTag" class="form-check-label d-none">Tag</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-11 pb-3">
|
||||
<div class=form-floating>
|
||||
<input type=text name=SourceValue id=sourceValueTag class=form-control placeholder=Tag
|
||||
{%- unless typ == "tag" %} disabled {% endunless %}required
|
||||
{%- unless typ == "tag" %} disabled{% endunless %} required
|
||||
{%- if typ == "tag" %} value="{{ model.source_value }}"{% endif %}>
|
||||
<label for=sourceValueTag>Tag</label>
|
||||
</div>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user