Skip to content

Commit

Permalink
buildstatus -> jinja
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-sonestedt committed Dec 13, 2009
1 parent e987ecd commit ca45b27
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
22 changes: 10 additions & 12 deletions buildbot/status/web/buildstatus.py
Expand Up @@ -9,26 +9,22 @@ def __init__(self, categories=None):
def head(self, request):
return ""

def body(self, request):
def content(self, request, ctx):
"""Display a build in the same format as the waterfall page.
The HTTP GET parameters are the builder name and the build
number."""

status = self.getStatus(request)
data = ""

# Get the parameters.
name = request.args.get("builder", [None])[0]
number = request.args.get("number", [None])[0]
if not name or not number:
return "builder and number parameter missing"

# Main table for the build status.
data += '<table>\n'

# Check if the builder in parameter exists.
try:
builder = status.getBuilder(name)
builder = status.getBuilder(name)
except:
return "unknown builder"

Expand All @@ -37,19 +33,21 @@ def body(self, request):
if not build:
return "unknown build %s" % number

rows = ctx['rows'] = []

# Display each step, starting by the last one.
for i in range(len(build.getSteps()) - 1, -1, -1):
if build.getSteps()[i].getText():
data += " <tr>\n"
data += IBox(build.getSteps()[i]).getBox(request).td(align="center")
data += " </tr>\n"
rows.append(IBox(build.getSteps()[i]).getBox(request).td(align="center"))

# Display the bottom box with the build number in it.
data += "<tr>"
data += IBox(build).getBox(request).td(align="center")
data += "</tr></table>\n"
ctx['build'] = IBox(build).getBox(request).td(align="center")

template = request.site.buildbot_service.templates.get_template("buildstatus.html")
data = template.render(**ctx)

# We want all links to display in a new tab/window instead of in the
# current one.
# TODO: Move to template
data = data.replace('<a ', '<a target="_blank"')
return data
11 changes: 11 additions & 0 deletions buildbot/status/web/templates/buildstatus.html
@@ -0,0 +1,11 @@
{% extends "layout.html" %}

{% block content %}
<table>
{% for r in rows %}
<tr>{{ r }}</tr>
{% endfor %}

<tr>{{ build }}</tr>
</table>
{% endblock %}

0 comments on commit ca45b27

Please sign in to comment.