@@ -92,7 +92,7 @@ defaultTemplate = "template.tex"
9292------------------------------------------------------------------------------
9393-- $Types
9494
95- -- | Name of a queue
95+ -- | Name of a queue or queue item
9696newtype Name = Name Text
9797 deriving newtype Show
9898
@@ -105,6 +105,19 @@ instance Ginger.ToGVal m Name where
105105instance TTC. Render Name where
106106 render (Name t) = TTC. fromT t
107107
108+ -- | URL of queue or queue item
109+ newtype Url = Url Text
110+ deriving newtype Show
111+
112+ instance FromJSON Url where
113+ parseJSON = fmap Url . parseToString
114+
115+ instance Ginger. ToGVal m Url where
116+ toGVal (Url t) = Ginger. toGVal $ escapeTeX t
117+
118+ instance TTC. Render Url where
119+ render (Url t) = TTC. fromT t
120+
108121-- | Section used to organize queues
109122newtype Section = Section Text
110123 deriving newtype (Eq , Show )
@@ -144,22 +157,38 @@ instance TTC.Render Date where
144157 render (Date t) = TTC. fromT t
145158
146159-- | Queue item
147- newtype Item = Item Text
148- deriving newtype Show
160+ data Item
161+ = Item
162+ { itemName :: ! Name
163+ , itemUrl :: ! (Maybe Url )
164+ }
165+ deriving Show
149166
150167instance FromJSON Item where
151- parseJSON = fmap Item . parseToString
168+ parseJSON = \ case
169+ (A. Object o) ->
170+ Item
171+ <$> o .: " name"
172+ <*> o .:? " url"
173+ value ->
174+ Item
175+ <$> fmap Name (parseToString value)
176+ <*> pure Nothing
152177
153178instance Ginger. ToGVal m Item where
154- toGVal (Item t) = Ginger. toGVal $ escapeTeX t
179+ toGVal Item {.. } = Ginger. dict
180+ [ " name" ~> itemName
181+ , " url" ~> itemUrl
182+ ]
155183
156- instance TTC. Render Item where
157- render (Item t) = TTC. fromT t
184+ -- instance TTC.Render Item where
185+ -- render (Item t) = TTC.fromT t
158186
159187-- | Queue information
160188data Queue
161189 = Queue
162190 { queueName :: ! Name
191+ , queueUrl :: ! (Maybe Url )
163192 , queueSection :: ! Section
164193 , queueSplit :: ! Bool
165194 , queueTags :: ! [Tag ]
@@ -171,6 +200,7 @@ data Queue
171200instance FromJSON Queue where
172201 parseJSON = A. withObject " Queue" $ \ o -> do
173202 queueName <- o .: " name"
203+ queueUrl <- o .:? " url"
174204 queueSection <- o .: " section"
175205 queueSplit <- o .:? " split" .!= False
176206 queueTags <- o .:? " tags" .!= []
@@ -262,6 +292,7 @@ loadQueuesYaml path = do
262292data QueueCtx
263293 = QueueCtx
264294 { name :: ! Name
295+ , url :: ! (Maybe Url )
265296 , isSplit :: ! Bool
266297 , isPartial :: ! Bool
267298 , isComplete :: ! Bool
@@ -273,6 +304,7 @@ data QueueCtx
273304instance Ginger. ToGVal m QueueCtx where
274305 toGVal QueueCtx {.. } = Ginger. dict
275306 [ " name" ~> name
307+ , " url" ~> url
276308 , " isSplit" ~> isSplit
277309 , " isPartial" ~> isPartial
278310 , " isComplete" ~> isComplete
@@ -285,6 +317,7 @@ instance Ginger.ToGVal m QueueCtx where
285317queueCtx :: Queue -> QueueCtx
286318queueCtx Queue {.. } = QueueCtx
287319 { name = queueName
320+ , url = queueUrl
288321 , isSplit = queueSplit
289322 , isPartial = TagPartial `elem` queueTags
290323 , isComplete = TagComplete `elem` queueTags
@@ -384,7 +417,7 @@ data Options
384417 }
385418 deriving Show
386419
387- -- Parse program options
420+ -- | Parse program options
388421parseOptions :: IO Options
389422parseOptions = OA. execParser
390423 $ OA. info (LibOA. helper <*> LibOA. versioner version <*> options)
0 commit comments