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 Browser.Navigation as Nav
import Http import Http
import Mi import Mi
import Mi.POSSE
import Mi.Switch exposing (Switch) import Mi.Switch exposing (Switch)
import Mi.WebMention exposing (WebMention) import Mi.WebMention exposing (WebMention)
import Route exposing (Route, routeParser) import Route exposing (Route, routeParser)
@ -24,6 +25,7 @@ type alias Model =
, webMentions : List WebMention , webMentions : List WebMention
, switchByID : Maybe Switch , switchByID : Maybe Switch
, webMentionByID : Maybe WebMention , webMentionByID : Maybe WebMention
, post : Mi.POSSE.Post
} }
@ -66,6 +68,7 @@ init _ url key =
, webMentions = [] , webMentions = []
, switchByID = Nothing , switchByID = Nothing
, webMentionByID = Nothing , webMentionByID = Nothing
, post = Mi.POSSE.init
} }
, Nav.pushUrl key "/login" , 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 Html.Attributes exposing (height, src, width)
import Iso8601 import Iso8601
import Layout exposing (basic, template) 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 } = view { tokenData, front } =
case tokenData of case tokenData of
Nothing -> Nothing ->

View File

@ -5,10 +5,14 @@ import Html exposing (button, input, p, text)
import Html.Attributes exposing (placeholder, value) import Html.Attributes exposing (placeholder, value)
import Html.Events exposing (onClick, onInput) import Html.Events exposing (onClick, onInput)
import Layout exposing (basic, template) 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 = view model =
basic "Login" basic "Login"
[ p [] [ text "Enter the secret code. Unauthorized access is prohibited." ] [ p [] [ text "Enter the secret code. Unauthorized access is prohibited." ]

View File

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

View File

@ -6,12 +6,21 @@ import Html.Attributes exposing (height, href, src, style, width)
import Html.Events exposing (onClick) import Html.Events exposing (onClick)
import Iso8601 import Iso8601
import Layout exposing (template) import Layout exposing (template)
import Model exposing (Model, Msg(..)) import Mi.Switch exposing (Switch)
import Model exposing (Msg(..))
import Page exposing (format) import Page exposing (format)
import Time exposing (Month(..), utc) 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 } = view { front, switches, switchPage } =
let let
frontInfo = frontInfo =