From f4b6d1e3f5529ca2e9afab9a9d87ba609c54ba04 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 7 Jun 2018 11:26:41 +0200 Subject: [PATCH] Introduce pageHeading function --- messages/de.msg | 1 + src/Foundation.hs | 11 +++++++++-- templates/default-layout.hamlet | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/messages/de.msg b/messages/de.msg index 5332201d5..a4e8637fa 100644 --- a/messages/de.msg +++ b/messages/de.msg @@ -49,3 +49,4 @@ SubmissionAlreadyExistsFor user@Text: #{user} hat bereits eine Abgabe zu diesem EMailUnknown email@Text: E-Mail #{email} gehört zu keinem bekannten Benutzer. NotAParticipant user@Text tid@TermIdentifier csh@Text: #{user} ist nicht im Kurs #{termToText tid}-#{csh} angemeldet. +HomeHeading: Startseite \ No newline at end of file diff --git a/src/Foundation.hs b/src/Foundation.hs index 70c4327a5..c6a43c77b 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -434,13 +434,14 @@ instance Yesod UniWorX where -- value passed to hamletToRepHtml cannot be a widget, this allows -- you to use normal widget features in default-layout. + let navbar :: Widget navbar = $(widgetFile "widgets/navbar") asidenav :: Widget asidenav = $(widgetFile "widgets/asidenav") - contentHeadline :: Maybe String - contentHeadline = Just "Some Headline" -- should be coming from the currently viewed page + contentHeadline :: Maybe Widget + contentHeadline = pageHeading =<< mcurrentRoute breadcrumbs :: Widget breadcrumbs = $(widgetFile "widgets/breadcrumbs") pageactionprime :: Widget @@ -686,6 +687,12 @@ pageActions (TermCourseListR _) = pageActions _ = [] +pageHeading :: Route UniWorx -> Maybe Widget +pageHeading HomeR + = Just [whamlet|_{MsgHomeHeading}|] +pageHeading _ + = Nothing + defaultLinks :: [MenuTypes] defaultLinks = -- Define the menu items of the header. [ NavbarRight $ MenuItem diff --git a/templates/default-layout.hamlet b/templates/default-layout.hamlet index 99b24bfca..165096dfd 100644 --- a/templates/default-layout.hamlet +++ b/templates/default-layout.hamlet @@ -14,8 +14,9 @@
#{msg} -

- #{fromMaybe "default headline" contentHeadline} + $maybe headline <- contentHeadline +

+ ^{headline}