mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 12:52:27 +03:00
Update some test examples.
This commit is contained in:
parent
d59c57ac01
commit
706ead2dc1
@ -1,12 +1,27 @@
|
||||
module Effect exposing (Effect(..), batch, fromCmd, map, none, perform)
|
||||
|
||||
import Browser.Navigation
|
||||
import Http
|
||||
import Json.Decode as Decode
|
||||
import Url exposing (Url)
|
||||
|
||||
|
||||
type Effect msg
|
||||
= None
|
||||
| Cmd (Cmd msg)
|
||||
| Batch (List (Effect msg))
|
||||
| GetStargazers (Result Http.Error Int -> msg)
|
||||
| FetchPageData
|
||||
{ body : Maybe { contentType : String, body : String }
|
||||
, path : Maybe String
|
||||
, toMsg : Result Http.Error Url -> msg
|
||||
}
|
||||
|
||||
|
||||
type alias RequestInfo =
|
||||
{ contentType : String
|
||||
, body : String
|
||||
}
|
||||
|
||||
|
||||
none : Effect msg
|
||||
@ -36,9 +51,30 @@ map fn effect =
|
||||
Batch list ->
|
||||
Batch (List.map (map fn) list)
|
||||
|
||||
GetStargazers toMsg ->
|
||||
GetStargazers (toMsg >> fn)
|
||||
|
||||
perform : (pageMsg -> msg) -> Browser.Navigation.Key -> Effect pageMsg -> Cmd msg
|
||||
perform fromPageMsg key effect =
|
||||
FetchPageData fetchInfo ->
|
||||
FetchPageData
|
||||
{ body = fetchInfo.body
|
||||
, path = fetchInfo.path
|
||||
, toMsg = fetchInfo.toMsg >> fn
|
||||
}
|
||||
|
||||
|
||||
perform :
|
||||
{ fetchRouteData :
|
||||
{ body : Maybe { contentType : String, body : String }
|
||||
, path : Maybe String
|
||||
, toMsg : Result Http.Error Url -> pageMsg
|
||||
}
|
||||
-> Cmd msg
|
||||
}
|
||||
-> (pageMsg -> msg)
|
||||
-> Browser.Navigation.Key
|
||||
-> Effect pageMsg
|
||||
-> Cmd msg
|
||||
perform info fromPageMsg key effect =
|
||||
case effect of
|
||||
None ->
|
||||
Cmd.none
|
||||
@ -47,4 +83,18 @@ perform fromPageMsg key effect =
|
||||
Cmd.map fromPageMsg cmd
|
||||
|
||||
Batch list ->
|
||||
Cmd.batch (List.map (perform fromPageMsg key) list)
|
||||
Cmd.batch (List.map (perform info fromPageMsg key) list)
|
||||
|
||||
GetStargazers toMsg ->
|
||||
Http.get
|
||||
{ url =
|
||||
"https://api.github.com/repos/dillonkearns/elm-pages"
|
||||
, expect = Http.expectJson (toMsg >> fromPageMsg) (Decode.field "stargazers_count" Decode.int)
|
||||
}
|
||||
|
||||
FetchPageData fetchInfo ->
|
||||
info.fetchRouteData
|
||||
{ body = fetchInfo.body
|
||||
, path = fetchInfo.path
|
||||
, toMsg = fetchInfo.toMsg
|
||||
}
|
||||
|
@ -1,6 +1,37 @@
|
||||
module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
||||
module ErrorPage exposing (ErrorPage(..), Model, Msg, head, init, internalError, notFound, statusCode, update, view)
|
||||
|
||||
import Html exposing (Html)
|
||||
import Effect exposing (Effect)
|
||||
import Head
|
||||
import Html.Styled as Html exposing (Html)
|
||||
import View exposing (View)
|
||||
|
||||
|
||||
type Msg
|
||||
= Increment
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ count : Int
|
||||
}
|
||||
|
||||
|
||||
init : ErrorPage -> ( Model, Effect Msg )
|
||||
init errorPage =
|
||||
( { count = 0 }
|
||||
, Effect.none
|
||||
)
|
||||
|
||||
|
||||
update : ErrorPage -> Msg -> Model -> ( Model, Effect Msg )
|
||||
update errorPage msg model =
|
||||
case msg of
|
||||
Increment ->
|
||||
( { model | count = model.count + 1 }, Effect.none )
|
||||
|
||||
|
||||
head : ErrorPage -> List Head.Tag
|
||||
head errorPage =
|
||||
[]
|
||||
|
||||
|
||||
type ErrorPage
|
||||
@ -18,13 +49,14 @@ internalError =
|
||||
InternalError
|
||||
|
||||
|
||||
view : ErrorPage -> { body : Html msg, title : String }
|
||||
view error =
|
||||
view : ErrorPage -> Model -> View Msg
|
||||
view error model =
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.text "Hi! This is a NotFound error"
|
||||
[ Html.div []
|
||||
[ Html.p [] [ Html.text "Page not found. Maybe try another URL?" ]
|
||||
]
|
||||
, title = "Error"
|
||||
]
|
||||
, title = "This is a NotFound Error"
|
||||
}
|
||||
|
||||
|
||||
|
8
examples/base-path/package-lock.json
generated
8
examples/base-path/package-lock.json
generated
@ -41,8 +41,8 @@
|
||||
"node-fetch": "^2.6.7",
|
||||
"object-hash": "^2.2.0",
|
||||
"serve-static": "^1.14.1",
|
||||
"terser": "^5.12.0",
|
||||
"vite": "^2.8.6",
|
||||
"terser": "^5.12.1",
|
||||
"vite": "^2.9.1",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
"bin": {
|
||||
@ -1585,9 +1585,9 @@
|
||||
"node-fetch": "^2.6.7",
|
||||
"object-hash": "^2.2.0",
|
||||
"serve-static": "^1.14.1",
|
||||
"terser": "^5.12.0",
|
||||
"terser": "^5.12.1",
|
||||
"typescript": "4.3.5",
|
||||
"vite": "^2.8.6",
|
||||
"vite": "^2.9.1",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -1,12 +1,26 @@
|
||||
module Effect exposing (Effect(..), batch, fromCmd, map, none, perform)
|
||||
|
||||
import Browser.Navigation
|
||||
import Http
|
||||
import Json.Decode as Decode
|
||||
import Url exposing (Url)
|
||||
|
||||
|
||||
type Effect msg
|
||||
= None
|
||||
| Cmd (Cmd msg)
|
||||
| Batch (List (Effect msg))
|
||||
| FetchPageData
|
||||
{ body : Maybe { contentType : String, body : String }
|
||||
, path : Maybe String
|
||||
, toMsg : Result Http.Error Url -> msg
|
||||
}
|
||||
|
||||
|
||||
type alias RequestInfo =
|
||||
{ contentType : String
|
||||
, body : String
|
||||
}
|
||||
|
||||
|
||||
none : Effect msg
|
||||
@ -36,9 +50,27 @@ map fn effect =
|
||||
Batch list ->
|
||||
Batch (List.map (map fn) list)
|
||||
|
||||
FetchPageData fetchInfo ->
|
||||
FetchPageData
|
||||
{ body = fetchInfo.body
|
||||
, path = fetchInfo.path
|
||||
, toMsg = fetchInfo.toMsg >> fn
|
||||
}
|
||||
|
||||
perform : (pageMsg -> msg) -> Browser.Navigation.Key -> Effect pageMsg -> Cmd msg
|
||||
perform fromPageMsg key effect =
|
||||
|
||||
perform :
|
||||
{ fetchRouteData :
|
||||
{ body : Maybe { contentType : String, body : String }
|
||||
, path : Maybe String
|
||||
, toMsg : Result Http.Error Url -> pageMsg
|
||||
}
|
||||
-> Cmd msg
|
||||
}
|
||||
-> (pageMsg -> msg)
|
||||
-> Browser.Navigation.Key
|
||||
-> Effect pageMsg
|
||||
-> Cmd msg
|
||||
perform info fromPageMsg key effect =
|
||||
case effect of
|
||||
None ->
|
||||
Cmd.none
|
||||
@ -47,4 +79,11 @@ perform fromPageMsg key effect =
|
||||
Cmd.map fromPageMsg cmd
|
||||
|
||||
Batch list ->
|
||||
Cmd.batch (List.map (perform fromPageMsg key) list)
|
||||
Cmd.batch (List.map (perform info fromPageMsg key) list)
|
||||
|
||||
FetchPageData fetchInfo ->
|
||||
info.fetchRouteData
|
||||
{ body = fetchInfo.body
|
||||
, path = fetchInfo.path
|
||||
, toMsg = fetchInfo.toMsg
|
||||
}
|
||||
|
@ -1,6 +1,37 @@
|
||||
module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
||||
module ErrorPage exposing (ErrorPage(..), Model, Msg, head, init, internalError, notFound, statusCode, update, view)
|
||||
|
||||
import Html exposing (Html)
|
||||
import Effect exposing (Effect)
|
||||
import Head
|
||||
import Html.Styled as Html exposing (Html)
|
||||
import View exposing (View)
|
||||
|
||||
|
||||
type Msg
|
||||
= Increment
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ count : Int
|
||||
}
|
||||
|
||||
|
||||
init : ErrorPage -> ( Model, Effect Msg )
|
||||
init errorPage =
|
||||
( { count = 0 }
|
||||
, Effect.none
|
||||
)
|
||||
|
||||
|
||||
update : ErrorPage -> Msg -> Model -> ( Model, Effect Msg )
|
||||
update errorPage msg model =
|
||||
case msg of
|
||||
Increment ->
|
||||
( { model | count = model.count + 1 }, Effect.none )
|
||||
|
||||
|
||||
head : ErrorPage -> List Head.Tag
|
||||
head errorPage =
|
||||
[]
|
||||
|
||||
|
||||
type ErrorPage
|
||||
@ -18,13 +49,14 @@ internalError =
|
||||
InternalError
|
||||
|
||||
|
||||
view : ErrorPage -> { body : Html msg, title : String }
|
||||
view error =
|
||||
view : ErrorPage -> Model -> View Msg
|
||||
view error model =
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.text "Hi! This is a NotFound error"
|
||||
[ Html.div []
|
||||
[ Html.p [] [ Html.text "Page not found. Maybe try another URL?" ]
|
||||
]
|
||||
, title = "Error"
|
||||
]
|
||||
, title = "This is a NotFound Error"
|
||||
}
|
||||
|
||||
|
||||
|
6
examples/escaping/dist/escaping/index.html
vendored
6
examples/escaping/dist/escaping/index.html
vendored
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="modulepreload" href="assets/index.a677aaa6.js" />
|
||||
<link rel="modulepreload" href="/assets/index.ef4a3a15.js" />
|
||||
<script defer src="/elm.js" type="text/javascript"></script>
|
||||
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
content="black-translucent"
|
||||
/>
|
||||
<link rel="canonical" href="https://elm-pages.com/escaping" /> <meta name="description" content="These quotes should be escaped "ESCAPE THIS", and so should <CARETS>" /> <meta property="og:image" content="TODO" /> <meta property="og:image:secure_url" content="TODO" /> <meta property="og:image:alt" content="elm-pages logo" /> <meta property="og:title" content="TODO title" /> <meta property="og:url" content="https://elm-pages.com/escaping" /> <meta property="og:description" content="These quotes should be escaped "ESCAPE THIS", and so should <CARETS>" /> <meta property="og:site_name" content="elm-pages" /> <meta property="twitter:card" content="summary" /> <meta property="twitter:title" content="TODO title" /> <meta property="twitter:description" content="These quotes should be escaped "ESCAPE THIS", and so should <CARETS>" /> <meta property="twitter:image" content="TODO" /> <meta property="twitter:image:alt" content="elm-pages logo" /> <meta property="og:type" content="website" /> <link rel="icon" sizes="32x32" type="image/png" href="https://res.cloudinary.com/dillonkearns/image/upload/c_pad,w_32,h_32,q_auto,f_png/v1603234028/elm-pages/elm-pages-icon" /> <link rel="icon" sizes="16x16" type="image/png" href="https://res.cloudinary.com/dillonkearns/image/upload/c_pad,w_16,h_16,q_auto,f_png/v1603234028/elm-pages/elm-pages-icon" /> <link rel="apple-touch-icon" sizes="180x180" href="https://res.cloudinary.com/dillonkearns/image/upload/c_pad,w_180,h_180,q_auto,f_png/v1603234028/elm-pages/elm-pages-icon" /> <link rel="apple-touch-icon" sizes="192x192" href="https://res.cloudinary.com/dillonkearns/image/upload/c_pad,w_192,h_192,q_auto,f_png/v1603234028/elm-pages/elm-pages-icon" /> <link rel="sitemap" type="application/xml" href="/sitemap.xml" />
|
||||
<script id="__ELM_PAGES_BYTES_DATA__" type="application/octet-stream">AQGEPHNjcmlwdD48L3NjcmlwdD4gaXMgdW5zYWZlIGluIEpTT04gdW5sZXNzIGl0IGlzIGVzY2FwZWQgcHJvcGVybHku</script>
|
||||
<script type="module" crossorigin src="/assets/index.a677aaa6.js"></script>
|
||||
<script id="__ELM_PAGES_BYTES_DATA__" type="application/octet-stream">AAKEPHNjcmlwdD48L3NjcmlwdD4gaXMgdW5zYWZlIGluIEpTT04gdW5sZXNzIGl0IGlzIGVzY2FwZWQgcHJvcGVybHku</script>
|
||||
<script type="module" crossorigin src="/assets/index.ef4a3a15.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index.b0f41fb5.css">
|
||||
</head>
|
||||
<body>
|
||||
|
8
examples/escaping/package-lock.json
generated
8
examples/escaping/package-lock.json
generated
@ -40,8 +40,8 @@
|
||||
"node-fetch": "^2.6.7",
|
||||
"object-hash": "^2.2.0",
|
||||
"serve-static": "^1.14.1",
|
||||
"terser": "^5.12.0",
|
||||
"vite": "^2.8.6",
|
||||
"terser": "^5.12.1",
|
||||
"vite": "^2.9.1",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
"bin": {
|
||||
@ -1526,9 +1526,9 @@
|
||||
"node-fetch": "^2.6.7",
|
||||
"object-hash": "^2.2.0",
|
||||
"serve-static": "^1.14.1",
|
||||
"terser": "^5.12.0",
|
||||
"terser": "^5.12.1",
|
||||
"typescript": "4.3.5",
|
||||
"vite": "^2.8.6",
|
||||
"vite": "^2.9.1",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -1,12 +1,25 @@
|
||||
module Effect exposing (Effect(..), batch, fromCmd, map, none, perform)
|
||||
|
||||
import Browser.Navigation
|
||||
import Http
|
||||
import Url exposing (Url)
|
||||
|
||||
|
||||
type Effect msg
|
||||
= None
|
||||
| Cmd (Cmd msg)
|
||||
| Batch (List (Effect msg))
|
||||
| FetchPageData
|
||||
{ body : Maybe { contentType : String, body : String }
|
||||
, path : Maybe String
|
||||
, toMsg : Result Http.Error Url -> msg
|
||||
}
|
||||
|
||||
|
||||
type alias RequestInfo =
|
||||
{ contentType : String
|
||||
, body : String
|
||||
}
|
||||
|
||||
|
||||
none : Effect msg
|
||||
@ -36,9 +49,27 @@ map fn effect =
|
||||
Batch list ->
|
||||
Batch (List.map (map fn) list)
|
||||
|
||||
FetchPageData fetchInfo ->
|
||||
FetchPageData
|
||||
{ body = fetchInfo.body
|
||||
, path = fetchInfo.path
|
||||
, toMsg = fetchInfo.toMsg >> fn
|
||||
}
|
||||
|
||||
perform : (pageMsg -> msg) -> Browser.Navigation.Key -> Effect pageMsg -> Cmd msg
|
||||
perform fromPageMsg key effect =
|
||||
|
||||
perform :
|
||||
{ fetchRouteData :
|
||||
{ body : Maybe { contentType : String, body : String }
|
||||
, path : Maybe String
|
||||
, toMsg : Result Http.Error Url -> pageMsg
|
||||
}
|
||||
-> Cmd msg
|
||||
}
|
||||
-> (pageMsg -> msg)
|
||||
-> Browser.Navigation.Key
|
||||
-> Effect pageMsg
|
||||
-> Cmd msg
|
||||
perform info fromPageMsg key effect =
|
||||
case effect of
|
||||
None ->
|
||||
Cmd.none
|
||||
@ -47,4 +78,11 @@ perform fromPageMsg key effect =
|
||||
Cmd.map fromPageMsg cmd
|
||||
|
||||
Batch list ->
|
||||
Cmd.batch (List.map (perform fromPageMsg key) list)
|
||||
Cmd.batch (List.map (perform info fromPageMsg key) list)
|
||||
|
||||
FetchPageData fetchInfo ->
|
||||
info.fetchRouteData
|
||||
{ body = fetchInfo.body
|
||||
, path = fetchInfo.path
|
||||
, toMsg = fetchInfo.toMsg
|
||||
}
|
||||
|
@ -1,6 +1,37 @@
|
||||
module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
||||
module ErrorPage exposing (ErrorPage(..), Model, Msg, head, init, internalError, notFound, statusCode, update, view)
|
||||
|
||||
import Html exposing (Html)
|
||||
import Effect exposing (Effect)
|
||||
import Head
|
||||
import Html.Styled as Html exposing (Html)
|
||||
import View exposing (View)
|
||||
|
||||
|
||||
type Msg
|
||||
= Increment
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ count : Int
|
||||
}
|
||||
|
||||
|
||||
init : ErrorPage -> ( Model, Effect Msg )
|
||||
init errorPage =
|
||||
( { count = 0 }
|
||||
, Effect.none
|
||||
)
|
||||
|
||||
|
||||
update : ErrorPage -> Msg -> Model -> ( Model, Effect Msg )
|
||||
update errorPage msg model =
|
||||
case msg of
|
||||
Increment ->
|
||||
( { model | count = model.count + 1 }, Effect.none )
|
||||
|
||||
|
||||
head : ErrorPage -> List Head.Tag
|
||||
head errorPage =
|
||||
[]
|
||||
|
||||
|
||||
type ErrorPage
|
||||
@ -18,13 +49,14 @@ internalError =
|
||||
InternalError
|
||||
|
||||
|
||||
view : ErrorPage -> { body : Html msg, title : String }
|
||||
view error =
|
||||
view : ErrorPage -> Model -> View Msg
|
||||
view error model =
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.text "Hi! This is a NotFound error"
|
||||
[ Html.div []
|
||||
[ Html.p [] [ Html.text "Page not found. Maybe try another URL?" ]
|
||||
]
|
||||
, title = "Error"
|
||||
]
|
||||
, title = "This is a NotFound Error"
|
||||
}
|
||||
|
||||
|
||||
|
8
examples/routing/package-lock.json
generated
8
examples/routing/package-lock.json
generated
@ -40,8 +40,8 @@
|
||||
"node-fetch": "^2.6.7",
|
||||
"object-hash": "^2.2.0",
|
||||
"serve-static": "^1.14.1",
|
||||
"terser": "^5.12.0",
|
||||
"vite": "^2.8.6",
|
||||
"terser": "^5.12.1",
|
||||
"vite": "^2.9.1",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
"bin": {
|
||||
@ -1526,9 +1526,9 @@
|
||||
"node-fetch": "^2.6.7",
|
||||
"object-hash": "^2.2.0",
|
||||
"serve-static": "^1.14.1",
|
||||
"terser": "^5.12.0",
|
||||
"terser": "^5.12.1",
|
||||
"typescript": "4.3.5",
|
||||
"vite": "^2.8.6",
|
||||
"vite": "^2.9.1",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user