From a5ef793dcf60c7cccd8dc130cf8335fb573f62e8 Mon Sep 17 00:00:00 2001 From: Vidir Valberg Gudmundsson Date: Sun, 16 Jul 2017 18:31:29 +0200 Subject: [PATCH] Use a slug instead, makes for niccer urls --- schedule/Main.elm | 19 ++++++++++--------- schedule/Makefile | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/schedule/Main.elm b/schedule/Main.elm index e79a26f2..7219dd56 100644 --- a/schedule/Main.elm +++ b/schedule/Main.elm @@ -34,7 +34,7 @@ scheduleServer = type Route = OverviewRoute - | EventInstanceRoute EventInstanceId + | EventInstanceRoute EventInstanceSlug | NotFoundRoute @@ -42,7 +42,7 @@ matchers : UrlParser.Parser (Route -> a) a matchers = UrlParser.oneOf [ 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 = - Int +type alias EventInstanceSlug = + String type alias EventInstance = { title : String - , id : EventInstanceId + , id : Int , url : String , abstract : String - , eventSlug : String + , eventSlug : EventInstanceSlug , eventType : String , backgroundColor : String , forgroundColor : String @@ -115,6 +115,7 @@ type alias EventInstance = } +emptyEventInstance : EventInstance emptyEventInstance = { title = "This should not happen!" , id = 0 @@ -367,11 +368,11 @@ view model = ] -eventInstanceDetailView : EventInstanceId -> List EventInstance -> Html Msg +eventInstanceDetailView : EventInstanceSlug -> List EventInstance -> Html Msg eventInstanceDetailView eventInstanceId eventInstances = let 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 -> eventInstance @@ -464,7 +465,7 @@ dayEventInstanceView : EventInstance -> Html Msg dayEventInstanceView eventInstance = a [ class "event" - , href ("#event/" ++ (toString eventInstance.id)) + , href ("#event/" ++ eventInstance.eventSlug) , style [ ( "background-color", eventInstance.backgroundColor ) , ( "color", eventInstance.forgroundColor ) diff --git a/schedule/Makefile b/schedule/Makefile index 681e2bb6..5cfdeb9c 100644 --- a/schedule/Makefile +++ b/schedule/Makefile @@ -1,5 +1,5 @@ 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: - 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