summaryrefslogtreecommitdiff
path: root/Main.hs
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-05-04 11:01:54 +0200
committerLars-Dominik Braun <lars@6xq.net>2015-05-04 11:01:54 +0200
commita2618d9d5c488c6b20208227b04800df1a09e211 (patch)
tree63ba2c384a3ec99f0b920cbfbb5f634027af99d1 /Main.hs
parent2da0a83cf927b11609dcaafa03312f34e594f2b5 (diff)
downloadcomatose-a2618d9d5c488c6b20208227b04800df1a09e211.tar.gz
comatose-a2618d9d5c488c6b20208227b04800df1a09e211.tar.bz2
comatose-a2618d9d5c488c6b20208227b04800df1a09e211.zip
Show related field
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/Main.hs b/Main.hs
index e96f7ea..b99b78d 100644
--- a/Main.hs
+++ b/Main.hs
@@ -35,6 +35,9 @@ data Protocol = Protocol {
, pref :: [String]
-- |Feature references of this protocol
, pfeatures :: M.Map String (Maybe String)
+ -- |List of references to other protocols, usually from the paper’s
+ -- “related work” section
+ , prelated :: [String]
} deriving Show
-- |A MAC protocol feature
@@ -62,6 +65,7 @@ instance FromJSON Protocol where
<*> v .:? "description"
<*> v .:? "ref" .!= []
<*> v .:? "features" .!= M.empty
+ <*> v .:? "related" .!= []
parseJSON _ = mzero
instance FromJSON Feature where
@@ -131,6 +135,18 @@ protodesc Protocol { pdescription = Just desc } = do
dt_ "Description"
dd_ $ p_ $ toHtml desc
+protorelated :: Database -> Protocol -> Html ()
+protorelated _ p | null $ prelated p = mempty
+protorelated db p =
+ let
+ algos = dalgos db
+ lookup k = M.lookup k algos >>= \y -> return (k, y)
+ rel = catMaybes $ map lookup $ prelated p
+ in do
+ dt_ "Related"
+ dd_ [class_ "related"] $ ul_ $ forM_ rel $
+ \(ident, x) -> li_ $ a_ [href_ (T.pack $ '#':ident)] $ toHtml $ pname x
+
-- |One protocol
protoentry :: Database -> (String, Protocol) -> Html ()
protoentry db (ident, p) =
@@ -155,6 +171,7 @@ protoentry db (ident, p) =
protopapers pubs
protodesc p
protofeatures db p
+ protorelated db p
extcss url = link_ [rel_ "stylesheet", type_ "text/css", href_ url]