This is your default home page.
", + Revisions = new[] + { + new PageRevision + { + Id = WebLogDbContext.NewId(), + AsOf = DateTime.UtcNow, + SourceType = RevisionSource.Html, + Text = "This is your default home page.
" + } + } + }; + await db.Pages.AddAsync(home); + + // Add the details + var timeZone = TimeZoneInfo.Local.Id; + if (!TimeZoneInfo.Local.HasIanaId) + { + timeZone = TimeZoneInfo.TryConvertWindowsIdToIanaId(timeZone, out var ianaId) + ? ianaId + : throw new TimeZoneNotFoundException($"Cannot find IANA timezone for {timeZone}"); + } + var details = new WebLogDetails + { + Name = args[2], + UrlBase = args[1], + DefaultPage = home.Id, + TimeZone = timeZone + }; + await db.WebLogDetails.AddAsync(details); + + await db.SaveChangesAsync(); + + Console.WriteLine($"Successfully initialized database for {args[2]} with URL base {args[1]}"); +} diff --git a/src/MyWebLog/Program.fs b/src/MyWebLog/Program.fs deleted file mode 100644 index 139a10e..0000000 --- a/src/MyWebLog/Program.fs +++ /dev/null @@ -1,4 +0,0 @@ -open MyWebLog -open Suave - -startWebServer defaultConfig (Successful.OK (Strings.get "LastUpdated")) diff --git a/src/MyWebLog/Properties/launchSettings.json b/src/MyWebLog/Properties/launchSettings.json new file mode 100644 index 0000000..7d7face --- /dev/null +++ b/src/MyWebLog/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:3330", + "sslPort": 0 + } + }, + "profiles": { + "MyWebLog": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5010", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/MyWebLog/Resources/en-US.json b/src/MyWebLog/Resources/en-US.json deleted file mode 100644 index be2715a..0000000 --- a/src/MyWebLog/Resources/en-US.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "Action": "Action", - "Added": "Added", - "AddNew": "Add New", - "AddNewCategory": "Add New Category", - "AddNewPage": "Add New Page", - "AddNewPost": "Add New Post", - "Admin": "Admin", - "AndPublished": " and Published", - "andXMore": "and {0} more...", - "at": "at", - "BackToCategoryList": "Back to Category List", - "BackToPageList": "Back to Page List", - "BackToPostList": "Back to Post List", - "Categories": "Categories", - "Category": "Category", - "CategoryDeleteWarning": "Are you sure you wish to delete the category", - "Close": "Close", - "Comments": "Comments", - "Dashboard": "Dashboard", - "Date": "Date", - "Delete": "Delete", - "Description": "Description", - "Edit": "Edit", - "EditCategory": "Edit Category", - "EditPage": "Edit Page", - "EditPost": "Edit Post", - "EmailAddress": "E-mail Address", - "ErrBadAppConfig": "Could not convert config.json to myWebLog configuration", - "ErrBadLogOnAttempt": "Invalid e-mail address or password", - "ErrDataConfig": "Could not convert data-config.json to RethinkDB connection", - "ErrNotConfigured": "is not properly configured for myWebLog", - "Error": "Error", - "LastUpdated": "Last Updated", - "LastUpdatedDate": "Last Updated Date", - "ListAll": "List All", - "LoadedIn": "Loaded in", - "LogOff": "Log Off", - "LogOn": "Log On", - "MsgCategoryDeleted": "Deleted category {0} successfully", - "MsgCategoryEditSuccess": "{0} category successfully", - "MsgLogOffSuccess": "Log off successful | Have a nice day!", - "MsgLogOnSuccess": "Log on successful | Welcome to myWebLog!", - "MsgPageDeleted": "Deleted page successfully", - "MsgPageEditSuccess": "{0} page successfully", - "MsgPostEditSuccess": "{0}{1} post successfully", - "Name": "Name", - "NewerPosts": "Newer Posts", - "NextPost": "Next Post", - "NoComments": "No Comments", - "NoParent": "No Parent", - "OlderPosts": "Older Posts", - "OneComment": "1 Comment", - "PageDeleteWarning": "Are you sure you wish to delete the page", - "PageDetails": "Page Details", - "PageHash": "Page #", - "Pages": "Pages", - "ParentCategory": "Parent Category", - "Password": "Password", - "Permalink": "Permalink", - "PermanentLinkTo": "Permanent Link to", - "PostDetails": "Post Details", - "Posts": "Posts", - "PostsTagged": "Posts Tagged", - "PostStatus": "Post Status", - "PoweredBy": "Powered by", - "PreviousPost": "Previous Post", - "PublishedDate": "Published Date", - "PublishThisPost": "Publish This Post", - "Save": "Save", - "Seconds": "Seconds", - "ShowInPageList": "Show in Page List", - "Slug": "Slug", - "startingWith": "starting with", - "Status": "Status", - "Tags": "Tags", - "Time": "Time", - "Title": "Title", - "Updated": "Updated", - "View": "View", - "Warning": "Warning", - "XComments": "{0} Comments" -} diff --git a/src/MyWebLog/Strings.fs b/src/MyWebLog/Strings.fs deleted file mode 100644 index 55a725b..0000000 --- a/src/MyWebLog/Strings.fs +++ /dev/null @@ -1,40 +0,0 @@ -module MyWebLog.Strings - -open System.Collections.Generic -open System.Globalization -open System.IO -open System.Reflection -open System.Text.Json - -/// The locales we'll try to load -let private supportedLocales = [ "en-US" ] - -/// The fallback locale, if a key is not found in a non-default locale -let private fallbackLocale = "en-US" - -/// Get an embedded JSON file as a string -let private getEmbedded locale = - let str = sprintf "MyWebLog.Resources.%s.json" locale |> Assembly.GetExecutingAssembly().GetManifestResourceStream - use rdr = new StreamReader (str) - rdr.ReadToEnd() - -/// The dictionary of localized strings -let private strings = - supportedLocales - |> List.map (fun loc -> loc, getEmbedded loc |> JsonSerializer.Deserialize