--- /dev/null
+module Epublishable
+where
+
+import Codec.EBook
+import qualified Data.ByteString.Lazy as B (writeFile)
+import Data.List (foldl')
+import Data.Tree.NTree.TypeDefs (NTree)
+import System.FilePath (normalise)
+import Text.XML.HXT.Core (IOSArrow, XNode, XmlTree)
+
+import Misc (string_to_bytestring)
+import XHTML
+
+
+class (XHTML a) => Epublishable a where
+ parse :: IOSArrow XmlTree (NTree XNode) -> IO (Maybe a)
+
+ title :: a -> String
+
+ epublish :: a -> FilePath -> Integer -> IO ()
+ epublish obj path time = do
+ let book_name = title obj
+ let book =
+ emptyBook {
+ bookID = "http://lwn.net/" ++ book_name,
+ bookAuthor = "LWN <http://lwn.net> Copyright Eklektix, Inc.",
+ bookTitle = book_name
+ }
+ let xhtml = to_xhtml obj
+ bs_xhtml <- string_to_bytestring xhtml
+ let iid = "iid-1"
+ let normalized_path = normalise path
+ let metadata = Just (ChapterMetadata book_name)
+ let bi = BookItem iid normalized_path bs_xhtml opsMediatype metadata
+ let bookFull = foldl' addItem2Book book [bi]
+ let outdata = book2Bin bookFull time
+ B.writeFile normalized_path outdata