Update frontend

This commit is contained in:
Valentin Brandl 2019-07-29 21:16:33 +02:00
parent d5020d0b41
commit 63cf3866b6
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D
3 changed files with 52 additions and 46 deletions

View File

@ -1,4 +1,14 @@
module Data exposing (Provider(..), Url, hostname, pathSeparator, toHost, toUrl)
module Data exposing (Provider(..), Url, hostname, pathSeparator, repository, servicename, toUrl)
repository : String
repository =
"https://git.vbrandl.net/vbrandl/gitache"
servicename : String
servicename =
"GitCDN"
hostname : String

View File

@ -1,9 +1,9 @@
module Main exposing (Model, Msg(..), init, main, update, view)
import Browser
import Data exposing (Url, hostname, toHost, toUrl)
import Html exposing (Html, br, div, h1, input, table, td, text, tr)
import Html.Attributes exposing (disabled, placeholder, style, value)
import Data exposing (Url, hostname, repository, servicename, toUrl)
import Html exposing (Html, a, article, div, h1, input, li, nav, small, text, ul)
import Html.Attributes exposing (disabled, href, placeholder, style, value)
import Html.Events exposing (onInput)
import Parse exposing (parseUrl)
import Ribbon exposing (ribbon)
@ -33,37 +33,6 @@ update msg state =
{ state | url = newUrl, parsed = parseUrl newUrl }
renderUrl : Url -> Html msg
renderUrl { prov, user, repo, file } =
div myStyle
[ table myStyle
[ tr myStyle
[ td myStyle [ text "host" ]
, td myStyle [ text (toHost prov) ]
]
, tr []
[ td myStyle [ text "user" ]
, td myStyle [ text user ]
]
, tr myStyle
[ td myStyle [ text "repo" ]
, td myStyle [ text repo ]
]
, tr myStyle
[ td myStyle [ text "file" ]
, td myStyle [ text file ]
]
]
]
renderMUrl : Maybe Url -> Html msg
renderMUrl mUrl =
mUrl
|> Maybe.map renderUrl
|> Maybe.withDefault (div myStyle [ text "Parse Error" ])
displayMUrl : Maybe Url -> String
displayMUrl mUrl =
mUrl
@ -84,15 +53,42 @@ myStyle2 =
view : Model -> Html Msg
view state =
div myStyle
[ h1 []
[ text "Gitache" ]
, ribbon
, input (myStyle2 [ placeholder "URL to parse", value state.url, onInput UrlChange ])
[ header
, body state
, footer
]
header : Html msg
header =
Html.header []
[ h1 myStyle [ text servicename ]
, ribbon repository
]
footer : Html msg
footer =
Html.footer myStyle
[ nav []
[ ul []
[ li []
[ small []
[ text "Created by "
, a [ href "https://www.vbrandl.net/" ] [ text "Valentin Brandl" ]
, text "."
]
]
]
]
]
body : Model -> Html Msg
body state =
article myStyle
[ input (myStyle2 [ placeholder "GitHub/GitLab/Bitbucket URL", value state.url, onInput UrlChange ])
[]
, text
"Parsed URL: "
, br [] []
, renderMUrl state.parsed
, input (myStyle2 [ disabled True, value (displayMUrl state.parsed) ]) []
]

View File

@ -6,10 +6,10 @@ import Svg exposing (Svg, path, svg)
import Svg.Attributes exposing (class, d, fill, height, style, viewBox, width)
ribbon : Html msg
ribbon =
ribbon : String -> Html msg
ribbon repo =
a
[ href "https://github.com/vbrandl/gitache" ]
[ href repo ]
[ ribbonSvg ]