Use a slug instead, makes for niccer urls

This commit is contained in:
Vidir Valberg Gudmundsson 2017-07-16 18:31:29 +02:00
parent b0086d6a81
commit a5ef793dcf
2 changed files with 12 additions and 11 deletions

View file

@ -34,7 +34,7 @@ scheduleServer =
type Route type Route
= OverviewRoute = OverviewRoute
| EventInstanceRoute EventInstanceId | EventInstanceRoute EventInstanceSlug
| NotFoundRoute | NotFoundRoute
@ -42,7 +42,7 @@ matchers : UrlParser.Parser (Route -> a) a
matchers = matchers =
UrlParser.oneOf UrlParser.oneOf
[ UrlParser.map OverviewRoute UrlParser.top [ UrlParser.map OverviewRoute UrlParser.top
, UrlParser.map EventInstanceRoute (UrlParser.s "event" </> UrlParser.int) , UrlParser.map EventInstanceRoute (UrlParser.s "event" </> UrlParser.string)
] ]
@ -91,16 +91,16 @@ type alias Speaker =
} }
type alias EventInstanceId = type alias EventInstanceSlug =
Int String
type alias EventInstance = type alias EventInstance =
{ title : String { title : String
, id : EventInstanceId , id : Int
, url : String , url : String
, abstract : String , abstract : String
, eventSlug : String , eventSlug : EventInstanceSlug
, eventType : String , eventType : String
, backgroundColor : String , backgroundColor : String
, forgroundColor : String , forgroundColor : String
@ -115,6 +115,7 @@ type alias EventInstance =
} }
emptyEventInstance : EventInstance
emptyEventInstance = emptyEventInstance =
{ title = "This should not happen!" { title = "This should not happen!"
, id = 0 , id = 0
@ -367,11 +368,11 @@ view model =
] ]
eventInstanceDetailView : EventInstanceId -> List EventInstance -> Html Msg eventInstanceDetailView : EventInstanceSlug -> List EventInstance -> Html Msg
eventInstanceDetailView eventInstanceId eventInstances = eventInstanceDetailView eventInstanceId eventInstances =
let let
eventInstance = eventInstance =
case List.head (List.filter (\e -> e.id == eventInstanceId) eventInstances) of case List.head (List.filter (\e -> e.eventSlug == eventInstanceId) eventInstances) of
Just eventInstance -> Just eventInstance ->
eventInstance eventInstance
@ -464,7 +465,7 @@ dayEventInstanceView : EventInstance -> Html Msg
dayEventInstanceView eventInstance = dayEventInstanceView eventInstance =
a a
[ class "event" [ class "event"
, href ("#event/" ++ (toString eventInstance.id)) , href ("#event/" ++ eventInstance.eventSlug)
, style , style
[ ( "background-color", eventInstance.backgroundColor ) [ ( "background-color", eventInstance.backgroundColor )
, ( "color", eventInstance.forgroundColor ) , ( "color", eventInstance.forgroundColor )

View file

@ -1,5 +1,5 @@
all: all:
elm-make Main.elm --output ../src/program/static/js/elm_based_schedule.js elm-make Main.elm --warn --output ../src/program/static/js/elm_based_schedule.js
debug: debug:
elm-make Main.elm --debug --output ../src/program/static/js/elm_based_schedule.js elm-make Main.elm --debug --warn --output ../src/program/static/js/elm_based_schedule.js