packages feed

epub-tools 1.1.1 → 1.1.2

raw patch · 21 files changed

+91/−74 lines, 21 filesdep ~epub-metadatasetup-changed

Dependency ranges changed: epub-metadata

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2008-2011 Dino Morelli+Copyright (c) 2008-2012 Dino Morelli All rights reserved.  Redistribution and use in source and binary forms, with or without
Setup.hs view
@@ -1,6 +1,6 @@ #! /usr/bin/env runhaskell --- Copyright: 2008, 2011 Dino Morelli+-- Copyright: 2008-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
epub-tools.cabal view
@@ -1,10 +1,10 @@ name:                epub-tools cabal-version:       >= 1.8-version:             1.1.1+version:             1.1.2 build-type:          Simple license:             BSD3 license-file:        LICENSE-copyright:           2008-2011 Dino Morelli +copyright:           2008-2012 Dino Morelli  author:              Dino Morelli  maintainer:          Dino Morelli <dino@ui3.info> stability:           stable@@ -23,7 +23,7 @@ executable           epubmeta    main-is:          EpubTools/epubmeta.hs    build-depends:    base >= 3 && < 5, bytestring, directory,-                     epub-metadata >= 2.2, filepath, mtl, process,+                     epub-metadata >= 2.3, filepath, mtl, process,                      zip-archive    hs-source-dirs:   src    other-modules:    EpubTools.EpubMeta.Display@@ -32,14 +32,11 @@                      EpubTools.EpubMeta.Import                      EpubTools.EpubMeta.Opts                      EpubTools.EpubMeta.Util--   -- Strip symbols from binary, for Windows, not portable, see [1] below-   --ghc-options:      -Wall -optl-s    ghc-options:      -Wall  executable           epubname    main-is:          EpubTools/epubname.hs-   build-depends:    base >= 3 && < 5, directory, epub-metadata >= 2.2, +   build-depends:    base >= 3 && < 5, directory, epub-metadata >= 2.3,                       mtl, regex-compat    hs-source-dirs:   src    other-modules:    EpubTools.EpubName.Author@@ -47,31 +44,20 @@                      EpubTools.EpubName.Opts                      EpubTools.EpubName.PubYear                      EpubTools.EpubName.Util--   -- Strip symbols from binary, for Windows, not portable, see [1] below-   --ghc-options:      -Wall -optl-s    ghc-options:      -Wall  test-suite           epubname-tests    type:             exitcode-stdio-1.0    main-is:          EpubTools/test-epubname.hs-   build-depends:    base, directory, epub-metadata >= 2.2, HUnit, mtl,+   build-depends:    base, directory, epub-metadata >= 2.3, HUnit, mtl,                      regex-compat    hs-source-dirs:   src testsuite    ghc-options:      -Wall  executable           epubzip    main-is:          EpubTools/epubzip.hs-   build-depends:    base >= 3 && < 5, directory, epub-metadata >= 2.2,+   build-depends:    base >= 3 && < 5, directory, epub-metadata >= 2.3,                      filepath, mtl, regex-compat    hs-source-dirs:   src    other-modules:    EpubTools.EpubZip.Opts--   -- Strip symbols from binary, for Windows, not portable, see [1] below-   --ghc-options:      -Wall -optl-s    ghc-options:      -Wall----- [1] The right way to handle this should be an if os(windows) block---     but that makes this package unacceptable to Hackage. Sorry,---     you'll have to use comments to switch this on.
src/EpubTools/EpubMeta/Display.hs view
@@ -1,4 +1,4 @@--- Copyright: 2010, 2011 Dino Morelli+-- Copyright: 2010-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
src/EpubTools/EpubMeta/Edit.hs view
@@ -1,4 +1,4 @@--- Copyright: 2010, 2011 Dino Morelli+-- Copyright: 2010-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
src/EpubTools/EpubMeta/Export.hs view
@@ -1,4 +1,4 @@--- Copyright: 2010, 2011 Dino Morelli+-- Copyright: 2010-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
src/EpubTools/EpubMeta/Import.hs view
@@ -1,4 +1,4 @@--- Copyright: 2010, 2011 Dino Morelli+-- Copyright: 2010-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> @@ -9,8 +9,8 @@ import Codec.Archive.Zip ( Entry (..), addEntryToArchive, readEntry, toArchive ) import Codec.Epub.Archive ( writeArchive ) import Codec.Epub.IO ( opfContentsFromBS )-import qualified Data.ByteString as S-import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString as BS+import qualified Data.ByteString.Lazy as BL import Data.Maybe ( fromJust ) import System.Directory ( removeFile ) @@ -27,15 +27,14 @@    tempEntry <- liftIO $ readEntry [] pathToNewOpf     -- The path in the book where new file must go-   strictBytes <- liftIO $ S.readFile zipPath-   let bytes = B.fromChunks [strictBytes]-   (pathToOldFile, _) <- opfContentsFromBS bytes+   strictBytes <- liftIO $ BS.readFile zipPath+   (pathToOldFile, _) <- opfContentsFromBS strictBytes     -- Adjust the entry's path    let newEntry = tempEntry { eRelativePath = pathToOldFile }     -- Bytes of existing archive already loaded, make an Archive from that-   let oldArchive = toArchive bytes+   let oldArchive = toArchive . BL.fromChunks $ [strictBytes]     -- Add new entry to it (replacing old one)    let newArchive = addEntryToArchive newEntry oldArchive
src/EpubTools/EpubMeta/Opts.hs view
@@ -1,4 +1,4 @@--- Copyright: 2010, 2011 Dino Morelli+-- Copyright: 2010-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> @@ -103,5 +103,5 @@          , ""          , "For more information please see the IDPF OPF specification found here: http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm"          , ""-         , "Version 1.1.1  Dino Morelli <dino@ui3.info>"+         , "Version 1.1.2  Dino Morelli <dino@ui3.info>"          ]
src/EpubTools/EpubMeta/Util.hs view
@@ -1,4 +1,4 @@--- Copyright: 2008-2011 Dino Morelli+-- Copyright: 2008-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
src/EpubTools/EpubName/Author.hs view
@@ -1,4 +1,4 @@--- Copyright: 2008-2011 Dino Morelli+-- Copyright: 2008-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
src/EpubTools/EpubName/Format.hs view
@@ -1,4 +1,4 @@--- Copyright: 2008-2011 Dino Morelli+-- Copyright: 2008-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> @@ -10,6 +10,7 @@ import Codec.Epub.Opf.Package import Control.Monad.Error import Data.List ( isPrefixOf )+import Data.Maybe ( fromJust ) import Text.Printf import Text.Regex @@ -114,10 +115,17 @@  magEclipse :: Metadata -> EN (String, [String]) magEclipse md = do-   (prefix:issue:_) <--      extractTitle md "^(Eclipse) ([^ ]+)$"-   let title = printf "%s%s" prefix (wordNum issue)+   authorMatches md "Jonathan Strahan" +   (prefix:issueRaw:_) <- extractTitle md "^(Eclipse) ([^ :]+)"++   let issue = fromJust $+         mbWordNum issueRaw+         `mplus`+         (Just $ printf "%02d" (read issueRaw :: Int))++   let title = printf "%s%s" prefix issue+    return ("magEclipse", [title])  @@ -361,24 +369,27 @@ {- Convert an English word for a number into number form -} wordNum :: String -> String-wordNum "One"       = "01"-wordNum "Two"       = "02"-wordNum "Three"     = "03"-wordNum "Four"      = "04"-wordNum "Five"      = "05"-wordNum "Six"       = "06"-wordNum "Seven"     = "07"-wordNum "Eight"     = "08"-wordNum "Nine"      = "09"-wordNum "Ten"       = "10"-wordNum "Eleven"    = "11"-wordNum "Twelve"    = "12"-wordNum "Thirteen"  = "13"-wordNum "Fourteen"  = "14"-wordNum "Fifteen"   = "15"-wordNum "Sixteen"   = "16"-wordNum "Seventeen" = "17"-wordNum "Eighteen"  = "18"-wordNum "Nineteen"  = "19"-wordNum "Twenty"    = "20"-wordNum x           = "[ERROR wordNum " ++ x ++ "]"+wordNum s = maybe ("[ERROR mbWordNum " ++ s ++ "]") id $ mbWordNum s++mbWordNum :: String -> Maybe String+mbWordNum "One"       = Just "01"+mbWordNum "Two"       = Just "02"+mbWordNum "Three"     = Just "03"+mbWordNum "Four"      = Just "04"+mbWordNum "Five"      = Just "05"+mbWordNum "Six"       = Just "06"+mbWordNum "Seven"     = Just "07"+mbWordNum "Eight"     = Just "08"+mbWordNum "Nine"      = Just "09"+mbWordNum "Ten"       = Just "10"+mbWordNum "Eleven"    = Just "11"+mbWordNum "Twelve"    = Just "12"+mbWordNum "Thirteen"  = Just "13"+mbWordNum "Fourteen"  = Just "14"+mbWordNum "Fifteen"   = Just "15"+mbWordNum "Sixteen"   = Just "16"+mbWordNum "Seventeen" = Just "17"+mbWordNum "Eighteen"  = Just "18"+mbWordNum "Nineteen"  = Just "19"+mbWordNum "Twenty"    = Just "20"+mbWordNum _           = Nothing
src/EpubTools/EpubName/Opts.hs view
@@ -1,4 +1,4 @@--- Copyright: 2008-2011 Dino Morelli+-- Copyright: 2008-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> @@ -113,7 +113,7 @@          , ""          , "Only creator tags with either a role attribute of 'aut' or no role at all are considered authors. If a file-as attribute is present, this will be the preferred string. If not, the program tries to do some intelligent parsing of the name."          , ""-         , "The OPF spec suggests there may be a <dc:date event='publication'>2011</date> element representing original publication date. If this is present, or event='original-publication', it will be used by default. The --any-date switch will fall back to the first date found as necessary. The year can be parsed out of many date formats, it's very flexible."+         , "The OPF spec suggests there may be a <dc:date opf:event='publication'>2011</date> element representing original publication date. If this (or opf:event='original-publication') is present, it will be used by default for _year as in the above examples. The --any-date switch will use the first date tag found, regardless of attributes. The year can be parsed out of many date formats, it's very flexible."          , ""          , "Publisher: I wanted to provide a way to have multiple copies of the same book produced by different publishers and name them sort-of unambiguously. I came up with the idea of expecting a contributor tag with role attribute of 'bkp' (so far, this is fairly normal). And then use a file-as attribute on that tag to contain a small string to be used in the filename. The idea here is short and sweet for the file-as."          , ""@@ -121,5 +121,5 @@          , ""          , "For more information please see the IDPF OPF specification found here: http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm"          , ""-         , "Version 1.1.1  Dino Morelli <dino@ui3.info>"+         , "Version 1.1.2  Dino Morelli <dino@ui3.info>"          ]
src/EpubTools/EpubName/PubYear.hs view
@@ -1,4 +1,4 @@--- Copyright: 2011 Dino Morelli+-- Copyright: 2011, 2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
src/EpubTools/EpubName/Util.hs view
@@ -1,4 +1,4 @@--- Copyright: 2008-2011 Dino Morelli+-- Copyright: 2008-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
src/EpubTools/EpubZip/Opts.hs view
@@ -1,4 +1,4 @@--- Copyright: 2010, 2011 Dino Morelli+-- Copyright: 2010-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> @@ -68,5 +68,5 @@          , ""          , "For more information please see the IDPF OPF specification found here: http://idpf.org/epub/20/spec/OPF_2.0.1_draft.htm"          , ""-         , "Version 1.1.1  Dino Morelli <dino@ui3.info>"+         , "Version 1.1.2  Dino Morelli <dino@ui3.info>"          ]
src/EpubTools/epubmeta.hs view
@@ -1,4 +1,4 @@--- Copyright: 2010, 2011 Dino Morelli+-- Copyright: 2010-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
src/EpubTools/epubname.hs view
@@ -1,4 +1,4 @@--- Copyright: 2008-2011 Dino Morelli+-- Copyright: 2008-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
src/EpubTools/epubzip.hs view
@@ -1,4 +1,4 @@--- Copyright: 2011 Dino Morelli+-- Copyright: 2011, 2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
testsuite/EpubTools/Test/EpubName/Format.hs view
@@ -1,4 +1,4 @@--- Copyright: 2011 Dino Morelli+-- Copyright: 2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> @@ -64,6 +64,7 @@    , testMagBlackStatic    , testRageMachineMag    , testEclipseMag+   , testEclipseMagNum    , testBcs    , testBkpFileAs    , testBkpText@@ -831,6 +832,23 @@       expected =          ( "magEclipse"          , "Eclipse01.epub"+         )+++testEclipseMagNum :: Test+testEclipseMagNum = TestCase $+   assertNewName "Eclipse Magazine" meta expected+   where+      meta = emptyMetadata+         { metaCreators = [MetaCreator (Just "aut")+            (Just "Strahan, Jonathan")+            "Jonathan Strahan"]+         , metaTitles = [MetaTitle Nothing +            "Eclipse 4: New Science Fiction and Fantasy"]+         }+      expected =+         ( "magEclipse"+         , "Eclipse04.epub"          )  
testsuite/EpubTools/Test/EpubName/PubYear.hs view
@@ -1,4 +1,4 @@--- Copyright: 2011 Dino Morelli+-- Copyright: 2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> @@ -21,6 +21,9 @@    , testExtractYear "2009-11-19T07:00:00+00:00" "2009"    , testExtractYear "2010-09-21" "2010"    , testExtractYear "2010-02-14T21:47:47.682882+00:00" "2010"+   , testExtractYear "2011-11-16T09:19:50-0500" "2011"+   , testExtractYear "2011-11-16T14:19:52Z" "2011"+   , testExtractYear "Tue, 29 Nov 2011 06:21:19 +0000" "2011"    ]  
testsuite/EpubTools/test-epubname.hs view
@@ -1,4 +1,4 @@--- Copyright: 2008-2011 Dino Morelli+-- Copyright: 2008-2012 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info>