@ -42,7 +42,6 @@ type alias App =
|
||||
, website : Maybe String
|
||||
}
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ url : Url Params
|
||||
, status : Status
|
||||
@ -94,8 +93,12 @@ update msg model =
|
||||
Just item ->
|
||||
( { model | status = Success (item) }, loadREADME item)
|
||||
|
||||
Err _ ->
|
||||
( { model | status = Failure }, Cmd.none )
|
||||
Err err ->
|
||||
let
|
||||
_ =
|
||||
Debug.log "Something failed" err
|
||||
in
|
||||
( { model | status = Failure } , Cmd.none )
|
||||
|
||||
GotText result ->
|
||||
case result of
|
||||
@ -109,8 +112,12 @@ update msg model =
|
||||
in
|
||||
( { model | readme = Regex.replace regex (\_ -> "") content }, Cmd.none )
|
||||
|
||||
Err _ ->
|
||||
( { model | status = Failure }, Cmd.none )
|
||||
Err err ->
|
||||
let
|
||||
_ =
|
||||
Debug.log "Something failed" err
|
||||
in
|
||||
( { model | status = Failure } , Cmd.none )
|
||||
|
||||
|
||||
|
||||
@ -241,10 +248,8 @@ viewApp app readme =
|
||||
|
||||
loadApp : Cmd Msg
|
||||
loadApp =
|
||||
-- fetch app JSON and README in parallel
|
||||
Http.get
|
||||
-- FIXME: change to absolute URL, if this works?
|
||||
{ url = "/abra-apps-list.json"
|
||||
{ url = "/abra-apps.json"
|
||||
, expect = Http.expectJson GotApps appListDecoder }
|
||||
|
||||
|
||||
@ -260,12 +265,13 @@ loadREADME app =
|
||||
Nothing ->
|
||||
text ""
|
||||
in
|
||||
Http.get
|
||||
-- FIXME use live Gitea link
|
||||
{ url = "https://cors-container.herokuapp.com/https://git.autonomic.zone/coop-cloud/" ++ app.slug ++ "/raw/branch/" ++ app.default_branch ++ "/README.md"
|
||||
, expect = Http.expectString GotText }
|
||||
Http.get
|
||||
-- FIXME use live Gitea link
|
||||
{ url = "https://cors-container.herokuapp.com/https://git.autonomic.zone/coop-cloud/" ++ app.slug ++ "/raw/branch/" ++ app.default_branch ++ "/README.md"
|
||||
, expect = Http.expectString GotText }
|
||||
|
||||
|
||||
featuresDecoder : Decode.Decoder String
|
||||
featuresDecoder =
|
||||
-- get features.status if it's there
|
||||
(Decode.oneOf
|
||||
@ -284,11 +290,17 @@ appDecoder =
|
||||
|> andMap (Decode.succeed Nothing)
|
||||
|> andMap (Decode.maybe (Decode.field "icon" Decode.string))
|
||||
|> andMap (Decode.at [ "features" ] featuresDecoder)
|
||||
|> andMap (Decode.field "slug" Decode.string)
|
||||
|> andMap (Decode.succeed "")
|
||||
|> andMap (Decode.field "default_branch" Decode.string)
|
||||
|> andMap (Decode.maybe (Decode.field "website" Decode.string))
|
||||
|
||||
|
||||
appListDecoder : Decode.Decoder (List App)
|
||||
appListDecoder =
|
||||
Decode.list appDecoder
|
||||
Decode.keyValuePairs appDecoder
|
||||
|> Decode.map buildApp
|
||||
|
||||
|
||||
buildApp : List (String, App) -> (List App)
|
||||
buildApp apps =
|
||||
List.map (\(slug, app) -> { app | slug = slug}) apps
|
||||
|
Reference in New Issue
Block a user