summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-04-14 13:39:45 +0200
committerLars-Dominik Braun <lars@6xq.net>2015-04-14 13:39:45 +0200
commit73dc07a092b16be90c43a42035bb27ac16d6e78a (patch)
treef285f48c729f79f34c63f6e8538506fdce8b975b
parentc19379e085ac0d18f18a017e59c88a67997b45d4 (diff)
downloadcomatose-73dc07a092b16be90c43a42035bb27ac16d6e78a.tar.gz
comatose-73dc07a092b16be90c43a42035bb27ac16d6e78a.tar.bz2
comatose-73dc07a092b16be90c43a42035bb27ac16d6e78a.zip
Add links to DOI/Google scholar
-rw-r--r--Main.hs9
-rw-r--r--comatose.cabal2
2 files changed, 10 insertions, 1 deletions
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