/[navidoc]/navidoc/navidoc/modules/navbar.py
ViewVC logotype

Diff of /navidoc/navidoc/modules/navbar.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by humppake, Fri Mar 21 10:36:28 2003 UTC revision 1.4 by benja, Fri Mar 21 22:02:54 2003 UTC
# Line 51  class Tree: Line 51  class Tree:
51            
52      def addFile(self, filename, contents=None):      def addFile(self, filename, contents=None):
53          if contents is None:          if contents is None:
54              contents = open(filename).read()              file = open(filename)
55                contents = file.read()
56                file.close()
57                    
58          match = self.re_title.search(contents)          match = self.re_title.search(contents)
59          if not match:          if not match:
# Line 64  class Tree: Line 66  class Tree:
66          if os.path.basename(filename) in ('index.html',          if os.path.basename(filename) in ('index.html',
67                                            'peg.gen.html'):                                            'peg.gen.html'):
68              self.name = name              self.name = name
69          else:  
70              self.files.append([filename, name])          self.files.append([filename, name])
71    
72      def addDir(self, dir):      def addDir(self, dir):
73          t = Tree(dir)          t = Tree(dir)
# Line 88  class Tree: Line 90  class Tree:
90  def simpleNavbar(tree, indent=""):  def simpleNavbar(tree, indent=""):
91      s = ""      s = ""
92      for el in tree.files:      for el in tree.files:
93            if el[0].endswith('index.html'): continue
94          s += '%s<a href="%s">%s</a><br>\n' % \          s += '%s<a href="%s">%s</a><br>\n' % \
95               (indent, el[0][len(_slashify(config.working_directory)):len(el[0])], el[1])               (indent, el[0][len(_slashify(config.working_directory)):len(el[0])], el[1])
96          if len(el) > 2:          if len(el) > 2:
# Line 98  def insertNavbars(tree, bar=None, single Line 101  def insertNavbars(tree, bar=None, single
101      if bar is None:      if bar is None:
102          bar = '<hr class="footer"/>'          bar = '<hr class="footer"/>'
103          bar += '<div class="left-bar">\n'          bar += '<div class="left-bar">\n'
104          bar += ('<h1 class="boxhead"><a href="./">%s'          bar += ('<h3 class="boxhead"><a href="./">%s'
105                  '</a></h1>\n') % tree.name                  '</a></h3>\n') % tree.name
106          bar += '<p class="boxcontent">\n'          bar += '<p class="boxcontent">\n'
107          bar += simpleNavbar(tree)          bar += simpleNavbar(tree)
108          bar += '</p></div>\n'          bar += '</p></div>\n'
109    
110      if single_file:      if single_file:
111          s = open(filename).read()          file = open(el[0]); s = file.read(); file.close()
112          i = s.find('<hr class="footer"/>')          i = s.find('<hr class="footer"/>')
113          s = s[:i] + bar + s[i:]          s = s[:i] + bar + s[i:]
114          open(filename, 'w').write(s)          file = open(el[0], 'w')
115            file.write(s)
116            file.close()
117          dbg("Inserted navbar into %s" % filename)          dbg("Inserted navbar into %s" % filename)
118    
119      else:      else:
120          for el in tree.files:          for el in tree.files:
121              if len(el) == 2:              if len(el) == 2:
122                  s = open(el[0]).read()                  file = open(el[0]); s = file.read(); file.close()
123                  i = s.find('<hr class="footer"/>')                  i = s.find('<hr class="footer"/>')
124                  s = s[:i] + bar + s[i:]                  s = s[:i] + bar + s[i:]
125                  open(el[0], 'w').write(s)                  file = open(el[0], 'w')
126                    file.write(s)
127                    file.close()
128                  dbg( "Inserted navbar into %s" % el[0])                  dbg( "Inserted navbar into %s" % el[0])
129              else:              else:
130                  insertNavbars(el[2], bar)                  insertNavbars(el[2], bar)

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26