= proc tree
-> do pName <- getXPathTreesInDoc "/page/@name/text()" >>> getText -< tree
pType <- getXPathTreesInDoc "/page/@type/text()" >>> getText >>> arr read -< tree
- pIsBinary <- getXPathTreesInDoc "/page/@isBinary/text()" >>> getText -< tree
pFileName <- maybeA (getXPathTreesInDoc "/page/fileName/text()" >>> getText) -< tree
textData <- maybeA (getXPathTreesInDoc "/page/textData/text()" >>> getText) -< tree
+ base64Data <- maybeA (getXPathTreesInDoc "/page/binaryData/text()" >>> getText) -< tree
+
+ let dataURI = fmap (binToURI pType) base64Data
case pType of
MIMEType "text" "x-rakka" _
Right xs -> returnA -< xs
MIMEType "image" _ _
- -> returnA -< [ Paragraph [Image pName Nothing] ]
-
- _ -> if pIsBinary == "yes" then
- returnA -< [ Paragraph [ ObjectLink {
- objLinkPage = pName
- , objLinkText = Just $ fromMaybe (defaultFileName pType pName) pFileName
- }
+ -- <img src="data:image/png;base64,..." />
+ -> returnA -< [ Paragraph [Image (Left $ fromJust dataURI) Nothing] ]
+
+ _ -> if isJust dataURI then
+ -- <a href="data:application/zip;base64,...">foo.zip</a>
+ returnA -< [ Paragraph [ Anchor
+ [("href", show dataURI)]
+ [Text (fromMaybe (defaultFileName pType pName) pFileName)]
]
]
else