entities
listlengths 1
2.22k
| max_stars_repo_path
stringlengths 6
98
| max_stars_repo_name
stringlengths 9
55
| max_stars_count
int64 0
8.27k
| content
stringlengths 93
965k
| id
stringlengths 2
5
| new_content
stringlengths 85
964k
| modified
bool 1
class | references
stringlengths 98
970k
| language
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|
[
{
"context": " Expect.equal True (isPublicKey \"EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7gSrZcBpunuuTxiYkKqb6d\")\n , test \"start with EOS False\" <|\n ",
"end": 1110,
"score": 0.9997432232,
"start": 1057,
"tag": "KEY",
"value": "EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7gSrZcBpunuuTxiYkKqb6d"
},
{
"context": " Expect.equal False (isPublicKey \"eos5uxjV3FYZvwqyAM2StkFEvUvf43F7gSrZcBpunuuTxiYkKqb6d\")\n , test \"length 53 False\" <|\n ",
"end": 1287,
"score": 0.9997465611,
"start": 1234,
"tag": "KEY",
"value": "eos5uxjV3FYZvwqyAM2StkFEvUvf43F7gSrZcBpunuuTxiYkKqb6d"
},
{
"context": " \\() -> Expect.equal False (isPublicKey \"EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7OSrZcBpunuuTxiYkKqb6d\")\n ]\n , describe \"validateAccou",
"end": 1603,
"score": 0.9997442961,
"start": 1550,
"tag": "KEY",
"value": "EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7OSrZcBpunuuTxiYkKqb6d"
},
{
"context": " (validatePublicKey\n \"EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7gSrZcBpunuuTxiYkKqb6d\"\n )\n , test \"In",
"end": 4674,
"score": 0.9270279408,
"start": 4621,
"tag": "KEY",
"value": "EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7gSrZcBpunuuTxiYkKqb6d"
}
] | test/frontend/elm/Test/Util/Validation.elm | EOSYS-io/eoshub.io | 11 | module Test.Util.Validation exposing (tests)
import Expect
import Test exposing (..)
import Util.Validation exposing (..)
balance : Float
balance =
300.0
validateQuantityWithBalance : String -> QuantityStatus
validateQuantityWithBalance quantity =
validateQuantity quantity balance
tests : Test
tests =
describe "Validation module"
[ describe "isAccount"
[ test "a-z.1-5 True" <|
\() ->
Expect.equal True (isAccount "abc.xyz12345")
, test "a-z.1-5 False" <|
\() ->
Expect.equal False (isAccount "ABC!@#$67890")
, test "{1,12} True" <|
\() ->
Expect.equal True (isAccount "eosio.ram")
, test "{1,12} False" <|
\() ->
Expect.equal False (isAccount "eosio.ram.eosio.system")
]
, describe "isPublicKey"
[ test "start with EOS True" <|
\() ->
Expect.equal True (isPublicKey "EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7gSrZcBpunuuTxiYkKqb6d")
, test "start with EOS False" <|
\() ->
Expect.equal False (isPublicKey "eos5uxjV3FYZvwqyAM2StkFEvUvf43F7gSrZcBpunuuTxiYkKqb6d")
, test "length 53 False" <|
\() ->
Expect.equal False (isAccount "EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7")
, test "Contains invalid character - O" <|
\() -> Expect.equal False (isPublicKey "EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7OSrZcBpunuuTxiYkKqb6d")
]
, describe "validateAccount"
[ test "EmptyAccount" <|
\() -> Expect.equal EmptyAccount (validateAccount "" NotSent)
, test "AccountToBeVerified" <|
\() -> Expect.equal AccountToBeVerified (validateAccount "validacc" NotSent)
, test "ValidAccount" <|
\() -> Expect.equal ValidAccount (validateAccount "validacc" Succeed)
, test "InexistentAccount" <|
\() -> Expect.equal InexistentAccount (validateAccount "validacc" Fail)
, test "InvalidAccount" <|
\() -> Expect.equal InvalidAccount (validateAccount "INVALIDACC" NotSent)
]
, describe "validateQuantity"
[ test "EmptyQuantity" <|
\() ->
Expect.equal
EmptyQuantity
(validateQuantityWithBalance
""
)
, test "InvalidQuantity" <|
\() ->
Expect.equal
InvalidQuantity
(validateQuantityWithBalance
"-1.0"
)
, test "OverValidQuantity" <|
\() ->
Expect.equal
OverValidQuantity
(validateQuantityWithBalance
"301.0"
)
, test "ValidQuantity" <|
\() ->
Expect.equal
ValidQuantity
(validateQuantityWithBalance
"299.9999"
)
]
, describe "validateMemo"
[ test "EmptyMemo" <|
\() ->
Expect.equal
ValidMemo
(validateMemo
""
)
, test "ValidMemo" <|
\() ->
Expect.equal
ValidMemo
(validateMemo
"hi~"
)
, test "InvalidMemo" <|
\() ->
Expect.equal
MemoTooLong
(validateMemo "This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.")
]
, describe "validatePublicKey"
[ test "EmptyPubKey" <|
\() -> Expect.equal EmptyPublicKey (validatePublicKey "")
, test "ValidPubKey" <|
\() ->
Expect.equal ValidPublicKey
(validatePublicKey
"EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7gSrZcBpunuuTxiYkKqb6d"
)
, test "InvalidPubKey" <|
\() -> Expect.equal InvalidPublicKey (validatePublicKey "INVALID_KEY")
]
]
| 20459 | module Test.Util.Validation exposing (tests)
import Expect
import Test exposing (..)
import Util.Validation exposing (..)
balance : Float
balance =
300.0
validateQuantityWithBalance : String -> QuantityStatus
validateQuantityWithBalance quantity =
validateQuantity quantity balance
tests : Test
tests =
describe "Validation module"
[ describe "isAccount"
[ test "a-z.1-5 True" <|
\() ->
Expect.equal True (isAccount "abc.xyz12345")
, test "a-z.1-5 False" <|
\() ->
Expect.equal False (isAccount "ABC!@#$67890")
, test "{1,12} True" <|
\() ->
Expect.equal True (isAccount "eosio.ram")
, test "{1,12} False" <|
\() ->
Expect.equal False (isAccount "eosio.ram.eosio.system")
]
, describe "isPublicKey"
[ test "start with EOS True" <|
\() ->
Expect.equal True (isPublicKey "<KEY>")
, test "start with EOS False" <|
\() ->
Expect.equal False (isPublicKey "<KEY>")
, test "length 53 False" <|
\() ->
Expect.equal False (isAccount "EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7")
, test "Contains invalid character - O" <|
\() -> Expect.equal False (isPublicKey "<KEY>")
]
, describe "validateAccount"
[ test "EmptyAccount" <|
\() -> Expect.equal EmptyAccount (validateAccount "" NotSent)
, test "AccountToBeVerified" <|
\() -> Expect.equal AccountToBeVerified (validateAccount "validacc" NotSent)
, test "ValidAccount" <|
\() -> Expect.equal ValidAccount (validateAccount "validacc" Succeed)
, test "InexistentAccount" <|
\() -> Expect.equal InexistentAccount (validateAccount "validacc" Fail)
, test "InvalidAccount" <|
\() -> Expect.equal InvalidAccount (validateAccount "INVALIDACC" NotSent)
]
, describe "validateQuantity"
[ test "EmptyQuantity" <|
\() ->
Expect.equal
EmptyQuantity
(validateQuantityWithBalance
""
)
, test "InvalidQuantity" <|
\() ->
Expect.equal
InvalidQuantity
(validateQuantityWithBalance
"-1.0"
)
, test "OverValidQuantity" <|
\() ->
Expect.equal
OverValidQuantity
(validateQuantityWithBalance
"301.0"
)
, test "ValidQuantity" <|
\() ->
Expect.equal
ValidQuantity
(validateQuantityWithBalance
"299.9999"
)
]
, describe "validateMemo"
[ test "EmptyMemo" <|
\() ->
Expect.equal
ValidMemo
(validateMemo
""
)
, test "ValidMemo" <|
\() ->
Expect.equal
ValidMemo
(validateMemo
"hi~"
)
, test "InvalidMemo" <|
\() ->
Expect.equal
MemoTooLong
(validateMemo "This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.")
]
, describe "validatePublicKey"
[ test "EmptyPubKey" <|
\() -> Expect.equal EmptyPublicKey (validatePublicKey "")
, test "ValidPubKey" <|
\() ->
Expect.equal ValidPublicKey
(validatePublicKey
"<KEY>"
)
, test "InvalidPubKey" <|
\() -> Expect.equal InvalidPublicKey (validatePublicKey "INVALID_KEY")
]
]
| true | module Test.Util.Validation exposing (tests)
import Expect
import Test exposing (..)
import Util.Validation exposing (..)
balance : Float
balance =
300.0
validateQuantityWithBalance : String -> QuantityStatus
validateQuantityWithBalance quantity =
validateQuantity quantity balance
tests : Test
tests =
describe "Validation module"
[ describe "isAccount"
[ test "a-z.1-5 True" <|
\() ->
Expect.equal True (isAccount "abc.xyz12345")
, test "a-z.1-5 False" <|
\() ->
Expect.equal False (isAccount "ABC!@#$67890")
, test "{1,12} True" <|
\() ->
Expect.equal True (isAccount "eosio.ram")
, test "{1,12} False" <|
\() ->
Expect.equal False (isAccount "eosio.ram.eosio.system")
]
, describe "isPublicKey"
[ test "start with EOS True" <|
\() ->
Expect.equal True (isPublicKey "PI:KEY:<KEY>END_PI")
, test "start with EOS False" <|
\() ->
Expect.equal False (isPublicKey "PI:KEY:<KEY>END_PI")
, test "length 53 False" <|
\() ->
Expect.equal False (isAccount "EOS5uxjV3FYZvwqyAM2StkFEvUvf43F7")
, test "Contains invalid character - O" <|
\() -> Expect.equal False (isPublicKey "PI:KEY:<KEY>END_PI")
]
, describe "validateAccount"
[ test "EmptyAccount" <|
\() -> Expect.equal EmptyAccount (validateAccount "" NotSent)
, test "AccountToBeVerified" <|
\() -> Expect.equal AccountToBeVerified (validateAccount "validacc" NotSent)
, test "ValidAccount" <|
\() -> Expect.equal ValidAccount (validateAccount "validacc" Succeed)
, test "InexistentAccount" <|
\() -> Expect.equal InexistentAccount (validateAccount "validacc" Fail)
, test "InvalidAccount" <|
\() -> Expect.equal InvalidAccount (validateAccount "INVALIDACC" NotSent)
]
, describe "validateQuantity"
[ test "EmptyQuantity" <|
\() ->
Expect.equal
EmptyQuantity
(validateQuantityWithBalance
""
)
, test "InvalidQuantity" <|
\() ->
Expect.equal
InvalidQuantity
(validateQuantityWithBalance
"-1.0"
)
, test "OverValidQuantity" <|
\() ->
Expect.equal
OverValidQuantity
(validateQuantityWithBalance
"301.0"
)
, test "ValidQuantity" <|
\() ->
Expect.equal
ValidQuantity
(validateQuantityWithBalance
"299.9999"
)
]
, describe "validateMemo"
[ test "EmptyMemo" <|
\() ->
Expect.equal
ValidMemo
(validateMemo
""
)
, test "ValidMemo" <|
\() ->
Expect.equal
ValidMemo
(validateMemo
"hi~"
)
, test "InvalidMemo" <|
\() ->
Expect.equal
MemoTooLong
(validateMemo "This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.This memo is over 256 bytes.")
]
, describe "validatePublicKey"
[ test "EmptyPubKey" <|
\() -> Expect.equal EmptyPublicKey (validatePublicKey "")
, test "ValidPubKey" <|
\() ->
Expect.equal ValidPublicKey
(validatePublicKey
"PI:KEY:<KEY>END_PI"
)
, test "InvalidPubKey" <|
\() -> Expect.equal InvalidPublicKey (validatePublicKey "INVALID_KEY")
]
]
| elm |
[
{
"context": "stName : String\n}\nuser: User\nuser = {firstName = \"Kacper\", lastName = \"Moskala\"}\n\nfullname: User -> String",
"end": 604,
"score": 0.9998267293,
"start": 598,
"tag": "NAME",
"value": "Kacper"
},
{
"context": "r: User\nuser = {firstName = \"Kacper\", lastName = \"Moskala\"}\n\nfullname: User -> String\nfullname user = user.",
"end": 626,
"score": 0.9992901683,
"start": 619,
"tag": "NAME",
"value": "Moskala"
}
] | todo.elm | k-gan/elm-todo | 0 | import Html
import Html.Attributes
import Html.Events exposing (..)
import TodoList exposing (..)
import TodoListJson exposing (..)
import Bootstrap.CDN as CDN
import Bootstrap.Button as BootstrapButton
import Bootstrap.ListGroup as BootList
-- main = Html.beginnerProgram {model = model, view = view, update = update}
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}
init: (Model, Cmd Msg)
init = (model, Cmd.none)
type alias User = {
firstName : String
, lastName : String
}
user: User
user = {firstName = "Kacper", lastName = "Moskala"}
fullname: User -> String
fullname user = user.firstName ++ " " ++ user.lastName
type Msg =
ShowForm | SaveNote | NoteChanged String | SaveToFile | LoadFromFile | EncodedTodoListChanged String
| CloseTask Int
type Mode =
ShowAddNoteForm | ShowButton
type alias Model = {
user : User
, todos : List Todo
, mode : Mode
, newNote : Maybe String
, encodedTodos : Maybe String
}
model: Model
model = {
user = user
, todos = [
Todo 1 "write app" Pending
, Todo 2 "write app again" Done ]
, mode = ShowButton
, newNote = Nothing
, encodedTodos = Nothing }
sortTasksBasedOnStatus tasks =
List.map mapTaskStatusToInt tasks |> List.sortWith maxTuples |> List.map (\t -> Tuple.second t)
maxTuples t1 t2 =
compare (Tuple.first t1) (Tuple.first t2)
mapTaskStatusToInt task =
case task.status of
Pending -> (1, task)
Done -> (2, task)
view: Model -> Html.Html Msg
view model =
Html.div [Html.Attributes.style [("text-align", "center")]] [
CDN.stylesheet
, Html.h1 [] [Html.text (fullname model.user)]
, BootList.keyedUl (createKeyedTaskList (sortTasksBasedOnStatus model.todos) 1)
, handleForm model
, Html.br [] []
, Html.br [] []
, BootstrapButton.button [ BootstrapButton.success, BootstrapButton.onClick SaveToFile ] [Html.text "Save to file"]
, Html.br [] []
, Html.br [] []
, Html.div [ Html.Attributes.style [("display", "block" )] ] [
Html.textarea
[Html.Attributes.style [("width", "400px"), ("height", "150px")],
onInput EncodedTodoListChanged ]
[ Maybe.withDefault "" model.encodedTodos |> Html.text]
, Html.br [] []
, BootstrapButton.button [ BootstrapButton.primary, BootstrapButton.onClick LoadFromFile ] [Html.text "Load notes"]
]
]
update: Msg -> Model -> (Model, Cmd Msg)
update msg model
= case msg of
ShowForm -> ({model | mode = ShowAddNoteForm}, Cmd.none)
SaveNote -> (
{model | mode = ShowButton, newNote = Nothing, todos = insertNewTodo model.newNote model.todos}
, Cmd.none)
NoteChanged note -> ({model | newNote = Just note}, Cmd.none)
SaveToFile -> (
{ model | encodedTodos = encodeTodos model.todos |> encodeTodosToString |> Just }
, Cmd.none)
LoadFromFile -> (
{model | todos = Maybe.withDefault "" model.encodedTodos |> decodeTodosFromString }
, Cmd.none)
EncodedTodoListChanged encodedTodoList ->
({ model | encodedTodos = Maybe.Just encodedTodoList }, Cmd.none)
CloseTask id ->
({model | todos = (closeTaskInListWithId model.todos id)}, Cmd.none)
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
handleForm: Model -> Html.Html Msg
handleForm model =
case model.mode of
ShowButton -> Html.button [ onClick ShowForm ] [Html.text "New note" ]
ShowAddNoteForm -> Html.div [] [
Html.input [ onInput NoteChanged ] [ ]
, BootstrapButton.button [ BootstrapButton.primary, BootstrapButton.onClick SaveNote] [Html.text "Add"]
]
createKeyedTaskList: List (Todo) -> Int -> List (String, BootList.Item Msg)
createKeyedTaskList tasks startIdx =
case tasks of
[] -> []
(x::xs) -> (createKeyedLi startIdx x) :: (createKeyedTaskList xs (startIdx + 1))
createKeyedLi: Int -> Todo -> (String, BootList.Item Msg)
createKeyedLi id task =
(toString id, createTodoLi id task)
createTodoLi: Int -> Todo -> BootList.Item Msg
createTodoLi key todo =
BootList.li
[BootList.attrs [Html.Attributes.style [("text-decoration", getTextDecoration todo.status)]]]
(appendDoneButton todo.status todo.id <| [Html.text (toString key ++ ". " ++ todo.content)])
appendDoneButton: TaskStatus -> Int -> List (Html.Html Msg) -> List (Html.Html Msg)
appendDoneButton status id elements =
case status of
Pending -> elements ++
[(BootstrapButton.button
[BootstrapButton.danger, BootstrapButton.small, BootstrapButton.onClick <| CloseTask id ]
[Html.text "done"])]
_ -> elements
getTextDecoration: TaskStatus -> String
getTextDecoration taskStatus =
case taskStatus of
Done -> "line-through"
_ -> "none"
closeTaskInListWithId: List (Todo) -> Int -> List (Todo)
closeTaskInListWithId tasks id =
List.map (closeTaskWithId id) tasks
closeTaskWithId: Int -> Todo -> Todo
closeTaskWithId id task =
if task.id == id then {task | status = Done }
else task
| 41738 | import Html
import Html.Attributes
import Html.Events exposing (..)
import TodoList exposing (..)
import TodoListJson exposing (..)
import Bootstrap.CDN as CDN
import Bootstrap.Button as BootstrapButton
import Bootstrap.ListGroup as BootList
-- main = Html.beginnerProgram {model = model, view = view, update = update}
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}
init: (Model, Cmd Msg)
init = (model, Cmd.none)
type alias User = {
firstName : String
, lastName : String
}
user: User
user = {firstName = "<NAME>", lastName = "<NAME>"}
fullname: User -> String
fullname user = user.firstName ++ " " ++ user.lastName
type Msg =
ShowForm | SaveNote | NoteChanged String | SaveToFile | LoadFromFile | EncodedTodoListChanged String
| CloseTask Int
type Mode =
ShowAddNoteForm | ShowButton
type alias Model = {
user : User
, todos : List Todo
, mode : Mode
, newNote : Maybe String
, encodedTodos : Maybe String
}
model: Model
model = {
user = user
, todos = [
Todo 1 "write app" Pending
, Todo 2 "write app again" Done ]
, mode = ShowButton
, newNote = Nothing
, encodedTodos = Nothing }
sortTasksBasedOnStatus tasks =
List.map mapTaskStatusToInt tasks |> List.sortWith maxTuples |> List.map (\t -> Tuple.second t)
maxTuples t1 t2 =
compare (Tuple.first t1) (Tuple.first t2)
mapTaskStatusToInt task =
case task.status of
Pending -> (1, task)
Done -> (2, task)
view: Model -> Html.Html Msg
view model =
Html.div [Html.Attributes.style [("text-align", "center")]] [
CDN.stylesheet
, Html.h1 [] [Html.text (fullname model.user)]
, BootList.keyedUl (createKeyedTaskList (sortTasksBasedOnStatus model.todos) 1)
, handleForm model
, Html.br [] []
, Html.br [] []
, BootstrapButton.button [ BootstrapButton.success, BootstrapButton.onClick SaveToFile ] [Html.text "Save to file"]
, Html.br [] []
, Html.br [] []
, Html.div [ Html.Attributes.style [("display", "block" )] ] [
Html.textarea
[Html.Attributes.style [("width", "400px"), ("height", "150px")],
onInput EncodedTodoListChanged ]
[ Maybe.withDefault "" model.encodedTodos |> Html.text]
, Html.br [] []
, BootstrapButton.button [ BootstrapButton.primary, BootstrapButton.onClick LoadFromFile ] [Html.text "Load notes"]
]
]
update: Msg -> Model -> (Model, Cmd Msg)
update msg model
= case msg of
ShowForm -> ({model | mode = ShowAddNoteForm}, Cmd.none)
SaveNote -> (
{model | mode = ShowButton, newNote = Nothing, todos = insertNewTodo model.newNote model.todos}
, Cmd.none)
NoteChanged note -> ({model | newNote = Just note}, Cmd.none)
SaveToFile -> (
{ model | encodedTodos = encodeTodos model.todos |> encodeTodosToString |> Just }
, Cmd.none)
LoadFromFile -> (
{model | todos = Maybe.withDefault "" model.encodedTodos |> decodeTodosFromString }
, Cmd.none)
EncodedTodoListChanged encodedTodoList ->
({ model | encodedTodos = Maybe.Just encodedTodoList }, Cmd.none)
CloseTask id ->
({model | todos = (closeTaskInListWithId model.todos id)}, Cmd.none)
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
handleForm: Model -> Html.Html Msg
handleForm model =
case model.mode of
ShowButton -> Html.button [ onClick ShowForm ] [Html.text "New note" ]
ShowAddNoteForm -> Html.div [] [
Html.input [ onInput NoteChanged ] [ ]
, BootstrapButton.button [ BootstrapButton.primary, BootstrapButton.onClick SaveNote] [Html.text "Add"]
]
createKeyedTaskList: List (Todo) -> Int -> List (String, BootList.Item Msg)
createKeyedTaskList tasks startIdx =
case tasks of
[] -> []
(x::xs) -> (createKeyedLi startIdx x) :: (createKeyedTaskList xs (startIdx + 1))
createKeyedLi: Int -> Todo -> (String, BootList.Item Msg)
createKeyedLi id task =
(toString id, createTodoLi id task)
createTodoLi: Int -> Todo -> BootList.Item Msg
createTodoLi key todo =
BootList.li
[BootList.attrs [Html.Attributes.style [("text-decoration", getTextDecoration todo.status)]]]
(appendDoneButton todo.status todo.id <| [Html.text (toString key ++ ". " ++ todo.content)])
appendDoneButton: TaskStatus -> Int -> List (Html.Html Msg) -> List (Html.Html Msg)
appendDoneButton status id elements =
case status of
Pending -> elements ++
[(BootstrapButton.button
[BootstrapButton.danger, BootstrapButton.small, BootstrapButton.onClick <| CloseTask id ]
[Html.text "done"])]
_ -> elements
getTextDecoration: TaskStatus -> String
getTextDecoration taskStatus =
case taskStatus of
Done -> "line-through"
_ -> "none"
closeTaskInListWithId: List (Todo) -> Int -> List (Todo)
closeTaskInListWithId tasks id =
List.map (closeTaskWithId id) tasks
closeTaskWithId: Int -> Todo -> Todo
closeTaskWithId id task =
if task.id == id then {task | status = Done }
else task
| true | import Html
import Html.Attributes
import Html.Events exposing (..)
import TodoList exposing (..)
import TodoListJson exposing (..)
import Bootstrap.CDN as CDN
import Bootstrap.Button as BootstrapButton
import Bootstrap.ListGroup as BootList
-- main = Html.beginnerProgram {model = model, view = view, update = update}
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}
init: (Model, Cmd Msg)
init = (model, Cmd.none)
type alias User = {
firstName : String
, lastName : String
}
user: User
user = {firstName = "PI:NAME:<NAME>END_PI", lastName = "PI:NAME:<NAME>END_PI"}
fullname: User -> String
fullname user = user.firstName ++ " " ++ user.lastName
type Msg =
ShowForm | SaveNote | NoteChanged String | SaveToFile | LoadFromFile | EncodedTodoListChanged String
| CloseTask Int
type Mode =
ShowAddNoteForm | ShowButton
type alias Model = {
user : User
, todos : List Todo
, mode : Mode
, newNote : Maybe String
, encodedTodos : Maybe String
}
model: Model
model = {
user = user
, todos = [
Todo 1 "write app" Pending
, Todo 2 "write app again" Done ]
, mode = ShowButton
, newNote = Nothing
, encodedTodos = Nothing }
sortTasksBasedOnStatus tasks =
List.map mapTaskStatusToInt tasks |> List.sortWith maxTuples |> List.map (\t -> Tuple.second t)
maxTuples t1 t2 =
compare (Tuple.first t1) (Tuple.first t2)
mapTaskStatusToInt task =
case task.status of
Pending -> (1, task)
Done -> (2, task)
view: Model -> Html.Html Msg
view model =
Html.div [Html.Attributes.style [("text-align", "center")]] [
CDN.stylesheet
, Html.h1 [] [Html.text (fullname model.user)]
, BootList.keyedUl (createKeyedTaskList (sortTasksBasedOnStatus model.todos) 1)
, handleForm model
, Html.br [] []
, Html.br [] []
, BootstrapButton.button [ BootstrapButton.success, BootstrapButton.onClick SaveToFile ] [Html.text "Save to file"]
, Html.br [] []
, Html.br [] []
, Html.div [ Html.Attributes.style [("display", "block" )] ] [
Html.textarea
[Html.Attributes.style [("width", "400px"), ("height", "150px")],
onInput EncodedTodoListChanged ]
[ Maybe.withDefault "" model.encodedTodos |> Html.text]
, Html.br [] []
, BootstrapButton.button [ BootstrapButton.primary, BootstrapButton.onClick LoadFromFile ] [Html.text "Load notes"]
]
]
update: Msg -> Model -> (Model, Cmd Msg)
update msg model
= case msg of
ShowForm -> ({model | mode = ShowAddNoteForm}, Cmd.none)
SaveNote -> (
{model | mode = ShowButton, newNote = Nothing, todos = insertNewTodo model.newNote model.todos}
, Cmd.none)
NoteChanged note -> ({model | newNote = Just note}, Cmd.none)
SaveToFile -> (
{ model | encodedTodos = encodeTodos model.todos |> encodeTodosToString |> Just }
, Cmd.none)
LoadFromFile -> (
{model | todos = Maybe.withDefault "" model.encodedTodos |> decodeTodosFromString }
, Cmd.none)
EncodedTodoListChanged encodedTodoList ->
({ model | encodedTodos = Maybe.Just encodedTodoList }, Cmd.none)
CloseTask id ->
({model | todos = (closeTaskInListWithId model.todos id)}, Cmd.none)
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
handleForm: Model -> Html.Html Msg
handleForm model =
case model.mode of
ShowButton -> Html.button [ onClick ShowForm ] [Html.text "New note" ]
ShowAddNoteForm -> Html.div [] [
Html.input [ onInput NoteChanged ] [ ]
, BootstrapButton.button [ BootstrapButton.primary, BootstrapButton.onClick SaveNote] [Html.text "Add"]
]
createKeyedTaskList: List (Todo) -> Int -> List (String, BootList.Item Msg)
createKeyedTaskList tasks startIdx =
case tasks of
[] -> []
(x::xs) -> (createKeyedLi startIdx x) :: (createKeyedTaskList xs (startIdx + 1))
createKeyedLi: Int -> Todo -> (String, BootList.Item Msg)
createKeyedLi id task =
(toString id, createTodoLi id task)
createTodoLi: Int -> Todo -> BootList.Item Msg
createTodoLi key todo =
BootList.li
[BootList.attrs [Html.Attributes.style [("text-decoration", getTextDecoration todo.status)]]]
(appendDoneButton todo.status todo.id <| [Html.text (toString key ++ ". " ++ todo.content)])
appendDoneButton: TaskStatus -> Int -> List (Html.Html Msg) -> List (Html.Html Msg)
appendDoneButton status id elements =
case status of
Pending -> elements ++
[(BootstrapButton.button
[BootstrapButton.danger, BootstrapButton.small, BootstrapButton.onClick <| CloseTask id ]
[Html.text "done"])]
_ -> elements
getTextDecoration: TaskStatus -> String
getTextDecoration taskStatus =
case taskStatus of
Done -> "line-through"
_ -> "none"
closeTaskInListWithId: List (Todo) -> Int -> List (Todo)
closeTaskInListWithId tasks id =
List.map (closeTaskWithId id) tasks
closeTaskWithId: Int -> Todo -> Todo
closeTaskWithId id task =
if task.id == id then {task | status = Done }
else task
| elm |
[
{
"context": " [ div [] [ viewInput model Email \"Email\" \"text\" \"johndoe@example.com\" ]\r\n , div [] [ viewInput model Pa",
"end": 2064,
"score": 0.9999292493,
"start": 2045,
"tag": "EMAIL",
"value": "johndoe@example.com"
},
{
"context": "[ viewInput model Password \"Password\" \"password\" \"*******\" ]\r\n , div []\r\n ",
"end": 2144,
"score": 0.6345327497,
"start": 2144,
"tag": "PASSWORD",
"value": ""
}
] | frontend/src/Page/Login.elm | Pancakem/food-recommender | 0 | module Page.Login exposing (Model, Msg, init, subscriptions, toSession, update, view)
import Browser.Navigation as Navigation exposing (load)
import Helper exposing (Response, decodeResponse, endPoint, informHttpError)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
import Http
import Json.Encode as Encode
import Route exposing (Route)
import Session exposing (Session)
import Url.Builder as Builder
import User exposing (Profile)
init : Session -> ( Model, Cmd Msg )
init session =
let
cmd =
case Session.cred session of
Just cred ->
Route.replaceUrl (Session.navKey session) Route.Home
Nothing ->
Cmd.none
in
( { session = session
, problems = []
, form =
{ email = ""
, password = ""
}
}
, cmd
)
type alias Model =
{ session : Session
, form : Form
, problems : List Problem
}
type Problem
= InvalidEntry ValidatedField String
| ServerError String
-- VIEW
view : Model -> { title : String, content : Html Msg }
view model =
{ title = "Eat Right - Login"
, content = loginView model
}
type alias Form =
{ email : String
, password : String
}
loginView : Model -> Html Msg
loginView model =
div [ class "container" ]
[ div [ class "card .login-card" ]
[ div [ class "card-body" ]
[ p [ class "validation-problem" ]
(List.map (\str -> viewServerError str) model.problems)
, loginForm model
]
]
]
loginForm : Model -> Html Msg
loginForm model =
div [ class "login-form" ]
[ h3 [ class "card-title" ] [ text "Login" ]
, div []
[ div [ class "form-group" ]
[ div [] [ viewInput model Email "Email" "text" "johndoe@example.com" ]
, div [] [ viewInput model Password "Password" "password" "*******" ]
, div []
[ button [ class "btn btn-primary", onClick SubmittedDetails ] [ text "LOGIN" ] ]
]
]
]
viewServerError : Problem -> Html Msg
viewServerError problem =
case problem of
ServerError str ->
text str
_ ->
text ""
viewProblem : Model -> ValidatedField -> Problem -> Html msg
viewProblem model formfield problem =
let
errorMsg =
case problem of
InvalidEntry f str ->
if f == formfield then
str
else
""
ServerError _ ->
""
in
if String.length errorMsg > 1 then
p [ class "validation-problem" ] [ text errorMsg ]
else
text ""
setErrors : List Problem -> Model -> Model
setErrors problems model =
{ model | problems = problems }
setField : ValidatedField -> String -> Model -> Model
setField field value model =
case field of
Email ->
updateForm (\form -> { form | email = value }) model
Password ->
updateForm (\form -> { form | password = value }) model
viewInput : Model -> ValidatedField -> String -> String -> String -> Html Msg
viewInput model formField labelName inputType inputName =
let
what =
case formField of
Email ->
model.form.email
Password ->
model.form.password
lis =
List.map (\err -> viewProblem model formField err) model.problems
in
label
[ class "" ]
[ text labelName
, input
[ type_ inputType
, placeholder inputName
, onInput <| SetField formField
, value what
, class "form-control"
]
[]
, ul [] lis
]
type Msg
= SubmittedDetails
| SetField ValidatedField String
| GotResponse (Result Http.Error Response)
| GotSession Session
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
let
problemList =
validate model.form
in
case msg of
SubmittedDetails ->
case problemList of
[] ->
-- send data to the server
-- receive server response
-- trigger command to handle or consume response
( { model | problems = [] }
, login model
)
problems ->
( { model | problems = problems }
, Cmd.none
)
SetField field value ->
( model
|> setField field value
|> setErrors problemList
, Cmd.none
)
GotResponse resp ->
case resp of
Ok successData ->
( model
, Cmd.batch [ Session.login successData, Route.loadPage Route.Home ]
)
Err err ->
let
errorMsg =
informHttpError err
in
( { model | problems = [ ServerError errorMsg ] }
, Cmd.none
)
GotSession session ->
( { model | session = session }
, Navigation.load "/home"
)
-- tiny helper function to update the form in the session
updateForm : (Form -> Form) -> Model -> Model
updateForm transform model =
{ model | form = transform model.form }
-- Subscriptions
subscriptions : Model -> Sub Msg
subscriptions model =
Session.changes GotSession (Session.navKey model.session)
-- Handle the Form
type ValidatedField
= Email
| Password
-- To ensure we only trim the form when the user is done
type TrimmedForm
= Trimmed Form
fieldsToValidate : List ValidatedField
fieldsToValidate =
[ Email
, Password
]
-- trim and validate form
validate : Form -> List Problem
validate form =
let
trimmedForm =
trimFields form
in
case List.concatMap (validateField trimmedForm) fieldsToValidate of
[] ->
[]
problems ->
problems
-- validateField
validateField : TrimmedForm -> ValidatedField -> List Problem
validateField (Trimmed form) field =
List.map (InvalidEntry field) <|
case field of
Email ->
if String.isEmpty form.email then
[ "email can't be blank." ]
else
[]
Password ->
if String.isEmpty form.password then
[ "password can't be blank." ]
else if String.length form.password < 8 then
[ "password should be at least 8 characters long." ]
else
[]
-- trimFields on demand
trimFields : Form -> TrimmedForm
trimFields form =
Trimmed
{ email = String.trim form.email
, password = String.trim form.password
}
-- Exported Session Builder
toSession : Model -> Session
toSession model =
model.session
-- http
login : Model -> Cmd Msg
login model =
Http.request
{ url = endPoint [ "auth", "login" ]
, headers = [ Http.header "Origin" "http://localhost:5000" ]
, body = Http.jsonBody (encodeLogin model)
, expect = Http.expectJson GotResponse decodeResponse
, method = "POST"
, timeout = Nothing
, tracker = Nothing
}
encodeLogin : Model -> Encode.Value
encodeLogin { form } =
Encode.object
[ ( "email", Encode.string form.email )
, ( "password", Encode.string form.password )
]
| 29799 | module Page.Login exposing (Model, Msg, init, subscriptions, toSession, update, view)
import Browser.Navigation as Navigation exposing (load)
import Helper exposing (Response, decodeResponse, endPoint, informHttpError)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
import Http
import Json.Encode as Encode
import Route exposing (Route)
import Session exposing (Session)
import Url.Builder as Builder
import User exposing (Profile)
init : Session -> ( Model, Cmd Msg )
init session =
let
cmd =
case Session.cred session of
Just cred ->
Route.replaceUrl (Session.navKey session) Route.Home
Nothing ->
Cmd.none
in
( { session = session
, problems = []
, form =
{ email = ""
, password = ""
}
}
, cmd
)
type alias Model =
{ session : Session
, form : Form
, problems : List Problem
}
type Problem
= InvalidEntry ValidatedField String
| ServerError String
-- VIEW
view : Model -> { title : String, content : Html Msg }
view model =
{ title = "Eat Right - Login"
, content = loginView model
}
type alias Form =
{ email : String
, password : String
}
loginView : Model -> Html Msg
loginView model =
div [ class "container" ]
[ div [ class "card .login-card" ]
[ div [ class "card-body" ]
[ p [ class "validation-problem" ]
(List.map (\str -> viewServerError str) model.problems)
, loginForm model
]
]
]
loginForm : Model -> Html Msg
loginForm model =
div [ class "login-form" ]
[ h3 [ class "card-title" ] [ text "Login" ]
, div []
[ div [ class "form-group" ]
[ div [] [ viewInput model Email "Email" "text" "<EMAIL>" ]
, div [] [ viewInput model Password "Password" "password" "<PASSWORD>*******" ]
, div []
[ button [ class "btn btn-primary", onClick SubmittedDetails ] [ text "LOGIN" ] ]
]
]
]
viewServerError : Problem -> Html Msg
viewServerError problem =
case problem of
ServerError str ->
text str
_ ->
text ""
viewProblem : Model -> ValidatedField -> Problem -> Html msg
viewProblem model formfield problem =
let
errorMsg =
case problem of
InvalidEntry f str ->
if f == formfield then
str
else
""
ServerError _ ->
""
in
if String.length errorMsg > 1 then
p [ class "validation-problem" ] [ text errorMsg ]
else
text ""
setErrors : List Problem -> Model -> Model
setErrors problems model =
{ model | problems = problems }
setField : ValidatedField -> String -> Model -> Model
setField field value model =
case field of
Email ->
updateForm (\form -> { form | email = value }) model
Password ->
updateForm (\form -> { form | password = value }) model
viewInput : Model -> ValidatedField -> String -> String -> String -> Html Msg
viewInput model formField labelName inputType inputName =
let
what =
case formField of
Email ->
model.form.email
Password ->
model.form.password
lis =
List.map (\err -> viewProblem model formField err) model.problems
in
label
[ class "" ]
[ text labelName
, input
[ type_ inputType
, placeholder inputName
, onInput <| SetField formField
, value what
, class "form-control"
]
[]
, ul [] lis
]
type Msg
= SubmittedDetails
| SetField ValidatedField String
| GotResponse (Result Http.Error Response)
| GotSession Session
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
let
problemList =
validate model.form
in
case msg of
SubmittedDetails ->
case problemList of
[] ->
-- send data to the server
-- receive server response
-- trigger command to handle or consume response
( { model | problems = [] }
, login model
)
problems ->
( { model | problems = problems }
, Cmd.none
)
SetField field value ->
( model
|> setField field value
|> setErrors problemList
, Cmd.none
)
GotResponse resp ->
case resp of
Ok successData ->
( model
, Cmd.batch [ Session.login successData, Route.loadPage Route.Home ]
)
Err err ->
let
errorMsg =
informHttpError err
in
( { model | problems = [ ServerError errorMsg ] }
, Cmd.none
)
GotSession session ->
( { model | session = session }
, Navigation.load "/home"
)
-- tiny helper function to update the form in the session
updateForm : (Form -> Form) -> Model -> Model
updateForm transform model =
{ model | form = transform model.form }
-- Subscriptions
subscriptions : Model -> Sub Msg
subscriptions model =
Session.changes GotSession (Session.navKey model.session)
-- Handle the Form
type ValidatedField
= Email
| Password
-- To ensure we only trim the form when the user is done
type TrimmedForm
= Trimmed Form
fieldsToValidate : List ValidatedField
fieldsToValidate =
[ Email
, Password
]
-- trim and validate form
validate : Form -> List Problem
validate form =
let
trimmedForm =
trimFields form
in
case List.concatMap (validateField trimmedForm) fieldsToValidate of
[] ->
[]
problems ->
problems
-- validateField
validateField : TrimmedForm -> ValidatedField -> List Problem
validateField (Trimmed form) field =
List.map (InvalidEntry field) <|
case field of
Email ->
if String.isEmpty form.email then
[ "email can't be blank." ]
else
[]
Password ->
if String.isEmpty form.password then
[ "password can't be blank." ]
else if String.length form.password < 8 then
[ "password should be at least 8 characters long." ]
else
[]
-- trimFields on demand
trimFields : Form -> TrimmedForm
trimFields form =
Trimmed
{ email = String.trim form.email
, password = String.trim form.password
}
-- Exported Session Builder
toSession : Model -> Session
toSession model =
model.session
-- http
login : Model -> Cmd Msg
login model =
Http.request
{ url = endPoint [ "auth", "login" ]
, headers = [ Http.header "Origin" "http://localhost:5000" ]
, body = Http.jsonBody (encodeLogin model)
, expect = Http.expectJson GotResponse decodeResponse
, method = "POST"
, timeout = Nothing
, tracker = Nothing
}
encodeLogin : Model -> Encode.Value
encodeLogin { form } =
Encode.object
[ ( "email", Encode.string form.email )
, ( "password", Encode.string form.password )
]
| true | module Page.Login exposing (Model, Msg, init, subscriptions, toSession, update, view)
import Browser.Navigation as Navigation exposing (load)
import Helper exposing (Response, decodeResponse, endPoint, informHttpError)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)
import Http
import Json.Encode as Encode
import Route exposing (Route)
import Session exposing (Session)
import Url.Builder as Builder
import User exposing (Profile)
init : Session -> ( Model, Cmd Msg )
init session =
let
cmd =
case Session.cred session of
Just cred ->
Route.replaceUrl (Session.navKey session) Route.Home
Nothing ->
Cmd.none
in
( { session = session
, problems = []
, form =
{ email = ""
, password = ""
}
}
, cmd
)
type alias Model =
{ session : Session
, form : Form
, problems : List Problem
}
type Problem
= InvalidEntry ValidatedField String
| ServerError String
-- VIEW
view : Model -> { title : String, content : Html Msg }
view model =
{ title = "Eat Right - Login"
, content = loginView model
}
type alias Form =
{ email : String
, password : String
}
loginView : Model -> Html Msg
loginView model =
div [ class "container" ]
[ div [ class "card .login-card" ]
[ div [ class "card-body" ]
[ p [ class "validation-problem" ]
(List.map (\str -> viewServerError str) model.problems)
, loginForm model
]
]
]
loginForm : Model -> Html Msg
loginForm model =
div [ class "login-form" ]
[ h3 [ class "card-title" ] [ text "Login" ]
, div []
[ div [ class "form-group" ]
[ div [] [ viewInput model Email "Email" "text" "PI:EMAIL:<EMAIL>END_PI" ]
, div [] [ viewInput model Password "Password" "password" "PI:PASSWORD:<PASSWORD>END_PI*******" ]
, div []
[ button [ class "btn btn-primary", onClick SubmittedDetails ] [ text "LOGIN" ] ]
]
]
]
viewServerError : Problem -> Html Msg
viewServerError problem =
case problem of
ServerError str ->
text str
_ ->
text ""
viewProblem : Model -> ValidatedField -> Problem -> Html msg
viewProblem model formfield problem =
let
errorMsg =
case problem of
InvalidEntry f str ->
if f == formfield then
str
else
""
ServerError _ ->
""
in
if String.length errorMsg > 1 then
p [ class "validation-problem" ] [ text errorMsg ]
else
text ""
setErrors : List Problem -> Model -> Model
setErrors problems model =
{ model | problems = problems }
setField : ValidatedField -> String -> Model -> Model
setField field value model =
case field of
Email ->
updateForm (\form -> { form | email = value }) model
Password ->
updateForm (\form -> { form | password = value }) model
viewInput : Model -> ValidatedField -> String -> String -> String -> Html Msg
viewInput model formField labelName inputType inputName =
let
what =
case formField of
Email ->
model.form.email
Password ->
model.form.password
lis =
List.map (\err -> viewProblem model formField err) model.problems
in
label
[ class "" ]
[ text labelName
, input
[ type_ inputType
, placeholder inputName
, onInput <| SetField formField
, value what
, class "form-control"
]
[]
, ul [] lis
]
type Msg
= SubmittedDetails
| SetField ValidatedField String
| GotResponse (Result Http.Error Response)
| GotSession Session
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
let
problemList =
validate model.form
in
case msg of
SubmittedDetails ->
case problemList of
[] ->
-- send data to the server
-- receive server response
-- trigger command to handle or consume response
( { model | problems = [] }
, login model
)
problems ->
( { model | problems = problems }
, Cmd.none
)
SetField field value ->
( model
|> setField field value
|> setErrors problemList
, Cmd.none
)
GotResponse resp ->
case resp of
Ok successData ->
( model
, Cmd.batch [ Session.login successData, Route.loadPage Route.Home ]
)
Err err ->
let
errorMsg =
informHttpError err
in
( { model | problems = [ ServerError errorMsg ] }
, Cmd.none
)
GotSession session ->
( { model | session = session }
, Navigation.load "/home"
)
-- tiny helper function to update the form in the session
updateForm : (Form -> Form) -> Model -> Model
updateForm transform model =
{ model | form = transform model.form }
-- Subscriptions
subscriptions : Model -> Sub Msg
subscriptions model =
Session.changes GotSession (Session.navKey model.session)
-- Handle the Form
type ValidatedField
= Email
| Password
-- To ensure we only trim the form when the user is done
type TrimmedForm
= Trimmed Form
fieldsToValidate : List ValidatedField
fieldsToValidate =
[ Email
, Password
]
-- trim and validate form
validate : Form -> List Problem
validate form =
let
trimmedForm =
trimFields form
in
case List.concatMap (validateField trimmedForm) fieldsToValidate of
[] ->
[]
problems ->
problems
-- validateField
validateField : TrimmedForm -> ValidatedField -> List Problem
validateField (Trimmed form) field =
List.map (InvalidEntry field) <|
case field of
Email ->
if String.isEmpty form.email then
[ "email can't be blank." ]
else
[]
Password ->
if String.isEmpty form.password then
[ "password can't be blank." ]
else if String.length form.password < 8 then
[ "password should be at least 8 characters long." ]
else
[]
-- trimFields on demand
trimFields : Form -> TrimmedForm
trimFields form =
Trimmed
{ email = String.trim form.email
, password = String.trim form.password
}
-- Exported Session Builder
toSession : Model -> Session
toSession model =
model.session
-- http
login : Model -> Cmd Msg
login model =
Http.request
{ url = endPoint [ "auth", "login" ]
, headers = [ Http.header "Origin" "http://localhost:5000" ]
, body = Http.jsonBody (encodeLogin model)
, expect = Http.expectJson GotResponse decodeResponse
, method = "POST"
, timeout = Nothing
, tracker = Nothing
}
encodeLogin : Model -> Encode.Value
encodeLogin { form } =
Encode.object
[ ( "email", Encode.string form.email )
, ( "password", Encode.string form.password )
]
| elm |
[
{
"context": "me/6/22103l.jpg)\n\nI finished Cross Game yesterday. Sam had suggested it to me. I'm surprised how heavily",
"end": 496,
"score": 0.5829942226,
"start": 493,
"tag": "NAME",
"value": "Sam"
},
{
"context": "g a close friend in real life I can talk to anime. David and Samarth have gotten into it too, it's awesome",
"end": 656,
"score": 0.9982308149,
"start": 651,
"tag": "NAME",
"value": "David"
},
{
"context": "friend in real life I can talk to anime. David and Samarth have gotten into it too, it's awesome.\nBeing a sp",
"end": 668,
"score": 0.9978985786,
"start": 661,
"tag": "NAME",
"value": "Samarth"
},
{
"context": "ey introduced us to two very important characters: Kou, the protragonist, and his childhood friend, Waka",
"end": 1052,
"score": 0.804191649,
"start": 1049,
"tag": "NAME",
"value": "Kou"
},
{
"context": ": Kou, the protragonist, and his childhood friend, Wakaba. Despite having only 20min to work with, Wakaba's",
"end": 1104,
"score": 0.7841370702,
"start": 1098,
"tag": "NAME",
"value": "Wakaba"
},
{
"context": "rk with, Wakaba's character captivated all of us (David, Samarth, Sam and I). She was very likable to beg",
"end": 1192,
"score": 0.9989308715,
"start": 1187,
"tag": "NAME",
"value": "David"
},
{
"context": "h, Wakaba's character captivated all of us (David, Samarth, Sam and I). She was very likable to begin with, ",
"end": 1201,
"score": 0.9958310127,
"start": 1194,
"tag": "NAME",
"value": "Samarth"
},
{
"context": "'s character captivated all of us (David, Samarth, Sam and I). She was very likable to begin with, she a",
"end": 1206,
"score": 0.9915962815,
"start": 1203,
"tag": "NAME",
"value": "Sam"
},
{
"context": " from the get-go. We see that she is interested in Kou as more than a friend, despite them only being ",
"end": 1343,
"score": 0.5068118572,
"start": 1342,
"tag": "NAME",
"value": "K"
},
{
"context": "oduced to Aoba, the main heroine of the story, and Akaishi, his best friend.\nThey kill off Wakaba in t",
"end": 1478,
"score": 0.9827158451,
"start": 1477,
"tag": "NAME",
"value": "A"
},
{
"context": "s after that summer, and the story revolves around Kou, Aoba, Akaishi (to a lesser extent), and the pe",
"end": 2159,
"score": 0.5834592581,
"start": 2158,
"tag": "NAME",
"value": "K"
},
{
"context": "ble for people on either side of that scale, i.e.: Brandon to David (with regards to their level of understa",
"end": 2609,
"score": 0.9916340113,
"start": 2602,
"tag": "NAME",
"value": "Brandon"
},
{
"context": "ple on either side of that scale, i.e.: Brandon to David (with regards to their level of understanding/pas",
"end": 2618,
"score": 0.9512627721,
"start": 2613,
"tag": "NAME",
"value": "David"
},
{
"context": "the show.\nCharacters\n----------\nFirst off, I loved Kou. While he wasn't the hardest character to figure ",
"end": 2870,
"score": 0.9730758667,
"start": 2867,
"tag": "NAME",
"value": "Kou"
},
{
"context": "ar line of character development (cough: Clannad). Kou wasn't like that. He didn't need to explicitly ",
"end": 3123,
"score": 0.8649997115,
"start": 3122,
"tag": "NAME",
"value": "K"
},
{
"context": " way, and you couldn't help but smile when her and Kou butted heads. Ichiyou knew her shit, so I'm ech",
"end": 3664,
"score": 0.528347373,
"start": 3663,
"tag": "NAME",
"value": "K"
},
{
"context": "r shit, so I'm echoing her when I say that she and Kou were very alike. They had a hard time seeing th",
"end": 3748,
"score": 0.5897304416,
"start": 3747,
"tag": "NAME",
"value": "K"
}
] | src/pages/Writing/CrossGame.elm | branjwong/personal-site | 0 | module Writing.CrossGame exposing (view)
import Html exposing (..)
import Html.Attributes exposing (..)
--
import Writing.Post
import Model exposing (Model, Msg)
postTitle =
"Cross Game"
view : Model -> Html Msg
view model =
Writing.Post.post
postTitle
(Writing.Post.Date 2013 7 12)
(Writing.Post.Time 12 47 "pm")
content
content =
"""
![Cross Game](http://cdn.myanimelist.net/images/anime/6/22103l.jpg)
I finished Cross Game yesterday. Sam had suggested it to me. I'm surprised how heavily Sam's invested himself into anime. It's awesome having a close friend in real life I can talk to anime. David and Samarth have gotten into it too, it's awesome.
Being a sports anime, I was kind of iffy about starting it before. I put it off for awhile. When Sam suggested it, I was like, "hey I recognize that name, if you say it's good, I guess I'll give it a shot." Man, am I glad I did.
Synopsis
--------
Cross Game started very strong.
At first they introduced us to two very important characters: Kou, the protragonist, and his childhood friend, Wakaba. Despite having only 20min to work with, Wakaba's character captivated all of us (David, Samarth, Sam and I). She was very likable to begin with, she appeared to be strong and kind right from the get-go. We see that she is interested in Kou as more than a friend, despite them only being in the 5th grade. We're also introduced to Aoba, the main heroine of the story, and Akaishi, his best friend.
They kill off Wakaba in the first episode.
After building up Wakaba to be such a likable character, she dies, and the first episode ends with both Kou and Akaishi crying about losing someone they both loved. They play it off brilliantly. Kou wanders around the Summer Festival (that him and Wakaba were supposed to attend together after she got back from the swimming camp that ended up being her demise) wondering what to do with himself, and only after seeing Akaishi preying for her and crying, does he realize that all he can really do right now is cry as well.
The second episode resumes some 6 years after that summer, and the story revolves around Kou, Aoba, Akaishi (to a lesser extent), and the people they meet through baseball.
This isn't the first story I've done a review for for nothing. Despite this being a 50 episode long anime, I was enthralled for the whole ride. While the story is mostly character driven, the plot serves as a great device for character development. Even though I'm not a huge fan of baseball, they made enjoyable for people on either side of that scale, i.e.: Brandon to David (with regards to their level of understanding/passion for baseball). While perhaps I would have been happy with less baseball, that's only a personal preference, and in no way should be a fault to the show.
Characters
----------
First off, I loved Kou. While he wasn't the hardest character to figure out, he definitely wasn't the easiest. Too many times in anime, I see characters that are defined (through obvious means) at the beginning, with a linear line of character development (cough: Clannad). Kou wasn't like that. He didn't need to explicitly say how he felt to get the audience to understand. In Cross Game, actions spoke a lot louder than words; the two main characters weren't outwardly honest about their feelings for one another. It was only through speculation of the other characters and what you could see from the way they acted could the audience know the reality of what Aoba and Kou felt for one another.
Aoba was phenomenal in her own right. She was cute in an abrasive way, and you couldn't help but smile when her and Kou butted heads. Ichiyou knew her shit, so I'm echoing her when I say that she and Kou were very alike. They had a hard time seeing the light in each other because, honestly, who sees the light in their own character? Aoba was definitely was one of the stronger female characters I've come to know. She's definitey up there with Kurisu, Ami, and Ohana.
Verdict: 10/10
--------------
"""
| 1830 | module Writing.CrossGame exposing (view)
import Html exposing (..)
import Html.Attributes exposing (..)
--
import Writing.Post
import Model exposing (Model, Msg)
postTitle =
"Cross Game"
view : Model -> Html Msg
view model =
Writing.Post.post
postTitle
(Writing.Post.Date 2013 7 12)
(Writing.Post.Time 12 47 "pm")
content
content =
"""
![Cross Game](http://cdn.myanimelist.net/images/anime/6/22103l.jpg)
I finished Cross Game yesterday. <NAME> had suggested it to me. I'm surprised how heavily Sam's invested himself into anime. It's awesome having a close friend in real life I can talk to anime. <NAME> and <NAME> have gotten into it too, it's awesome.
Being a sports anime, I was kind of iffy about starting it before. I put it off for awhile. When Sam suggested it, I was like, "hey I recognize that name, if you say it's good, I guess I'll give it a shot." Man, am I glad I did.
Synopsis
--------
Cross Game started very strong.
At first they introduced us to two very important characters: <NAME>, the protragonist, and his childhood friend, <NAME>. Despite having only 20min to work with, Wakaba's character captivated all of us (<NAME>, <NAME>, <NAME> and I). She was very likable to begin with, she appeared to be strong and kind right from the get-go. We see that she is interested in <NAME>ou as more than a friend, despite them only being in the 5th grade. We're also introduced to Aoba, the main heroine of the story, and <NAME>kaishi, his best friend.
They kill off Wakaba in the first episode.
After building up Wakaba to be such a likable character, she dies, and the first episode ends with both Kou and Akaishi crying about losing someone they both loved. They play it off brilliantly. Kou wanders around the Summer Festival (that him and Wakaba were supposed to attend together after she got back from the swimming camp that ended up being her demise) wondering what to do with himself, and only after seeing Akaishi preying for her and crying, does he realize that all he can really do right now is cry as well.
The second episode resumes some 6 years after that summer, and the story revolves around <NAME>ou, Aoba, Akaishi (to a lesser extent), and the people they meet through baseball.
This isn't the first story I've done a review for for nothing. Despite this being a 50 episode long anime, I was enthralled for the whole ride. While the story is mostly character driven, the plot serves as a great device for character development. Even though I'm not a huge fan of baseball, they made enjoyable for people on either side of that scale, i.e.: <NAME> to <NAME> (with regards to their level of understanding/passion for baseball). While perhaps I would have been happy with less baseball, that's only a personal preference, and in no way should be a fault to the show.
Characters
----------
First off, I loved <NAME>. While he wasn't the hardest character to figure out, he definitely wasn't the easiest. Too many times in anime, I see characters that are defined (through obvious means) at the beginning, with a linear line of character development (cough: Clannad). <NAME>ou wasn't like that. He didn't need to explicitly say how he felt to get the audience to understand. In Cross Game, actions spoke a lot louder than words; the two main characters weren't outwardly honest about their feelings for one another. It was only through speculation of the other characters and what you could see from the way they acted could the audience know the reality of what Aoba and Kou felt for one another.
Aoba was phenomenal in her own right. She was cute in an abrasive way, and you couldn't help but smile when her and <NAME>ou butted heads. Ichiyou knew her shit, so I'm echoing her when I say that she and <NAME>ou were very alike. They had a hard time seeing the light in each other because, honestly, who sees the light in their own character? Aoba was definitely was one of the stronger female characters I've come to know. She's definitey up there with Kurisu, Ami, and Ohana.
Verdict: 10/10
--------------
"""
| true | module Writing.CrossGame exposing (view)
import Html exposing (..)
import Html.Attributes exposing (..)
--
import Writing.Post
import Model exposing (Model, Msg)
postTitle =
"Cross Game"
view : Model -> Html Msg
view model =
Writing.Post.post
postTitle
(Writing.Post.Date 2013 7 12)
(Writing.Post.Time 12 47 "pm")
content
content =
"""
![Cross Game](http://cdn.myanimelist.net/images/anime/6/22103l.jpg)
I finished Cross Game yesterday. PI:NAME:<NAME>END_PI had suggested it to me. I'm surprised how heavily Sam's invested himself into anime. It's awesome having a close friend in real life I can talk to anime. PI:NAME:<NAME>END_PI and PI:NAME:<NAME>END_PI have gotten into it too, it's awesome.
Being a sports anime, I was kind of iffy about starting it before. I put it off for awhile. When Sam suggested it, I was like, "hey I recognize that name, if you say it's good, I guess I'll give it a shot." Man, am I glad I did.
Synopsis
--------
Cross Game started very strong.
At first they introduced us to two very important characters: PI:NAME:<NAME>END_PI, the protragonist, and his childhood friend, PI:NAME:<NAME>END_PI. Despite having only 20min to work with, Wakaba's character captivated all of us (PI:NAME:<NAME>END_PI, PI:NAME:<NAME>END_PI, PI:NAME:<NAME>END_PI and I). She was very likable to begin with, she appeared to be strong and kind right from the get-go. We see that she is interested in PI:NAME:<NAME>END_PIou as more than a friend, despite them only being in the 5th grade. We're also introduced to Aoba, the main heroine of the story, and PI:NAME:<NAME>END_PIkaishi, his best friend.
They kill off Wakaba in the first episode.
After building up Wakaba to be such a likable character, she dies, and the first episode ends with both Kou and Akaishi crying about losing someone they both loved. They play it off brilliantly. Kou wanders around the Summer Festival (that him and Wakaba were supposed to attend together after she got back from the swimming camp that ended up being her demise) wondering what to do with himself, and only after seeing Akaishi preying for her and crying, does he realize that all he can really do right now is cry as well.
The second episode resumes some 6 years after that summer, and the story revolves around PI:NAME:<NAME>END_PIou, Aoba, Akaishi (to a lesser extent), and the people they meet through baseball.
This isn't the first story I've done a review for for nothing. Despite this being a 50 episode long anime, I was enthralled for the whole ride. While the story is mostly character driven, the plot serves as a great device for character development. Even though I'm not a huge fan of baseball, they made enjoyable for people on either side of that scale, i.e.: PI:NAME:<NAME>END_PI to PI:NAME:<NAME>END_PI (with regards to their level of understanding/passion for baseball). While perhaps I would have been happy with less baseball, that's only a personal preference, and in no way should be a fault to the show.
Characters
----------
First off, I loved PI:NAME:<NAME>END_PI. While he wasn't the hardest character to figure out, he definitely wasn't the easiest. Too many times in anime, I see characters that are defined (through obvious means) at the beginning, with a linear line of character development (cough: Clannad). PI:NAME:<NAME>END_PIou wasn't like that. He didn't need to explicitly say how he felt to get the audience to understand. In Cross Game, actions spoke a lot louder than words; the two main characters weren't outwardly honest about their feelings for one another. It was only through speculation of the other characters and what you could see from the way they acted could the audience know the reality of what Aoba and Kou felt for one another.
Aoba was phenomenal in her own right. She was cute in an abrasive way, and you couldn't help but smile when her and PI:NAME:<NAME>END_PIou butted heads. Ichiyou knew her shit, so I'm echoing her when I say that she and PI:NAME:<NAME>END_PIou were very alike. They had a hard time seeing the light in each other because, honestly, who sees the light in their own character? Aoba was definitely was one of the stronger female characters I've come to know. She's definitey up there with Kurisu, Ami, and Ohana.
Verdict: 10/10
--------------
"""
| elm |
[
{
"context": " , tr []\n [ td [] [text \"Sébastien\"]\n , td [] [text \"GOUTTEBEL\"]\n ",
"end": 3666,
"score": 0.999838233,
"start": 3657,
"tag": "NAME",
"value": "Sébastien"
},
{
"context": "xt \"Sébastien\"]\n , td [] [text \"GOUTTEBEL\"]\n , td [] [text \"président\"]\n ",
"end": 3712,
"score": 0.9998327494,
"start": 3703,
"tag": "NAME",
"value": "GOUTTEBEL"
},
{
"context": "xt \"président\"]\n , td [] [text \"Chautignat\"]\n , td [] [text \"06 45 28 85 8",
"end": 3805,
"score": 0.9994295835,
"start": 3795,
"tag": "NAME",
"value": "Chautignat"
},
{
"context": " , tr []\n [ td [] [text \"Sylvie\"]\n , td [] [text \"GILLARD\"]\n ",
"end": 3942,
"score": 0.9998008609,
"start": 3936,
"tag": "NAME",
"value": "Sylvie"
},
{
"context": "[text \"Sylvie\"]\n , td [] [text \"GILLARD\"]\n , td [] [text \"vice-présiden",
"end": 3986,
"score": 0.9997441173,
"start": 3979,
"tag": "NAME",
"value": "GILLARD"
},
{
"context": " , tr []\n [ td [] [text \"Floriane\"]\n , td [] [text \"CHAZEY\"]\n ",
"end": 4231,
"score": 0.9969611764,
"start": 4223,
"tag": "NAME",
"value": "Floriane"
},
{
"context": "ext \"Floriane\"]\n , td [] [text \"CHAZEY\"]\n , td [] [text \"secrétaire\"]\n",
"end": 4274,
"score": 0.9752659202,
"start": 4268,
"tag": "NAME",
"value": "CHAZEY"
},
{
"context": "secrétaire\"]\n , td [] [text \"Rue George Sand\"]\n , td [] [text \"06 79 79 20 7",
"end": 4373,
"score": 0.9974753261,
"start": 4362,
"tag": "NAME",
"value": "George Sand"
},
{
"context": " , tr []\n [ td [] [text \"Catherine\"]\n , td [] [text \"MAURY\"]\n ",
"end": 4513,
"score": 0.9992406368,
"start": 4504,
"tag": "NAME",
"value": "Catherine"
},
{
"context": "xt \"Catherine\"]\n , td [] [text \"MAURY\"]\n , td [] [text \"trésorière\"]\n",
"end": 4555,
"score": 0.9922471642,
"start": 4550,
"tag": "NAME",
"value": "MAURY"
},
{
"context": " , tr []\n [ td [] [text \"Joséphine\"]\n , td [] [text \"LANARO\"]\n ",
"end": 4801,
"score": 0.9993669391,
"start": 4792,
"tag": "NAME",
"value": "Joséphine"
},
{
"context": "xt \"Joséphine\"]\n , td [] [text \"LANARO\"]\n , td [] [text \"régisseur\"]\n ",
"end": 4844,
"score": 0.9958075881,
"start": 4838,
"tag": "NAME",
"value": "LANARO"
},
{
"context": "\"régisseur\"]\n , td [] [text \"Allée de la Plage\"]\n , td [] [text \"0",
"end": 4932,
"score": 0.5975009203,
"start": 4930,
"tag": "NAME",
"value": "ée"
},
{
"context": " , tr []\n [ td [] [text \"Monique\"]\n , td [] [text \"PICOT\"]\n ",
"end": 5082,
"score": 0.970110774,
"start": 5075,
"tag": "NAME",
"value": "Monique"
},
{
"context": "text \"Monique\"]\n , td [] [text \"PICOT\"]\n , td [] [text \"régisseur sup",
"end": 5124,
"score": 0.9927037358,
"start": 5119,
"tag": "NAME",
"value": "PICOT"
},
{
"context": " , tr []\n [ td [] [text \"Véronique\"]\n , td [] [text \"DEBOU",
"end": 5362,
"score": 0.6805111766,
"start": 5361,
"tag": "NAME",
"value": "V"
},
{
"context": "ipale\"]\n , td [] [text \"Rue de Besse\"]\n , td [] [text \"06 28 06 81 7",
"end": 5521,
"score": 0.8094572425,
"start": 5517,
"tag": "NAME",
"value": "esse"
},
{
"context": " , tr []\n [ td [] [text \"Christelle\"]\n , td [] [text \"ROUX\"]\n ",
"end": 5662,
"score": 0.9985225201,
"start": 5652,
"tag": "NAME",
"value": "Christelle"
},
{
"context": "t \"Christelle\"]\n , td [] [text \"ROUX\"]\n , td [] [text \"conseillère m",
"end": 5703,
"score": 0.9598062038,
"start": 5699,
"tag": "NAME",
"value": "ROUX"
},
{
"context": " , tr []\n [ td [] [text \"Paulette\"]\n , td [] [text \"BENATEK\"]\n ",
"end": 5953,
"score": 0.9301905036,
"start": 5945,
"tag": "NAME",
"value": "Paulette"
},
{
"context": "ext \"Paulette\"]\n , td [] [text \"BENATEK\"]\n , td [] [text \"membre nommé\"",
"end": 5997,
"score": 0.9977266192,
"start": 5990,
"tag": "NAME",
"value": "BENATEK"
},
{
"context": " , tr []\n [ td [] [text \"Olivier\"]\n , td [] [text \"DHAINAUT\"]\n ",
"end": 6231,
"score": 0.9997384548,
"start": 6224,
"tag": "NAME",
"value": "Olivier"
},
{
"context": "text \"Olivier\"]\n , td [] [text \"DHAINAUT\"]\n , td [] [text \"membre nommé\"",
"end": 6276,
"score": 0.9986143112,
"start": 6268,
"tag": "NAME",
"value": "DHAINAUT"
},
{
"context": "\"membre nommé\"]\n , td [] [text \"Groire\"]\n , td [] [text \"06 99 40 17 0",
"end": 6368,
"score": 0.9988628626,
"start": 6362,
"tag": "NAME",
"value": "Groire"
},
{
"context": " , tr []\n [ td [] [text \"Suzanne\"]\n , td [] [text \"PLANEIX\"]\n ",
"end": 6506,
"score": 0.8814409375,
"start": 6499,
"tag": "NAME",
"value": "Suzanne"
},
{
"context": " ]\n ]\n\n\n --, p [] [text \"Président: Sébastien GOUTTEBEL\"]\n --, p [] [text \"Vice-présidente: Sylvie ",
"end": 6812,
"score": 0.9998850822,
"start": 6793,
"tag": "NAME",
"value": "Sébastien GOUTTEBEL"
},
{
"context": "OUTTEBEL\"]\n --, p [] [text \"Vice-présidente: Sylvie GILLARD\"]\n --, p [] [text \"Membres: Véronique DEBOU",
"end": 6869,
"score": 0.999889195,
"start": 6855,
"tag": "NAME",
"value": "Sylvie GILLARD"
},
{
"context": ": Sylvie GILLARD\"]\n --, p [] [text \"Membres: Véronique DEBOUT, Joséphine LANARO, Cathy MAURY\"]\n --, p [] ",
"end": 6920,
"score": 0.999889493,
"start": 6904,
"tag": "NAME",
"value": "Véronique DEBOUT"
},
{
"context": "\n --, p [] [text \"Membres: Véronique DEBOUT, Joséphine LANARO, Cathy MAURY\"]\n --, p [] [text \"Régie : Jos",
"end": 6938,
"score": 0.9998884201,
"start": 6922,
"tag": "NAME",
"value": "Joséphine LANARO"
},
{
"context": "text \"Membres: Véronique DEBOUT, Joséphine LANARO, Cathy MAURY\"]\n --, p [] [text \"Régie : Joséphine LANARO",
"end": 6951,
"score": 0.9998801351,
"start": 6940,
"tag": "NAME",
"value": "Cathy MAURY"
},
{
"context": "NARO, Cathy MAURY\"]\n --, p [] [text \"Régie : Joséphine LANARO\"]\n --, p [] [text \"Membres non élus désigné",
"end": 7001,
"score": 0.9998746514,
"start": 6985,
"tag": "NAME",
"value": "Joséphine LANARO"
},
{
"context": "aire parmi les Murolais:\"]\n --, p [] [text \"Paulette Benatek, Floriane Chazet-Fillon, Olivier Dhainaut, Moniqu",
"end": 7127,
"score": 0.9998889565,
"start": 7111,
"tag": "NAME",
"value": "Paulette Benatek"
},
{
"context": "rolais:\"]\n --, p [] [text \"Paulette Benatek, Floriane Chazet-Fillon, Olivier Dhainaut, Monique Picot et Suzanne Plane",
"end": 7151,
"score": 0.9998351336,
"start": 7129,
"tag": "NAME",
"value": "Floriane Chazet-Fillon"
},
{
"context": "] [text \"Paulette Benatek, Floriane Chazet-Fillon, Olivier Dhainaut, Monique Picot et Suzanne Planeix\"]\n --, p ",
"end": 7169,
"score": 0.9998960495,
"start": 7153,
"tag": "NAME",
"value": "Olivier Dhainaut"
},
{
"context": "Benatek, Floriane Chazet-Fillon, Olivier Dhainaut, Monique Picot et Suzanne Planeix\"]\n --, p [] [text \"+ cin",
"end": 7184,
"score": 0.9998863935,
"start": 7171,
"tag": "NAME",
"value": "Monique Picot"
},
{
"context": " Chazet-Fillon, Olivier Dhainaut, Monique Picot et Suzanne Planeix\"]\n --, p [] [text \"+ cinq membres non élus ",
"end": 7203,
"score": 0.999871254,
"start": 7188,
"tag": "NAME",
"value": "Suzanne Planeix"
}
] | src/CCAS.elm | eniac314/mairieMurol | 0 | module CCAS where
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import StartApp.Simple as StartApp
import List exposing (..)
import String exposing (words, join, cons, uncons)
import Char
import Dict exposing (..)
import Utils exposing (mainMenu,
renderMainMenu,
pageFooter,
capitalize,
renderListImg,
logos,
Action (..),
renderSubMenu,
mail,
site,
link)
-- Model
subMenu = []
initialModel =
{ mainMenu = mainMenu
, subMenu = subMenu
, mainContent = initialContent
}
type alias Category =
{ title : String
, entries : List Entry
}
type alias Entry = (String,String)
-- View
view address model =
div [ id "container"]
[ renderMainMenu ["Mairie","CCAS"]
(.mainMenu model)
, div [ id "subContainer"]
[ .mainContent model
]
, pageFooter
]
contentMap =
fromList []
update action model =
case action of
NoOp -> model
Entry s -> changeMain model s
changeMain model s =
let newContent = get s contentMap
in case newContent of
Nothing -> model
Just c -> { model | mainContent = c }
--Main
main =
StartApp.start
{ model = initialModel
, view = view
, update = update
}
initialContent =
div [ class "subContainerData noSubmenu", id "ccas"]
[ h2 [] [text "Centre Communal d'Action Sociale"]
, p []
[ text "Le CCAS organise chaque année des manifestations
pour petits et grands (Noël des enfants et "
, a [href "/Annee2017.html"]
[text "repas du CCAS"]
, text ")."
]
, p []
[ text "En dehors de ces actions collectives, le CCAS
souhaite être une "
, b [] [text "réponse de proximité"]
, text " aux difficultés
que vous pouvez rencontrer dans votre vie quotidienne:"
]
, ul []
[ li [] [b [] [text "Aide d’urgence"]
, text " grâce à la régie d’avance
(denrées alimentaires, soins médicaux,
transport, fourniture d’énergie…) "
]
, li [] [b [] [text "Secours"], text " ponctuels "]
, li [] [ text "Don de "
, b [] [text "bois"]
, text " de chauffage"]
, li [] [ text "Aide pour les "
, b [] [text "démarches administratives"]
, text " (constitution de
dossiers, mise en relation avec les services sociaux…) "]
, li [] [text "Aide à l’accès à la "
, b [] [text "téléassistance"]
, text " pour
les personnes seules, financée en partie par le
CCAS"
]
]
, p [style [("text-align","center"),("fonts-size","2em")]]
[b [] [text "N’hésitez pas à nous contacter! "]]
, p [style [("text-align","center")]]
[text "Les membres du CCAS se sont engagés à
la confidentialité. "]
, table [id "tableCCAS"]
[ th [colspan 5]
[text "LES MEMBRES DU CENTRE COMMUNAL D’ACTION SOCIALE (CCAS)"]
, tr []
[ td [] [text "Sébastien"]
, td [] [text "GOUTTEBEL"]
, td [] [text "président"]
, td [] [text "Chautignat"]
, td [] [text "06 45 28 85 89"]
]
, tr []
[ td [] [text "Sylvie"]
, td [] [text "GILLARD"]
, td [] [text "vice-présidente"]
, td [] [text "Allée de la Plage"]
, td [] [text "06 60 97 80 58"]
]
, tr []
[ td [] [text "Floriane"]
, td [] [text "CHAZEY"]
, td [] [text "secrétaire"]
, td [] [text "Rue George Sand"]
, td [] [text "06 79 79 20 71"]
]
, tr []
[ td [] [text "Catherine"]
, td [] [text "MAURY"]
, td [] [text "trésorière"]
, td [] [text "Rue de la Vieille Tour"]
, td [] [text "06 45 18 45 35"]
]
, tr []
[ td [] [text "Joséphine"]
, td [] [text "LANARO"]
, td [] [text "régisseur"]
, td [] [text "Allée de la Plage"]
, td [] [text "06 33 65 09 04"]
]
, tr []
[ td [] [text "Monique"]
, td [] [text "PICOT"]
, td [] [text "régisseur suppléante"]
, td [] [text "La Chassagne"]
, td [] [text "04 73 88 65 79"]
]
, tr []
[ td [] [text "Véronique"]
, td [] [text "DEBOUT"]
, td [] [text "conseillère municipale"]
, td [] [text "Rue de Besse"]
, td [] [text "06 28 06 81 77"]
]
, tr []
[ td [] [text "Christelle"]
, td [] [text "ROUX"]
, td [] [text "conseillère municipale"]
, td [] [text "Route de Jassat"]
, td [] [text "06 47 01 43 62"]
]
, tr []
[ td [] [text "Paulette"]
, td [] [text "BENATEK"]
, td [] [text "membre nommé"]
, td [] [text "Chautignat"]
, td [] [text "04 73 88 63 90"]
]
, tr []
[ td [] [text "Olivier"]
, td [] [text "DHAINAUT"]
, td [] [text "membre nommé"]
, td [] [text "Groire"]
, td [] [text "06 99 40 17 08"]
]
, tr []
[ td [] [text "Suzanne"]
, td [] [text "PLANEIX"]
, td [] [text "membre nommé"]
, td [] [text "Rue de la Vieille Tour"]
, td [] [text "04 73 78 65 08"]
]
]
]
--, p [] [text "Président: Sébastien GOUTTEBEL"]
--, p [] [text "Vice-présidente: Sylvie GILLARD"]
--, p [] [text "Membres: Véronique DEBOUT, Joséphine LANARO, Cathy MAURY"]
--, p [] [text "Régie : Joséphine LANARO"]
--, p [] [text "Membres non élus désignés par le maire parmi les Murolais:"]
--, p [] [text "Paulette Benatek, Floriane Chazet-Fillon, Olivier Dhainaut, Monique Picot et Suzanne Planeix"]
--, p [] [text "+ cinq membres non élus à désigner par le maire parmi les Murolais."]
--, h4 [] [text "Mutuelle municipale"]
--, p [] [text "Votre avis compte !"]
--, p [] [text "Lors des élections, vous avez soutenu l’élaboration d’un
-- projet concret pour améliorer votre pouvoir d’achat :"]
--, p [] [text "la création d’une complémentaire santé communale avec un
-- tarif unique et accessible à tous. Une complémentaire
-- santé, rappelons-le, sert à couvrir partiellement ou en
-- totalité les frais médicaux non remboursés par votre
-- assurance maladie. Nous sollicitons aujourd’hui un peu de
-- votre temps pour répondre à quelques questions qui
-- permettront de créer une offre adaptée à vos
-- besoins. Grâce au questionnaire ci-dessous les tarifs des
-- différentes mutuelles seront mis en concurrence. "]
--, p [] [text "La commune lance une consultation pour proposer une
-- complémentaire santé à des tarifs négociés à ses
-- habitants. Proposé aux murolais de se regrouper pour
-- négocier une complémentaire santé à des tarifs préférentiels"]
--, p [] [text "Vous recevrez dans le bulletin municipal un questionnaire
-- à remplir et à retourner pour cerner les
-- besoins et les personnes concernées par ce dispositif,
-- vous pouvez également répondre en ligne au questionnaire
-- en suivant le lien ci-dessous.. "]
--, p [] [text "Une fois les réponses des murolais compilées par
-- la mairie, les élus passeront ensuite à la
-- phase de négociation avec les organismes de santé.
-- \" Plus nous serons nombreux, plus les tarifs
-- seront intéressants.\""]
--, h5 [] [text "Questionnaire Mutuelle municipale"]
--, link "Remplir en ligne" "https://docs.google.com/forms/d/179U2zTrhm6usamB724BMlI197oXq58-TS-3sIi933wM/viewform?usp=send_form"
--]
| 34418 | module CCAS where
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import StartApp.Simple as StartApp
import List exposing (..)
import String exposing (words, join, cons, uncons)
import Char
import Dict exposing (..)
import Utils exposing (mainMenu,
renderMainMenu,
pageFooter,
capitalize,
renderListImg,
logos,
Action (..),
renderSubMenu,
mail,
site,
link)
-- Model
subMenu = []
initialModel =
{ mainMenu = mainMenu
, subMenu = subMenu
, mainContent = initialContent
}
type alias Category =
{ title : String
, entries : List Entry
}
type alias Entry = (String,String)
-- View
view address model =
div [ id "container"]
[ renderMainMenu ["Mairie","CCAS"]
(.mainMenu model)
, div [ id "subContainer"]
[ .mainContent model
]
, pageFooter
]
contentMap =
fromList []
update action model =
case action of
NoOp -> model
Entry s -> changeMain model s
changeMain model s =
let newContent = get s contentMap
in case newContent of
Nothing -> model
Just c -> { model | mainContent = c }
--Main
main =
StartApp.start
{ model = initialModel
, view = view
, update = update
}
initialContent =
div [ class "subContainerData noSubmenu", id "ccas"]
[ h2 [] [text "Centre Communal d'Action Sociale"]
, p []
[ text "Le CCAS organise chaque année des manifestations
pour petits et grands (Noël des enfants et "
, a [href "/Annee2017.html"]
[text "repas du CCAS"]
, text ")."
]
, p []
[ text "En dehors de ces actions collectives, le CCAS
souhaite être une "
, b [] [text "réponse de proximité"]
, text " aux difficultés
que vous pouvez rencontrer dans votre vie quotidienne:"
]
, ul []
[ li [] [b [] [text "Aide d’urgence"]
, text " grâce à la régie d’avance
(denrées alimentaires, soins médicaux,
transport, fourniture d’énergie…) "
]
, li [] [b [] [text "Secours"], text " ponctuels "]
, li [] [ text "Don de "
, b [] [text "bois"]
, text " de chauffage"]
, li [] [ text "Aide pour les "
, b [] [text "démarches administratives"]
, text " (constitution de
dossiers, mise en relation avec les services sociaux…) "]
, li [] [text "Aide à l’accès à la "
, b [] [text "téléassistance"]
, text " pour
les personnes seules, financée en partie par le
CCAS"
]
]
, p [style [("text-align","center"),("fonts-size","2em")]]
[b [] [text "N’hésitez pas à nous contacter! "]]
, p [style [("text-align","center")]]
[text "Les membres du CCAS se sont engagés à
la confidentialité. "]
, table [id "tableCCAS"]
[ th [colspan 5]
[text "LES MEMBRES DU CENTRE COMMUNAL D’ACTION SOCIALE (CCAS)"]
, tr []
[ td [] [text "<NAME>"]
, td [] [text "<NAME>"]
, td [] [text "président"]
, td [] [text "<NAME>"]
, td [] [text "06 45 28 85 89"]
]
, tr []
[ td [] [text "<NAME>"]
, td [] [text "<NAME>"]
, td [] [text "vice-présidente"]
, td [] [text "Allée de la Plage"]
, td [] [text "06 60 97 80 58"]
]
, tr []
[ td [] [text "<NAME>"]
, td [] [text "<NAME>"]
, td [] [text "secrétaire"]
, td [] [text "Rue <NAME>"]
, td [] [text "06 79 79 20 71"]
]
, tr []
[ td [] [text "<NAME>"]
, td [] [text "<NAME>"]
, td [] [text "trésorière"]
, td [] [text "Rue de la Vieille Tour"]
, td [] [text "06 45 18 45 35"]
]
, tr []
[ td [] [text "<NAME>"]
, td [] [text "<NAME>"]
, td [] [text "régisseur"]
, td [] [text "All<NAME> de la Plage"]
, td [] [text "06 33 65 09 04"]
]
, tr []
[ td [] [text "<NAME>"]
, td [] [text "<NAME>"]
, td [] [text "régisseur suppléante"]
, td [] [text "La Chassagne"]
, td [] [text "04 73 88 65 79"]
]
, tr []
[ td [] [text "<NAME>éronique"]
, td [] [text "DEBOUT"]
, td [] [text "conseillère municipale"]
, td [] [text "Rue de B<NAME>"]
, td [] [text "06 28 06 81 77"]
]
, tr []
[ td [] [text "<NAME>"]
, td [] [text "<NAME>"]
, td [] [text "conseillère municipale"]
, td [] [text "Route de Jassat"]
, td [] [text "06 47 01 43 62"]
]
, tr []
[ td [] [text "<NAME>"]
, td [] [text "<NAME>"]
, td [] [text "membre nommé"]
, td [] [text "Chautignat"]
, td [] [text "04 73 88 63 90"]
]
, tr []
[ td [] [text "<NAME>"]
, td [] [text "<NAME>"]
, td [] [text "membre nommé"]
, td [] [text "<NAME>"]
, td [] [text "06 99 40 17 08"]
]
, tr []
[ td [] [text "<NAME>"]
, td [] [text "PLANEIX"]
, td [] [text "membre nommé"]
, td [] [text "Rue de la Vieille Tour"]
, td [] [text "04 73 78 65 08"]
]
]
]
--, p [] [text "Président: <NAME>"]
--, p [] [text "Vice-présidente: <NAME>"]
--, p [] [text "Membres: <NAME>, <NAME>, <NAME>"]
--, p [] [text "Régie : <NAME>"]
--, p [] [text "Membres non élus désignés par le maire parmi les Murolais:"]
--, p [] [text "<NAME>, <NAME>, <NAME>, <NAME> et <NAME>"]
--, p [] [text "+ cinq membres non élus à désigner par le maire parmi les Murolais."]
--, h4 [] [text "Mutuelle municipale"]
--, p [] [text "Votre avis compte !"]
--, p [] [text "Lors des élections, vous avez soutenu l’élaboration d’un
-- projet concret pour améliorer votre pouvoir d’achat :"]
--, p [] [text "la création d’une complémentaire santé communale avec un
-- tarif unique et accessible à tous. Une complémentaire
-- santé, rappelons-le, sert à couvrir partiellement ou en
-- totalité les frais médicaux non remboursés par votre
-- assurance maladie. Nous sollicitons aujourd’hui un peu de
-- votre temps pour répondre à quelques questions qui
-- permettront de créer une offre adaptée à vos
-- besoins. Grâce au questionnaire ci-dessous les tarifs des
-- différentes mutuelles seront mis en concurrence. "]
--, p [] [text "La commune lance une consultation pour proposer une
-- complémentaire santé à des tarifs négociés à ses
-- habitants. Proposé aux murolais de se regrouper pour
-- négocier une complémentaire santé à des tarifs préférentiels"]
--, p [] [text "Vous recevrez dans le bulletin municipal un questionnaire
-- à remplir et à retourner pour cerner les
-- besoins et les personnes concernées par ce dispositif,
-- vous pouvez également répondre en ligne au questionnaire
-- en suivant le lien ci-dessous.. "]
--, p [] [text "Une fois les réponses des murolais compilées par
-- la mairie, les élus passeront ensuite à la
-- phase de négociation avec les organismes de santé.
-- \" Plus nous serons nombreux, plus les tarifs
-- seront intéressants.\""]
--, h5 [] [text "Questionnaire Mutuelle municipale"]
--, link "Remplir en ligne" "https://docs.google.com/forms/d/179U2zTrhm6usamB724BMlI197oXq58-TS-3sIi933wM/viewform?usp=send_form"
--]
| true | module CCAS where
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import StartApp.Simple as StartApp
import List exposing (..)
import String exposing (words, join, cons, uncons)
import Char
import Dict exposing (..)
import Utils exposing (mainMenu,
renderMainMenu,
pageFooter,
capitalize,
renderListImg,
logos,
Action (..),
renderSubMenu,
mail,
site,
link)
-- Model
subMenu = []
initialModel =
{ mainMenu = mainMenu
, subMenu = subMenu
, mainContent = initialContent
}
type alias Category =
{ title : String
, entries : List Entry
}
type alias Entry = (String,String)
-- View
view address model =
div [ id "container"]
[ renderMainMenu ["Mairie","CCAS"]
(.mainMenu model)
, div [ id "subContainer"]
[ .mainContent model
]
, pageFooter
]
contentMap =
fromList []
update action model =
case action of
NoOp -> model
Entry s -> changeMain model s
changeMain model s =
let newContent = get s contentMap
in case newContent of
Nothing -> model
Just c -> { model | mainContent = c }
--Main
main =
StartApp.start
{ model = initialModel
, view = view
, update = update
}
initialContent =
div [ class "subContainerData noSubmenu", id "ccas"]
[ h2 [] [text "Centre Communal d'Action Sociale"]
, p []
[ text "Le CCAS organise chaque année des manifestations
pour petits et grands (Noël des enfants et "
, a [href "/Annee2017.html"]
[text "repas du CCAS"]
, text ")."
]
, p []
[ text "En dehors de ces actions collectives, le CCAS
souhaite être une "
, b [] [text "réponse de proximité"]
, text " aux difficultés
que vous pouvez rencontrer dans votre vie quotidienne:"
]
, ul []
[ li [] [b [] [text "Aide d’urgence"]
, text " grâce à la régie d’avance
(denrées alimentaires, soins médicaux,
transport, fourniture d’énergie…) "
]
, li [] [b [] [text "Secours"], text " ponctuels "]
, li [] [ text "Don de "
, b [] [text "bois"]
, text " de chauffage"]
, li [] [ text "Aide pour les "
, b [] [text "démarches administratives"]
, text " (constitution de
dossiers, mise en relation avec les services sociaux…) "]
, li [] [text "Aide à l’accès à la "
, b [] [text "téléassistance"]
, text " pour
les personnes seules, financée en partie par le
CCAS"
]
]
, p [style [("text-align","center"),("fonts-size","2em")]]
[b [] [text "N’hésitez pas à nous contacter! "]]
, p [style [("text-align","center")]]
[text "Les membres du CCAS se sont engagés à
la confidentialité. "]
, table [id "tableCCAS"]
[ th [colspan 5]
[text "LES MEMBRES DU CENTRE COMMUNAL D’ACTION SOCIALE (CCAS)"]
, tr []
[ td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "président"]
, td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "06 45 28 85 89"]
]
, tr []
[ td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "vice-présidente"]
, td [] [text "Allée de la Plage"]
, td [] [text "06 60 97 80 58"]
]
, tr []
[ td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "secrétaire"]
, td [] [text "Rue PI:NAME:<NAME>END_PI"]
, td [] [text "06 79 79 20 71"]
]
, tr []
[ td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "trésorière"]
, td [] [text "Rue de la Vieille Tour"]
, td [] [text "06 45 18 45 35"]
]
, tr []
[ td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "régisseur"]
, td [] [text "AllPI:NAME:<NAME>END_PI de la Plage"]
, td [] [text "06 33 65 09 04"]
]
, tr []
[ td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "régisseur suppléante"]
, td [] [text "La Chassagne"]
, td [] [text "04 73 88 65 79"]
]
, tr []
[ td [] [text "PI:NAME:<NAME>END_PIéronique"]
, td [] [text "DEBOUT"]
, td [] [text "conseillère municipale"]
, td [] [text "Rue de BPI:NAME:<NAME>END_PI"]
, td [] [text "06 28 06 81 77"]
]
, tr []
[ td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "conseillère municipale"]
, td [] [text "Route de Jassat"]
, td [] [text "06 47 01 43 62"]
]
, tr []
[ td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "membre nommé"]
, td [] [text "Chautignat"]
, td [] [text "04 73 88 63 90"]
]
, tr []
[ td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "membre nommé"]
, td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "06 99 40 17 08"]
]
, tr []
[ td [] [text "PI:NAME:<NAME>END_PI"]
, td [] [text "PLANEIX"]
, td [] [text "membre nommé"]
, td [] [text "Rue de la Vieille Tour"]
, td [] [text "04 73 78 65 08"]
]
]
]
--, p [] [text "Président: PI:NAME:<NAME>END_PI"]
--, p [] [text "Vice-présidente: PI:NAME:<NAME>END_PI"]
--, p [] [text "Membres: PI:NAME:<NAME>END_PI, PI:NAME:<NAME>END_PI, PI:NAME:<NAME>END_PI"]
--, p [] [text "Régie : PI:NAME:<NAME>END_PI"]
--, p [] [text "Membres non élus désignés par le maire parmi les Murolais:"]
--, p [] [text "PI:NAME:<NAME>END_PI, PI:NAME:<NAME>END_PI, PI:NAME:<NAME>END_PI, PI:NAME:<NAME>END_PI et PI:NAME:<NAME>END_PI"]
--, p [] [text "+ cinq membres non élus à désigner par le maire parmi les Murolais."]
--, h4 [] [text "Mutuelle municipale"]
--, p [] [text "Votre avis compte !"]
--, p [] [text "Lors des élections, vous avez soutenu l’élaboration d’un
-- projet concret pour améliorer votre pouvoir d’achat :"]
--, p [] [text "la création d’une complémentaire santé communale avec un
-- tarif unique et accessible à tous. Une complémentaire
-- santé, rappelons-le, sert à couvrir partiellement ou en
-- totalité les frais médicaux non remboursés par votre
-- assurance maladie. Nous sollicitons aujourd’hui un peu de
-- votre temps pour répondre à quelques questions qui
-- permettront de créer une offre adaptée à vos
-- besoins. Grâce au questionnaire ci-dessous les tarifs des
-- différentes mutuelles seront mis en concurrence. "]
--, p [] [text "La commune lance une consultation pour proposer une
-- complémentaire santé à des tarifs négociés à ses
-- habitants. Proposé aux murolais de se regrouper pour
-- négocier une complémentaire santé à des tarifs préférentiels"]
--, p [] [text "Vous recevrez dans le bulletin municipal un questionnaire
-- à remplir et à retourner pour cerner les
-- besoins et les personnes concernées par ce dispositif,
-- vous pouvez également répondre en ligne au questionnaire
-- en suivant le lien ci-dessous.. "]
--, p [] [text "Une fois les réponses des murolais compilées par
-- la mairie, les élus passeront ensuite à la
-- phase de négociation avec les organismes de santé.
-- \" Plus nous serons nombreux, plus les tarifs
-- seront intéressants.\""]
--, h5 [] [text "Questionnaire Mutuelle municipale"]
--, link "Remplir en ligne" "https://docs.google.com/forms/d/179U2zTrhm6usamB724BMlI197oXq58-TS-3sIi933wM/viewform?usp=send_form"
--]
| elm |
[
{
"context": "he version of the OpenAPI document: v1\n Contact: support@coinapi.io\n\n NOTE: This file is auto generated by the open",
"end": 343,
"score": 0.9999236465,
"start": 325,
"tag": "EMAIL",
"value": "support@coinapi.io"
},
{
"context": "d by the openapi-generator.\n https://github.com/openapitools/openapi-generator.git\n Do not edit this file ma",
"end": 442,
"score": 0.999558568,
"start": 430,
"tag": "USERNAME",
"value": "openapitools"
}
] | oeml-sdk/elm/src/Data/Fills.elm | byblakeorriver/coinapi-sdk | 0 | {-
OEML - REST API
This section will provide necessary information about the `CoinAPI OEML REST API` protocol. This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a>
The version of the OpenAPI document: v1
Contact: support@coinapi.io
NOTE: This file is auto generated by the openapi-generator.
https://github.com/openapitools/openapi-generator.git
Do not edit this file manually.
-}
module Data.Fills exposing (Fills, decoder, encode, encodeWithTag, toString)
import DateOnly exposing (DateOnly)
import Dict exposing (Dict)
import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (optional, required)
import Json.Encode as Encode
type alias Fills =
{ time : Maybe (DateOnly)
, price : Maybe (Float)
, amount : Maybe (Float)
}
decoder : Decoder Fills
decoder =
Decode.succeed Fills
|> optional "time" (Decode.nullable DateOnly.decoder) Nothing
|> optional "price" (Decode.nullable Decode.float) Nothing
|> optional "amount" (Decode.nullable Decode.float) Nothing
encode : Fills -> Encode.Value
encode =
Encode.object << encodePairs
encodeWithTag : ( String, String ) -> Fills -> Encode.Value
encodeWithTag (tagField, tag) model =
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
encodePairs : Fills -> List (String, Encode.Value)
encodePairs model =
[ ( "time", Maybe.withDefault Encode.null (Maybe.map DateOnly.encode model.time) )
, ( "price", Maybe.withDefault Encode.null (Maybe.map Encode.float model.price) )
, ( "amount", Maybe.withDefault Encode.null (Maybe.map Encode.float model.amount) )
]
toString : Fills -> String
toString =
Encode.encode 0 << encode
| 1051 | {-
OEML - REST API
This section will provide necessary information about the `CoinAPI OEML REST API` protocol. This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a>
The version of the OpenAPI document: v1
Contact: <EMAIL>
NOTE: This file is auto generated by the openapi-generator.
https://github.com/openapitools/openapi-generator.git
Do not edit this file manually.
-}
module Data.Fills exposing (Fills, decoder, encode, encodeWithTag, toString)
import DateOnly exposing (DateOnly)
import Dict exposing (Dict)
import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (optional, required)
import Json.Encode as Encode
type alias Fills =
{ time : Maybe (DateOnly)
, price : Maybe (Float)
, amount : Maybe (Float)
}
decoder : Decoder Fills
decoder =
Decode.succeed Fills
|> optional "time" (Decode.nullable DateOnly.decoder) Nothing
|> optional "price" (Decode.nullable Decode.float) Nothing
|> optional "amount" (Decode.nullable Decode.float) Nothing
encode : Fills -> Encode.Value
encode =
Encode.object << encodePairs
encodeWithTag : ( String, String ) -> Fills -> Encode.Value
encodeWithTag (tagField, tag) model =
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
encodePairs : Fills -> List (String, Encode.Value)
encodePairs model =
[ ( "time", Maybe.withDefault Encode.null (Maybe.map DateOnly.encode model.time) )
, ( "price", Maybe.withDefault Encode.null (Maybe.map Encode.float model.price) )
, ( "amount", Maybe.withDefault Encode.null (Maybe.map Encode.float model.amount) )
]
toString : Fills -> String
toString =
Encode.encode 0 << encode
| true | {-
OEML - REST API
This section will provide necessary information about the `CoinAPI OEML REST API` protocol. This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a>
The version of the OpenAPI document: v1
Contact: PI:EMAIL:<EMAIL>END_PI
NOTE: This file is auto generated by the openapi-generator.
https://github.com/openapitools/openapi-generator.git
Do not edit this file manually.
-}
module Data.Fills exposing (Fills, decoder, encode, encodeWithTag, toString)
import DateOnly exposing (DateOnly)
import Dict exposing (Dict)
import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (optional, required)
import Json.Encode as Encode
type alias Fills =
{ time : Maybe (DateOnly)
, price : Maybe (Float)
, amount : Maybe (Float)
}
decoder : Decoder Fills
decoder =
Decode.succeed Fills
|> optional "time" (Decode.nullable DateOnly.decoder) Nothing
|> optional "price" (Decode.nullable Decode.float) Nothing
|> optional "amount" (Decode.nullable Decode.float) Nothing
encode : Fills -> Encode.Value
encode =
Encode.object << encodePairs
encodeWithTag : ( String, String ) -> Fills -> Encode.Value
encodeWithTag (tagField, tag) model =
Encode.object <| encodePairs model ++ [ ( tagField, Encode.string tag ) ]
encodePairs : Fills -> List (String, Encode.Value)
encodePairs model =
[ ( "time", Maybe.withDefault Encode.null (Maybe.map DateOnly.encode model.time) )
, ( "price", Maybe.withDefault Encode.null (Maybe.map Encode.float model.price) )
, ( "amount", Maybe.withDefault Encode.null (Maybe.map Encode.float model.amount) )
]
toString : Fills -> String
toString =
Encode.encode 0 << encode
| elm |
[
{
"context": " Username\n [ Textfield.ID \"login_username\"\n , Textfield.Hint \"Username\"\n ",
"end": 2105,
"score": 0.9417398572,
"start": 2091,
"tag": "USERNAME",
"value": "login_username"
},
{
"context": "ath = \"/api/manage/login\"\n , username = usernameModel\n , password = passwordModel\n ",
"end": 2889,
"score": 0.9943056703,
"start": 2876,
"tag": "USERNAME",
"value": "usernameModel"
},
{
"context": " username = usernameModel\n , password = passwordModel\n , state = Unauthorized Nothing\n ",
"end": 2928,
"score": 0.9991513491,
"start": 2915,
"tag": "PASSWORD",
"value": "passwordModel"
},
{
"context": " ]\n\n m2 =\n { m1 | username = um, password = pm }\n in\n case authErr of\n ",
"end": 4507,
"score": 0.8962560892,
"start": 4505,
"tag": "USERNAME",
"value": "um"
},
{
"context": " m2 =\n { m1 | username = um, password = pm }\n in\n case authErr of\n Othe",
"end": 4522,
"score": 0.9978394508,
"start": 4520,
"tag": "PASSWORD",
"value": "pm"
},
{
"context": " in\n ( { m2 | username = um }\n , Task.attempt ignore (Dom.",
"end": 5001,
"score": 0.9830653667,
"start": 4999,
"tag": "USERNAME",
"value": "um"
},
{
"context": "er _ wrongUsername)) ->\n if username == wrongUsername then\n Textfield.updateModel\n ",
"end": 5797,
"score": 0.8598778844,
"start": 5784,
"tag": "USERNAME",
"value": "wrongUsername"
}
] | src/login/Login.elm | yizha/article-cms-ui | 2 | module Login
exposing
( Model
, Msg
, view
, update
, init
, subscriptions
, authToken
, logout
)
import Global
import Html exposing (..)
import Html.Attributes exposing (href, class, style, disabled)
import Html.Events exposing (onClick)
import Dom
import Date
import Time
import Http
import Task
import Mouse
import Keyboard
import Json.Decode as Json
import Json.Decode.Extra as JsonExtra
import Common.Debug exposing (debug)
import Common.Util exposing (httpErrorString)
import MDC.Textfield as Textfield
-- MODEL
type alias AuthData =
{ token : String
, expire : Time.Time
, role : Int
}
type AuthError
= NoSuchUser Http.Error String
| WrongPassword Http.Error String
| OtherError Http.Error
authError : Http.Error -> String -> String -> AuthError
authError err username password =
case err of
Http.BadStatus resp ->
case resp.status.code of
403 ->
case resp.body of
"username" ->
NoSuchUser err username
"password" ->
WrongPassword err password
_ ->
OtherError err
_ ->
OtherError err
_ ->
OtherError err
type State
= Authorized AuthData
| Unauthorized (Maybe AuthError)
| InProgress
type alias Model =
{ loginPath : String
, username : Textfield.Model Msg
, password : Textfield.Model Msg
, state : State
, lastActivityTime : Maybe Time.Time
, maxIdleTime : Time.Time
}
authToken : Model -> Maybe String
authToken model =
case model.state of
Authorized data ->
Just data.token
_ ->
Nothing
logout : Model -> ( Model, Cmd Msg )
logout model =
init
init : ( Model, Cmd Msg )
init =
let
usernameModel =
Textfield.init
Username
[ Textfield.ID "login_username"
, Textfield.Hint "Username"
, Textfield.HelpAsValidationMsg True
, Textfield.OnInput (Just UsernameInput)
, Textfield.OnEnter (Just (LoginRequest (Just "login_username")))
]
passwordModel =
Textfield.init
Password
[ Textfield.Type Textfield.Password
, Textfield.ID "login_password"
, Textfield.Hint "Password"
, Textfield.HelpAsValidationMsg True
, Textfield.OnInput (Just PasswordInput)
, Textfield.OnEnter (Just (LoginRequest (Just "login_password")))
]
m =
{ loginPath = "/api/manage/login"
, username = usernameModel
, password = passwordModel
, state = Unauthorized Nothing
, lastActivityTime = Nothing
, maxIdleTime = (Time.minute * 30)
}
in
m ! [ Task.attempt ignore (Dom.focus "login_username") ]
-- ACTION, UPDATE
type Msg
= Ignore
| Username (Textfield.Msg Msg)
| Password (Textfield.Msg Msg)
| UsernameInput String
| PasswordInput String
| LoginRequest (Maybe String)
| LoginResponse (Result Http.Error AuthData)
| UserActivity
| LogUserActivity Time.Time
| CheckIdleTimeout Time.Time
ignore : a -> Msg
ignore =
always Ignore
checkIdleTimeout : Time.Time -> Model -> ( Model, Cmd Msg )
checkIdleTimeout now model =
case model.lastActivityTime of
Just t ->
if now - t > model.maxIdleTime then
init
else
( model, Cmd.none )
Nothing ->
( model, Cmd.none )
handleLoginErr : Http.Error -> Model -> ( Model, Cmd Msg, Global.Event )
handleLoginErr err model =
let
authErr =
authError err model.username.value model.password.value
m1 =
{ model | state = Unauthorized (Just authErr) }
um =
Textfield.updateModel
model.username
[ Textfield.Help ""
, Textfield.Valid True
]
pm =
Textfield.updateModel
model.password
[ Textfield.Help ""
, Textfield.Valid True
]
m2 =
{ m1 | username = um, password = pm }
in
case authErr of
OtherError err ->
( m2, Cmd.none, Global.None )
NoSuchUser _ _ ->
let
um =
Textfield.updateModel
model.username
[ Textfield.Help "No such user!"
, Textfield.Valid False
]
in
( { m2 | username = um }
, Task.attempt ignore (Dom.focus "login_username")
, Global.None
)
WrongPassword _ _ ->
let
pm =
Textfield.updateModel
model.password
[ Textfield.Help "Wrong password!"
, Textfield.Valid False
]
in
( { m2 | password = pm }, Task.attempt ignore (Dom.focus "login_password"), Global.None )
handleUsernameInput : Model -> String -> Textfield.Model Msg
handleUsernameInput model username =
case model.state of
Unauthorized (Just (NoSuchUser _ wrongUsername)) ->
if username == wrongUsername then
Textfield.updateModel
model.username
[ Textfield.Value username
, Textfield.Valid False
, Textfield.Help "No such user!"
]
else
Textfield.updateModel
model.username
[ Textfield.Value username
, Textfield.Valid True
, Textfield.Help ""
]
_ ->
Textfield.updateModel model.username [ Textfield.Value username ]
handlePasswordInput : Model -> String -> Textfield.Model Msg
handlePasswordInput model password =
case model.state of
Unauthorized (Just (WrongPassword _ wrongPassword)) ->
if password == wrongPassword then
Textfield.updateModel
model.password
[ Textfield.Value password
, Textfield.Valid False
, Textfield.Help "Wrong password!"
]
else
Textfield.updateModel
model.password
[ Textfield.Value password
, Textfield.Valid True
, Textfield.Help ""
]
_ ->
(Textfield.updateModel model.password [ Textfield.Value password ])
update : Msg -> Model -> ( Model, Cmd Msg, Global.Event )
update msg model =
case msg of
Ignore ->
( model, Cmd.none, Global.None )
Username tfm ->
let
m =
Textfield.update tfm model.username
in
( { model | username = m }, Cmd.none, Global.None )
Password tfm ->
let
m =
Textfield.update tfm model.password
in
( { model | password = m }, Cmd.none, Global.None )
UsernameInput v ->
let
um =
handleUsernameInput model v
in
( { model | username = um }, Cmd.none, Global.None )
PasswordInput v ->
let
pm =
handlePasswordInput model v
in
( { model | password = pm }, Cmd.none, Global.None )
LoginRequest source ->
if model.username.value /= "" && model.password.value /= "" then
let
task =
case source of
Nothing ->
getAuthData model.loginPath model.username.value model.password.value
Just id ->
Cmd.batch
[ Task.attempt ignore (Dom.blur id)
, getAuthData model.loginPath model.username.value model.password.value
]
in
( debug "login-request" { model | state = InProgress }
, task
, Global.None
)
else
( model, Cmd.none, Global.None )
LoginResponse (Ok authdata) ->
( debug "login-ok" { model | state = Authorized authdata }
, Task.perform LogUserActivity Time.now
, Global.Login model.username.value authdata.token
)
LoginResponse (Err err) ->
handleLoginErr err model
UserActivity ->
( model, Task.perform LogUserActivity Time.now, Global.None )
LogUserActivity time ->
( { model | lastActivityTime = Just time }, Cmd.none, Global.None )
CheckIdleTimeout time ->
let
( m, c ) =
checkIdleTimeout time model
in
( debug "login-check" m, c, Global.None )
-- VIEW
disableLoginBtn : Model -> Bool
disableLoginBtn model =
model.username.value == "" || model.password.value == "" || model.state == InProgress
noSuchUserErr : Model -> String
noSuchUserErr model =
case model.state of
Unauthorized (Just (NoSuchUser _ username)) ->
if model.username.value == username then
"No such user!"
else
""
_ ->
""
wrongPasswordErr : Model -> String
wrongPasswordErr model =
case model.state of
Unauthorized (Just (WrongPassword _ password)) ->
if model.password.value == password then
"Wrong password!"
else
""
_ ->
""
otherErr : Model -> String
otherErr model =
case model.state of
Unauthorized (Just (OtherError err)) ->
httpErrorString model.loginPath err
_ ->
""
view : Model -> Html Msg
view model =
let
um =
(Textfield.updateModel
model.username
[ Textfield.Disabled (model.state == InProgress) ]
)
pm =
(Textfield.updateModel
model.password
[ Textfield.Disabled (model.state == InProgress) ]
)
in
ul [ style [ ( "list-style-type", "none" ) ] ]
[ li []
[ div
[ style
[ ( "padding", "8rem 2rem 2rem 2rem" )
, ( "display", "flex" )
, ( "align-items", "center" )
, ( "justify-content", "center" )
]
]
[ ul [ class "mdc-list" ]
[ li [ class "mdc-list-item" ] [ Textfield.view um ]
, li [ class "mdc-list-item" ] []
, li [ class "mdc-list-item" ] [ Textfield.view pm ]
, li [ class "mdc-list-item" ] []
, li [ class "mdc-list-item" ]
[ button
[ class "mdc-button mdc-button--raised"
, disabled (disableLoginBtn model)
, onClick (LoginRequest Nothing)
]
[ text "Login" ]
]
]
]
]
, li []
[ p [ style [ ( "color", "red" ) ] ]
[ text (otherErr model) ]
]
]
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
case model.state of
Authorized _ ->
Sub.batch
[ Mouse.clicks (\_ -> UserActivity)
, Keyboard.presses (\_ -> UserActivity)
, Time.every Time.minute CheckIdleTimeout
]
_ ->
Sub.none
-- HTTP
getAuthData : String -> String -> String -> Cmd Msg
getAuthData path username password =
let
url =
path ++ "?username=" ++ username ++ "&password=" ++ password
in
Http.send LoginResponse (Http.get url decodeAuthData)
decodeAuthData : Json.Decoder AuthData
decodeAuthData =
Json.map3 AuthData
(Json.field "token" Json.string)
(Json.map Date.toTime (Json.field "expire" JsonExtra.date))
(Json.field "role" Json.int)
| 8494 | module Login
exposing
( Model
, Msg
, view
, update
, init
, subscriptions
, authToken
, logout
)
import Global
import Html exposing (..)
import Html.Attributes exposing (href, class, style, disabled)
import Html.Events exposing (onClick)
import Dom
import Date
import Time
import Http
import Task
import Mouse
import Keyboard
import Json.Decode as Json
import Json.Decode.Extra as JsonExtra
import Common.Debug exposing (debug)
import Common.Util exposing (httpErrorString)
import MDC.Textfield as Textfield
-- MODEL
type alias AuthData =
{ token : String
, expire : Time.Time
, role : Int
}
type AuthError
= NoSuchUser Http.Error String
| WrongPassword Http.Error String
| OtherError Http.Error
authError : Http.Error -> String -> String -> AuthError
authError err username password =
case err of
Http.BadStatus resp ->
case resp.status.code of
403 ->
case resp.body of
"username" ->
NoSuchUser err username
"password" ->
WrongPassword err password
_ ->
OtherError err
_ ->
OtherError err
_ ->
OtherError err
type State
= Authorized AuthData
| Unauthorized (Maybe AuthError)
| InProgress
type alias Model =
{ loginPath : String
, username : Textfield.Model Msg
, password : Textfield.Model Msg
, state : State
, lastActivityTime : Maybe Time.Time
, maxIdleTime : Time.Time
}
authToken : Model -> Maybe String
authToken model =
case model.state of
Authorized data ->
Just data.token
_ ->
Nothing
logout : Model -> ( Model, Cmd Msg )
logout model =
init
init : ( Model, Cmd Msg )
init =
let
usernameModel =
Textfield.init
Username
[ Textfield.ID "login_username"
, Textfield.Hint "Username"
, Textfield.HelpAsValidationMsg True
, Textfield.OnInput (Just UsernameInput)
, Textfield.OnEnter (Just (LoginRequest (Just "login_username")))
]
passwordModel =
Textfield.init
Password
[ Textfield.Type Textfield.Password
, Textfield.ID "login_password"
, Textfield.Hint "Password"
, Textfield.HelpAsValidationMsg True
, Textfield.OnInput (Just PasswordInput)
, Textfield.OnEnter (Just (LoginRequest (Just "login_password")))
]
m =
{ loginPath = "/api/manage/login"
, username = usernameModel
, password = <PASSWORD>
, state = Unauthorized Nothing
, lastActivityTime = Nothing
, maxIdleTime = (Time.minute * 30)
}
in
m ! [ Task.attempt ignore (Dom.focus "login_username") ]
-- ACTION, UPDATE
type Msg
= Ignore
| Username (Textfield.Msg Msg)
| Password (Textfield.Msg Msg)
| UsernameInput String
| PasswordInput String
| LoginRequest (Maybe String)
| LoginResponse (Result Http.Error AuthData)
| UserActivity
| LogUserActivity Time.Time
| CheckIdleTimeout Time.Time
ignore : a -> Msg
ignore =
always Ignore
checkIdleTimeout : Time.Time -> Model -> ( Model, Cmd Msg )
checkIdleTimeout now model =
case model.lastActivityTime of
Just t ->
if now - t > model.maxIdleTime then
init
else
( model, Cmd.none )
Nothing ->
( model, Cmd.none )
handleLoginErr : Http.Error -> Model -> ( Model, Cmd Msg, Global.Event )
handleLoginErr err model =
let
authErr =
authError err model.username.value model.password.value
m1 =
{ model | state = Unauthorized (Just authErr) }
um =
Textfield.updateModel
model.username
[ Textfield.Help ""
, Textfield.Valid True
]
pm =
Textfield.updateModel
model.password
[ Textfield.Help ""
, Textfield.Valid True
]
m2 =
{ m1 | username = um, password = <PASSWORD> }
in
case authErr of
OtherError err ->
( m2, Cmd.none, Global.None )
NoSuchUser _ _ ->
let
um =
Textfield.updateModel
model.username
[ Textfield.Help "No such user!"
, Textfield.Valid False
]
in
( { m2 | username = um }
, Task.attempt ignore (Dom.focus "login_username")
, Global.None
)
WrongPassword _ _ ->
let
pm =
Textfield.updateModel
model.password
[ Textfield.Help "Wrong password!"
, Textfield.Valid False
]
in
( { m2 | password = pm }, Task.attempt ignore (Dom.focus "login_password"), Global.None )
handleUsernameInput : Model -> String -> Textfield.Model Msg
handleUsernameInput model username =
case model.state of
Unauthorized (Just (NoSuchUser _ wrongUsername)) ->
if username == wrongUsername then
Textfield.updateModel
model.username
[ Textfield.Value username
, Textfield.Valid False
, Textfield.Help "No such user!"
]
else
Textfield.updateModel
model.username
[ Textfield.Value username
, Textfield.Valid True
, Textfield.Help ""
]
_ ->
Textfield.updateModel model.username [ Textfield.Value username ]
handlePasswordInput : Model -> String -> Textfield.Model Msg
handlePasswordInput model password =
case model.state of
Unauthorized (Just (WrongPassword _ wrongPassword)) ->
if password == wrongPassword then
Textfield.updateModel
model.password
[ Textfield.Value password
, Textfield.Valid False
, Textfield.Help "Wrong password!"
]
else
Textfield.updateModel
model.password
[ Textfield.Value password
, Textfield.Valid True
, Textfield.Help ""
]
_ ->
(Textfield.updateModel model.password [ Textfield.Value password ])
update : Msg -> Model -> ( Model, Cmd Msg, Global.Event )
update msg model =
case msg of
Ignore ->
( model, Cmd.none, Global.None )
Username tfm ->
let
m =
Textfield.update tfm model.username
in
( { model | username = m }, Cmd.none, Global.None )
Password tfm ->
let
m =
Textfield.update tfm model.password
in
( { model | password = m }, Cmd.none, Global.None )
UsernameInput v ->
let
um =
handleUsernameInput model v
in
( { model | username = um }, Cmd.none, Global.None )
PasswordInput v ->
let
pm =
handlePasswordInput model v
in
( { model | password = pm }, Cmd.none, Global.None )
LoginRequest source ->
if model.username.value /= "" && model.password.value /= "" then
let
task =
case source of
Nothing ->
getAuthData model.loginPath model.username.value model.password.value
Just id ->
Cmd.batch
[ Task.attempt ignore (Dom.blur id)
, getAuthData model.loginPath model.username.value model.password.value
]
in
( debug "login-request" { model | state = InProgress }
, task
, Global.None
)
else
( model, Cmd.none, Global.None )
LoginResponse (Ok authdata) ->
( debug "login-ok" { model | state = Authorized authdata }
, Task.perform LogUserActivity Time.now
, Global.Login model.username.value authdata.token
)
LoginResponse (Err err) ->
handleLoginErr err model
UserActivity ->
( model, Task.perform LogUserActivity Time.now, Global.None )
LogUserActivity time ->
( { model | lastActivityTime = Just time }, Cmd.none, Global.None )
CheckIdleTimeout time ->
let
( m, c ) =
checkIdleTimeout time model
in
( debug "login-check" m, c, Global.None )
-- VIEW
disableLoginBtn : Model -> Bool
disableLoginBtn model =
model.username.value == "" || model.password.value == "" || model.state == InProgress
noSuchUserErr : Model -> String
noSuchUserErr model =
case model.state of
Unauthorized (Just (NoSuchUser _ username)) ->
if model.username.value == username then
"No such user!"
else
""
_ ->
""
wrongPasswordErr : Model -> String
wrongPasswordErr model =
case model.state of
Unauthorized (Just (WrongPassword _ password)) ->
if model.password.value == password then
"Wrong password!"
else
""
_ ->
""
otherErr : Model -> String
otherErr model =
case model.state of
Unauthorized (Just (OtherError err)) ->
httpErrorString model.loginPath err
_ ->
""
view : Model -> Html Msg
view model =
let
um =
(Textfield.updateModel
model.username
[ Textfield.Disabled (model.state == InProgress) ]
)
pm =
(Textfield.updateModel
model.password
[ Textfield.Disabled (model.state == InProgress) ]
)
in
ul [ style [ ( "list-style-type", "none" ) ] ]
[ li []
[ div
[ style
[ ( "padding", "8rem 2rem 2rem 2rem" )
, ( "display", "flex" )
, ( "align-items", "center" )
, ( "justify-content", "center" )
]
]
[ ul [ class "mdc-list" ]
[ li [ class "mdc-list-item" ] [ Textfield.view um ]
, li [ class "mdc-list-item" ] []
, li [ class "mdc-list-item" ] [ Textfield.view pm ]
, li [ class "mdc-list-item" ] []
, li [ class "mdc-list-item" ]
[ button
[ class "mdc-button mdc-button--raised"
, disabled (disableLoginBtn model)
, onClick (LoginRequest Nothing)
]
[ text "Login" ]
]
]
]
]
, li []
[ p [ style [ ( "color", "red" ) ] ]
[ text (otherErr model) ]
]
]
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
case model.state of
Authorized _ ->
Sub.batch
[ Mouse.clicks (\_ -> UserActivity)
, Keyboard.presses (\_ -> UserActivity)
, Time.every Time.minute CheckIdleTimeout
]
_ ->
Sub.none
-- HTTP
getAuthData : String -> String -> String -> Cmd Msg
getAuthData path username password =
let
url =
path ++ "?username=" ++ username ++ "&password=" ++ password
in
Http.send LoginResponse (Http.get url decodeAuthData)
decodeAuthData : Json.Decoder AuthData
decodeAuthData =
Json.map3 AuthData
(Json.field "token" Json.string)
(Json.map Date.toTime (Json.field "expire" JsonExtra.date))
(Json.field "role" Json.int)
| true | module Login
exposing
( Model
, Msg
, view
, update
, init
, subscriptions
, authToken
, logout
)
import Global
import Html exposing (..)
import Html.Attributes exposing (href, class, style, disabled)
import Html.Events exposing (onClick)
import Dom
import Date
import Time
import Http
import Task
import Mouse
import Keyboard
import Json.Decode as Json
import Json.Decode.Extra as JsonExtra
import Common.Debug exposing (debug)
import Common.Util exposing (httpErrorString)
import MDC.Textfield as Textfield
-- MODEL
type alias AuthData =
{ token : String
, expire : Time.Time
, role : Int
}
type AuthError
= NoSuchUser Http.Error String
| WrongPassword Http.Error String
| OtherError Http.Error
authError : Http.Error -> String -> String -> AuthError
authError err username password =
case err of
Http.BadStatus resp ->
case resp.status.code of
403 ->
case resp.body of
"username" ->
NoSuchUser err username
"password" ->
WrongPassword err password
_ ->
OtherError err
_ ->
OtherError err
_ ->
OtherError err
type State
= Authorized AuthData
| Unauthorized (Maybe AuthError)
| InProgress
type alias Model =
{ loginPath : String
, username : Textfield.Model Msg
, password : Textfield.Model Msg
, state : State
, lastActivityTime : Maybe Time.Time
, maxIdleTime : Time.Time
}
authToken : Model -> Maybe String
authToken model =
case model.state of
Authorized data ->
Just data.token
_ ->
Nothing
logout : Model -> ( Model, Cmd Msg )
logout model =
init
init : ( Model, Cmd Msg )
init =
let
usernameModel =
Textfield.init
Username
[ Textfield.ID "login_username"
, Textfield.Hint "Username"
, Textfield.HelpAsValidationMsg True
, Textfield.OnInput (Just UsernameInput)
, Textfield.OnEnter (Just (LoginRequest (Just "login_username")))
]
passwordModel =
Textfield.init
Password
[ Textfield.Type Textfield.Password
, Textfield.ID "login_password"
, Textfield.Hint "Password"
, Textfield.HelpAsValidationMsg True
, Textfield.OnInput (Just PasswordInput)
, Textfield.OnEnter (Just (LoginRequest (Just "login_password")))
]
m =
{ loginPath = "/api/manage/login"
, username = usernameModel
, password = PI:PASSWORD:<PASSWORD>END_PI
, state = Unauthorized Nothing
, lastActivityTime = Nothing
, maxIdleTime = (Time.minute * 30)
}
in
m ! [ Task.attempt ignore (Dom.focus "login_username") ]
-- ACTION, UPDATE
type Msg
= Ignore
| Username (Textfield.Msg Msg)
| Password (Textfield.Msg Msg)
| UsernameInput String
| PasswordInput String
| LoginRequest (Maybe String)
| LoginResponse (Result Http.Error AuthData)
| UserActivity
| LogUserActivity Time.Time
| CheckIdleTimeout Time.Time
ignore : a -> Msg
ignore =
always Ignore
checkIdleTimeout : Time.Time -> Model -> ( Model, Cmd Msg )
checkIdleTimeout now model =
case model.lastActivityTime of
Just t ->
if now - t > model.maxIdleTime then
init
else
( model, Cmd.none )
Nothing ->
( model, Cmd.none )
handleLoginErr : Http.Error -> Model -> ( Model, Cmd Msg, Global.Event )
handleLoginErr err model =
let
authErr =
authError err model.username.value model.password.value
m1 =
{ model | state = Unauthorized (Just authErr) }
um =
Textfield.updateModel
model.username
[ Textfield.Help ""
, Textfield.Valid True
]
pm =
Textfield.updateModel
model.password
[ Textfield.Help ""
, Textfield.Valid True
]
m2 =
{ m1 | username = um, password = PI:PASSWORD:<PASSWORD>END_PI }
in
case authErr of
OtherError err ->
( m2, Cmd.none, Global.None )
NoSuchUser _ _ ->
let
um =
Textfield.updateModel
model.username
[ Textfield.Help "No such user!"
, Textfield.Valid False
]
in
( { m2 | username = um }
, Task.attempt ignore (Dom.focus "login_username")
, Global.None
)
WrongPassword _ _ ->
let
pm =
Textfield.updateModel
model.password
[ Textfield.Help "Wrong password!"
, Textfield.Valid False
]
in
( { m2 | password = pm }, Task.attempt ignore (Dom.focus "login_password"), Global.None )
handleUsernameInput : Model -> String -> Textfield.Model Msg
handleUsernameInput model username =
case model.state of
Unauthorized (Just (NoSuchUser _ wrongUsername)) ->
if username == wrongUsername then
Textfield.updateModel
model.username
[ Textfield.Value username
, Textfield.Valid False
, Textfield.Help "No such user!"
]
else
Textfield.updateModel
model.username
[ Textfield.Value username
, Textfield.Valid True
, Textfield.Help ""
]
_ ->
Textfield.updateModel model.username [ Textfield.Value username ]
handlePasswordInput : Model -> String -> Textfield.Model Msg
handlePasswordInput model password =
case model.state of
Unauthorized (Just (WrongPassword _ wrongPassword)) ->
if password == wrongPassword then
Textfield.updateModel
model.password
[ Textfield.Value password
, Textfield.Valid False
, Textfield.Help "Wrong password!"
]
else
Textfield.updateModel
model.password
[ Textfield.Value password
, Textfield.Valid True
, Textfield.Help ""
]
_ ->
(Textfield.updateModel model.password [ Textfield.Value password ])
update : Msg -> Model -> ( Model, Cmd Msg, Global.Event )
update msg model =
case msg of
Ignore ->
( model, Cmd.none, Global.None )
Username tfm ->
let
m =
Textfield.update tfm model.username
in
( { model | username = m }, Cmd.none, Global.None )
Password tfm ->
let
m =
Textfield.update tfm model.password
in
( { model | password = m }, Cmd.none, Global.None )
UsernameInput v ->
let
um =
handleUsernameInput model v
in
( { model | username = um }, Cmd.none, Global.None )
PasswordInput v ->
let
pm =
handlePasswordInput model v
in
( { model | password = pm }, Cmd.none, Global.None )
LoginRequest source ->
if model.username.value /= "" && model.password.value /= "" then
let
task =
case source of
Nothing ->
getAuthData model.loginPath model.username.value model.password.value
Just id ->
Cmd.batch
[ Task.attempt ignore (Dom.blur id)
, getAuthData model.loginPath model.username.value model.password.value
]
in
( debug "login-request" { model | state = InProgress }
, task
, Global.None
)
else
( model, Cmd.none, Global.None )
LoginResponse (Ok authdata) ->
( debug "login-ok" { model | state = Authorized authdata }
, Task.perform LogUserActivity Time.now
, Global.Login model.username.value authdata.token
)
LoginResponse (Err err) ->
handleLoginErr err model
UserActivity ->
( model, Task.perform LogUserActivity Time.now, Global.None )
LogUserActivity time ->
( { model | lastActivityTime = Just time }, Cmd.none, Global.None )
CheckIdleTimeout time ->
let
( m, c ) =
checkIdleTimeout time model
in
( debug "login-check" m, c, Global.None )
-- VIEW
disableLoginBtn : Model -> Bool
disableLoginBtn model =
model.username.value == "" || model.password.value == "" || model.state == InProgress
noSuchUserErr : Model -> String
noSuchUserErr model =
case model.state of
Unauthorized (Just (NoSuchUser _ username)) ->
if model.username.value == username then
"No such user!"
else
""
_ ->
""
wrongPasswordErr : Model -> String
wrongPasswordErr model =
case model.state of
Unauthorized (Just (WrongPassword _ password)) ->
if model.password.value == password then
"Wrong password!"
else
""
_ ->
""
otherErr : Model -> String
otherErr model =
case model.state of
Unauthorized (Just (OtherError err)) ->
httpErrorString model.loginPath err
_ ->
""
view : Model -> Html Msg
view model =
let
um =
(Textfield.updateModel
model.username
[ Textfield.Disabled (model.state == InProgress) ]
)
pm =
(Textfield.updateModel
model.password
[ Textfield.Disabled (model.state == InProgress) ]
)
in
ul [ style [ ( "list-style-type", "none" ) ] ]
[ li []
[ div
[ style
[ ( "padding", "8rem 2rem 2rem 2rem" )
, ( "display", "flex" )
, ( "align-items", "center" )
, ( "justify-content", "center" )
]
]
[ ul [ class "mdc-list" ]
[ li [ class "mdc-list-item" ] [ Textfield.view um ]
, li [ class "mdc-list-item" ] []
, li [ class "mdc-list-item" ] [ Textfield.view pm ]
, li [ class "mdc-list-item" ] []
, li [ class "mdc-list-item" ]
[ button
[ class "mdc-button mdc-button--raised"
, disabled (disableLoginBtn model)
, onClick (LoginRequest Nothing)
]
[ text "Login" ]
]
]
]
]
, li []
[ p [ style [ ( "color", "red" ) ] ]
[ text (otherErr model) ]
]
]
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
case model.state of
Authorized _ ->
Sub.batch
[ Mouse.clicks (\_ -> UserActivity)
, Keyboard.presses (\_ -> UserActivity)
, Time.every Time.minute CheckIdleTimeout
]
_ ->
Sub.none
-- HTTP
getAuthData : String -> String -> String -> Cmd Msg
getAuthData path username password =
let
url =
path ++ "?username=" ++ username ++ "&password=" ++ password
in
Http.send LoginResponse (Http.get url decodeAuthData)
decodeAuthData : Json.Decoder AuthData
decodeAuthData =
Json.map3 AuthData
(Json.field "token" Json.string)
(Json.map Date.toTime (Json.field "expire" JsonExtra.date))
(Json.field "role" Json.int)
| elm |
[{"context":" ]\n \nkey : ColumnDesc -> String\nkey =\n .name\n \n\ntablesView : Mode(...TRUNCATED) | mdl_example/Main.elm | ali--/elm-polymer-cookiecutter | 0 | "module Main exposing (..)\nimport Html exposing (..)\nimport Http exposing (..)\nimport Html.Attrib(...TRUNCATED) | 8854 | "module Main exposing (..)\nimport Html exposing (..)\nimport Http exposing (..)\nimport Html.Attrib(...TRUNCATED) | true | "module Main exposing (..)\nimport Html exposing (..)\nimport Http exposing (..)\nimport Html.Attrib(...TRUNCATED) | elm |
[{"context":"Page -> Model\ndefaultModel key page =\n { name = \"Brian\"\n , page = page\n , key (...TRUNCATED) | runner/elm-spec-harness/test/browserTests/harness/src/Navigation/App.elm | elm-review-bot/elm-spec | 0 | "port module Navigation.App exposing (..)\n\nimport Html exposing (Html)\nimport Html.Attributes as (...TRUNCATED) | 15975 | "port module Navigation.App exposing (..)\n\nimport Html exposing (Html)\nimport Html.Attributes as (...TRUNCATED) | true | "port module Navigation.App exposing (..)\n\nimport Html exposing (Html)\nimport Html.Attributes as (...TRUNCATED) | elm |
[{"context":", ( \" 345 m \", Ok 345 )\n\n -- 2020-03-12 from TheRealManiac (https://forum.bot(...TRUNCATED) | implement/alternate-ui/source/tests/ParseMemoryReadingTest.elm | Threepwood-eve/Sanderling | 0 | "module ParseMemoryReadingTest exposing (allTests)\n\nimport Common.EffectOnWindow\nimport EveOnline(...TRUNCATED) | 25941 | "module ParseMemoryReadingTest exposing (allTests)\n\nimport Common.EffectOnWindow\nimport EveOnline(...TRUNCATED) | true | "module ParseMemoryReadingTest exposing (allTests)\n\nimport Common.EffectOnWindow\nimport EveOnline(...TRUNCATED) | elm |
End of preview. Expand
in Dataset Viewer.
- Downloads last month
- 38