summaryrefslogtreecommitdiff
path: root/Main.hs
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-06-08 14:35:04 +0200
committerLars-Dominik Braun <lars@6xq.net>2015-06-08 14:35:04 +0200
commit9d00df8bc5b6f4ba313b1085c069c19faeaaaaf9 (patch)
treedc1471817679c5782aa07cc81b21788dd2867767 /Main.hs
parent99d72446511240b08e50cd5cb02eae90d3b16689 (diff)
downloadcomatose-9d00df8bc5b6f4ba313b1085c069c19faeaaaaf9.tar.gz
comatose-9d00df8bc5b6f4ba313b1085c069c19faeaaaaf9.tar.bz2
comatose-9d00df8bc5b6f4ba313b1085c069c19faeaaaaf9.zip
Do not link paper title of no url is available
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/Main.hs b/Main.hs
index 9ef47be..9e728ca 100644
--- a/Main.hs
+++ b/Main.hs
@@ -143,7 +143,7 @@ calcRank db =
stop prevalgos algos = rankdiff prevalgos algos > 0.00001
in db { dalgos = (iterateUntil run stop initalgos) }
-maybeToHtml = maybe (toHtml ("" :: String)) toHtml
+maybeToHtml = maybe mempty toHtml
scholarSearch q = "http://scholar.google.com/scholar?q=" ++ escapeURIString isReserved q
resolveDoi q = "http://doi.org/" ++ q
@@ -221,12 +221,17 @@ bibentryurl bib = safeHead $ catMaybes [doi, url]
-- | Format bibliography/references item
bibentry :: E.T -> Html ()
bibentry bib = do
- let fields = E.fields bib
- a_ [href_ $ T.pack $ maybe "" id $ bibentryurl bib, class_ "title"] $ maybeToHtml $ lookup "title" fields
+ let
+ fields = E.fields bib
+ htmlLookup k = maybeToHtml $ lookup k fields
+ maybe
+ (span_ [class_ "title"] $ htmlLookup "title")
+ (\x -> a_ [href_ $ T.pack $ x, class_ "title"] $ htmlLookup "title")
+ (bibentryurl bib)
", "
- span_ [class_ "author"] $ maybeToHtml $ lookup "author" fields
+ span_ [class_ "author"] $ htmlLookup "author"
", "
- span_ [class_ "year"] $ maybeToHtml $ lookup "year" fields
+ span_ [class_ "year"] $ htmlLookup "year"
-- | References section
references :: [E.T] -> Html ()