Code review comment for lp://staging/~jml/loggerhead/branch-from-loggerhead-simple

Revision history for this message
Jonathan Lange (jml) wrote :

This patch allows loggerhead to serve Bazaar branches over HTTP. It
does this by catching requests to any paths with a '.bzr' segment, and
ensuring that those paths are served with a static application, rather
than with the branch application.

I've added a box with information about how to get the branch to every
page in loggerhead. It's not beautiful, but it's a start. To do this
well, I've had to tweak the CSS a bit. Hope it's OK.

=== modified file 'loggerhead/apps/branch.py'
--- loggerhead/apps/branch.py 2008-12-05 18:52:44 +0000
+++ loggerhead/apps/branch.py 2009-01-23 20:39:37 +0000
@@ -70,6 +70,11 @@
         kw = util.get_context(**kw)
         return self.url(*args, **kw)

+ @property
+ def served_url(self):
+ """The URL that you can fetch this branch from."""
+ return self.url([])
+
     def static_url(self, path):
         return self._static_url_base + path

=== modified file 'loggerhead/apps/filesystem.py'
--- loggerhead/apps/filesystem.py 2008-12-05 20:09:14 +0000
+++ loggerhead/apps/filesystem.py 2009-01-23 18:59:42 +0000
@@ -7,6 +7,7 @@

 from paste.request import path_info_pop
 from paste import httpexceptions
+from paste import urlparser

 from loggerhead.apps.branch import BranchWSGIApp
 from loggerhead.apps import favicon_app, static_app
@@ -80,6 +81,9 @@
             return static_app(environ, start_response)
         elif environ['PATH_INFO'] == '/favicon.ico':
             return favicon_app(environ, start_response)
+ elif '/.bzr/' in environ['PATH_INFO']:
+ app = urlparser.make_static(None, self.folder)
+ return app(environ, start_response)
         else:
             return BranchesFromFileSystemServer(
                 self.folder, self)(environ, start_response)

=== modified file 'loggerhead/static/css/diff.css'
--- loggerhead/static/css/diff.css 2008-07-24 22:07:40 +0000
+++ loggerhead/static/css/diff.css 2009-01-23 19:21:26 +0000
@@ -1,5 +1,5 @@
 /*Info Box*/
-#infoContainer {
+.infoContainer {
  width:970px;
  padding:10px 10px 0px 10px;
  margin:0px 0px 10px 0px;
@@ -31,7 +31,7 @@
  width:493px;
  margin:0px 0px 5px 0px;
 }
