From 73dc07a092b16be90c43a42035bb27ac16d6e78a Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 14 Apr 2015 13:39:45 +0200 Subject: Add links to DOI/Google scholar --- Main.hs | 9 +++++++++ comatose.cabal | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Main.hs b/Main.hs index be2e409..5713b43 100644 --- a/Main.hs +++ b/Main.hs @@ -14,6 +14,7 @@ import Text.Parsec.Error import Text.ParserCombinators.Parsec.Prim import qualified Data.ByteString.Lazy as BS import System.FilePath ((<.>), splitExtension) +import Network.URI (isReserved, escapeURIString) import Lucid import Paths_comatose @@ -87,6 +88,9 @@ maybeToHtml = maybe (toHtml ("" :: String)) toHtml head' [] = Nothing head' (x:_) = Just x +scholarSearch q = "http://scholar.google.com/scholar?q=" ++ escapeURIString isReserved q +resolveDoi q = "http://doi.org/" ++ q + protoentry :: Database -> (String, Protocol) -> Html () protoentry db (ident, p) = tr_ [id_ $ T.pack ident] $ do let @@ -95,6 +99,10 @@ protoentry db (ident, p) = tr_ [id_ $ T.pack ident] $ do field key = firstpub >>= (return . E.fields) >>= lookup key td_ $ toHtml $ pname p 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)) @@ -126,6 +134,7 @@ page db = doctypehtml_ $ do tr_ $ do th_ "Name" th_ "" + th_ "" th_ "Year" th_ "Features" tbody_ $ forM_ (M.toList $ dalgos db) (protoentry db) diff --git a/comatose.cabal b/comatose.cabal index 9f70b88..0847041 100644 --- a/comatose.cabal +++ b/comatose.cabal @@ -19,7 +19,7 @@ executable comatose main-is: Main.hs -- other-modules: -- other-extensions: - build-depends: base >=4.6 && <4.7, bibtex, yaml, containers, parsec, lucid, bytestring, text, filepath + build-depends: base >=4.6 && <4.7, bibtex, yaml, containers, parsec, lucid, bytestring, text, filepath, network -- hs-source-dirs: default-language: Haskell2010 -- cgit v1.2.3