| LineBreak ![Attribute]
| Span ![Attribute] ![InlineElement]
| Image {
- imgSource :: !(PageName)
+ imgSource :: !(Either URI PageName)
, imgAlt :: !(Maybe String)
}
| Anchor ![Attribute] ![InlineElement]
= 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
formatImage :: (ArrowXml a) => a (URI, InlineElement) XmlTree
formatImage = proc (baseURI, Image src alt)
- -> let uri = mkObjectURI baseURI src
+ -> let uri = case src of
+ Left uri -> uri
+ Right name -> mkObjectURI baseURI name
href = uriToString id uri ""
in
( eelem "img"
Just others -> error ("unknown \"float\" attribute: " ++ others)
anchorAttrs = [hrefAttr, classAttr]
- return (Anchor anchorAttrs [Image pageName alt])
+ return (Anchor anchorAttrs [Image (Right pageName) alt])
}
return (Div [classAttr]
[ Block (Div [("class", "imageData")]
[ Inline (Anchor [hrefAttr]
- [ Image pageName Nothing ]) ])
+ [ Image (Right pageName) Nothing ]) ])
, Block (Div [("class", "imageCaption")]
[ Block x | x <- inside ])
]
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://cielonegro.org/schema/Rakka/Page/1.0"
type="text/x-rakka"
- isBoring="no"
- lang="en"><!-- FIXME: isBoring="yes" -->
+ isBoring="yes"
+ lang="en">
- <!-- FIXME: delete this -->
- <summary>The description of syntax of Rakka</summary>
-
- <textData><![CDATA[= Syntax Help =
+ <textData><![CDATA[
+= Syntax Help =
== Heading ==
blah blah blah...
blah blah blah blah...
<cite>-- John Doe<cite>
+</blockquote>
-->
== Listing ==
<div id="example">example</div>
-
]]>
</textData>
</page>
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://cielonegro.org/schema/Rakka/Page/1.0"
type="text/x-rakka"
- isBoring="no"
- lang="en"><!-- FIXME: isBoring="yes" -->
+ isBoring="yes"
+ lang="en">
<otherLang>
<link lang="ja" page="メインページ" />
</otherLang>
- <!-- FIXME: delete this -->
- <summary>The main page to be shown as an index page.</summary>
-
<textData><![CDATA[
= Main Page =
This is the main page.
: $page.attr("type") == "text/css" ? "css"
: "unknown"
;
- var source = $page.find("source").text();
+ var source = $page.find("textData").text();
Rakka.displayPageEditor($body, pageName, oldRevision, defaultType, source);
},
error : function (req) {