[Fencommits] fenserve: make the edit links use Exps with a Focus set -- doesn't yet convert the exps to the new URI syntax for potions, though

Benja Fallenstein benja.fallenstein at gmail.com
Wed Jun 20 12:12:46 EEST 2007


Wed Jun 20 12:12:25 EEST 2007  Benja Fallenstein <benja.fallenstein at gmail.com>
  * make the edit links use Exps with a Focus set -- doesn't yet convert the exps to the new URI syntax for potions, though
diff -rN -u old-fenserve/fendata/Rendering.hs new-fenserve/fendata/Rendering.hs
--- old-fenserve/fendata/Rendering.hs	2007-06-20 12:12:45.000000000 +0300
+++ new-fenserve/fendata/Rendering.hs	2007-06-20 12:12:45.000000000 +0300
@@ -84,12 +84,14 @@
     ren t | (x,xs) <- tsplit1 t = renderOne x >> ren xs
 
 
+showExp = show
+
 renderExp :: (?db :: DB, ?time :: Int64) => (String -> Potion) -> Exp -> HTML
 renderExp getPotion exp = potion $ fst $ f [] (HTML "") $ execWriter $ flip runStateT 0 $ runReaderT (renderExp' getPotion exp) $ Env [] [] exp where
     potion = tag "span" [P "class" "potion"]
     lnk p = tag "a"
       [ P "class" "editLink"
-      , P "href" $ "/path/" ++ concat (intersperse "." (map show p)) ]
+      , P "href" $ "/path/" ++ showExp (focusPath p exp) ]
       
     f p h ((q,i):(r,j):xs) | q == r = f p h ((q,i&j):xs)
     f p h ((q,i):xs) | p == q           = f p (h & lnk p i) xs
diff -rN -u old-fenserve/fendata/Types.hs new-fenserve/fendata/Types.hs
--- old-fenserve/fendata/Types.hs	2007-06-20 12:12:45.000000000 +0300
+++ new-fenserve/fendata/Types.hs	2007-06-20 12:12:45.000000000 +0300
@@ -160,12 +160,21 @@
     deriving (Read, Show, Typeable, Data, Eq, Ord)
     
     
+expTy = mkDataType "Types.Exp" [cExp, cQuestion, cFocus]
+constr s = mkConstr expTy s [] Prefix
+cExp = constr "Exp"; cQuestion = constr "Question"; cFocus = constr "Focus"
+    
 instance Read Exp where
 instance Show Exp where
     show (Exp name arg) = "(Exp " ++ show name ++ " " ++ gshow arg ++ ")"
     show (Question ty) = "(Question " ++ show ty ++ ")"
     show (Focus exp) = "(Focus " ++ show exp ++ ")"
 instance Data Exp where
+    gfoldl k z (Exp a b) = z Exp `k` a `k` b
+    gfoldl k z (Question a) = z Question `k` a
+    gfoldl k z (Focus a) = z Focus `k` a
+    dataTypeOf _ = expTy; toConstr (Exp _ _) = cExp
+    toConstr (Question _) = cQuestion; toConstr (Focus _) = cFocus
 instance Eq Exp where
 instance Ord Exp where
 




More information about the Fencommits mailing list