mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-23 14:15:33 +03:00
Update examples to use ErrorPage, and add to NoContractViolations.
This commit is contained in:
parent
34f428f1df
commit
339d54a9e9
38
examples/base-path/app/ErrorPage.elm
Normal file
38
examples/base-path/app/ErrorPage.elm
Normal file
@ -0,0 +1,38 @@
|
||||
module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
||||
|
||||
import Html exposing (Html)
|
||||
|
||||
|
||||
type ErrorPage
|
||||
= NotFound
|
||||
| InternalError String
|
||||
|
||||
|
||||
notFound : ErrorPage
|
||||
notFound =
|
||||
NotFound
|
||||
|
||||
|
||||
internalError : String -> ErrorPage
|
||||
internalError =
|
||||
InternalError
|
||||
|
||||
|
||||
view : ErrorPage -> { body : Html msg, title : String }
|
||||
view error =
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.text "Hi! This is a NotFound error"
|
||||
]
|
||||
, title = "Error"
|
||||
}
|
||||
|
||||
|
||||
statusCode : ErrorPage -> number
|
||||
statusCode error =
|
||||
case error of
|
||||
NotFound ->
|
||||
404
|
||||
|
||||
InternalError _ ->
|
||||
500
|
38
examples/docs/app/ErrorPage.elm
Normal file
38
examples/docs/app/ErrorPage.elm
Normal file
@ -0,0 +1,38 @@
|
||||
module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
||||
|
||||
import Html exposing (Html)
|
||||
|
||||
|
||||
type ErrorPage
|
||||
= NotFound
|
||||
| InternalError String
|
||||
|
||||
|
||||
notFound : ErrorPage
|
||||
notFound =
|
||||
NotFound
|
||||
|
||||
|
||||
internalError : String -> ErrorPage
|
||||
internalError =
|
||||
InternalError
|
||||
|
||||
|
||||
view : ErrorPage -> { body : Html msg, title : String }
|
||||
view error =
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.text "Hi! This is a NotFound error"
|
||||
]
|
||||
, title = "Error"
|
||||
}
|
||||
|
||||
|
||||
statusCode : ErrorPage -> number
|
||||
statusCode error =
|
||||
case error of
|
||||
NotFound ->
|
||||
404
|
||||
|
||||
InternalError _ ->
|
||||
500
|
38
examples/end-to-end/app/ErrorPage.elm
Normal file
38
examples/end-to-end/app/ErrorPage.elm
Normal file
@ -0,0 +1,38 @@
|
||||
module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
||||
|
||||
import Html exposing (Html)
|
||||
|
||||
|
||||
type ErrorPage
|
||||
= NotFound
|
||||
| InternalError String
|
||||
|
||||
|
||||
notFound : ErrorPage
|
||||
notFound =
|
||||
NotFound
|
||||
|
||||
|
||||
internalError : String -> ErrorPage
|
||||
internalError =
|
||||
InternalError
|
||||
|
||||
|
||||
view : ErrorPage -> { body : Html msg, title : String }
|
||||
view error =
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.text "Hi! This is a NotFound error"
|
||||
]
|
||||
, title = "Error"
|
||||
}
|
||||
|
||||
|
||||
statusCode : ErrorPage -> number
|
||||
statusCode error =
|
||||
case error of
|
||||
NotFound ->
|
||||
404
|
||||
|
||||
InternalError _ ->
|
||||
500
|
38
examples/escaping/app/ErrorPage.elm
Normal file
38
examples/escaping/app/ErrorPage.elm
Normal file
@ -0,0 +1,38 @@
|
||||
module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
||||
|
||||
import Html exposing (Html)
|
||||
|
||||
|
||||
type ErrorPage
|
||||
= NotFound
|
||||
| InternalError String
|
||||
|
||||
|
||||
notFound : ErrorPage
|
||||
notFound =
|
||||
NotFound
|
||||
|
||||
|
||||
internalError : String -> ErrorPage
|
||||
internalError =
|
||||
InternalError
|
||||
|
||||
|
||||
view : ErrorPage -> { body : Html msg, title : String }
|
||||
view error =
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.text "Hi! This is a NotFound error"
|
||||
]
|
||||
, title = "Error"
|
||||
}
|
||||
|
||||
|
||||
statusCode : ErrorPage -> number
|
||||
statusCode error =
|
||||
case error of
|
||||
NotFound ->
|
||||
404
|
||||
|
||||
InternalError _ ->
|
||||
500
|
2
examples/escaping/dist/escaping/index.html
vendored
2
examples/escaping/dist/escaping/index.html
vendored
@ -17,7 +17,7 @@
|
||||
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">AAGEPHNjcmlwdD48L3NjcmlwdD4gaXMgdW5zYWZlIGluIEpTT04gdW5sZXNzIGl0IGlzIGVzY2FwZWQgcHJvcGVybHku</script>
|
||||
<script id="__ELM_PAGES_BYTES_DATA__" type="application/octet-stream">AQGEPHNjcmlwdD48L3NjcmlwdD4gaXMgdW5zYWZlIGluIEpTT04gdW5sZXNzIGl0IGlzIGVzY2FwZWQgcHJvcGVybHku</script>
|
||||
<script type="module" crossorigin src="/assets/index.a677aaa6.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index.b0f41fb5.css">
|
||||
</head>
|
||||
|
38
examples/hello/app/ErrorPage.elm
Normal file
38
examples/hello/app/ErrorPage.elm
Normal file
@ -0,0 +1,38 @@
|
||||
module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
||||
|
||||
import Html exposing (Html)
|
||||
|
||||
|
||||
type ErrorPage
|
||||
= NotFound
|
||||
| InternalError String
|
||||
|
||||
|
||||
notFound : ErrorPage
|
||||
notFound =
|
||||
NotFound
|
||||
|
||||
|
||||
internalError : String -> ErrorPage
|
||||
internalError =
|
||||
InternalError
|
||||
|
||||
|
||||
view : ErrorPage -> { body : Html msg, title : String }
|
||||
view error =
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.text "Hi! This is a NotFound error"
|
||||
]
|
||||
, title = "Error"
|
||||
}
|
||||
|
||||
|
||||
statusCode : ErrorPage -> number
|
||||
statusCode error =
|
||||
case error of
|
||||
NotFound ->
|
||||
404
|
||||
|
||||
InternalError _ ->
|
||||
500
|
38
examples/routing/app/ErrorPage.elm
Normal file
38
examples/routing/app/ErrorPage.elm
Normal file
@ -0,0 +1,38 @@
|
||||
module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
||||
|
||||
import Html exposing (Html)
|
||||
|
||||
|
||||
type ErrorPage
|
||||
= NotFound
|
||||
| InternalError String
|
||||
|
||||
|
||||
notFound : ErrorPage
|
||||
notFound =
|
||||
NotFound
|
||||
|
||||
|
||||
internalError : String -> ErrorPage
|
||||
internalError =
|
||||
InternalError
|
||||
|
||||
|
||||
view : ErrorPage -> { body : Html msg, title : String }
|
||||
view error =
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.text "Hi! This is a NotFound error"
|
||||
]
|
||||
, title = "Error"
|
||||
}
|
||||
|
||||
|
||||
statusCode : ErrorPage -> number
|
||||
statusCode error =
|
||||
case error of
|
||||
NotFound ->
|
||||
404
|
||||
|
||||
InternalError _ ->
|
||||
500
|
38
generator/template/app/ErrorPage.elm
Normal file
38
generator/template/app/ErrorPage.elm
Normal file
@ -0,0 +1,38 @@
|
||||
module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
||||
|
||||
import Html exposing (Html)
|
||||
|
||||
|
||||
type ErrorPage
|
||||
= NotFound
|
||||
| InternalError String
|
||||
|
||||
|
||||
notFound : ErrorPage
|
||||
notFound =
|
||||
NotFound
|
||||
|
||||
|
||||
internalError : String -> ErrorPage
|
||||
internalError =
|
||||
InternalError
|
||||
|
||||
|
||||
view : ErrorPage -> { body : Html msg, title : String }
|
||||
view error =
|
||||
{ body =
|
||||
Html.div []
|
||||
[ Html.text "Hi! This is a NotFound error"
|
||||
]
|
||||
, title = "Error"
|
||||
}
|
||||
|
||||
|
||||
statusCode : ErrorPage -> number
|
||||
statusCode error =
|
||||
case error of
|
||||
NotFound ->
|
||||
404
|
||||
|
||||
InternalError _ ->
|
||||
500
|
@ -439,8 +439,7 @@ update config appMsg model =
|
||||
(updateResult
|
||||
|> Result.mapError
|
||||
(\_ ->
|
||||
--"Http error"
|
||||
Debug.todo "HTTP ERROR"
|
||||
config.internalError "Http error"
|
||||
)
|
||||
)
|
||||
model.pageData
|
||||
|
@ -112,6 +112,7 @@ coreModules =
|
||||
Set.fromList
|
||||
[ [ "Api" ]
|
||||
, [ "Effect" ]
|
||||
, [ "ErrorPage" ]
|
||||
, [ "Shared" ]
|
||||
, [ "Site" ]
|
||||
, [ "View" ]
|
||||
@ -123,6 +124,7 @@ coreModulesAndExports =
|
||||
Dict.fromList
|
||||
[ ( [ "Api" ], [ "routes" ] )
|
||||
, ( [ "Effect" ], [ "Effect", "batch", "fromCmd", "map", "none", "perform" ] )
|
||||
, ( [ "ErrorPage" ], [ "ErrorPage", "notFound", "internalError", "view", "statusCode" ] )
|
||||
, ( [ "Shared" ], [ "Data", "Model", "Msg", "template" ] )
|
||||
, ( [ "Site" ], [ "config" ] )
|
||||
, ( [ "View" ], [ "View", "map", "placeholder" ] )
|
||||
|
@ -190,6 +190,7 @@ config =
|
||||
, details =
|
||||
[ "Api"
|
||||
, "Effect"
|
||||
, "ErrorPage"
|
||||
, "Shared"
|
||||
, "View"
|
||||
]
|
||||
@ -220,7 +221,9 @@ invalid = Debug.todo ""
|
||||
"""
|
||||
, """module Effect exposing (invalid)
|
||||
invalid = Debug.todo ""
|
||||
|
||||
"""
|
||||
, """module ErrorPage exposing (invalid)
|
||||
invalid = Debug.todo ""
|
||||
"""
|
||||
, """module Shared exposing (invalid)
|
||||
invalid = Debug.todo ""
|
||||
@ -254,6 +257,16 @@ invalid = Debug.todo ""
|
||||
}
|
||||
]
|
||||
)
|
||||
, ( "ErrorPage"
|
||||
, [ Review.Test.error
|
||||
{ message = "A core elm-pages module needs to expose something"
|
||||
, details =
|
||||
[ "The ErrorPage module must expose `ErrorPage`, `internalError`, `notFound`, `statusCode`, `view`"
|
||||
]
|
||||
, under = "exposing (invalid)"
|
||||
}
|
||||
]
|
||||
)
|
||||
, ( "Shared"
|
||||
, [ Review.Test.error
|
||||
{ message = "A core elm-pages module needs to expose something"
|
||||
@ -301,6 +314,9 @@ routes = Debug.todo ""
|
||||
"""
|
||||
, """module Effect exposing (Effect(..), batch, fromCmd, map, none, perform)
|
||||
routes = Debug.todo ""
|
||||
"""
|
||||
, """module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
||||
routes = Debug.todo ""
|
||||
"""
|
||||
, """module Shared exposing (Data, Model, Msg, template)
|
||||
routes = Debug.todo ""
|
||||
|
@ -444,7 +444,7 @@ startLowLevel apiRoutes staticHttpCache pages =
|
||||
Nothing ->
|
||||
Debug.todo "Error - no pages"
|
||||
|
||||
config : ProgramConfig Msg () Route () () Effect mappedMsg
|
||||
config : ProgramConfig Msg () Route () () Effect mappedMsg ()
|
||||
config =
|
||||
{ toJsPort = toJsPort
|
||||
, fromJsPort = fromJsPort
|
||||
@ -514,6 +514,14 @@ startLowLevel apiRoutes staticHttpCache pages =
|
||||
, globalHeadTags = Nothing
|
||||
, perform = \_ _ _ -> Cmd.none
|
||||
, cmdToEffect = \_ -> Effect.NoEffect
|
||||
, errorStatusCode = \_ -> 404
|
||||
, notFoundPage = ()
|
||||
, internalError = \_ -> ()
|
||||
, errorView =
|
||||
\() ->
|
||||
{ title = "Error"
|
||||
, body = Html.text ""
|
||||
}
|
||||
}
|
||||
|
||||
encodedFlags : Encode.Value
|
||||
@ -591,7 +599,7 @@ startWithRoutes :
|
||||
-> ProgramTest (Model Route) Msg Effect
|
||||
startWithRoutes pageToLoad staticRoutes staticHttpCache pages =
|
||||
let
|
||||
config : ProgramConfig Msg () Route () () Effect mappedMsg
|
||||
config : ProgramConfig Msg () Route () () Effect mappedMsg ()
|
||||
config =
|
||||
{ toJsPort = toJsPort
|
||||
, fromJsPort = fromJsPort
|
||||
@ -671,6 +679,14 @@ startWithRoutes pageToLoad staticRoutes staticHttpCache pages =
|
||||
, globalHeadTags = Nothing
|
||||
, perform = \_ _ _ -> Cmd.none
|
||||
, cmdToEffect = \_ -> Effect.NoEffect
|
||||
, errorStatusCode = \_ -> 404
|
||||
, notFoundPage = ()
|
||||
, internalError = \_ -> ()
|
||||
, errorView =
|
||||
\() ->
|
||||
{ title = "Error"
|
||||
, body = Html.text ""
|
||||
}
|
||||
}
|
||||
|
||||
encodedFlags : Encode.Value
|
||||
|
Loading…
Reference in New Issue
Block a user