[Fencommits] fenserve: move the navbar and form to the *bottom* of the page, to make it less of a problem when the pages grow to more than a screenful
Benja Fallenstein
benja.fallenstein at gmail.com
Sat Apr 28 00:33:05 EEST 2007
Sat Apr 28 00:32:55 EEST 2007 Benja Fallenstein <benja.fallenstein at gmail.com>
* move the navbar and form to the *bottom* of the page, to make it less of a problem when the pages grow to more than a screenful
diff -rN -u old-fenserve/notetaker/Main.hs new-fenserve/notetaker/Main.hs
--- old-fenserve/notetaker/Main.hs 2007-04-28 00:33:05.000000000 +0300
+++ new-fenserve/notetaker/Main.hs 2007-04-28 00:33:05.000000000 +0300
@@ -20,7 +20,9 @@
data Note = Note String [Note] deriving (Eq,Ord,Read,Show)
-form nick = "<form id='myform' action='/' method='post'>\
+style = "<style type='text/css'>li, p.logline { margin-bottom: 0.3em; margin-top: 0.3em }</style>"
+
+form nick = "<p><form id='myform' action='/?nick="++nick++"' method='post'>\
\ Nick: <input name='nick' type='text' size=8 \
\value='" ++ nick ++ "'> \
\ <input name='line' id='myline' type='text' size=60>\
@@ -28,10 +30,9 @@
\</form>\
\<script type='text/javascript'>\
\ document.forms[0].elements[1].focus();\
- \</script>\
- \<style type='text/css'>li, p.logline { margin-bottom: 0.3em; margin-top: 0.3em }</style>"
+ \</script>"
-views n nick = "Views: "++concat (intersperse " | " [view i|i<-[0..2]])++"<p>"
+views n nick = "<p>Views: "++concat (intersperse " | " [view i|i<-[0..2]])
where links = [("main", "/"), ("log", "/log"), ("lastlog", "/lastlog")]
view i | i == n = printf "<b>%s</b>" name
| otherwise = printf "<a href=%s?nick=%s>%s</a>" uri nick name
@@ -40,7 +41,7 @@
page nick = do
(lines :: [Line]) <- get
let Note _ notes = foldl (flip execute) (Note "HOME" []) lines
- respond $ form nick ++ views 0 nick ++ renderNotes notes
+ respond $ style ++ renderNotes notes ++ views 0 nick ++ form nick
renderNotes notes = "<ol>" ++ concatMap renderNote notes ++ "</ol>" where
renderNote (Note title children) = "<li>" ++ title ++ renderNotes children
@@ -81,10 +82,10 @@
renderLog nick lastlog = do
lines <- if not lastlog then get
else get >>= return . reverse . take 15 . reverse
- respond $ form nick ++ views (if lastlog then 2 else 1) nick ++
- flip concatMap lines (\(Line time nick body) ->
+ respond $ style ++ flip concatMap lines (\(Line time nick body) ->
"<p class='logline'>" ++ renderTime time ++ " "
++ renderBody nick body)
+ ++ views (if lastlog then 2 else 1) nick ++ form nick
renderBody :: String -> Body -> String
renderBody nick (Body s) = printf "<<b>%s</b>> %s" nick s
More information about the Fencommits
mailing list