[viewvc-dev] [PATCH] new "nav_path_start" template variable

Christian Schoenebeck <[email protected]>
Newsgroups gmane.comp.version-control.cvs.viewcvs.devel
Message-ID <[email protected]>
Hi!

I know viewcvs is outdated, etc, I'm just sending this patch for completeness. 
Probably it won't be useful for anybody, but who knows ...

I needed a way to show informations depending on which CVS module the user is 
currently navigating in. The supplied patch adds a template 
variable "nav_path_start" to viewcvs which can be used in ones own 
template(s), e.g. to do the following (e.g. in ones directory.ezt template 
file):

[is nav_path_start "libfoo"]
    <tr><td>Description:</td><td>this is foo library, written in C++</td></tr>
    <tr><td>License:</td><td><b>libfoo</b> is released under the terms of the
            <a href="http://www.gnu.org/licenses/lgpl.html">
              <b>GNU Lesser General Public License</b></a></td></tr>
[end]
[is nav_path_start "fooapp"]
    <tr><td>Description:</td><td>this is the famous foo application</td></tr>
    <tr><td>License:</td><td><b>libfoo</b> is released under the terms of the
            <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">
              <b>GNU General Public License</b></a></td></tr>
[end]

So that way one can easily show customized informations for the respective 
project / CVS module.

CU
Christian

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
viewcvs_navpathstart.patch (text/x-diff, 2.1 KB)
diff -U 6 -r libold/viewcvs.py lib/viewcvs.py
--- libold/viewcvs.py	2007-04-30 23:35:30.000000000 +0200
+++ lib/viewcvs.py	2007-12-07 02:58:09.000000000 +0100
@@ -331,12 +331,19 @@
           (request.script_name, where, slash, request.qmark_query, parts[i])
     else:
       s = s + ' / ' + parts[i]
 
   return s
 
+def cur_cvs_module(path):
+  parts = filter(None, string.split(path, '/'))
+  cur_mod = ''
+  if len(parts) > 0:
+    cur_mod = parts[0]
+  return cur_mod
+
 def prep_tags(query_dict, file_url, tags):
   links = [ ]
   for tag in tags:
     href = file_url + toggle_query(query_dict, 'only_with_tag', tag)
     links.append(_item(name=tag, href=href))
   return links
@@ -427,12 +434,13 @@
       s = s + ', ' + ext
   return s
 
 def nav_header_data(request, path, filename, rev):
   return {
     'nav_path' : clickable_path(request, path, 1, 0, 0),
+    'nav_path_start' : cur_cvs_module(path),
     'path' : path,
     'filename' : filename,
     'file_url' : urllib.quote(filename),
     'rev' : rev,
     'qquery' : request.qmark_query,
     }
@@ -1193,12 +1201,13 @@
 
   if where:
     ### in the future, it might be nice to break this path up into
     ### a list of elements, allowing the template to display it in
     ### a variety of schemes.
     data['nav_path'] = clickable_path(request, where, 0, 0, 0)
+    data['nav_path_start'] = cur_cvs_module(where)
 
   # fileinfo will be len==0 if we only have dirs and !show_subdir_lastmod.
   # in that case, we don't need the extra columns
   if len(fileinfo):
     data['have_logs'] = 'yes'
 
@@ -1734,12 +1743,13 @@
 
     ### in the future, it might be nice to break this path up into
     ### a list of elements, allowing the template to display it in
     ### a variety of schemes.
     ### maybe use drop_leaf here?
     'nav_path' : clickable_path(request, up_where, 1, 0, 0),
+    'nav_path_start' : cur_cvs_module(up_where),
 
     'branch' : None,
     'mime_type' : request.mime_type,
     'view_tag' : view_tag,
     'entries' : show_revs,   ### rename the show_rev local to entries?
     'rev_selected' : query_dict.get('r1'),
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.