WIP: conversion to Fluid (#47)
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
/// View rendering context for myWebLog
|
||||
[<AutoOpen>]
|
||||
module MyWebLog.ViewContext
|
||||
|
||||
open Microsoft.AspNetCore.Antiforgery
|
||||
open MyWebLog.ViewModels
|
||||
|
||||
/// The rendering context for this application
|
||||
[<NoComparison; NoEquality>]
|
||||
type AppViewContext = {
|
||||
/// The web log for this request
|
||||
WebLog: WebLog
|
||||
|
||||
/// The ID of the current user
|
||||
UserId: WebLogUserId option
|
||||
|
||||
/// The title of the page being rendered
|
||||
PageTitle: string
|
||||
|
||||
/// The subtitle for the page
|
||||
Subtitle: string option
|
||||
|
||||
/// The anti-Cross Site Request Forgery (CSRF) token set to use when rendering a form
|
||||
Csrf: AntiforgeryTokenSet option
|
||||
|
||||
/// The page list for the web log
|
||||
PageList: DisplayPage array
|
||||
|
||||
/// Categories and post counts for the web log
|
||||
Categories: DisplayCategory array
|
||||
|
||||
/// Tag mappings
|
||||
TagMappings: TagMap array
|
||||
|
||||
/// The URL of the page being rendered
|
||||
CurrentPage: string
|
||||
|
||||
/// User messages
|
||||
Messages: UserMessage array
|
||||
|
||||
/// The generator string for the rendered page
|
||||
Generator: string
|
||||
|
||||
/// The payload for this page (see other properties that wrap this one)
|
||||
Payload: obj
|
||||
|
||||
/// The content of a page (wrapped when rendering the layout)
|
||||
Content: string
|
||||
|
||||
/// A string to load the minified htmx script
|
||||
HtmxScript: string
|
||||
|
||||
/// Whether the current user is an author
|
||||
IsAuthor: bool
|
||||
|
||||
/// Whether the current user is an editor (implies author)
|
||||
IsEditor: bool
|
||||
|
||||
/// Whether the current user is a web log administrator (implies author and editor)
|
||||
IsWebLogAdmin: bool
|
||||
|
||||
/// Whether the current user is an installation administrator (implies all web log rights)
|
||||
IsAdministrator: bool
|
||||
|
||||
/// Whether the current page is the home page of the web log
|
||||
IsHome: bool
|
||||
|
||||
/// Whether the current page is a category archive page
|
||||
IsCategory: bool
|
||||
|
||||
/// Whether the current page is a category archive home page
|
||||
IsCategoryHome: bool
|
||||
|
||||
/// Whether the current page is a tag archive page
|
||||
IsTag: bool
|
||||
|
||||
/// Whether the current page is a tag archive home page
|
||||
IsTagHome: bool
|
||||
|
||||
/// Whether the current page is a single post
|
||||
IsPost: bool
|
||||
|
||||
/// Whether the current page is a static page
|
||||
IsPage: bool
|
||||
|
||||
/// The slug for a category or tag
|
||||
Slug: string option }
|
||||
with
|
||||
|
||||
/// Whether there is a user logged on
|
||||
member this.IsLoggedOn = Option.isSome this.UserId
|
||||
|
||||
member this.Page =
|
||||
this.Payload :?> DisplayPage
|
||||
|
||||
member this.Posts =
|
||||
this.Payload :?> PostDisplay
|
||||
|
||||
/// An empty view context
|
||||
static member Empty =
|
||||
{ WebLog = WebLog.Empty
|
||||
UserId = None
|
||||
PageTitle = ""
|
||||
Subtitle = None
|
||||
Csrf = None
|
||||
PageList = [||]
|
||||
Categories = [||]
|
||||
TagMappings = [||]
|
||||
CurrentPage = ""
|
||||
Messages = [||]
|
||||
Generator = ""
|
||||
Payload = obj ()
|
||||
Content = ""
|
||||
HtmxScript = ""
|
||||
IsAuthor = false
|
||||
IsEditor = false
|
||||
IsWebLogAdmin = false
|
||||
IsAdministrator = false
|
||||
IsHome = false
|
||||
IsCategory = false
|
||||
IsCategoryHome = false
|
||||
IsTag = false
|
||||
IsTagHome = false
|
||||
IsPost = false
|
||||
IsPage = false
|
||||
Slug = None }
|
||||
Reference in New Issue
Block a user