5 import qualified Data.ByteString.Lazy as B (writeFile)
6 import Data.List (foldl')
7 import Data.Tree.NTree.TypeDefs (NTree)
8 import System.FilePath (normalise)
9 import Text.XML.HXT.Core (IOSArrow, XNode, XmlTree)
11 import Misc (string_to_bytestring)
15 class (XHTML a) => Epublishable a where
16 parse :: IOSArrow XmlTree (NTree XNode) -> IO (Maybe a)
20 epublish :: a -> FilePath -> Integer -> IO ()
21 epublish obj path time = do
22 let book_name = title obj
25 bookID = "http://lwn.net/" ++ book_name,
26 bookAuthor = "LWN <http://lwn.net> Copyright Eklektix, Inc.",
29 let xhtml = to_xhtml obj
30 bs_xhtml <- string_to_bytestring xhtml
32 let normalized_path = normalise path
33 let metadata = Just (ChapterMetadata book_name)
34 let bi = BookItem iid normalized_path bs_xhtml opsMediatype metadata
35 let bookFull = foldl' addItem2Book book [bi]
36 let outdata = book2Bin bookFull time
37 B.writeFile normalized_path outdata