]> gitweb @ CieloNegro.org - Rakka.git/commitdiff
Record before chucking Data.Generics. It's way too slow.
authorpho <pho@cielonegro.org>
Wed, 31 Oct 2007 02:30:07 +0000 (11:30 +0900)
committerpho <pho@cielonegro.org>
Wed, 31 Oct 2007 02:30:07 +0000 (11:30 +0900)
darcs-hash:20071031023007-62b54-0068627704a20e0153d10ff0bfa7700e0787b370.gz

Rakka/Wiki.hs
Rakka/Wiki/Engine.hs
Rakka/Wiki/Formatter.hs
Rakka/Wiki/Interpreter/Image.hs
defaultPages/Help/Syntax
defaultPages/MainPage
js/editPage.js

index af50afbc7adef90939cdba3376cad8bca3de214b..c1b7c7dda18adef0195087644057f54cb9f51d16 100644 (file)
@@ -74,7 +74,7 @@ data InlineElement
     | LineBreak ![Attribute]
     | Span ![Attribute] ![InlineElement]
     | Image {
-        imgSource :: !(PageName)
+        imgSource :: !(Either URI PageName)
       , imgAlt    :: !(Maybe String)
       }
     | Anchor ![Attribute] ![InlineElement]
index 1f24e37332b96f1f6f093d75546ed73ce385edc2..1d05d5036ff02fd401ec948894833bb0159be42c 100644 (file)
@@ -126,9 +126,11 @@ wikifyPage interpTable
     = 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" _
@@ -137,13 +139,14 @@ wikifyPage interpTable
                      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
index 969c228a756ad93d269ff8d69d219466ece5bd99..4b483db37dba260310b2263ea644db9085684b3c 100644 (file)
@@ -241,7 +241,9 @@ formatPageLink
 
 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"
index 5482d8cffa5eb73cfde7852dea8bf8ce01fc8d57..97ffc8e1fafebc738a0818af3820548f417ac882 100644 (file)
@@ -41,7 +41,7 @@ imageInterp
                                    Just others  -> error ("unknown \"float\" attribute: " ++ others)
                    anchorAttrs = [hrefAttr, classAttr]
 
-               return (Anchor anchorAttrs [Image pageName alt])
+               return (Anchor anchorAttrs [Image (Right pageName) alt])
       }
 
 
@@ -76,7 +76,7 @@ imgFrameInterp
                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 ])
                        ]
index 5e54aed9f49f2ede54689209bda9bea07bcade12..ed2b90cdd2e3b2c61a780e7fcce2608579006a4e 100644 (file)
@@ -1,13 +1,11 @@
 <?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 ==
 
@@ -62,6 +60,7 @@ blah blah blah...
 blah blah blah...
 blah blah blah blah...
 <cite>-- John Doe<cite>
+</blockquote>
 -->
 
 == Listing ==
@@ -99,7 +98,6 @@ blah blah blah blah...
 
 
 <div id="example">example</div>
-
 ]]>
 </textData>
 </page>
index b6e177b6b2b8e2d0653ac436d53ebc7e6bc6112e..cdfb7d6f720233ffc6552921603115e5402bc242 100644 (file)
@@ -1,16 +1,13 @@
 <?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.
index 5297e057726aee809148a390a8f6291c3f3ba286..49b021b619c2231335bc3f7575104f58e129ff89 100644 (file)
@@ -14,7 +14,7 @@ Rakka.editPage = function (baseURI, pageName) {
                                        : $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) {