From 9d00df8bc5b6f4ba313b1085c069c19faeaaaaf9 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 8 Jun 2015 14:35:04 +0200 Subject: Do not link paper title of no url is available --- Main.hs | 15 ++++++++++----- 1 file 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 () -- cgit v1.2.3