yagcdn/frontend/src/Data.elm
Valentin Brandl 3f5b118ac5
All checks were successful
continuous-integration/drone/push Build is passing
Rename project
2019-08-09 19:43:58 +02:00

53 lines
838 B
Elm

module Data exposing (Provider(..), Url, hostname, pathSeparator, toUrl)
hostname : String
hostname =
"https://yagcdn.tk/"
type Provider
= GitHub
| Bitbucket
| GitLab
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/"
GitLab ->
"gitlab/"
pathSeparator : Provider -> String
pathSeparator prov =
case prov of
GitHub ->
"blob"
Bitbucket ->
"src"
GitLab ->
"blob"
toUrl : Url -> String
toUrl { prov, user, repo, gitref, file } =
hostname ++ toHost prov ++ String.join "/" [ user, repo, gitref, file ]