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
|
2019-07-28 17:32:50 +02:00
|
|
|
| GitLab
|
2019-07-27 16:24:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
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/"
|
|
|
|
|
2019-07-28 17:32:50 +02:00
|
|
|
GitLab ->
|
|
|
|
"gitlab/"
|
|
|
|
|
2019-07-27 16:24:13 +02:00
|
|
|
|
|
|
|
pathSeparator : Provider -> String
|
|
|
|
pathSeparator prov =
|
|
|
|
case prov of
|
|
|
|
GitHub ->
|
|
|
|
"blob"
|
|
|
|
|
|
|
|
Bitbucket ->
|
|
|
|
"src"
|
|
|
|
|
2019-07-28 17:32:50 +02:00
|
|
|
GitLab ->
|
|
|
|
"blob"
|
|
|
|
|
2019-07-27 16:24:13 +02:00
|
|
|
|
|
|
|
toUrl : Url -> String
|
|
|
|
toUrl { prov, user, repo, gitref, file } =
|
2019-07-28 17:32:50 +02:00
|
|
|
hostname ++ toHost prov ++ String.join "/" [ user, repo, gitref, file ]
|