From b7d443d03125d9081c1dc67e002a6c62c5d70770 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Wed, 25 May 2016 07:50:10 +0000 Subject: [PATCH] Show creation date in group page --- src/Vervis/Handler/Group.hs | 1 + src/Vervis/Time.hs | 34 ++++++++++++++++++++++++++++++++++ src/Vervis/Widget.hs | 7 ++----- templates/group/one.hamlet | 3 +++ vervis.cabal | 1 + 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/Vervis/Time.hs diff --git a/src/Vervis/Handler/Group.hs b/src/Vervis/Handler/Group.hs index ebb4fd1..5ece8b9 100644 --- a/src/Vervis/Handler/Group.hs +++ b/src/Vervis/Handler/Group.hs @@ -39,6 +39,7 @@ import Vervis.Foundation import Vervis.Model import Vervis.Model.Ident (ShrIdent, shr2text) import Vervis.Settings (widgetFile) +import Vervis.Time (showDate) import Vervis.Widget.Sharer (groupLinkW, personLinkW) getGroupsR :: Handler Html diff --git a/src/Vervis/Time.hs b/src/Vervis/Time.hs new file mode 100644 index 0000000..ef0959d --- /dev/null +++ b/src/Vervis/Time.hs @@ -0,0 +1,34 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ Copying is an act of love. Please copy, reuse and share. + - + - The author(s) have dedicated all copyright and related and neighboring + - rights to this software to the public domain worldwide. This software is + - distributed without any warranty. + - + - You should have received a copy of the CC0 Public Domain Dedication along + - with this software. If not, see + - . + -} + +module Vervis.Time + ( showDate + ) +where + +import Prelude + +import Data.Text (Text) +import Data.Time.Calendar (toGregorian) +import Data.Time.Clock (UTCTime (..)) +import Formatting (sformat, (%), int, left) + +import qualified Data.Text as T (take) + +showDate :: UTCTime -> Text +showDate t = + let (y, m, d) = toGregorian $ utctDay t + padded = left 2 '0' + in sformat (int % "-" % padded % "-" % padded) y m d diff --git a/src/Vervis/Widget.hs b/src/Vervis/Widget.hs index e889c88..24a327b 100644 --- a/src/Vervis/Widget.hs +++ b/src/Vervis/Widget.hs @@ -35,6 +35,7 @@ import Data.Revision.Local import Development.DarcsRev (darcsTotalPatches, darcsRevision) import Vervis.Settings (widgetFile) import Vervis.Style +import Vervis.Time (showDate) breadcrumbsW :: YesodBreadcrumbs site => WidgetT site IO () breadcrumbsW = do @@ -43,11 +44,7 @@ breadcrumbsW = do revisionW :: WidgetT site IO () revisionW = - let fmtTime t = - let (y, m, d) = toGregorian $ utctDay t - padded = left 2 '0' - in sformat (int % "-" % padded % "-" % padded) y m d - cgTimeFmt = fmtTime . cgTime + let cgTimeFmt = showDate . cgTime mrev = $darcsRevision sharer = "fr33domlover" :: Text repo = "vervis" :: Text diff --git a/templates/group/one.hamlet b/templates/group/one.hamlet index d537141..3de334a 100644 --- a/templates/group/one.hamlet +++ b/templates/group/one.hamlet @@ -15,6 +15,9 @@ $# .

#{fromMaybe (shr2text $ sharerIdent group) $ sharerName group} +

+ Created on #{showDate $ sharerCreated group}. +

Members: diff --git a/vervis.cabal b/vervis.cabal index b14b269..cf06a67 100644 --- a/vervis.cabal +++ b/vervis.cabal @@ -124,6 +124,7 @@ library Vervis.Ssh Vervis.Style Vervis.TicketFilter + Vervis.Time Vervis.Widget Vervis.Widget.Discussion Vervis.Widget.Repo