diff --git a/backend/templates/app.html b/backend/templates/app.html index 45b25f4..7ace735 100644 --- a/backend/templates/app.html +++ b/backend/templates/app.html @@ -17,6 +17,9 @@ node: document.getElementById("app") }); + diff --git a/sina/src/Layout.elm b/sina/src/Layout.elm new file mode 100644 index 0000000..4418832 --- /dev/null +++ b/sina/src/Layout.elm @@ -0,0 +1,29 @@ +module Layout exposing (template) + +import Browser exposing (Document) +import Html exposing (Html, a, div, h1, main_, nav, text) +import Html.Attributes exposing (class, href) + + +template : String -> List (Html msg) -> Document msg +template title body = + { title = title + , body = + [ main_ + [] + ([ nav + [ class "nav" ] + [ a [ href "/" ] [ text "Mi" ] + , text " - " + , a [ href "/posse" ] [ text "POSSE" ] + , text " - " + , a [ href "/switches" ] [ text "Switches" ] + , text " - " + , a [ href "/webmentions" ] [ text "WebMentions" ] + ] + , h1 [] [ text title ] + ] + ++ body + ) + ] + } diff --git a/sina/src/Main.elm b/sina/src/Main.elm index eb17c73..e7d7094 100644 --- a/sina/src/Main.elm +++ b/sina/src/Main.elm @@ -1,9 +1,10 @@ -module Main exposing (..) +module Main exposing (main) import Browser import Html exposing (Html, div, h1, img, p, pre, text) import Html.Attributes exposing (src) import Http +import Layout import Mi @@ -39,28 +40,26 @@ update msg model = ( Failure (Mi.errorToString why), Cmd.none ) -view : Model -> Html Msg +view : Model -> Browser.Document msg view model = case model of Failure why -> - div [] - [ h1 [] [ text "Error" ] - , p [] [ text why ] + Layout.template "Error" + [ p [] [ text why ] ] Loading -> - div [] [ h1 [] [ text "Loading" ] ] + Layout.template "Loading" [] Success msg -> - div [] - [ h1 [] [ text "Mi" ] - , pre [] [ text msg ] + Layout.template "Mi" + [ pre [] [ text msg ] ] main : Program () Model Msg main = - Browser.element + Browser.document { view = view , init = init , update = update