citation-resolve 0.2.0.0 → 0.2.1
raw patch · 3 files changed
+38/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.CSL.Input.Identifier: readBibcode :: Resolver Reference
+ Text.CSL.Input.Identifier.Internal: readBibcode :: Resolver Reference
Files
- Text/CSL/Input/Identifier.hs +1/−1
- Text/CSL/Input/Identifier/Internal.hs +35/−2
- citation-resolve.cabal +2/−1
Text/CSL/Input/Identifier.hs view
@@ -11,7 +11,7 @@ module Text.CSL.Input.Identifier- (readID, readDOI, readArXiv, readISBN )+ (readID, readDOI, readArXiv, readBibcode, readISBN ) where
Text/CSL/Input/Identifier/Internal.hs view
@@ -15,6 +15,7 @@ import Data.Char (toLower) import Data.List (span) import qualified Data.Text as Text+import qualified Data.String.Utils as String (replace) import Database.Persist import Database.Persist.TH import Database.Persist.Sqlite@@ -66,10 +67,12 @@ Nothing -> do ret <- liftIO $ resolver0 url case ret of- Right content0 ->+ Right content0 -> do flip runSqlPool pool $ do insert $ WebCache url content0+ return ()+ Left _ -> return () return ret @@ -150,7 +153,37 @@ res <- cached (openURIWithOpts opts) url case res of Left msg -> return $ Left msg- Right bs -> resolveBibtex url $ BS.unpack bs+ Right bs -> resolveBibtex url $+ String.replace "adsurl" "url" $+ BS.unpack bs++++-- | resolve an Bibcode ID to a 'Reference'. +-- +-- >>> ref <- forceEither <$> readBibcode " 2012CS&D....5a5003M"+-- >>> title ref+-- "Paraiso: an automated tuning framework for explicit solvers of partial differential equations"+-- >>> containerTitle ref+-- "Computational Science and Discovery"++readBibcode :: Resolver Reference+readBibcode idstr = do+ let+ opts = [ CurlFollowLocation True]+ url = "http://adsabs.harvard.edu/cgi-bin/bib_query?data_type=BIBTEX&bibcode=" ++ idstr+ res <- cached (openURIWithOpts opts) url+ case res of+ Left msg -> return $ Left msg+ Right bs -> resolveBibtex url $+ String.replace "adsurl" "url" $+ BS.unpack bs++++++ -- | resolve an ISBN to a 'Reference'. --
citation-resolve.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: citation-resolve-version: 0.2.0.0+version: 0.2.1 synopsis: convert document IDs such as DOI, ISBN, arXiv ID to bibliographic reference. description: This modules provides a way to convert document identifiers, such@@ -46,6 +46,7 @@ , curl >= 1.3.8 , directory >= 1.2 , download-curl >= 0.1.4 + , MissingH >= 1.1 -- , hxt >= 9.3.1 -- TODO: treat xsl more properly -- , hxt-xslt >= 9.1.1 -- using these libraries. , persistent >= 1.1.4