-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pamplemousse
committed
Dec 1, 2024
1 parent
563b305
commit 47a420c
Showing
16 changed files
with
315 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Decoders exposing (decodeDate, decodeUrl) | ||
|
||
import Date exposing (Date) | ||
import Json.Decode as Decode exposing (Decoder) | ||
import Url exposing (Protocol(..), Url) | ||
|
||
|
||
decodeDate : Decoder Date | ||
decodeDate = | ||
Decode.andThen | ||
(\s -> | ||
case Date.fromIsoString s of | ||
Ok l -> | ||
Decode.succeed l | ||
|
||
Err e -> | ||
Decode.fail e | ||
) | ||
Decode.string | ||
|
||
|
||
decodeUrl : Decoder (Maybe Url) | ||
decodeUrl = | ||
Decode.map Url.fromString Decode.string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Lang exposing (Lang(..), decoder, toString) | ||
|
||
import Json.Decode as Decode exposing (Decoder) | ||
|
||
|
||
type Lang | ||
= EN | ||
| FR | ||
|
||
|
||
decoder : Decoder Lang | ||
decoder = | ||
Decode.andThen | ||
(\s -> | ||
case fromString s of | ||
Ok l -> | ||
Decode.succeed l | ||
|
||
Err e -> | ||
Decode.fail e | ||
) | ||
Decode.string | ||
|
||
|
||
fromString : String -> Result String Lang | ||
fromString s = | ||
case s of | ||
"FR" -> | ||
Ok FR | ||
|
||
"EN" -> | ||
Ok EN | ||
|
||
_ -> | ||
Err "invalid language" | ||
|
||
|
||
toString : Lang -> String | ||
toString l = | ||
case l of | ||
FR -> | ||
"FR" | ||
|
||
EN -> | ||
"EN" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Talks.Decoders exposing (decoder) | ||
|
||
import Decoders exposing (decodeDate) | ||
import Json.Decode as Decode | ||
import Json.Decode.Pipeline exposing (optional, required) | ||
import Lang | ||
import Link | ||
import Talks.Models exposing (Conference, Talk) | ||
|
||
|
||
decoder : Decode.Decoder (List Talk) | ||
decoder = | ||
Decode.list talkDecoder | ||
|
||
|
||
talkDecoder : Decode.Decoder Talk | ||
talkDecoder = | ||
Decode.succeed Talk | ||
|> required "id" Decode.int | ||
|> required "title" Decode.string | ||
|> required "description" Decode.string | ||
|> required "conferences" (Decode.list conferenceDecoder) | ||
|
||
|
||
conferenceDecoder : Decode.Decoder Conference | ||
conferenceDecoder = | ||
Decode.succeed Conference | ||
|> required "organisation" Decode.string | ||
|> required "date" decodeDate | ||
|> required "duration" Decode.int | ||
|> required "lang" Lang.decoder | ||
|> optional "recording" (Decode.map Just (Link.decoderWithDefaultValue "📺 recording")) Nothing | ||
|> optional "slides" (Decode.map Just (Link.decoderWithDefaultValue "📜 slides")) Nothing | ||
|> optional "sources" (Decode.map Just (Link.decoderWithDefaultValue "🧑\u{200D}💻 sources")) Nothing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Talks.Models exposing (Conference, Talk, talksDefaultUrl) | ||
|
||
import Date exposing (Date) | ||
import Lang exposing (Lang) | ||
import Link | ||
import Url exposing (Protocol(..), Url) | ||
|
||
|
||
type alias Id = | ||
Int | ||
|
||
|
||
type alias Conference = | ||
{ organisation : String | ||
, date : Date | ||
, duration : Int | ||
, lang : Lang | ||
, recording : Maybe Link.Model | ||
, slides : Maybe Link.Model | ||
, sources : Maybe Link.Model | ||
} | ||
|
||
|
||
type alias Talk = | ||
{ id : Id | ||
, title : String | ||
, description : String | ||
, conferences : List Conference | ||
} | ||
|
||
|
||
talksDefaultUrl : Url | ||
talksDefaultUrl = | ||
Url Https "www.xaviermaso.com" Nothing "api/talks" Nothing Nothing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
module Talks.Views exposing (renderCurrent) | ||
|
||
import Colours exposing (Colour, toStringLight) | ||
import Date exposing (format, year) | ||
import Html exposing (Html, br, div, h1, h3, i, li, span, text, ul) | ||
import Html.Attributes exposing (class) | ||
import Html.Events exposing (onClick) | ||
import Html.Extra exposing (viewMaybe) | ||
import Lang | ||
import Link | ||
import Talks.Models exposing (Conference, Talk) | ||
import TiledList exposing (Msg(..)) | ||
|
||
|
||
renderCurrent : Colour -> Talk -> Html (Msg Talk) | ||
renderCurrent colour talk = | ||
let | ||
allYears = | ||
talk.conferences |> List.map (\c -> c.date |> year) | ||
|
||
yearMin = | ||
allYears |> List.minimum | ||
|
||
yearMax = | ||
allYears |> List.maximum | ||
|
||
dates = | ||
case ( yearMin, yearMax ) of | ||
( Just min, Just max ) -> | ||
Just | ||
(case min == max of | ||
True -> | ||
String.fromInt max | ||
|
||
False -> | ||
String.fromInt min ++ "-" ++ String.fromInt max | ||
) | ||
|
||
_ -> | ||
Nothing | ||
|
||
foo = | ||
dates |> viewMaybe (\ds -> h3 [ class "date" ] [ text ds ]) | ||
in | ||
div [ class "row" ] | ||
[ div [ class "col-md-12" ] | ||
[ div [ class ("list-component-description " ++ toStringLight colour) ] | ||
[ h1 [] [ text talk.title ] | ||
, foo | ||
|
||
-- , h3 | ||
-- [ class "date" ] | ||
-- [ text dates ] | ||
, div [ class "row" ] | ||
[ div | ||
[ class "col-md-12 textDesc" ] | ||
[ text talk.description ] | ||
] | ||
, renderConferences talk.conferences | ||
, i | ||
[ class "fa fa-close fa-2x close" | ||
, onClick (CloseDescriptionOf talk) | ||
] | ||
[] | ||
] | ||
] | ||
] | ||
|
||
|
||
renderConferences : List Conference -> Html (Msg Talk) | ||
renderConferences conferences = | ||
if List.isEmpty conferences then | ||
div [] [] | ||
|
||
else | ||
div [] | ||
[ br [] [] | ||
, div [ class "textDesc" ] [ text "Presented at the following venues:" ] | ||
, conferences |> List.map renderConference |> ul [ class "list-group list-group-flush" ] | ||
] | ||
|
||
|
||
renderConference : Conference -> Html (Msg Talk) | ||
renderConference c = | ||
let | ||
date = | ||
c.date |> format "MMMM y" | ||
|
||
recording = | ||
c.recording |> viewMaybe (Link.view >> Html.map LinkMsg >> (\s -> div [] [ s, span [ class "textDesc" ] [ text (" (" ++ (c.duration |> String.fromInt) ++ "min)") ] ])) | ||
|
||
slides = | ||
c.slides |> viewMaybe (Link.view >> Html.map LinkMsg) | ||
|
||
sources = | ||
c.sources |> viewMaybe (Link.view >> Html.map LinkMsg) | ||
in | ||
li [ class "list-group-item" ] | ||
[ div [ class "me-auto" ] | ||
[ div [ class "row" ] | ||
[ div [ class "col-md-2 textDesc" ] [ text date ] | ||
, div [ class "col-md-3 textDesc" ] [ text ("[" ++ (c.lang |> Lang.toString) ++ "] " ++ c.organisation) ] | ||
, div [ class "col-md-2" ] [ sources ] | ||
, div [ class "col-md-2" ] [ slides ] | ||
, div [ class "col-md-3" ] [ recording ] | ||
] | ||
] | ||
] |
Oops, something went wrong.