Create theme dir if needed (#49)
- Use Path.Combine throughout - Update theme versions - Update generator version
This commit is contained in:
@@ -399,8 +399,11 @@ module Theme =
|
||||
let! _ = loadFromZip themeId stream data
|
||||
do! ThemeAssetCache.refreshTheme themeId data
|
||||
TemplateCache.invalidateTheme themeId
|
||||
// Ensure the themes directory exists
|
||||
let themeDir = Path.Combine(".", "themes")
|
||||
if not (Directory.Exists themeDir) then Directory.CreateDirectory themeDir |> ignore
|
||||
// Save the .zip file
|
||||
use file = new FileStream($"./themes/{themeId}-theme.zip", FileMode.Create)
|
||||
use file = new FileStream(Path.Combine(".", "themes", $"{themeId}-theme.zip"), FileMode.Create)
|
||||
do! themeFile.CopyToAsync file
|
||||
do! addMessage ctx
|
||||
{ UserMessage.Success with
|
||||
@@ -435,7 +438,7 @@ module Theme =
|
||||
| _ ->
|
||||
match! data.Theme.Delete (ThemeId themeId) with
|
||||
| true ->
|
||||
let zippedTheme = $"./themes/{themeId}-theme.zip"
|
||||
let zippedTheme = Path.Combine(".", "themes", $"{themeId}-theme.zip")
|
||||
if File.Exists zippedTheme then File.Delete zippedTheme
|
||||
do! addMessage ctx { UserMessage.Success with Message = $"Theme ID {themeId} deleted successfully" }
|
||||
return! all next ctx
|
||||
|
||||
@@ -218,8 +218,9 @@ let main args =
|
||||
// Load admin and default themes, and all themes in the /themes directory
|
||||
do! Maintenance.loadTheme [| ""; "./admin-theme.zip" |] app.Services
|
||||
do! Maintenance.loadTheme [| ""; "./default-theme.zip" |] app.Services
|
||||
if Directory.Exists "./themes" then
|
||||
for themeFile in Directory.EnumerateFiles("./themes", "*-theme.zip") do
|
||||
let themePath = Path.Combine(".", "themes")
|
||||
if Directory.Exists themePath then
|
||||
for themeFile in Directory.EnumerateFiles(themePath, "*-theme.zip") do
|
||||
do! Maintenance.loadTheme [| ""; themeFile |] app.Services
|
||||
|
||||
let _ = app.UseForwardedHeaders()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"Generator": "myWebLog 2.1.1",
|
||||
"Generator": "myWebLog 2.2",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"MyWebLog.Handlers": "Information"
|
||||
|
||||
Reference in New Issue
Block a user