summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-04-28 10:47:29 +0200
committerLars-Dominik Braun <lars@6xq.net>2015-04-28 10:47:29 +0200
commitca39456f4ba114cb0bbeb9c719f78bf7692c1686 (patch)
tree4d2c5bf841db7c65ea6c6b41a149031de55e8c0d
parentbe936e130800294866d3f7596b34a9324046d782 (diff)
downloadcomatose-ca39456f4ba114cb0bbeb9c719f78bf7692c1686.tar.gz
comatose-ca39456f4ba114cb0bbeb9c719f78bf7692c1686.tar.bz2
comatose-ca39456f4ba114cb0bbeb9c719f78bf7692c1686.zip
Enhance popup
-rw-r--r--Main.hs25
-rw-r--r--data/script.js3
2 files changed, 22 insertions, 6 deletions
diff --git a/Main.hs b/Main.hs
index 638cd43..1d5195a 100644
--- a/Main.hs
+++ b/Main.hs
@@ -46,6 +46,9 @@ data JQData = JQData {
jname :: String
, jlongname :: Maybe String
, jdescription :: Maybe String
+ , jdoi :: Maybe String
+ , jyear :: Maybe String
+ , jtitle :: Maybe String
} deriving Show
instance ToJSON JQData where
@@ -53,6 +56,9 @@ instance ToJSON JQData where
"name" .= jname d
, "longname" .= jlongname d
, "description" .= jdescription d
+ , "doi" .= jdoi d
+ , "year" .= jyear d
+ , "title" .= jtitle d
]
type FeatureList = M.Map String Feature
@@ -110,6 +116,9 @@ head' (x:_) = Just x
scholarSearch q = "http://scholar.google.com/scholar?q=" ++ escapeURIString isReserved q
resolveDoi q = "http://doi.org/" ++ q
+maybeLink :: Html () -> Maybe T.Text -> Html ()
+maybeLink text href = maybe text (\x -> a_ [href_ x] text) href
+
protoentry :: Database -> (String, Protocol) -> Html ()
protoentry db (ident, p) =
let
@@ -120,18 +129,17 @@ protoentry db (ident, p) =
jname = pname p
, jlongname = plongname p
, jdescription = pdescription p
+ , jdoi = field "doi"
+ , jyear = field "year"
+ , jtitle = field "title"
}
in
tr_ [
id_ $ T.pack ident
, data_ "proto" ((decodeUtf8 . BS.toStrict . A.encode) jdata)
] $ do
- td_ $ toHtml $ pname p
+ td_ $ maybeLink (toHtml $ pname p) (field "doi" >>= return . T.pack . resolveDoi)
td_ $ maybeToHtml $ plongname p
- td_ $ do
- maybe "" (\x -> a_ [href_ $ T.pack $ resolveDoi x] "doi") $ field "doi"
- " "
- maybe "" (\x -> a_ [href_ $ T.pack $ scholarSearch x] "Google") $ field "title"
td_ $ maybeToHtml $ field "year"
td_ [class_ "features"] $ ul_ $ forM_ (sort $ M.keys $ pfeatures p) (\x -> li_ $ toHtml $ maybe ("" :: String) fname $ M.lookup x (dfeatures db))
@@ -175,7 +183,6 @@ protocols db = table_ [id_ "algo", class_ "table table-striped"] $ do
tr_ $ do
th_ "Name"
th_ ""
- th_ ""
th_ "Year"
th_ "Features"
tbody_ $ forM_ (M.toList $ dalgos db) (protoentry db)
@@ -204,6 +211,12 @@ page db attrib = doctypehtml_ $ do
div_ [id_ "popup"] $ do
h2_ ""
p_ [class_ "subtitle"] ""
+ p_ [class_ "ref"] $ do
+ span_ [class_ "year"] ""
+ ", "
+ a_ [class_ "doi"] ""
+ ", "
+ a_ [class_ "scholar"] "Scholar"
p_ [class_ "description"] ""
extjs "script.js"
diff --git a/data/script.js b/data/script.js
index 8ed1aa8..58d94f3 100644
--- a/data/script.js
+++ b/data/script.js
@@ -7,6 +7,9 @@ $(document).ready (function () {
var data = $(this).data ('proto');
$('#popup h2').text (data.name);
$('#popup .subtitle').text (data.longname);
+ $('#popup .doi').text ('doi:' + data.doi);
+ $('#popup .doi').attr ('href', 'http://doi.org/' + data.doi);
+ $('#popup .scholar').attr ('href', 'http://scholar.google.com/scholar?q=' + encodeURIComponent (data.title));
$('#popup .year').text (data.year);
$('#popup .description').text (data.description);