[#892] Jinja templates for git

Jenny Steele Jenny Steele 2010-09-10

added Allura/allura/templates/jinja_master/main_menu.html
changed Allura/allura/config/app_cfg.py
changed Allura/allura/lib/gravatar.py
changed Allura/allura/templates/jinja_master/lib.html
changed Allura/allura/templates/jinja_master/master.html
changed ForgeGit/forgegit/templates/admin_extensions.html
changed ForgeGit/forgegit/templates/commit.html
changed ForgeGit/forgegit/templates/fork.html
changed ForgeGit/forgegit/templates/log.html
changed ForgeGit/forgegit/widgets/log.py
changed ForgeGit/forgegit/widgets/revisions.py
changed ForgeGit/forgegit/controllers.py
changed ForgeGit/forgegit/git_main.py
copied ForgeGit/forgegit/templates/index.html -> ForgeGit/forgegit/widgets/templates/git_log_widget.html
copied ForgeGit/forgegit/widgets/templates/log.html -> ForgeGit/forgegit/widgets/templates/git_revision_widget.html
copied ForgeGit/forgegit/widgets/templates/revision.html -> ForgeGit/forgegit/templates/git_index.html
Allura/allura/templates/jinja_master/main_menu.html Diff Switch to side-by-side view
Loading...
Allura/allura/config/app_cfg.py Diff Switch to side-by-side view
Loading...
Allura/allura/lib/gravatar.py Diff Switch to side-by-side view
Loading...
Allura/allura/templates/jinja_master/lib.html Diff Switch to side-by-side view
Loading...
Allura/allura/templates/jinja_master/master.html Diff Switch to side-by-side view
Loading...
ForgeGit/forgegit/templates/admin_extensions.html Diff Switch to side-by-side view
Loading...
ForgeGit/forgegit/templates/commit.html Diff Switch to side-by-side view
Loading...
ForgeGit/forgegit/templates/fork.html Diff Switch to side-by-side view
Loading...
ForgeGit/forgegit/templates/log.html Diff Switch to side-by-side view
Loading...
ForgeGit/forgegit/widgets/log.py Diff Switch to side-by-side view
Loading...
ForgeGit/forgegit/widgets/revisions.py Diff Switch to side-by-side view
Loading...
ForgeGit/forgegit/controllers.py Diff Switch to side-by-side view
Loading...
ForgeGit/forgegit/git_main.py Diff Switch to side-by-side view
Loading...
ForgeGit/forgegit/templates/index.html to ForgeGit/forgegit/widgets/templates/git_log_widget.html
--- a/ForgeGit/forgegit/templates/index.html
+++ b/ForgeGit/forgegit/widgets/templates/git_log_widget.html
@@ -1,42 +1,63 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:py="http://genshi.edgewall.org/"
-      xmlns:xi="http://www.w3.org/2001/XInclude">
-
-  <xi:include href="${g.allura_templates}/master.html"/>
-
-  <head>
-    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
-    <title py:if="not c.app.repo">Git Repository</title>
-    <title py:if="c.app.repo">Git Repository: ${c.app.repo.name}</title>
-  </head>
-
-  <body>
-    <h1 class="title">$c.app.config.options.mount_label</h1>
-    <div class="content">
-      <div class="row">
-        <div class="column grid_12">
-          <h2>Project: $c.project.shortname</h2>
-          <p py:if="c.app.repo">
-            Read access: <code>git clone git://$c.app.repo.scm_url_path</code><br/>
-            Read/write access: <code>git clone ssh://${c.user == c.user.anonymous() and 'USERNAME' or c.user.username}@$c.app.repo.scm_url_path</code><br/>
-            <form py:if="allow_fork" action="${c.app.repo.url()}fork" method="GET">
-              <input type="submit" value="Fork" py:if="c.user != c.user.anonymous()"/>
-            </form>
-          </p>
-          <div style="clear:both">&nbsp;</div>
-          <py:if test="log">
-            <h2>Recent Commits<py:if test="branch"> on $branch</py:if></h2>
-            ${c.log_widget.display(value=log, show_paging=False,
-                                   limit=limit, page=page, count=count)}
-            <a py:if="int(count) &gt; int(limit)" href="log?page=1">More</a>
-          </py:if>
-          <py:if test="not log">
-            <b>No (more) commits</b>
-          </py:if>
-        </div>
-      </div>
+{% from 'jinja_master/lib.html' import email_gravatar with context %}
+<div>
+  {% if show_paging %}
+    <div style="clear:both">
+      {{fields['page_list'].display(limit=limit, page=page, count=count)}}
     </div>
-  </body>
-</html>
+  {% endif %}
+  <table>
+    <thead>
+      <tr>
+        <th style="text-align:left">Commit</th>
+        <th style="text-align:left">Date</th>
+        <th>&nbsp;</th>
+      </tr>
+    </thead>
+    <tbody>
+      {% for commit in value %}
+        {% set cv = commit.value %}
+        <tr>
+          <td>
+            <b>{{h.really_unicode(h.text.truncate(commit.value.message, 75))}}</b><br/>
+            {% if cv.committer != cv.author %}
+              {% if cv.committer_url %}
+                <a href="{{cv.committer_url}}">{{email_gravatar(cv.committer.email, title=cv.committer.name, size=16)}}
+                {{cv.committer.name}}</a>
+                pushed
+              {% else %}
+                {{email_gravatar(cv.committer.email, title=cv.committer.name, size=16)}} {{cv.committer.name}}
+                pushed
+              {% endif %}
+            {% endif %}
+            <a href="{{cv.url()}}">{{h.text.truncate(cv.hexsha, 10)}}</a>
+            {% if cv.author_url %}
+              by
+              <a href="{{cv.author_url}}">{{email_gravatar(cv.author.email, title=cv.author.name, size=16)}}
+              {{cv.author.name}}</a>
+            {% else %}
+              by
+              {{email_gravatar(cv.author.email, title=cv.author.name, size=16)}} {{cv.author.name}}
+            {% endif %}
+          </td>
+          <td>
+            {% if cv.committed_datetime %}{{h.ago(cv.committed_datetime)}}{% endif %}
+          </td>
+          <td style="text-align: right">
+            {% if commit.prev %}
+              Parent(s):
+              {% for ci in commit.prev %}<a href="{{ci.url()}}">{{h.text.truncate(ci._id, 10)}}</a>{% endfor %}
+              <br/>
+            {% endif %}
+            <a href="{{cv.tree().url()}}">Tree</a>
+          </td>
+        </tr>
+      {% endfor %}
+    </tbody>
+  </table>
+  {% if show_paging %}
+    <div style="clear:both">
+      {{fields['page_list'].display(limit=limit, page=page, count=count)}}
+      {{fields['page_size'].display(limit=limit)}}
+    </div>
+  {% endif %}
+</div>
ForgeGit/forgegit/widgets/templates/log.html to ForgeGit/forgegit/widgets/templates/git_revision_widget.html
--- a/ForgeGit/forgegit/widgets/templates/log.html
+++ b/ForgeGit/forgegit/widgets/templates/git_revision_widget.html
@@ -1,60 +1,35 @@
-<div xmlns="http://www.w3.org/1999/xhtml"
-     xmlns:py="http://genshi.edgewall.org/"
-     xmlns:xi="http://www.w3.org/2001/XInclude">
-  <xi:include href="${g.allura_templates}/lib.html"/>
-  <div py:if="show_paging" style="clear:both">
-    ${fields['page_list'].display(limit=limit, page=page, count=count)}
-  </div>
-  <table>
-    <thead>
-      <tr>
-        <th style="text-align:left">Commit</th>
-        <th style="text-align:left">Date</th>
-        <th>&nbsp;</th>
-      </tr>
-    </thead>
-    <tbody>
-      <tr py:for="commit in value" py:with="cv = commit.value">
-        <td>
-          <b>${h.really_unicode(h.text.truncate(commit.value.message, 75))}</b><br/>
-          <py:if test="cv.committer != cv.author">
-            <py:if test="hasattr(cv,'committer_url') and cv.committer_url is not None">
-              <a href="${cv.committer_url}">${email_gravatar(cv.committer.email, title=cv.committer.name, size=16)}
-              ${cv.committer.name}</a>
-              pushed
-            </py:if>
-            <py:if test="not hasattr(cv,'committer_url') or cv.committer_url is None">
-              ${email_gravatar(cv.committer.email, title=cv.committer.name, size=16)} $cv.committer.name
-              pushed
-            </py:if>
-          </py:if>
-          <a href="${cv.url()}">${h.text.truncate(cv.hexsha, 10)}</a>
-          <py:if test="cv.author_url is not None">
-            by
-            <a href="${cv.author_url}">${email_gravatar(cv.author.email, title=cv.author.name, size=16)}
-            ${cv.author.name}</a>
-          </py:if>
-          <py:if test="cv.author_url is None">
-            by
-            ${email_gravatar(cv.author.email, title=cv.author.name, size=16)} $cv.author.name
-          </py:if>
-        </td>
-        <td>
-          <py:if test="hasattr(cv,'committed_datetime')">${h.ago(cv.committed_datetime)}</py:if>
-        </td>
-        <td style="text-align: right">
-          <py:if test="commit.prev">
-            Parent(s):
-            <py:for each="ci in commit.prev"><a href="${ci.url()}">${h.text.truncate(ci._id, 10)}</a></py:for>
-            <br/>
-          </py:if>
-          <a href="${cv.tree().url()}">Tree</a>
-        </td>
-      </tr>
-    </tbody>
-  </table>
-  <div py:if="show_paging" style="clear:both">
-    ${fields['page_list'].display(limit=limit, page=page, count=count)}
-    ${fields['page_size'].display(limit=limit)}
-  </div>
-</div>
+{% from 'jinja_master/lib.html' import email_gravatar with context %}
+{% if value.author_url %}
+  Authored by
+  <a href="{{value.author_url}}">{{email_gravatar(value.author.email, title=value.author.name, size=16)}}</a>
+  <a href="{{value.author_url}}">{{value.author.name}}</a>
+{% else %}
+  Authored by
+  {{email_gravatar(value.author.email, title=value.author.name, size=16)}} {{value.author.name}}
+{% endif %}
+{% if value.authored_datetime %}{{h.ago(value.authored_datetime)}}{% endif %}
+{% if value.committer != value.author %}
+  {% if value.committer_url %}
+    Committed by
+    <a href="{{value.committer_url}}">{{email_gravatar(value.committer.email, title=value.committer.name, size=16)}}</a>
+    <a href="{{value.committer_url}}">{{value.committer.name}}</a>
+  {% else %}
+    Committed by
+    {{email_gravatar(value.committer.email, title=value.committer.name, size=16)}} {{value.committer.name}}
+  {% endif %}
+  {% if value.committed_datetime %}{{h.ago(value.committed_datetime)}}{% endif %}
+{% endif %}
+
+<br/>
+<a href="{{value.tree().url()}}">Tree</a><br/>
+{% if prev %}
+  Parent(s):
+  {% for ci in prev %}<a href="{{ci.url()}}">{{h.text.truncate(ci._id, 10)}}</a>{% endfor %}
+  <br/>
+{% endif %}
+{% if next %}
+  Child(ren):
+  {% for ci in next %}<a href="{{ci.url()}}">{{h.text.truncate(ci._id, 10)}}</a>{% endfor %}
+  <br/>
+{% endif %}
+{{g.markdown.convert(h.really_unicode(value.message))}}
ForgeGit/forgegit/widgets/templates/revision.html to ForgeGit/forgegit/templates/git_index.html
--- a/ForgeGit/forgegit/widgets/templates/revision.html
+++ b/ForgeGit/forgegit/templates/git_index.html
@@ -1,42 +1,37 @@
-<div xmlns="http://www.w3.org/1999/xhtml"
-     xmlns:py="http://genshi.edgewall.org/"
-     xmlns:xi="http://www.w3.org/2001/XInclude">
-  <xi:include href="${g.allura_templates}/lib.html"/>
+{% extends 'jinja_master/master.html' %}
 
-  <py:if test="value.author_url is not None">
-    Authored by
-    <a href="${value.author_url}">${email_gravatar(value.author.email, title=value.author.name, size=16)}</a>
-    <a href="${value.author_url}">${value.author.name}</a>
-  </py:if>
-  <py:if test="value.author_url is None">
-    Authored by
-    ${email_gravatar(value.author.email, title=value.author.name, size=16)} $value.author.name
-  </py:if>  
-  <py:if test="hasattr(value,'authored_datetime')">${h.ago(value.authored_datetime)}</py:if>
-  <py:if test="value.committer != value.author">
-    <py:if test="hasattr(value,'committer_url') and value.committer_url is not None">
-      Committed by
-      <a href="${value.committer_url}">${email_gravatar(value.committer.email, title=value.committer.name, size=16)}</a>
-      <a href="${value.committer_url}">${value.committer.name}</a>
-    </py:if>
-    <py:if test="not hasattr(value,'committer_url') or value.committer_url is None">
-      Committed by
-      ${email_gravatar(value.committer.email, title=value.committer.name, size=16)} $value.committer.name
-    </py:if>
-    <py:if test="hasattr(value,'committed_datetime')">${h.ago(value.committed_datetime)}</py:if>
-  </py:if>
+{% block title %}
+  {% if c.app.repo %}
+    Git Repository: {{c.app.repo.name}}
+  {% else %}
+    Git Repository
+  {% endif %}
+{% endblock %}
 
-  <br/>
-  <a href="${value.tree().url()}">Tree</a><br/>
-  <py:if test="prev">
-    Parent(s):
-    <py:for each="ci in prev"><a href="${ci.url()}">${h.text.truncate(ci._id, 10)}</a></py:for>
-    <br/>
-  </py:if>
-  <py:if test="next">
-    Child(ren):
-    <py:for each="ci in next"><a href="${ci.url()}">${h.text.truncate(ci._id, 10)}</a></py:for>
-    <br/>
-  </py:if>
-  ${Markup(g.markdown.convert(h.really_unicode(value.message)))}
-</div>
+{% block header %}{{c.app.config.options.mount_label}}{% endblock %}
+
+{% block content %}
+<h2>Project: {{c.project.shortname}}</h2>
+  {% if c.app.repo %}
+    <p>
+      Read access: <code>git clone git://{{c.app.repo.scm_url_path}}</code><br/>
+      Read/write access: <code>git clone ssh://{{c.user == c.user.anonymous() and 'USERNAME' or c.user.username}}@{{c.app.repo.scm_url_path}}</code><br/>
+      {% if allow_fork and c.user != c.user.anonymous() %}
+        <form action="{{c.app.repo.url()}}fork" method="GET">
+          <input type="submit" value="Fork"/>
+        </form>    
+      {% endif %}
+    </p>
+  {% endif %}
+  <div style="clear:both">&nbsp;</div>
+  {% if log %}
+    <h2>Recent Commits{% if branch %} on {{branch}}{% endif %}</h2>
+    {{c.log_widget.display(value=log, show_paging=False,
+                           limit=limit, page=page, count=count)}}
+    {% if int(count) > int(limit) %}
+      <a href="log?page=1">More</a>
+    {% endif %}
+  {% else %}
+    <b>No (more) commits</b>
+  {% endif %}
+{% endblock %}