Compare commits

...

3 Commits

Author SHA1 Message Date
3wc a1fc0fa593 Update Drone to deploy to swarm-demo
continuous-integration/drone/push Build is passing Details
2021-05-04 18:37:15 +02:00
3wc 157c8f0c02 Add favicon 2021-05-04 18:27:55 +02:00
3wc e22980281a elm-format 2021-05-04 18:27:42 +02:00
4 changed files with 185 additions and 118 deletions

View File

@ -17,7 +17,8 @@ steps:
settings:
stack: dev_apps_coopcloud_tech
deploy_key:
from_secret: drone_ssh_swarm.autonomic.zone
from_secret: drone_ssh_swarm-demo.autonomic.zone
host: swarm-demo.autonomic.zone
trigger:
branch:
- main

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -1,19 +1,20 @@
module Pages.App_String exposing (Model, Msg, Params, page)
import Regex
import Html exposing (Html, button, div, h2, h5, img, text, ul, li, a, p, span, i)
import Html.Attributes exposing (src, style, class, alt, href)
import Html exposing (Html, a, button, div, h2, h5, i, img, li, p, span, text, ul)
import Html.Attributes exposing (alt, class, href, src, style)
import Html.Events exposing (onClick)
import Http
import Markdown
import Json.Decode as Decode
import Json.Decode.Extra as Decode exposing (andMap)
import Markdown
import Regex
import Spa.Document exposing (Document)
import Spa.Generated.Route as Route
import Spa.Page as Page exposing (Page)
import Spa.Url as Url exposing (Url)
-- INIT
@ -26,10 +27,12 @@ page =
, subscriptions = subscriptions
}
type alias Params =
{ app : String
}
type alias App =
{ name : String
, category : String
@ -43,6 +46,7 @@ type alias App =
, description : Maybe String
}
type alias Model =
{ url : Url Params
, status : Status
@ -62,8 +66,15 @@ init url =
default_image : String
-- FIXME: change to absolute URL, if this works?
default_image = "/logo.png"
default_image =
"/logo.png"
-- UPDATE
@ -86,13 +97,15 @@ update msg model =
Ok apps ->
let
-- TODO better way of getting a single app?
apps_filtered = List.filter (\app -> app.slug == model.url.params.app) apps
apps_filtered =
List.filter (\app -> app.slug == model.url.params.app) apps
in
case List.head apps_filtered of
Nothing ->
( { model | status = Failure }, Cmd.none )
Just item ->
( { model | status = Success (item) }, loadREADME item)
( { model | status = Success item }, loadREADME item )
Err _ ->
( { model | status = Failure }, Cmd.none )
@ -103,9 +116,14 @@ update msg model =
-- update model.content with the loaded README
let
-- remove HTML comments
pattern = "<!--.*-->"
maybeRegex = Regex.fromString pattern
regex = Maybe.withDefault Regex.never maybeRegex
pattern =
"<!--.*-->"
maybeRegex =
Regex.fromString pattern
regex =
Maybe.withDefault Regex.never maybeRegex
in
( { model | readme = Regex.replace regex (\_ -> "") content }, Cmd.none )
@ -113,7 +131,6 @@ update msg model =
( { model | status = Failure }, Cmd.none )
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
@ -135,8 +152,10 @@ title model =
case model.status of
Loading ->
"loading abra apps"
Failure ->
"error - abra apps"
Success app ->
app.name ++ " abra apps"
@ -156,8 +175,7 @@ body model =
Loading ->
div [ class "d-flex align-items-center", style "height" "89vh" ]
[ div [ class "spinner-border m-auto text-light" ]
[
span [ class "sr-only" ] [ text "Loading..." ]
[ span [ class "sr-only" ] [ text "Loading..." ]
]
]
@ -168,6 +186,7 @@ body model =
]
]
viewStatusBadge : App -> Html Msg
viewStatusBadge app =
let
@ -175,18 +194,23 @@ viewStatusBadge app =
case app.status of
"1" ->
"badge-success"
"2" ->
"badge-info"
"3" ->
"badge-warning"
"4" ->
"badge-danger"
_ ->
"badge-dark"
in
span [ class ("card-link badge " ++ status_class) ]
[ text ("Score: " ++ app.status) ]
viewApp : App -> String -> Html Msg
viewApp app readme =
let
@ -194,28 +218,37 @@ viewApp app readme =
case app.icon of
Just "" ->
default_image
Just i ->
i
Nothing ->
default_image
repository_link =
case app.repository of
Just link ->
a [ class "card-link", href link ]
[ i [ class "fab fa-git-alt" ] []
, text "code" ]
, text "code"
]
Nothing ->
text ""
website_link =
case app.website of
Just link ->
case link of
"" ->
text ""
_ ->
a [ class "card-link", href link ]
[ i [ class "fas fa-home" ] []
, text "homepage" ]
, text "homepage"
]
Nothing ->
text ""
in
@ -224,7 +257,8 @@ viewApp app readme =
[ div [ class "card-header" ]
[ a
[ class "btn btn-sm border border-secondary card-link"
, href (Route.toString Route.Top)]
, href (Route.toString Route.Top)
]
[ text " back" ]
, span [ class "card-link badge badge-secondary" ] [ text app.category ]
, viewStatusBadge app
@ -241,6 +275,8 @@ viewApp app readme =
]
]
-- HTTP
@ -248,7 +284,8 @@ loadApp : Cmd Msg
loadApp =
Http.get
{ url = "/abra-apps.json"
, expect = Http.expectJson GotApps appListDecoder }
, expect = Http.expectJson GotApps appListDecoder
}
loadREADME : App -> Cmd Msg
@ -259,24 +296,26 @@ loadREADME app =
Just link ->
a [ class "card-link", href link ]
[ i [ class "fab fa-git-alt" ] []
, text "code" ]
, text "code"
]
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 }
, expect = Http.expectString GotText
}
featuresDecoder : Decode.Decoder String
featuresDecoder =
-- get features.status if it's there
(Decode.oneOf
Decode.oneOf
[ Decode.at [ "status" ] Decode.string
, Decode.succeed ""
]
)
appDecoder : Decode.Decoder App
@ -300,6 +339,6 @@ appListDecoder =
|> Decode.map buildApp
buildApp : List (String, App) -> (List App)
buildApp : List ( String, App ) -> List App
buildApp apps =
List.map (\( slug, app ) -> { app | slug = slug }) apps

