start on posse support

This commit is contained in:
Cadey Ratio 2020-11-16 16:00:55 -05:00
parent 6d9aa3b064
commit 80076a2b8f
6 changed files with 79 additions and 13 deletions

40
sina/src/Mi/POSSE.elm Normal file
View File

@ -0,0 +1,40 @@
module Mi.POSSE exposing (Post, decoder, encoder, init)
import Json.Decode as D
import Json.Encode as E
init : Post
init =
{ title = ""
, body = ""
, url = ""
, tags = []
}
type alias Post =
{ title : String
, body : String
, url : String
, tags : List String
}
encoder : Post -> E.Value
encoder post =
E.object
[ ( "title", E.string post.title )
, ( "body", E.string post.body )
, ( "url", E.string post.url )
, ( "tags", E.list E.string post.tags )
]
decoder : D.Decoder Post
decoder =
D.map4 Post
(D.field "title" D.string)
(D.field "body" D.string)
(D.field "url" D.string)
(D.field "tags" (D.list D.string))

View File

@ -4,6 +4,7 @@ import Browser exposing (UrlRequest(..))
import Browser.Navigation as Nav
import Http
import Mi
import Mi.POSSE
import Mi.Switch exposing (Switch)
import Mi.WebMention exposing (WebMention)
import Route exposing (Route, routeParser)
@ -24,6 +25,7 @@ type alias Model =
, webMentions : List WebMention
, switchByID : Maybe Switch
, webMentionByID : Maybe WebMention
, post : Mi.POSSE.Post
}
@ -66,6 +68,7 @@ init _ url key =
, webMentions = []
, switchByID = Nothing
, webMentionByID = Nothing
, post = Mi.POSSE.init
}
, Nav.pushUrl key "/login"
)

View File

@ -5,10 +5,18 @@ import Html exposing (br, h2, img, p, s, span, text)
import Html.Attributes exposing (height, src, width)
import Iso8601
import Layout exposing (basic, template)
import Model exposing (Model)
import Mi
import Mi.Switch exposing (Switch)
view : Model -> Document msg
type alias Model a =
{ a
| tokenData : Maybe Mi.TokenData
, front : Maybe Switch
}
view : Model a -> Document msg
view { tokenData, front } =
case tokenData of
Nothing ->

View File

@ -5,10 +5,14 @@ import Html exposing (button, input, p, text)
import Html.Attributes exposing (placeholder, value)
import Html.Events exposing (onClick, onInput)
import Layout exposing (basic, template)
import Model exposing (Model, Msg(..))
import Model exposing (Msg(..))
view : Model -> Document Msg
type alias Model a =
{ a | token : Maybe String }
view : Model a -> Document Msg
view model =
basic "Login"
[ p [] [ text "Enter the secret code. Unauthorized access is prohibited." ]

View File

@ -1,17 +1,19 @@
module Page.SwitchInfo exposing (view)
import Browser exposing (Document)
import Browser.Navigation as Nav
import Html exposing (a, br, button, h2, img, p, span, table, td, text, th, tr)
import Html.Attributes exposing (href, src, style)
import Html.Events exposing (onClick)
import Html exposing (br, img, p, span, text)
import Html.Attributes exposing (src)
import Layout exposing (template)
import Model exposing (Model, Msg(..))
import Mi.Switch exposing (Switch)
import Page exposing (format)
import Time exposing (Month(..), utc)
import Time exposing (Month(..))
view : Model -> Document Msg
type alias Model a =
{ a | switchByID : Maybe Switch }
view : Model a -> Document msg
view { switchByID } =
case switchByID of
Nothing ->

View File

@ -6,12 +6,21 @@ import Html.Attributes exposing (height, href, src, style, width)
import Html.Events exposing (onClick)
import Iso8601
import Layout exposing (template)
import Model exposing (Model, Msg(..))
import Mi.Switch exposing (Switch)
import Model exposing (Msg(..))
import Page exposing (format)
import Time exposing (Month(..), utc)
view : Model -> Document Msg
type alias Model a =
{ a
| front : Maybe Switch
, switches : List Switch
, switchPage : Int
}
view : Model a -> Document Msg
view { front, switches, switchPage } =
let
frontInfo =