[Fencommits] fenserve: make foralls read better

Tuukka Hastrup Tuukka.Hastrup at iki.fi
Sat May 26 19:45:44 EEST 2007


Sat May 26 19:45:33 EEST 2007  Tuukka Hastrup <Tuukka.Hastrup at iki.fi>
  * make foralls read better
diff -rN -u old-fenserve-1/fendata/Main.hs new-fenserve-1/fendata/Main.hs
--- old-fenserve-1/fendata/Main.hs	2007-05-26 19:45:44.000000000 +0300
+++ new-fenserve-1/fendata/Main.hs	2007-05-26 19:45:44.000000000 +0300
@@ -42,7 +42,7 @@
         ])
         [("Blog_post_archive", [])]
 
-potion = Block [Just $ Forall (pluralType "post") 0 (Just $ AllItems "post") $
+potion = Block [Just $ Forall "post" 0 (Just $ AllItems "post") $
     Block (map Just [Str "<h2>", Field "post" "title" v, Str "</h2>",
                     Str "\n<p>Author: ", Field "post" "author" v,
                     Str "\n<p>", Field "post" "body" v,
diff -rN -u old-fenserve-1/fendata/Potions.hs new-fenserve-1/fendata/Potions.hs
--- old-fenserve-1/fendata/Potions.hs	2007-05-26 19:45:44.000000000 +0300
+++ new-fenserve-1/fendata/Potions.hs	2007-05-26 19:45:44.000000000 +0300
@@ -39,7 +39,7 @@
             ++ concatFor (Map.toList $ stateSchema s) (\(cat,fs) ->
                    AllItems cat
                  : NewItemButton cat
-                 : Forall (pluralType cat) 0 Nothing (Block [])
+                 : Forall cat 0 Nothing (Block [])
                  : concatFor fs (\f -> [ Field cat f Nothing
                                        , SortByField cat f 1 Nothing
                                        , SortByField cat f (-1) Nothing
@@ -89,13 +89,14 @@
 renderExp e0@(Field cat field exp) cx ty = editLink cx e0 ty ("the " +++ field +++ " of ") +++ renderMaybeExp' exp (\e -> cx $ Field cat field $ Just e) (catType cat) where
 renderExp e0@(AllItems cat) cx ty = editLink cx e0 ty ("all the "++cat++"s in the system")
 renderExp e0@(NewItemButton cat) cx ty = editLink cx e0 ty ("a link for creating a new "++cat)
-renderExp exp@(Var i) cx ty = editLink cx exp ty (renderVar i)
+renderExp exp@(Var i) cx ty@(Type cat) = 
+    editLink cx exp ty (cat +++ " '" +++ renderVar i +++ "'")
 renderExp Today cx ty = editLink cx Today ty "today's date"
 renderExp e0@(SortByField cat field i exp) cx ty = renderMaybeExp' exp (\e -> cx $ SortByField cat field i $ Just e) (pluralType cat) +++ editLink cx e0 ty (", sorted by "++field++if i<0 then ", descending" else ", ascending")
 renderExp e0@(FilterByField cat field i exp exp0) cx ty = editLink cx e0 ty "those of " +++ renderMaybeExp' exp (\e -> cx $ FilterByField cat field i (Just e) exp0) (pluralType cat) +++ editLink cx e0 ty (" whose "++field++if i<0 then " comes before " else if i>0 then " comes after " else " is ") +++ renderExp exp0 (\e -> cx $ FilterByField cat field i exp e) string
-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" (renderExp body (\e -> cx $ Forall t i exp e) string)
+renderExp e0@(Forall cat i exp body) cx _ = editLink cx e0 string "For each "+++cat+++" '"+++renderVar i+++"' of " +++ renderMaybeExp' exp (\e -> cx $ Forall cat i (Just e) body) (pluralType cat)
+                            +++ editLink cx e0 string (":\n")
+                            +++ tag' "blockquote" (renderExp body (\e -> cx $ Forall cat i exp e) string)
 renderExp (Str s) cx _ = tag "small" [] $ quoteP s
 renderExp exp@(Block exps) cx _ = para $ catMap (\(xs,x,xs') -> renderMaybeExp' x (\e -> cx (Block (xs ++ [Just e] ++ xs'))) string) (slices exps) +++ if ?link then para $ editLink cx exp string "[edit]" else toHTML ""
 renderExp exp@(Inline exps) cx _ = "\"" +++ catMap (\(xs,x,xs') -> renderMaybeExp' x (\e -> cx (Inline (xs ++ [Just e] ++ xs'))) string) (slices exps) +++ "\"" +++ if ?link then " " +++ editLink cx exp string "[edit]" else toHTML ""
diff -rN -u old-fenserve-1/fendata/PotionTypes.hs new-fenserve-1/fendata/PotionTypes.hs
--- old-fenserve-1/fendata/PotionTypes.hs	2007-05-26 19:45:44.000000000 +0300
+++ new-fenserve-1/fendata/PotionTypes.hs	2007-05-26 19:45:44.000000000 +0300
@@ -28,7 +28,7 @@
          | Var Int
          | SortByField Category Field Int (Maybe Exp)
          | FilterByField Category Field Int (Maybe Exp) Exp -- body should always be an Inline
-         | Forall Type Int (Maybe Exp) Exp -- body should always be a Block
+         | Forall Category Int (Maybe Exp) Exp -- body should always be a Block
          | Block [Maybe Exp] | Inline [Maybe Exp]
          | Str String
          | Today




More information about the Fencommits mailing list