2017-07-17 09:25:57 +00:00
|
|
|
module Routing exposing (..)
|
|
|
|
|
|
|
|
-- Local modules
|
|
|
|
|
2017-07-17 14:05:38 +00:00
|
|
|
import Models exposing (Route(..))
|
2017-07-17 09:25:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- External modules
|
|
|
|
|
|
|
|
import Navigation exposing (Location)
|
2017-07-17 14:05:38 +00:00
|
|
|
import UrlParser exposing (Parser, (</>), oneOf, map, top, s, string, parseHash)
|
2017-07-17 09:25:57 +00:00
|
|
|
|
|
|
|
|
2017-07-23 00:51:39 +00:00
|
|
|
{--
|
|
|
|
URLs to support:
|
|
|
|
|
|
|
|
- #
|
|
|
|
This show the overview of the schedule
|
|
|
|
|
|
|
|
- #?type={types},location={locations},video={no,yes,link}
|
|
|
|
This is the overview, just with filters enable
|
|
|
|
|
|
|
|
- #day/{year}-{month}-{day}
|
|
|
|
Show a particular day
|
|
|
|
|
|
|
|
- #event/{slug}
|
|
|
|
Show a particular event
|
|
|
|
|
|
|
|
--}
|
|
|
|
|
|
|
|
|
2017-07-17 14:05:38 +00:00
|
|
|
matchers : Parser (Route -> a) a
|
2017-07-17 09:25:57 +00:00
|
|
|
matchers =
|
2017-07-17 14:05:38 +00:00
|
|
|
oneOf
|
|
|
|
[ map OverviewRoute top
|
2017-07-23 00:51:39 +00:00
|
|
|
, map OverviewFilteredRoute (top </> string)
|
2017-07-17 14:05:38 +00:00
|
|
|
, map DayRoute (s "day" </> string)
|
|
|
|
, map EventRoute (s "event" </> string)
|
2017-07-17 09:25:57 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
parseLocation : Location -> Route
|
|
|
|
parseLocation location =
|
2017-07-23 16:30:27 +00:00
|
|
|
parseHash matchers location
|
|
|
|
|> Maybe.withDefault NotFoundRoute
|