[Fencommits] fenserve: shorten the export output, exporting only the commands for recreating the current structure
Benja Fallenstein
benja.fallenstein at gmail.com
Tue May 1 19:05:29 EEST 2007
Tue May 1 19:05:11 EEST 2007 Benja Fallenstein <benja.fallenstein at gmail.com>
* shorten the export output, exporting only the commands for recreating the current structure
diff -rN -u old-fenserve/notetaker/Main.hs new-fenserve/notetaker/Main.hs
--- old-fenserve/notetaker/Main.hs 2007-05-01 19:05:29.000000000 +0300
+++ new-fenserve/notetaker/Main.hs 2007-05-01 19:05:29.000000000 +0300
@@ -198,16 +198,11 @@
bodyView (MakeOwnPage p) nick = page p nick
bodyView (Unpage p) nick = page p nick
-export prefix = ("<pre>"++) . concatMap (\(Line _ _ body) -> f body) where
- r = renderPath . (prefix ++)
- f (Body s) = ""
- f (Add p s) = ":add " ++ r p ++ " " ++ h s [] ++ "\n"
- f (Edit p s) = ":edit " ++ r p ++ " " ++ h s [] ++ "\n"
- f (Move p q) = ":move " ++ r p ++ " " ++ r q ++ "\n"
- f (DeleteOne p) = ":del " ++ r p ++ "\n"
- f (Delete p) = ":deltree " ++ r p ++ "\n"
- f (MakeOwnPage p) = ":page " ++ r p ++ "\n"
- f (Unpage p) = ":unpage " ++ r p ++ "\n"
+export path notes = concatMap f [0..length notes-1] where
+ f i | Note title own cs <- notes !! i =
+ ":add " ++ renderPath path ++ " " ++ h title [] ++ "\n"
+ ++ (if own then ":page " ++ renderPath (path++[i]) ++ "\n" else "")
+ ++ export (path++[i]) cs where
h ('<':'e':'m':'>':cs) ls = "*" ++ h cs ls
h ('<':'/':'e':'m':'>':cs) ls = "*" ++ h cs ls
@@ -228,7 +223,9 @@
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] () -> get >>= respond . export (readPath p)
+ , h (Prefix ["export"]) GET $ ok $ \[p] () -> do
+ lines <- get; let (Note _ _ notes) = executeAll lines
+ respond $ "<pre>" ++ export (readPath p) notes
, h [""] GET $ ok $ \() nick -> page [] nick
, h () POST $ ok $ \() (nick,line) -> do
if line == ":ll" then
More information about the Fencommits
mailing list