1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 18:17:03 +00:00

ui: Easy renames and refactors

This commit is contained in:
James Hillyerd
2018-11-18 18:52:14 -08:00
parent 0ed0cd2d64
commit 5be2b57a12
11 changed files with 150 additions and 164 deletions

View File

@@ -16,17 +16,20 @@ type Route
| Status
routeParser : Parser (Route -> a) a
routeParser =
oneOf
[ map Home top
, map Message (s "m" </> string </> string)
, map Mailbox (s "m" </> string)
, map Monitor (s "monitor")
, map Status (s "status")
]
{-| Routes our application handles.
-}
routes : List (Parser (Route -> a) a)
routes =
[ map Home top
, map Message (s "m" </> string </> string)
, map Mailbox (s "m" </> string)
, map Monitor (s "monitor")
, map Status (s "status")
]
{-| Convert route to a URI.
-}
routeToString : Route -> String
routeToString page =
let
@@ -72,11 +75,11 @@ newUrl key =
routeToString >> Navigation.pushUrl key
{-| Returns the Route for a given URL; by matching the path after # (fragment.)
{-| Returns the Route for a given URL.
-}
fromUrl : Url -> Route
fromUrl location =
case Parser.parse routeParser location of
case Parser.parse (oneOf routes) location of
Nothing ->
Unknown location.path