Anonymous avatar Anonymous committed a890696

Renamed a few config keys

Comments (0)

Files changed (11)

scripts/initdb.py

 INSERT INTO config (section, name, value)
 VALUES('general', 'htdocs_location', '/svntrac/');
 INSERT INTO config (section, name, value)
-VALUES('general', 'svn_repository', '/var/svn/myrep');
+VALUES('general', 'repository_dir', '/var/svn/myrep');
 INSERT INTO config (section, name, value)
-VALUES('general', 'theme_dir', '/usr/lib/svntrac/templates');
+VALUES('general', 'templates_dir', '/usr/lib/svntrac/templates');
 INSERT INTO config (section, name, value)
-VALUES('general', 'cgi_name', 'svntrac.cgi');
-INSERT INTO config (section, name, value)
-VALUES('general', 'authcgi_name', 'svntrac_auth.cgi');
+VALUES('general', 'cgi_location', '');
 INSERT INTO config (section, name, value)
 VALUES('general', 'href_scheme', 'cgi');
 INSERT INTO config (section, name, value)
 from util import *
 
 class Href:
-    def __init__(self, cgi_name, authcgi_name):
-        self.cgi_name = cgi_name
-        self.authcgi_name = authcgi_name
+    def __init__(self, base):
+        self.base = base
 
     def log(self, path):
-        return '%s?mode=log&path=%s' % (self.cgi_name, path)
+        return '%ssvntrac.cgi?mode=log&path=%s' % (self.base, path)
         
     def file(self, path, rev):
-        return '%s?mode=file&path=%s&rev=%s' % (self.cgi_name, path, rev)
+        return '%ssvntrac.cgi?mode=file&path=%s&rev=%s' % (self.base, path, rev)
 
     def browser(self, path):
-        return '%s?mode=browser&path=%s' % (self.cgi_name, path)
+        return '%ssvntrac.cgi?mode=browser&path=%s' % (self.base, path)
 
     def login(self):
-        return self.authcgi_name
+        return '%ssvntrac_auth.cgi' % self.base
 
     def logout(self):
-        return '%s?logout=now' % self.cgi_name
+        return '%ssvntrac.cgi?logout=now' % self.base
 
     def timeline(self):
-        return '%s?mode=timeline' % self.cgi_name
+        return '%ssvntrac.cgi?mode=timeline' % self.base
 
     def changeset(self, rev):
-        return '%s?mode=changeset&rev=%s' % (self.cgi_name, rev)
+        return '%ssvntrac.cgi?mode=changeset&rev=%s' % (self.base, rev)
 
     def ticket(self, ticket):
-        return '%s?mode=ticket&id=%s' % (self.cgi_name, ticket)
+        return '%ssvntrac.cgi?mode=ticket&id=%s' % (self.base, ticket)
 
     def newticket(self):
-        return '%s?mode=newticket' % self.cgi_name
+        return '%ssvntrac.cgi?mode=newticket' % self.base
 
     def search(self):
-        return '%s?mode=search' % self.cgi_name
+        return '%ssvntrac.cgi?mode=search' % self.base
 
     def wiki(self, page = None, version=None):
         if page and version:
-            return '%s?mode=wiki&page=%s&version=%s' % \
-                   (self.cgi_name, page, version)
+            return '%ssvntrac.cgi?mode=wiki&page=%s&version=%s' % \
+                   (self.base, page, version)
         elif page:
-            return '%s?mode=wiki&page=%s' % (self.cgi_name, page)
+            return '%ssvntrac.cgi?mode=wiki&page=%s' % (self.base, page)
         else:
-            return '%s?mode=wiki' % self.cgi_name
+            return '%ssvntrac.cgi?mode=wiki' % self.base
 
     def report(self, report=None, action=None):
         if report and action:
-            return '%s?mode=report&id=%s&action=%s' % \
-                   (self.cgi_name, report, action)
+            return '%ssvntrac.cgi?mode=report&id=%s&action=%s' % \
+                   (self.base, report, action)
         elif report:
-            return '%s?mode=report&id=%s' % (self.cgi_name, report)
+            return '%ssvntrac.cgi?mode=report&id=%s' % (self.base, report)
+        elif action:
+            return '%ssvntrac.cgi?mode=report&action=%s' % (self.base,
+                                                            action)
         else:
