Skip to content

Commit

Permalink
Create first testing book using txt2epub.
Browse files Browse the repository at this point in the history
  • Loading branch information
dixiecko committed Jan 5, 2010
1 parent 0da6fe1 commit a151dba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Codec/EBook.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module Codec.EBook (
book2Str,
book2Str',
book2Arch',
book2Arch
book2Arch,
opsMediatype
)
where

Expand All @@ -18,6 +19,8 @@ import Codec.EBook.OPF
import Codec.EBook.OCF
import qualified Data.ByteString.Lazy as B

opsMediatype = "application/xhtml+xml"

book2Str :: Book -> Integer -> B.ByteString
book2Str book t = fromArchive (book2Arch book t)

Expand Down
14 changes: 12 additions & 2 deletions src/txt2epub.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import qualified Data.ByteString.Lazy as B
import Codec.EBook
import System.Environment (getArgs)
import Data.List (foldl')

main = do
fileNames <- getArgs
let book = emptyBook {
bookID = "http://localhost/pokus",
bookAuthor = "Jozef Chroustal",
bookTitle = "Macka a Pes"
}
print book
outdata <- book2Str' book
items <- mapM (loadItems) fileNames
let bookFull = foldl' (addItem2Book) book items
print bookFull
outdata <- book2Str' bookFull
print outdata
B.writeFile "book.epub" outdata

loadItems :: FilePath -> IO BookItem
loadItems p = do
c <- B.readFile p
return (BookItem ("http://localhost/"++p) p c opsMediatype (Just (ChapterMetadata p)))

0 comments on commit a151dba

Please sign in to comment.