diff --git a/src/MyWebLog.App/App.fs b/src/MyWebLog.App/App.fs index 4454307..5eba1cc 100644 --- a/src/MyWebLog.App/App.fs +++ b/src/MyWebLog.App/App.fs @@ -130,7 +130,7 @@ type MyWebLogBootstrapper() = let version = - let v = typeof.GetType().GetTypeInfo().Assembly.GetName().Version + let v = typeof.GetTypeInfo().Assembly.GetName().Version match v.Build with | 0 -> match v.Minor with 0 -> string v.Major | _ -> sprintf "%d.%d" v.Major v.Minor | _ -> sprintf "%d.%d.%d" v.Major v.Minor v.Build diff --git a/src/MyWebLog.App/AssemblyInfo.fs b/src/MyWebLog.App/AssemblyInfo.fs index 24c3209..0fb972b 100644 --- a/src/MyWebLog.App/AssemblyInfo.fs +++ b/src/MyWebLog.App/AssemblyInfo.fs @@ -1,4 +1,4 @@ -namespace myWebLog.Web.AssemblyInfo +namespace MyWebLog.AssemblyInfo open System.Reflection open System.Runtime.CompilerServices @@ -14,7 +14,7 @@ open System.Runtime.InteropServices [] [] [] -[] +[] [] do diff --git a/src/MyWebLog.App/PostModule.fs b/src/MyWebLog.App/PostModule.fs index 531e660..0a241e2 100644 --- a/src/MyWebLog.App/PostModule.fs +++ b/src/MyWebLog.App/PostModule.fs @@ -103,18 +103,18 @@ type PostModule(data : IMyWebLogData, clock : IClock) as this = upcast this.Response.FromStream(stream, sprintf "application/%s+xml" format) *) do - this.Get ("/", fun _ -> this.HomePage ()) - this.Get ("/{permalink*}", fun parms -> this.CatchAll (downcast parms)) - this.Get ("/posts/page/{page:int}", fun parms -> this.PublishedPostsPage (getPage <| downcast parms)) - this.Get ("/category/{slug}", fun parms -> this.CategorizedPosts (downcast parms)) - this.Get ("/category/{slug}/page/{page:int}", fun parms -> this.CategorizedPosts (downcast parms)) - this.Get ("/tag/{tag}", fun parms -> this.TaggedPosts (downcast parms)) - this.Get ("/tag/{tag}/page/{page:int}", fun parms -> this.TaggedPosts (downcast parms)) - this.Get ("/feed", fun _ -> this.Feed ()) - this.Get ("/posts/list", fun _ -> this.PostList 1) - this.Get ("/posts/list/page/{page:int}", fun parms -> this.PostList (getPage <| downcast parms)) - this.Get ("/post/{postId}/edit", fun parms -> this.EditPost (downcast parms)) - this.Post ("/post/{postId}/edit", fun parms -> this.SavePost (downcast parms)) + this.Get ("/", fun _ -> this.HomePage ()) + this.Get ("/{permalink*}", fun p -> this.CatchAll (downcast p)) + this.Get ("/posts/page/{page:int}", fun p -> this.PublishedPostsPage (getPage <| downcast p)) + this.Get ("/category/{slug}", fun p -> this.CategorizedPosts (downcast p)) + this.Get ("/category/{slug}/page/{page:int}", fun p -> this.CategorizedPosts (downcast p)) + this.Get ("/tag/{tag}", fun p -> this.TaggedPosts (downcast p)) + this.Get ("/tag/{tag}/page/{page:int}", fun p -> this.TaggedPosts (downcast p)) + this.Get ("/feed", fun _ -> this.Feed ()) + this.Get ("/posts/list", fun _ -> this.PostList 1) + this.Get ("/posts/list/page/{page:int}", fun p -> this.PostList (getPage <| downcast p)) + this.Get ("/post/{postId}/edit", fun p -> this.EditPost (downcast p)) + this.Post ("/post/{postId}/edit", fun p -> this.SavePost (downcast p)) // ---- Display posts to users ---- @@ -253,11 +253,10 @@ type PostModule(data : IMyWebLogData, clock : IClock) as this = | None -> Revision.Empty let model = EditPostModel (this.Context, this.WebLog, post, rev) model.Categories <- findAllCategories data this.WebLog.Id - |> List.map (fun cat -> string (fst cat).Id, - sprintf "%s%s" (String.replicate (snd cat) "     ") - (fst cat).Name) + |> List.map (fun cat -> + DisplayCategory.Create cat (post.CategoryIds |> List.contains (fst cat).Id)) model.PageTitle <- Strings.get <| match post.Id with "new" -> "AddNewPost" | _ -> "EditPost" - upcast this.View.["admin/post/edit"] + upcast this.View.["admin/post/edit", model] | _ -> this.NotFound () /// Save a post diff --git a/src/MyWebLog.App/ViewModels.fs b/src/MyWebLog.App/ViewModels.fs index 65c8252..675d9e4 100644 --- a/src/MyWebLog.App/ViewModels.fs +++ b/src/MyWebLog.App/ViewModels.fs @@ -9,7 +9,7 @@ open Newtonsoft.Json open NodaTime open NodaTime.Text open System - +open System.Net /// Levels for a user message [] @@ -90,7 +90,7 @@ module FormatDateTime = /// Parent view model for all myWebLog views -type MyWebLogModel (ctx : NancyContext, webLog : WebLog) = +type MyWebLogModel (ctx : NancyContext, webLog : WebLog) as this = /// Get the messages from the session let getMessages () = @@ -100,6 +100,20 @@ type MyWebLogModel (ctx : NancyContext, webLog : WebLog) = | _ -> ctx.Request.Session.Delete Keys.Messages msg + /// Generate a footer logo with the given scheme + let footerLogo scheme = + seq { + yield sprintf "\"myWebLog\"" + } + |> Seq.reduce (+) + /// The web log for this request member this.WebLog = webLog /// The subtitle for the webLog (SSVE can't do IsSome that deep) @@ -134,19 +148,11 @@ type MyWebLogModel (ctx : NancyContext, webLog : WebLog) = | None -> this.WebLog.Name | pt -> sprintf "%s | %s" pt this.WebLog.Name - /// An image with the version and load time in the tool tip - member this.FooterLogo = - seq { - yield "\"myWebLog\"" - } - |> Seq.reduce (+) + /// An image with the version and load time in the tool tip (using light text) + member this.FooterLogoLight = footerLogo "light" + + /// An image with the version and load time in the tool tip (using dark text) + member this.FooterLogoDark = footerLogo "dark" // ---- Admin models ---- @@ -399,6 +405,27 @@ type EditPostForm () = this.Text <- rev.Text this +/// Category information for display +type DisplayCategory = { + Id : string + Indent : string + Name : string + Description : string + IsChecked : bool + } +with + /// Create a display category + static member Create (cat : Category, indent) isChecked = + { Id = cat.Id + Indent = String.replicate indent "     " + Name = WebUtility.HtmlEncode cat.Name + IsChecked = isChecked + Description = WebUtility.HtmlEncode (match cat.Description with Some d -> d | _ -> cat.Name) + } + /// The "checked" attribute for this category + member this.CheckedAttr + with get() = match this.IsChecked with true -> "checked=\"checked\"" | _ -> "" + /// View model for the edit post page type EditPostModel (ctx, webLog, post, revision) = inherit MyWebLogModel (ctx, webLog) @@ -408,7 +435,7 @@ type EditPostModel (ctx, webLog, post, revision) = /// The post being edited member val Post = post with get, set /// The categories to which the post may be assigned - member val Categories : (string * string) list = [] with get, set + member val Categories : DisplayCategory list = [] with get, set /// Whether the post is currently published member this.IsPublished = PostStatus.Published = this.Post.Status /// The published date diff --git a/src/MyWebLog.Data.RethinkDB/Post.fs b/src/MyWebLog.Data.RethinkDB/Post.fs index da4f62a..9eb5eaa 100644 --- a/src/MyWebLog.Data.RethinkDB/Post.fs +++ b/src/MyWebLog.Data.RethinkDB/Post.fs @@ -100,9 +100,13 @@ let tryFindPost conn webLogId postId : Post option = let! p = r.Table(Table.Post) .Get(postId) - .Filter(ReqlFunction1 (fun p -> upcast p.["WebLogId"].Eq webLogId)) .RunAtomAsync conn - return match box p with null -> None | post -> Some <| unbox post + return + match box p with + | null -> None + | pst -> + let post : Post = unbox pst + match post.WebLogId = webLogId with true -> Some post | _ -> None } |> Async.RunSynchronously diff --git a/src/MyWebLog/content/logo-dark.png b/src/MyWebLog/content/logo-dark.png new file mode 100644 index 0000000..19bdcca Binary files /dev/null and b/src/MyWebLog/content/logo-dark.png differ diff --git a/src/MyWebLog/content/logo-light.png b/src/MyWebLog/content/logo-light.png new file mode 100644 index 0000000..c2d3357 Binary files /dev/null and b/src/MyWebLog/content/logo-light.png differ diff --git a/src/MyWebLog/project.json b/src/MyWebLog/project.json index 673b24b..6befde1 100644 --- a/src/MyWebLog/project.json +++ b/src/MyWebLog/project.json @@ -2,7 +2,7 @@ "buildOptions": { "emitEntryPoint": true, "copyToOutput": { - "include": "views" + "include": [ "views", "content" ] } }, "dependencies": { diff --git a/src/myWebLog/content/scripts/tinymce-init.js b/src/MyWebLog/views/admin/content/tinymce-init.js similarity index 100% rename from src/myWebLog/content/scripts/tinymce-init.js rename to src/MyWebLog/views/admin/content/tinymce-init.js diff --git a/src/myWebLog/content/styles/admin.css b/src/myWebLog/content/styles/admin.css deleted file mode 100644 index f6da49a..0000000 --- a/src/myWebLog/content/styles/admin.css +++ /dev/null @@ -1,5 +0,0 @@ -footer { - background-color: #808080; - border-top: solid 1px black; - color: white; -} \ No newline at end of file diff --git a/src/myWebLog/views/admin/admin-layout.html b/src/myWebLog/views/admin/admin-layout.html index 439dbcb..8b01c68 100644 --- a/src/myWebLog/views/admin/admin-layout.html +++ b/src/myWebLog/views/admin/admin-layout.html @@ -40,7 +40,7 @@
-
@Model.Generator
+
@Model.FooterLogoLight  
diff --git a/src/myWebLog/views/admin/content/logo.png b/src/myWebLog/views/admin/content/logo.png deleted file mode 100644 index bb6013e..0000000 Binary files a/src/myWebLog/views/admin/content/logo.png and /dev/null differ diff --git a/src/myWebLog/views/admin/dashboard.html b/src/myWebLog/views/admin/dashboard.html index 3781a5d..c4e75a5 100644 --- a/src/myWebLog/views/admin/dashboard.html +++ b/src/myWebLog/views/admin/dashboard.html @@ -2,7 +2,7 @@ @Section['Content']
-
+

@Translate.Posts  @Model.Posts

@Translate.ListAll @@ -10,7 +10,7 @@ @Translate.AddNew

-
+

@Translate.Pages  @Model.Pages

@Translate.ListAll @@ -18,9 +18,7 @@ @Translate.AddNew

-
-
-
+

@Translate.Categories  @Model.Categories

@Translate.ListAll @@ -29,4 +27,5 @@

+
@EndSection diff --git a/src/myWebLog/views/admin/page/edit.html b/src/myWebLog/views/admin/page/edit.html index a87fe3c..081fbd3 100644 --- a/src/myWebLog/views/admin/page/edit.html +++ b/src/myWebLog/views/admin/page/edit.html @@ -12,7 +12,7 @@
-

@Translate.startingWith http://@Model.webLog.urlBase/

+

@Translate.startingWith http://@Model.WebLog.UrlBase/

@@ -48,7 +48,7 @@ @EndSection @Section['Scripts'] - + +