View File

@ -1,17 +1,17 @@
module Pages.Top exposing (Model, Msg, Params, page)
import Html exposing (Html, button, div, h2, h5, img, text, ul, li, a, p, span, i)
import Html.Attributes exposing (src, style, class, alt, href)
import Html exposing (Html, a, button, div, h2, h5, i, img, li, p, span, text, ul)
import Html.Attributes exposing (alt, class, href, src, style)
import Html.Events exposing (onClick)
import Http
import Maybe exposing (withDefault)
import Json.Decode as Decode
import Json.Decode.Extra as Decode exposing (andMap)
import Spa.Generated.Route as Route
import Maybe exposing (withDefault)
import Spa.Document exposing (Document)
import Spa.Generated.Route as Route
import Spa.Page as Page exposing (Page)
import Spa.Url as Url exposing (Url)
import Util exposing (by, andThen, Direction(..))
import Util exposing (Direction(..), andThen, by)
page : Page Params Model Msg
@ -23,12 +23,15 @@ page =
, subscriptions = subscriptions
}
-- INIT
type alias Params =
()
type alias App =
{ name : String
, category : String
@ -55,7 +58,9 @@ init { params } =
default_image : String
default_image = "/logo.png"
default_image =
"/logo.png"
-- UPDATE
@ -103,6 +108,7 @@ body model =
[ viewApps model
]
viewStatusBadge : App -> Html Msg
viewStatusBadge app =
let
@ -110,18 +116,23 @@ viewStatusBadge app =
case app.status of
1 ->
"badge-success"
2 ->
"badge-info"
3 ->
"badge-warning"
4 ->
"badge-danger"
_ ->
"badge-dark"
in
span [ class ("card-link badge " ++ status_class) ]
[ text ("Score: " ++ String.fromInt app.status) ]
viewApp : App -> Html Msg
viewApp app =
let
@ -129,33 +140,42 @@ viewApp app =
case app.icon of
Just "" ->
default_image
Just i ->
i
Nothing ->
default_image
repository_link =
case app.repository of
Just link ->
a [ class "card-link", href link ]
[
i [ class "fab fa-git-alt" ] []
[ i [ class "fab fa-git-alt" ] []
, text "code"
]
Nothing ->
text ""
website_link =
case app.website of
Just link ->
case link of
"" ->
text ""
_ ->
a [ class "card-link", href link ]
[ i [ class "fas fa-home" ] []
, text "homepage" ]
, text "homepage"
]
Nothing ->
text ""
app_href = Route.toString <| Route.App_String { app = app.slug }
app_href =
Route.toString <| Route.App_String { app = app.slug }
in
div [ class "col-md-4 mb-3 col-sm-12" ]
[ div [ class "card" ]
@ -168,7 +188,8 @@ viewApp app =
, website_link
, a [ class "card-link", href app_href ]
[ i [ class "fas fa-book" ] []
, text "docs" ]
, text "docs"
]
]
, div [ class "card-footer" ]
[ span [ class "card-link badge badge-secondary" ] [ text app.category ]
@ -192,19 +213,25 @@ viewApps model =
Loading ->
div [ class "d-flex align-items-center", style "height" "89vh" ]
[ div [ class "spinner-border m-auto text-light" ]
[
span [ class "sr-only" ] [ text "Loading..." ]
[ span [ class "sr-only" ] [ text "Loading..." ]
]
]
Success apps ->
div []
[ div [ class "row" ]
(List.map viewApp (apps |> List.sortWith
(List.map viewApp
(apps
|> List.sortWith
(by .status ASC
|> andThen (String.toLower << .name) ASC))
|> andThen (String.toLower << .name) ASC
)
)
)
]
-- HTTP
@ -215,12 +242,12 @@ loadApps =
, expect = Http.expectJson GotApps appListDecoder
}
featuresDecoder =
(Decode.oneOf
Decode.oneOf
[ Decode.at [ "status" ] Decode.int
, Decode.succeed 5
]
)
appDecoder : Decode.Decoder App
@ -244,6 +271,6 @@ appListDecoder =
|> Decode.map buildApp
buildApp : List (String, App) -> (List App)
buildApp : List ( String, App ) -> List App
buildApp apps =
List.map (\( slug, app ) -> { app | slug = slug }) apps