upsiflu / matsite

2 stars 0 forks source link

Implement Markdown Backend (Stage I) #34

Open upsiflu opened 1 year ago

upsiflu commented 1 year ago

Markdown package: https://mweiss.github.io/elm-rte-toolkit/#/examples/markdown An editor with customizable spec

Combined Parser/Printer package: https://elm.dmy.fr/packages/lue-bird/elm-morph Safely convert between narrower and broader types

To Do (Stage I)

type Model
    = Loading
        { maybeZone : Maybe ( String, Time.Zone )
        , maybeNow : Maybe Time.Posix
        , maybeAccordion : Maybe Accordion
        }
    | Model
        { accordion : Accordion
        , zone : ( String, Time.Zone )
        , now : Time.Posix
        }

type alias Accordion =                    --New!
    { history : List (IntentId, Action) }

type Action
    = Name String
    | Modify Article.Action
    | Go Direction
    | Insert Direction
    | Delete
    | Reset String
    | Undo IntentId

type alias Accordion.ViewMode                    --New!
    = Viewing
    | Editing { viewingHistory : Bool, viewingMarkdownSource : Bool, viewingTemplates : Bool }

type alias Article =
    { id : String
    , caption : { text : String, showsDate : Bool }
    , info : Maybe InfoChoice
    , body : BodyChoice
    , shape : Shape
    , fab : Maybe Fab
    , additionalClasses : List String
    , body : Markdown                             --New!
    , templateArticleId : String            --New! Will serve as initial data in case the article cannot be found
    , directives : List (String, String)      --New!
    }

App Lifecycle:

  1. Download accordion and find out the current time and timezone
  2. view:
    1. Navigate to the current place
    2. Draw the Accordion
    3. Segments that are in view:
      • Is Article cached?
        • Yes:
          1. If it has an articleTemplateId, and we are previewing templates, -> view the template article instead
          2. Draw the Segment with the corresponding Article
        • No: Draw a placeholder.
      • In any case, the Segment also draws a custom-element that listens to remote changes.
  3. update:
    • A new accordion version has arrived (locally ore remotely): replace the Accordion
    • A new article version has arrived (locally ore remotely): insert it into the Articles dict under its .id
  4. directory:
    • Find result within in the list of articles
      • If article is not loaded, it's just the self-string
      • If article is loaded, insert its own directives

Stages

Stage I

Stage II

Stage III

Stage IV