[Fencommits] fenserve: 'up' links
Benja Fallenstein
benja.fallenstein at gmail.com
Tue May 8 19:18:23 EEST 2007
Tue May 8 19:18:08 EEST 2007 Benja Fallenstein <benja.fallenstein at gmail.com>
* 'up' links
diff -rN -u old-fenserve/notetaker/Main.hs new-fenserve/notetaker/Main.hs
--- old-fenserve/notetaker/Main.hs 2007-05-08 19:18:22.000000000 +0300
+++ new-fenserve/notetaker/Main.hs 2007-05-08 19:18:22.000000000 +0300
@@ -41,8 +41,11 @@
\ document.forms[0].elements[1].focus();\
\</script>"
-views n nick = "\n<p>Views: "++concat (intersperse " | " [view i|i<-[0..length links-1]])
- where links = [("main", "/"), ("log", "/log"), ("lastlog", "/lastlog")]
+views n item nick = "\n<p>Views: "++concat (intersperse " | " [view i|i<-[0..length links-1]])
+ where links = (if null item then []
+ else if length item == 1 then [("up", "/")]
+ else [("up", "/item/" ++ renderPath (init item))]) ++
+ [("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
where (name,uri) = links !! i
@@ -54,8 +57,8 @@
Just (Note title _ _ notes) ->
let title' = renderPath p ++ " " ++ title in
respond $ header title' ++ "<h2>" ++ title' ++ "</h2>"
- ++ views v nick ++ renderNotes p nick notes
- ++ views v nick ++ form nick ++ footer
+ ++ views v path nick ++ renderNotes p nick notes
+ ++ views v path nick ++ form nick ++ footer
Nothing -> respond $ "Path not found: " ++ renderPath path
-- get the path of the closest ancestor that is its own page
@@ -158,15 +161,15 @@
++ flip concatMap lines renderLine
++ views' ++ form nick ++ footer
where
- (title',views') | lastlog = ("LastLog for ", views 2 nick)
- | otherwise = ("Log for " , views 1 nick)
+ (title',views') | lastlog = ("LastLog for ", views 2 [] nick)
+ | otherwise = ("Log for " , views 1 [] nick)
itemLog nick path = do
lines <- get; respond $ case getPath path (executeAll lines) of
Nothing -> "Path not found: " ++ renderPath path
Just (Note title _ ls _) ->
let title' = "Log for item " ++ renderPath path ++ " " ++ title in
- header title' ++ "<h2>" ++ title' ++ "</h2>" ++ views (-1) nick
- ++ concatMap renderLine' ls ++ views (-1) (nick :: String) ++ footer
+ header title' ++ "<h2>" ++ title' ++ "</h2>" ++ views (-1) [] nick
+ ++ concatMap renderLine' ls ++ views (-1) [] (nick :: String) ++ footer
where renderLine' l@(Line t _ _) =
renderLine l ++ " (<a href='/log#"++show t++"'>context</a>)"
More information about the Fencommits
mailing list