Christian Boos wrote:
... I think it would be nice to have that part of the base repository subsystem, as I'm sure a majority of repositories have at least a few HTML documents in the repository.
Being able to access the latest version of those documents in full
(with their pictures, css and everything) without much hassle would be cool.

...
Other possibility: use /browser URLs for the browser mode, and /source URLs
for the raw mode.


Cleaned-up patch which implements the above.

-- Christian

diff -r 07927bf1cde7 trac/versioncontrol/web_ui/browser.py
--- a/trac/versioncontrol/web_ui/browser.py     Thu Jul 27 10:59:21 2006 +0200
+++ b/trac/versioncontrol/web_ui/browser.py     Thu Jul 27 11:06:20 2006 +0200
@@ -77,14 +77,16 @@ class BrowserModule(Component):
 
     def match_request(self, req):
         import re
-        match = re.match(r'/(browser|file)(?:(/.*))?', req.path_info)
+        match = re.match(r'/(source|browser|file)(?:(/.*))?', req.path_info)
         if match:
-            req.args['path'] = match.group(2) or '/'
-            if match.group(1) == 'file':
-                req.redirect(req.href.browser(req.args.get('path'),
-                                              rev=req.args.get('rev'),
+            mode, path = match.groups()
+            if mode == 'source':
+                req.args['format'] = 'raw'
+            elif mode == 'file':
+                req.redirect(req.href.browser(path, rev=req.args.get('rev'),
                                               format=req.args.get('format')),
                              permanent=True)
+            req.args['path'] = path or '/'
             return True
 
     def process_request(self, req):
@@ -274,6 +276,7 @@ class BrowserModule(Component):
 
     def get_link_resolvers(self):
         return [('repos', self._format_link),
+                ('raw-source', self._format_link),
                 ('source', self._format_link),
                 ('browser', self._format_link)]
 
@@ -282,5 +285,9 @@ class BrowserModule(Component):
         fragment = ''
         if line is not None:
             fragment = '#L%d' % line
+        if ns == 'raw-source' in ns:
+            href = formatter.href.source
+        else:
+            href = formatter.href.browser
         return html.A(label, class_='source',
-                      href=formatter.href.browser(path, rev=rev) + fragment)
+                      href=href(path, rev=rev) + fragment)
_______________________________________________
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac

Reply via email to