[Fencommits] fenserve: twids
Benja Fallenstein
benja.fallenstein at gmail.com
Thu May 24 19:49:40 EEST 2007
Thu May 24 19:49:30 EEST 2007 Benja Fallenstein <benja.fallenstein at gmail.com>
* twids
diff -rN -u old-fenserve/fendata/Main.hs new-fenserve/fendata/Main.hs
--- old-fenserve/fendata/Main.hs 2007-05-24 19:49:39.000000000 +0300
+++ new-fenserve/fendata/Main.hs 2007-05-24 19:49:39.000000000 +0300
@@ -38,7 +38,7 @@
\.content {float: right; width: 80% } \
\.sidebar {float: left; width: 15%; font-size: small } \
\h1, h2, h3, h4, h5, h6 { font-family: sans-serif } \
- \</style></head>"
+ \</style><title>Fendata demo</title></head>"
type Id = Int
@@ -283,7 +283,7 @@
expand s (Call n args) = case readFun s n of
Fun _ _ body -> Just
- (foldr (\i e -> subst' i (args !! i) e) body [0..length args-1], n)
+ (foldr (\i e -> subst' i (case args !! i of Just x -> Just x; Nothing -> Just (Var i)) e) body [0..length args-1], n)
_ -> Nothing
expand _ _ = Nothing
@@ -314,14 +314,18 @@
Left e -> respond $ ("", "Internal server error: " ++ show e)
potionGet exp args name s = (let ?state=s; ?link=True; ?name=name in
- makePage "Potion" $
+ makePage title $
renderExp exp id string +++ " " +++ lnk +++ hr
+++ if (isComplete exp)
then (HTML $ head $ evalStateT (runExp env exp) s)
else toHTML "(Incomplete expression.)"
, s) where
env = Map.fromList $ zip [0..length args-1] args
- lnk = case expand s exp of
+ expanded = expand s exp
+ title = case expanded of
+ Just (e,n) -> let ?state=s; ?link=True; ?name=name in renderExp exp id string
+ Nothing -> toHTML "Custom potion"
+ lnk = case expanded of
Just (e,n) -> link ("?exp="++show e++"&name="++n) "[expand definition]"
Nothing -> formP "addpotion" $ (+++hidden "exp" (show exp)) $
(+++link ("makefun?exp="++show exp) "[Save as...]") $
@@ -480,11 +484,12 @@
Just id = fmap read $ lookM msg "item"
makePage title body =
- (tag "title" [] title +++) . tag "body" [] $
+ --(tag "title" [] title +++) .
+ tag "body" [] $
tag "div" [("class", "header")]
(etag "img" [("src", "http://flowerpot.kaijanaho.fi/~benja/tmp/logo.jpg"),
("class", "logo")] +++
- h1 ("Fendata: " +++ title)) +++
+ h1 ("Fendata | " +++ title)) +++
tag "div" [("class", "main")] (
tag "div" [("class", "sidebar")] "Welcome to Fendata! The sidebar is empty so far." +++
tag "div" [("class", "content")] body) +++
More information about the Fencommits
mailing list