[Fencommits] fenserve: create separate page for editing potions (actual editing functionality TBD :))

Benja Fallenstein benja.fallenstein at gmail.com
Fri Jun 22 14:46:02 EEST 2007


Fri Jun 22 14:45:42 EEST 2007  Benja Fallenstein <benja.fallenstein at gmail.com>
  * create separate page for editing potions (actual editing functionality TBD :))
diff -rN -u old-fenserve/fendata/Main.hs new-fenserve/fendata/Main.hs
--- old-fenserve/fendata/Main.hs	2007-06-22 14:46:01.000000000 +0300
+++ new-fenserve/fendata/Main.hs	2007-06-22 14:46:01.000000000 +0300
@@ -22,12 +22,12 @@
 import qualified System.IO.Unsafe
 
 main = stdHTTP [ debugFilter
-               , h (Prefix ()) () $ \(path::[String]) req -> do
+               , h (Prefix ()) () $ \(_:path::[String]) req -> do
                    getTime -> time; get -> state :: DB
-                   let imp = Imp { impTime = time, impDB = state,
-                                   impPotions = let ?imp=imp in potions }
+                   let imp = Imp { impTime = time, impDB = state
+                                 , impPotions = let ?imp=imp in potions
+                                 , impRoot = concatMap (const "../") path }
                    let ?imp = imp; ?req = req; ?state = state
-                       ?root = concatMap (const "../") $ drop 1 path
                    runServerParts [app] req
                ]
 
@@ -117,9 +117,17 @@
               , for fs $ \f -> ( fieldName $ getField f
                                , Exp "getField" ( f, Exp "var" $ I (0::Int) )))))
                                
-  , h (Prefix ["potion"]) GET $ ok $ \[s] () -> respond $ 
-        either id id $ evaluate $ html $ header & let exp = readExp $ unEscapeString s in
-          ( renderExp exp
+  , h (Prefix ["potion"]) GET $ ok $ \[s] () -> respond $ either id id $ 
+      evaluate $ html $ header & let exp = readExp $ unEscapeString s in
+          ( para $ tag' "small" "Potion:"
+          , para $ renderExp exp
           , hr
           , renderValues $ runExp [] exp )
+          
+  , h (Prefix ["edit"]) GET $ ok $ \[s] () -> respond $ either id id $
+      evaluate $ html $ header & let exp = readExp $ unEscapeString s :: Exp in
+          ( para $ tag' "small" $
+                link (impRoot ?imp ++ "potion/" ++ showExp (removeFocus exp))
+                     "<< Back"
+          , para $ renderExp exp )
   ]
diff -rN -u old-fenserve/fendata/Rendering.hs new-fenserve/fendata/Rendering.hs
--- old-fenserve/fendata/Rendering.hs	2007-06-22 14:46:01.000000000 +0300
+++ new-fenserve/fendata/Rendering.hs	2007-06-22 14:46:01.000000000 +0300
@@ -102,7 +102,7 @@
 joinPieces exp ((True,h):xs)            = h & joinPieces exp xs
 joinPieces exp ((False,h):xs) = (& joinPieces exp xs) $ flip (tag "a") h
   [ P "class" "editLink"
-  , P "href" $ "/potion/" ++ showExp exp ]
+  , P "href" $ impRoot ?imp ++ "edit/" ++ showExp exp ]
 joinPieces exp [] = HTML ""
     
 renderExp' :: (?imp :: Imp) => Exp -> RenderExp [(Bool, HTML)]
diff -rN -u old-fenserve/fendata/Types.hs new-fenserve/fendata/Types.hs
--- old-fenserve/fendata/Types.hs	2007-06-22 14:46:01.000000000 +0300
+++ new-fenserve/fendata/Types.hs	2007-06-22 14:46:01.000000000 +0300
@@ -24,7 +24,8 @@
 -- Environment passed as implicit parameter
 ----------------------------------------------------------------------------
 
-data Imp = Imp { impDB :: DB, impTime :: Int64, impPotions :: [Potion] }
+data Imp = Imp { impDB :: DB, impTime :: Int64, impPotions :: [Potion]
+               , impRoot :: String }
 
 
 ----------------------------------------------------------------------------




More information about the Fencommits mailing list