-.information, .comiter, .timer, .mfrom, .mto, .revid {
+.information, .committer, .timer, .mfrom, .mto, .revid {
  clear:both;
  margin:0px;
  padding:0px 0px 2px 18px;
@@ -43,7 +43,7 @@
     padding:1px 0px 0px 18px;
     margin:0px 10px 5px 0px;
 }
-.comiter, .mfrom, .mto {
+.committer, .mfrom, .mto {
  color:#000;
  padding:1px 0px 0px 18px;
  margin:0px 10px 5px 0px;

=== modified file 'loggerhead/static/css/files.css'
--- loggerhead/static/css/files.css 2008-08-07 04:34:31 +0000
+++ loggerhead/static/css/files.css 2009-01-23 20:43:41 +0000
@@ -1,13 +1,5 @@
 /*Info Box*/
-#infoContainer {
- width:900px;
- padding:10px 10px 0px 10px;
- margin:0px 0px 10px 0px;
- color:#666;
- background:#fcfcfc;
- border:1px solid #b7b7b7;
-}
-.information, .comiter, .timer, .mfrom, .mto, .revid {
+.information, .committer, .timer, .mfrom, .mto, .revid {
  float:left;
  margin:0px 10px 5px 0px;
  padding:0px 0px 2px 18px;

=== modified file 'loggerhead/static/css/global.css'
--- loggerhead/static/css/global.css 2008-09-09 22:47:45 +0000
+++ loggerhead/static/css/global.css 2009-01-23 20:52:17 +0000
@@ -329,3 +329,11 @@
  font-weight:bold;
  font-size:18px;
 }
+#branch-info {
+ width:900px;
+ padding:10px 10px 10px 10px;
+ margin:0px 0px 10px 0px;
+ color:#666;
+ background:#fcfcfc;
+ border:1px solid #b7b7b7;
+}

=== modified file 'loggerhead/templatefunctions.py'
--- loggerhead/templatefunctions.py 2008-10-24 02:26:05 +0000
+++ loggerhead/templatefunctions.py 2009-01-23 20:21:44 +0000
@@ -53,6 +53,11 @@

 @templatefunc
+def branchinfo(branch):
+ return _pt('branchinfo').expand(branch=branch, **templatefunctions)
+
+
+@templatefunc
 def collapse_button(group, name, branch, normal='block'):
     return _pt('collapse-button').expand(
         group=group, name=name, normal=normal, branch=branch,

=== modified file 'loggerhead/templates/annotate.pt'
--- loggerhead/templates/annotate.pt 2009-01-22 22:14:47 +0000
+++ loggerhead/templates/annotate.pt 2009-01-23 20:47:07 +0000
@@ -28,6 +28,8 @@
     </h1>

     <div metal:fill-slot="content">
+ <tal:branch-info replace="structure python:branchinfo(branch)" />
+
         <ul id="submenuTabs">
             <li id="first">
                 <a tal:attributes="href python:url(['/files', change.revno], clear=1)">browse files</a>

=== added file 'loggerhead/templates/branchinfo.pt'
--- loggerhead/templates/branchinfo.pt 1970-01-01 00:00:00 +0000
+++ loggerhead/templates/branchinfo.pt 2009-01-23 20:51:05 +0000
@@ -0,0 +1,5 @@
+<div id="branch-info">
+ To get this branch, use: <br/>
+ <code>bzr branch
+ <tal:served-url tal:replace="python:branch.served_url" /></code>
+</div>

=== modified file 'loggerhead/templates/changelog.pt'
--- loggerhead/templates/changelog.pt 2008-10-30 11:37:16 +0000
+++ loggerhead/templates/changelog.pt 2009-01-23 20:46:32 +0000
@@ -34,7 +34,9 @@
          </h1>
         </tal:block>

- <div metal:fill-slot="content">
+ <div metal:fill-slot="content">
+ <tal:branch-info replace="structure python:branchinfo(branch)" />
+
            <!-- Something nicer-looking should be done with search -->
         <p tal:condition="search_failed">
           Sorry, no results found for your search.

=== modified file 'loggerhead/templates/inventory.pt'
--- loggerhead/templates/inventory.pt 2008-10-30 11:22:46 +0000
+++ loggerhead/templates/inventory.pt 2009-01-23 20:45:05 +0000
@@ -28,6 +28,8 @@
     </h1>

     <div metal:fill-slot="content">
+ <tal:branch-info replace="structure python:branchinfo(branch)" />
+
         <p tal:condition="python:not change">
           No revisions!
         </p>

=== modified file 'loggerhead/templates/revision.pt'
--- loggerhead/templates/revision.pt 2008-09-09 22:47:45 +0000
+++ loggerhead/templates/revision.pt 2009-01-23 20:52:04 +0000
@@ -30,6 +30,7 @@
           (compared to revision <tal:block content="python:history.get_revno(compare_revid)" />)
           </tal:compare-to>
         </span></h1>
+ <tal:branch-info replace="structure python:branchinfo(branch)" />
         <ul id="submenuTabs">
             <li id="first"><a tal:attributes="href python:url(['/files', change.revno]);
                                                title string:browse files at revision ${change/revno}"

=== modified file 'loggerhead/templates/revisioninfo.pt'
--- loggerhead/templates/revisioninfo.pt 2008-08-05 19:25:28 +0000
+++ loggerhead/templates/revisioninfo.pt 2009-01-23 19:19:03 +0000
@@ -1,6 +1,6 @@
-<div id="infoContainer" class="revision-info">
+<div class="infoContainer">
     <div id="infTxt">
- <div class="comiter" tal:content="python:util.hide_email(change.author)"></div>
+ <div class="committer" tal:content="python:util.hide_email(change.author)"></div>
         <div class="timer" tal:content="python:util.date_time(change.date)"></div>
         <div class="mfrom" tal:repeat="parent python:change.parents[1:]">
             <a tal:attributes="title string:Merged From ${parent/revno};

« Back to merge proposal