gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] navidoc ./TODO-navidoc navidoc/modules/navbar.p...


From: Asko Soukka
Subject: [Gzz-commits] navidoc ./TODO-navidoc navidoc/modules/navbar.p...
Date: Mon, 28 Apr 2003 04:27:34 -0400

CVSROOT:        /cvsroot/navidoc
Module name:    navidoc
Changes by:     Asko Soukka <address@hidden>    03/04/28 04:27:34

Modified files:
        .              : TODO-navidoc 
        navidoc/modules: navbar.py 
        navidoc/util   : path.py 

Log message:
        navbar fix

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/TODO-navidoc.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/modules/navbar.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/util/path.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: navidoc/TODO-navidoc
diff -u navidoc/TODO-navidoc:1.7 navidoc/TODO-navidoc:1.8
--- navidoc/TODO-navidoc:1.7    Fri Apr 25 04:25:33 2003
+++ navidoc/TODO-navidoc        Mon Apr 28 04:27:34 2003
@@ -6,10 +6,12 @@
 =================================
 
 humppake:
-  - documenting, tests
   - ".gen." midfix to be optional:
     + replacing ".gen" with global attribute
     + replacing some foo[a:b] with foo[a:len(midfix)+c]
+  - syntax to follow Fenfire coding standards
+  - documenting, tests
+  - more?
 
 anybody:
   - make pegboard run with cpython, could be tested
Index: navidoc/navidoc/modules/navbar.py
diff -u navidoc/navidoc/modules/navbar.py:1.8 
navidoc/navidoc/modules/navbar.py:1.9
--- navidoc/navidoc/modules/navbar.py:1.8       Fri Apr 25 12:02:08 2003
+++ navidoc/navidoc/modules/navbar.py   Mon Apr 28 04:27:34 2003
@@ -1,4 +1,4 @@
-# 
+#
 # Copyright (c) 2003 by Benja Fallenstein
 # 
 # This file is part of Navidoc.
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-#$Id: navbar.py,v 1.8 2003/04/25 16:02:08 tuukkah Exp $
+#$Id: navbar.py,v 1.9 2003/04/28 08:27:34 humppake Exp $
 
 #
 # Written by Benja Fallenstein
@@ -39,11 +39,12 @@
     re_title = re.compile("<title>(.*)</title>")
 
     def __init__(self, dir):
+        self.root = dir
         self.files = []
         self.name = None
 
-        for el in os.listdir(dir):
-            el = os.path.join(dir, el)
+        for el in os.listdir(self.root):
+            el = os.path.join(self.root, el)
             if os.path.isdir(el):
                 self.addDir(el)
             elif os.path.splitext(el)[1] == '.html':
@@ -87,31 +88,35 @@
             if len(el) == 2: list.append(el[0])
             else: list.extend(el[3].getFiles())
 
-def simpleNavbar(tree, indent=""):
+def simpleNavbar(tree, filepath, indent=""):
     s = ""
     for el in tree.files:
         if el[0].endswith('index.html'): continue
         s += '<li class="boxitem"><a href="%s">%s</a></li>\n' % \
-             (el[0][len(slashify(config.working_directory)):len(el[0])], el[1])
+             (relative_path(filepath, el[0]), el[1])
         if len(el) > 2:
-            s += simpleNavbar(el[2], indent+"&nbsp;&nbsp;")
+            s += simpleNavbar(el[2], filepath, indent+"&nbsp;&nbsp;")
     return s
 
-def insertNavbars(tree, bar=None, single_file=None):
-    if bar is None:
-        bar = '<hr class="footer"/>'
-        bar += '<center class="navigation-title">Navigation</center>\n'
-        bar += '<div class="left-bar">\n'
-        bar += ('<p class="boxhead"><a href="./">%s'
-                '</a></p>\n') % tree.name
-        bar += '<p class="boxcontent"><ul>\n'
-        bar += simpleNavbar(tree)
-        bar += '</ul></p></div>\n'
-
-    if single_file:
+def getBar(tree, filepath):
+    bar = '<hr class="footer"/>'
+    bar += '<center class="navigation-title">Navigation</center>\n'
+    bar += '<div class="left-bar">\n'
+    bar += ('<p class="boxhead"><a href="%s">%s'
+            '</a></p>\n') \
+            % (relative_path(filepath, slashify(tree.root)),
+               tree.name)
+    bar += '<p class="boxcontent"><ul>\n'
+    bar += simpleNavbar(tree, filepath=filepath)
+    bar += '</ul></p></div>\n'
+    return bar
+
+def insertNavbars(tree, navbarTree=None, singleFile=None):
+    if navbarTree == None: navbarTree = tree
+    if singleFile:
         file = open(el[0]); s = file.read(); file.close()
         i = s.find('<hr class="footer"/>')
-        s = s[:i] + bar + s[i:]
+        s = s[:i] + getBar(navbarTree, el[0]) + s[i:]
         file = open(el[0], 'w')
         file.write(s)
         file.close()
@@ -122,13 +127,13 @@
             if len(el) == 2:
                 file = open(el[0]); s = file.read(); file.close()
                 i = s.find('<hr class="footer"/>')
-                s = s[:i] + bar + s[i:]
+                s = s[:i] + getBar(navbarTree, el[0]) + s[i:]
                 file = open(el[0], 'w')
                 file.write(s)
                 file.close()
                 dbg( "Inserted navbar into %s" % el[0])
             else:
-                insertNavbars(el[2], bar)
+                insertNavbars(el[2], navbarTree)
 
 if __name__ == '__main__':
     import sys
Index: navidoc/navidoc/util/path.py
diff -u navidoc/navidoc/util/path.py:1.1 navidoc/navidoc/util/path.py:1.2
--- navidoc/navidoc/util/path.py:1.1    Mon Apr  7 11:58:00 2003
+++ navidoc/navidoc/util/path.py        Mon Apr 28 04:27:34 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-#$Id: path.py,v 1.1 2003/04/07 15:58:00 humppake Exp $
+#$Id: path.py,v 1.2 2003/04/28 08:27:34 humppake Exp $
 
 #
 # Written by Asko Soukka
@@ -88,5 +88,10 @@
                +''.join([target_parts[i+parts]+'/' \
                          for i in range(len(target_parts)-parts)])
 
-    dbg('Relative path: '+relative[0:len(relative)-1])
-    return (relative[0:len(relative)-1])
+    path = relative[0:len(relative)-1]
+
+    if path=='' and os.path.isdir(target): path = './'
+    elif path == '': path = os.path.basename(target)
+
+    dbg('Relative path: '+path)
+    return (path)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]