[Fencommits] fenserve: make '/export' yield plain text rather than HTML

Benja Fallenstein benja.fallenstein at gmail.com
Tue May 1 21:55:39 EEST 2007


Tue May  1 21:55:27 EEST 2007  Benja Fallenstein <benja.fallenstein at gmail.com>
  * make '/export' yield plain text rather than HTML
diff -rN -u old-fenserve/notetaker/Main.hs new-fenserve/notetaker/Main.hs
--- old-fenserve/notetaker/Main.hs	2007-05-01 21:55:39.000000000 +0300
+++ new-fenserve/notetaker/Main.hs	2007-05-01 21:55:39.000000000 +0300
@@ -171,17 +171,19 @@
 
 export path notes = concatMap f [0..length notes-1] where
     f i | Note title own cs <- notes !! i =
-        ":add " ++ renderPath path ++ " " ++ unformat title ++ "\n"
+        ":add " ++ renderPath path ++ " " ++ unquote (unformat title) ++ "\n"
      ++ (if own then ":page " ++ renderPath (path++[i]) ++ "\n" else "")
      ++ export (path++[i]) cs where
     
+plain s = setHeader "Content-Type" "text/plain" (toMessage s)
+    
 main = stdHTTP [ debugFilter
                , h ["log"] GET  $ ok $ \() nick -> renderLog nick False
                , h ["lastlog"] GET $ ok $ \() nick -> renderLog nick True
                , h (Prefix ["export"]) GET $ ok $ \[p] () -> do
                      lines <- get; let (Note _ _ notes) = executeAll lines
-                     respond $ "<pre>" ++ export (readPath p) notes
-               , h ["dump"] GET $ ok $ \() () -> get >>= respond . show
+                     respond $ plain $ export (readPath p) notes
+               , h ["dump"] GET $ ok $ \() () -> get >>= respond . plain . show
                , h [""]    GET  $ ok $ \() nick -> page [] nick
                , h ()      POST $ ok $ \() (nick,line) -> do
                      if line == ":ll" then
diff -rN -u old-fenserve/notetaker/Markup.hs new-fenserve/notetaker/Markup.hs
--- old-fenserve/notetaker/Markup.hs	2007-05-01 21:55:39.000000000 +0300
+++ new-fenserve/notetaker/Markup.hs	2007-05-01 21:55:39.000000000 +0300
@@ -9,6 +9,14 @@
 quote ('&':cs) = "&amp;" ++ quote cs
 quote (c:cs) = c : quote cs
 
+unquote ('&':'l':'t':';':cs) = '<' : unquote cs
+unquote ('&':'g':'t':';':cs) = '>' : unquote cs
+unquote ('&':'a':'m':'p':';':cs) = '&' : unquote cs
+unquote ('&':'q':'u':'o':'t':';':cs) = '"' : unquote cs
+unquote ('&':'a':'p':'o':'s':';':cs) = '\'' : unquote cs
+unquote (c:cs) = c : unquote cs
+unquote "" = ""
+
 format s = f text links where
     (text:links) = split s
     split ""       = [""]




More information about the Fencommits mailing list