aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Server/ControlRoom.hs28
-rw-r--r--lib/Yesod/Orphans.hs45
2 files changed, 46 insertions, 27 deletions
diff --git a/lib/Server/ControlRoom.hs b/lib/Server/ControlRoom.hs
index 11e72d5..f08abcb 100644
--- a/lib/Server/ControlRoom.hs
+++ b/lib/Server/ControlRoom.hs
@@ -64,6 +64,7 @@ import Numeric (showFFloat)
import Persist
import Yesod.Auth.OpenId (IdentifierType (..), authOpenId)
import Yesod.Auth.Uffd (UffdUser (..), uffdClient)
+import Yesod.Orphans ()
data ControlRoom = ControlRoom
@@ -462,30 +463,3 @@ mightbe :: Maybe Text -> Text
mightbe (Just a) = a
mightbe Nothing = ""
---- some orphans to make hamlet easier to deal with
-instance ToMarkup Time where
- toMarkup time =
- toMarkup (show time)
-
-instance ToMarkup Day where
- toMarkup day = toMarkup (iso8601Show day)
-
-instance ToMessage UTCTime where
- toMessage = formatW3
-
-instance ToMessage Token where
- toMessage (Token uuid) = UUID.toText uuid
-
-instance ToMarkup UTCTime where
- toMarkup = toMarkup . formatW3
-
-instance ToMarkup Token where
- toMarkup (Token uuid) = toMarkup (UUID.toText uuid)
-
-instance ToMessage Double where
- toMessage = T.pack . show
-
-instance ToMarkup Seconds where
- toMarkup (Seconds s) =
- if s > 0 then toMarkup ("+"+|s `div` 60|+"" :: Text)
- else toMarkup (s `div` 60)
diff --git a/lib/Yesod/Orphans.hs b/lib/Yesod/Orphans.hs
new file mode 100644
index 0000000..f66f8af
--- /dev/null
+++ b/lib/Yesod/Orphans.hs
@@ -0,0 +1,45 @@
+-- | a module containing orphan shakespeare instances to make writing templates
+-- a bit more fun & less of a hassle.
+module Yesod.Orphans where
+
+import Data.Text (Text)
+import qualified Data.Text as T
+import Data.Time (UTCTime)
+import Data.Time.Calendar (Day)
+import Data.Time.Format.ISO8601 (iso8601Show)
+import Data.UUID (UUID)
+import qualified Data.UUID as UUID
+import Fmt ((+|), (|+))
+import GTFS
+import Persist
+import Text.Blaze.Html (ToMarkup (..))
+import Text.Shakespeare.Text
+import Yesod
+
+--- some orphans to make hamlet easier to deal with
+instance ToMarkup Time where
+ toMarkup time =
+ toMarkup (show time)
+
+instance ToMarkup Day where
+ toMarkup day = toMarkup (iso8601Show day)
+
+instance ToMessage UTCTime where
+ toMessage = formatW3
+
+instance ToMessage Token where
+ toMessage (Token uuid) = UUID.toText uuid
+
+instance ToMarkup UTCTime where
+ toMarkup = toMarkup . formatW3
+
+instance ToMarkup Token where
+ toMarkup (Token uuid) = toMarkup (UUID.toText uuid)
+
+instance ToMessage Double where
+ toMessage = T.pack . show
+
+instance ToMarkup Seconds where
+ toMarkup (Seconds s) =
+ if s > 0 then toMarkup ("+"+|s `div` 60|+"" :: Text)
+ else toMarkup (s `div` 60)