yagcdn/frontend/src/Data.elm

46 lines
774 B
Elm
Raw Normal View History

2019-07-27 20:33:26 +02:00
module Data exposing (Provider(..), Url, hostname, pathSeparator, toHost, toUrl)
2019-07-27 16:24:13 +02:00
hostname : String
hostname =
2019-07-27 20:33:26 +02:00
"https://gitcdn.tk/"
2019-07-27 16:24:13 +02:00
type Provider
= GitHub
| Bitbucket
type alias Url =
{ prov : Provider
, user : String
, repo : String
, gitref : String
, file : String
}
toHost : Provider -> String
toHost prov =
case prov of
GitHub ->
"github/"
Bitbucket ->
"bitbucket/"
pathSeparator : Provider -> String
pathSeparator prov =
case prov of
GitHub ->
"blob"
Bitbucket ->
"src"
toUrl : Url -> String
toUrl { prov, user, repo, gitref, file } =
hostname ++ toHost prov ++ String.join "/" [ user, repo, pathSeparator prov, gitref, file ]