-            return '%s?mode=report' % self.cgi_name
+            return '%ssvntrac.cgi?mode=report' % self.base
 
 
 class RewriteHref(Href):
     server side configuration to work correctly
     """
     def log(self, path):
-        return href_join(self.cgi_name, 'log', path)
+        return href_join(self.base, 'log', path)
         
     def file(self, path, rev):
-        return href_join(self.cgi_name, 'file', path, str(rev))
+        return href_join(self.base, 'file', path, str(rev))
 
     def browser(self, path):
-        return href_join(self.cgi_name, 'browser', path)
+        return href_join(self.base, 'browser', path)
 
     def timeline(self):
-        return href_join(self.cgi_name, 'timeline/')
+        return href_join(self.base, 'timeline/')
 
     def changeset(self, rev):
-        return href_join(self.cgi_name, 'changeset', str(rev))
+        return href_join(self.base, 'changeset', str(rev))
 
     def ticket(self, ticket):
-        return href_join(self.cgi_name, 'ticket', str(ticket))
+        return href_join(self.base, 'ticket', str(ticket))
 
     def newticket(self):
-        return href_join(self.cgi_name, 'newticket/')
+        return href_join(self.base, 'newticket/')
 
     def search(self):
-        return href_join(self.cgi_name, 'search/')
+        return href_join(self.base, 'search/')
 
     def wiki(self, page = None, version=None):
         if page and version:
-            return href_join(self.cgi_name, 'wiki', page, str(version))
+            return href_join(self.base, 'wiki', page, str(version))
         elif page:
-            return href_join(self.cgi_name, 'wiki', page)
+            return href_join(self.base, 'wiki', page)
         else:
-            return href_join(self.cgi_name, 'wiki/')
+            return href_join(self.base, 'wiki/')
 
     def report(self, report=None, action=None):
         if report and action:
-            return href_join(self.cgi_name, 'report', str(report), action)
+            return href_join(self.base, 'report', str(report), action)
         elif report:
-            return href_join(self.cgi_name, 'report', str(report))
+            return href_join(self.base, 'report', str(report))
+        elif action:
+            return href_join(self.base, 'report', action)
         else:
-            return href_join(self.cgi_name, 'report/')
+            return href_join(self.base, 'report/')
 
 
 
     global href
     
     href_scheme = config['general']['href_scheme']
-    cgi_name = config['general']['cgi_name']
-    authcgi_name = config['general']['authcgi_name']
+    cgi_location = config['general']['cgi_location']
     
     if href_scheme == 'rewrite':
-        href = RewriteHref(cgi_name, authcgi_name)
+        href = RewriteHref(cgi_location)
     else:
-        href = Href(cgi_name, authcgi_name)
+        href = Href(cgi_location)

svntrac/Module.py

         pass
 
     def apply_template (self):
-        theme_dir = self.config['general']['theme_dir']
-        tmpl_filename = os.path.join (theme_dir, self.template_name)
-
         sql_to_hdf("SELECT name FROM enum WHERE type='priority' ORDER BY name",
                    self.cgi.hdf, 'enums.priority')
         sql_to_hdf("SELECT name FROM enum WHERE type='severity' ORDER BY name",
         self.cgi.hdf.setValue('title', '')
         self.cgi.hdf.setValue('htdocs_location',
                               self.config['general']['htdocs_location'])
-        self.cgi.hdf.setValue('cgi_name', get_cgi_name())
+        self.cgi.hdf.setValue('cgi_location',
+                              self.config['general']['cgi_location'])
         self.cgi.hdf.setValue('svntrac.active_module', self._name)
         self.cgi.hdf.setValue('svntrac.authname', auth.get_authname())
         self.cgi.hdf.setValue('svntrac.href.wiki', href.wiki())
         self.cgi.hdf.setValue('svntrac.href.login', href.login())
         self.cgi.hdf.setValue('svntrac.href.logout', href.logout())
         
+        templates_dir = self.config['general']['templates_dir']
+        tmpl_filename = os.path.join (templates_dir, self.template_name)
+
         self.cgi.display(tmpl_filename)
 
         
                         0, self.text)
         cnx.commit ()
 
-    def render_edit(self, out):
+    def render_edit(self, out, hdf):
         perm.assert_permission (perm.WIKI_MODIFY)
         out.write ('<h3>source</h3>')
-        out.write ('<form action="%s" method="POST">' % get_cgi_name())
+        out.write ('<form action="%s" method="POST">' %
+                   hdf.getValue('cgi_location', ''))
         out.write ('<input type="hidden" name="page" value="%s">' % self.name)
         out.write ('<input type="hidden" name="mode" value="wiki">')
         out.write ('<textarea name="text" rows="15" cols="80">')
         out.write ('<input type="submit" name="action" value="save changes">')
         out.write ('</form>')
 
-    def render_view(self, out, edit_button=1):
+    def render_view(self, out, hdf, edit_button=1):
         self.render_history(out)
         perm.assert_permission (perm.WIKI_VIEW)
         out.write ('<div class="wikipage">')
         Formatter().format(self.text, out)
         out.write ('</div><br>')
         if edit_button and perm.has_permission (perm.WIKI_MODIFY):
-            out.write ('<form action="%s" method="POST">' % get_cgi_name())
+            out.write ('<form action="%s" method="POST">' %
+                       hdf.getValue('cgi_location', ''))
             out.write ('<input type="hidden" name="mode" value="wiki">')
             out.write ('<input type="hidden" name="page" value="%s">' % self.name)
             out.write ('<input type="submit" name="action" value=" edit page ">')
             out.write ('</form>')
         
-    def render_preview (self, out):
+    def render_preview (self, out, hdf):
         perm.assert_permission (perm.WIKI_MODIFY)
         
-        self.render_edit (out)
+        self.render_edit (out, hdf)
         out.write ('<a name="preview" /><h3>preview</h3>')
-        self.render_view (out, edit_button=0)
+        self.render_view (out, hdf, edit_button=0)
         
     def render_history (self, out):
         cnx = get_connection ()
         elif action == ' edit page ':
             out.write ('<h2>edit <a href="%s">%s</a></h2>' %
                        (href.wiki(page.name), page.name))
-            page.render_edit (out)
+            page.render_edit (out, self.cgi.hdf)
             self.cgi.hdf.setValue('title', 'wiki - edit')
         elif action == 'preview':
             out.write ('<h2>edit <a href="%s">%s</a></h2>' %
                        (href.wiki(page.name), page.name))
-            page.render_preview (out)
+            page.render_preview (out, self.cgi.hdf)
             self.cgi.hdf.setValue('title', 'wiki - preview')
         else:
-            page.render_view (out)
+            page.render_view (out, self.cgi.hdf)
             self.cgi.hdf.setValue('title', 'wiki - view')
         self.cgi.hdf.setValue('content', out.getvalue())
 

svntrac/svntrac.py

 import sys
 import cgi
 import warnings
-from util import set_cgi_name, set_authcgi_name, dict_get_with_default
+from util import dict_get_with_default
 from svn import util, repos, core
 import Href
 
 def main():
     db.init()
     config = db.load_config()
-    set_cgi_name(config['general']['cgi_name'])
-    set_authcgi_name(config['general']['authcgi_name'])
     Href.initialize(config)
 
     core.apr_initialize()
     # Only open the subversion repository for the modules that really
     # need it. This saves us some precious time.
     if need_svn:
-        repos_dir = config['general']['svn_repository']
+        repos_dir = config['general']['repository_dir']
         rep = repos.svn_repos_open(repos_dir, pool)
         fs_ptr = repos.svn_repos_fs(rep)
         module.repos = rep
 from db import get_connection
 from xml.sax import saxutils
 
-cgi_name = 'svntrac.cgi'
-authcgi_name = 'svntrac_auth.cgi'
-
-def set_cgi_name(name):
-    global cgi_name
-    cgi_name = name
-
-def get_cgi_name():
-    return cgi_name
-
-def set_authcgi_name(name):
-    global authcgi_name
-    authcgi_name = name
-
-def get_authcgi_name():
-    return authcgi_name
-
 def time_to_string(date):
     date = time.asctime(time.localtime(date))
     return date[4:-8]

templates/browser.cs

 
 <h3>Revision <?cs var:revision?>: <?cs var:browser.path_links?></h3>
 
-<form action="<?cs var:cgi_name?>" method="get">
+<form action="<?cs var:cgi_location ?>" method="get">
   <input type="hidden" name="mode" value="browser">
   <input type="hidden" name="path" value="<?cs var:browser.path?>">
   Change revision: 

templates/newticket.cs

 
 <h3>New ticket:</h3>
 
-<form action="<?cs var:cgi_name ?>" method="POST">
+<form action="<?cs var:cgi_location ?>" method="POST">
 <input type="hidden" name="mode" value="ticket">
 <input type="hidden" name="action" value="create">
 <input type="hidden" name="status" value="new">

templates/report.cs

 
 <?cs elif report.mode == "editor" ?>
 
-  <form action="<?cs var:cgi_name ?>" method="post">
+  <form action="<?cs var:cgi_location ?>" method="POST">
     <input type="hidden" name="mode" value="report">
     <input type="hidden" name="id" value="<?cs var:report.id ?>">
     <input type="hidden" name="action" value="<?cs var:report.action ?>">

templates/search.cs

 <?cs include "../templates/header.cs"?>
 
 <h3>Search</h3>
-<form action="<?cs var:cgi_name ?>" method="GET">
+<form action="<?cs var:cgi_location ?>" method="GET">
 <input type="hidden" name="mode" value="search">
 <input type="text" name="q" size="40" value="<?cs var:search.q ?>">
 <input type="submit" value="Search">

templates/ticket.cs

 </tr>
 </table>
 
-<form action="<?cs var:cgi_name ?>" method="POST">
+<form action="<?cs var:cgi_location ?>" method="POST">
 <input type="hidden" name="mode" value="ticket">
 <input type="hidden" name="id"   value="<?cs var:ticket.id ?>">
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.