[Fencommits] fenserve: script for importing dumped notetaker data into a HAppS _state directory

Benja Fallenstein benja.fallenstein at gmail.com
Wed May 9 21:26:57 EEST 2007


Wed May  9 21:26:44 EEST 2007  Benja Fallenstein <benja.fallenstein at gmail.com>
  * script for importing dumped notetaker data into a HAppS _state directory
diff -rN -u old-fenserve/notetaker/Import.hs new-fenserve/notetaker/Import.hs
--- old-fenserve/notetaker/Import.hs	1970-01-01 02:00:00.000000000 +0200
+++ new-fenserve/notetaker/Import.hs	2007-05-09 21:26:57.000000000 +0300
@@ -0,0 +1,21 @@
+
+import HAppS
+import Types hiding (Body)
+
+import Data.ByteString.Char8 (ByteString)
+import qualified Data.ByteString.Char8 as ByteString
+import Control.Monad.State
+
+unBody NoBody = ByteString.empty
+unBody (Body b) = b
+unBody (LargeBody _ _) = error "FenServe.unBody: large body not handled"
+
+handler = Handle $ \req -> do
+    let body = unBody (rqBody req)
+    put (read (ByteString.unpack body) :: [Line])
+    respond (return $ toMessage "foo")
+
+main = do
+  let handlers = [ debugFilter, handler ]
+  stdMain $ (\conf -> simpleHTTP handlers $ conf {bodyLimit=1024*1024}) :*: End
+ 
diff -rN -u old-fenserve/notetaker/Main.hs new-fenserve/notetaker/Main.hs
--- old-fenserve/notetaker/Main.hs	2007-05-09 21:26:57.000000000 +0300
+++ new-fenserve/notetaker/Main.hs	2007-05-09 21:26:57.000000000 +0300
@@ -1,6 +1,7 @@
 {-# OPTIONS_GHC -fglasgow-exts #-}
 
 import Markup
+import Types
 
 import HAppS hiding (Body, getPath)
 import Control.Monad.State
@@ -12,18 +13,6 @@
 import Text.Printf
 import System.Time
 
-type Path = [Int]
-data Body = Body String | Add Path String 
-          | Edit Path String | Move Path Path | DeleteOne Path | Delete Path
-          | MakeOwnPage Path | Unpage Path | Revert Int
-                                      deriving (Eq,Ord,Read,Show,Typeable)
-data Line = Line { lineTime :: EpochTime, lineNick :: String, 
-                   lineBody :: Body } deriving (Eq,Ord,Read,Show,Typeable)
-                   
-instance Binary Line where
-
-data Note = Note String Bool [Line] [Note] deriving (Eq,Ord,Read,Show)
-
 style = "\n<style type='text/css'>li, p.logline { margin-bottom: 0.3em; margin-top: 0.3em }\n.children { font-style: italic }\n.loglink, .children { color: #aaa; font-size: small }\n.loglink a { color: #aaa }</style>"
 
 header title = printf "<html><head><title>%s</title>%s\n</head>\n<body>"
diff -rN -u old-fenserve/notetaker/Makefile new-fenserve/notetaker/Makefile
--- old-fenserve/notetaker/Makefile	2007-05-09 21:26:57.000000000 +0300
+++ new-fenserve/notetaker/Makefile	2007-05-09 21:26:57.000000000 +0300
@@ -18,6 +18,9 @@
 
 run: build install
 	./dist/build/notetaker/notetaker $(ARGS)
+
+import: build install
+	./dist/build/notetaker-import/notetaker-import $(ARGS)
 	
 reset:
 	rm -rf notetaker_state notetaker_error.log fenserve_code
diff -rN -u old-fenserve/notetaker/notetaker.cabal new-fenserve/notetaker/notetaker.cabal
--- old-fenserve/notetaker/notetaker.cabal	2007-05-09 21:26:57.000000000 +0300
+++ new-fenserve/notetaker/notetaker.cabal	2007-05-09 21:26:57.000000000 +0300
@@ -8,3 +8,6 @@
 
 Executable:     notetaker
 Main-Is:        Main.hs
+
+Executable:	notetaker-import
+Main-Is:	Import.hs




More information about the Fencommits mailing list