[Fencommits] fenserve: twiddle

Benja Fallenstein benja.fallenstein at gmail.com
Fri May 25 15:51:28 EEST 2007


Fri May 25 15:51:21 EEST 2007  Benja Fallenstein <benja.fallenstein at gmail.com>
  * twiddle
diff -rN -u old-fenserve/fendata/Main.hs new-fenserve/fendata/Main.hs
--- old-fenserve/fendata/Main.hs	2007-05-25 15:51:28.000000000 +0300
+++ new-fenserve/fendata/Main.hs	2007-05-25 15:51:28.000000000 +0300
@@ -115,10 +115,14 @@
       ?root++"edit?exp="++(escape' $ show $ f $ Var (-1))++"&old="++(escape' $ show old)++"&type="++show t
     ++maybe "" ("&name="++) ?name)]
                   
-renderMaybeExp (Just exp) cx ty = renderExp' exp cx ty
-renderMaybeExp Nothing cx ty = editLink cx (Var 0) ty $ surroundSpan $ bold $
+renderMaybeExp (Just exp) cx ty = renderExp exp cx ty
+renderMaybeExp Nothing cx ty = editLink cx (Var 0) ty $ bold $
                                "[" +++ typeQuestion ty +++ "]"
 
+renderMaybeExp' (Just exp) cx ty = renderExp' exp cx ty
+renderMaybeExp' Nothing cx ty = editLink cx (Var 0) ty $ surroundSpan $ bold $
+                                "[" +++ typeQuestion ty +++ "]"
+
 renderExp :: (?state :: MyState, ?link :: Bool, ?name :: Maybe String, 
               ?root :: String) => Exp -> (Exp -> Exp) -> Type -> HTML
 renderExp exp@(Call fname args) cx ty = f (funTypes fun) (funParts fun) args 0 where
@@ -126,19 +130,18 @@
     cx' n e = cx $ Call fname $ take n args ++ [Just e] ++ drop (n+1) args
     f []     [x]    _      n = editLink cx exp ty x
     f (t:ts) (x:xs) (y:ys) n = 
-        editLink cx exp ty x +++ renderMaybeExp y (cx' n) t +++ f ts xs ys (n+1)
+        editLink cx exp ty x +++ renderMaybeExp' y (cx' n) t +++ f ts xs ys (n+1)
 renderExp exp@(Var i) cx ty = editLink cx exp ty (renderVar i)
-renderExp e0@(Forall t i exp body) cx _ = surroundSpan (editLink cx e0 string "For each of " +++ renderMaybeExp exp (\e -> cx $ Forall t i (Just e) body) t
-                            +++ editLink cx e0 string (" (call it '" +++ renderVar i +++ "'):\n"))
+renderExp e0@(Forall t i exp body) cx _ = editLink cx e0 string "For each of " +++ renderMaybeExp' exp (\e -> cx $ Forall t i (Just e) body) t
+                            +++ editLink cx e0 string (" (call it '" +++ renderVar i +++ "'):\n")
                             +++ tag' "blockquote" (renderMaybeExp body (\e -> cx $ Forall t i exp (Just e)) string)
 renderExp (Str s) cx _ = tag "small" [] $ quoteP s
-renderExp exp@(Concat exps) cx _ = para $ catMap (\(xs,x,xs') -> renderMaybeExp x (\e -> cx (Concat (xs ++ [Just e] ++ xs'))) string) (slices exps) +++ if ?link then para $ editLink cx exp string "[edit]" else toHTML ""
+renderExp exp@(Concat exps) cx _ = para $ catMap (\(xs,x,xs') -> renderMaybeExp' x (\e -> cx (Concat (xs ++ [Just e] ++ xs'))) string) (slices exps) +++ if ?link then para $ editLink cx exp string "[edit]" else toHTML ""
 
 renderExp' e@(Str _) cx ty = renderExp e cx ty
 renderExp' e cx ty = surroundSpan (renderExp e cx ty)
 
 surroundSpan s = tag "span" [("class", if ?link then "editPotion" else "potion")] s
-surroundDiv s = tag "div" [("class", "potion")] s
 
 slices xs = map (\i -> (take i xs, xs !! i, drop (i+1) xs)) [0..length xs-1]
 




More information about the Fencommits mailing list