Skip to content

Commit

Permalink
Replace index.html root with jinja template (fixes buildbot#656) + us…
Browse files Browse the repository at this point in the history
…e new default.css everywhere
  • Loading branch information
marcus-sonestedt committed Dec 19, 2009
1 parent 0c23a77 commit 3694085
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 141 deletions.
6 changes: 2 additions & 4 deletions buildbot/scripts/runner.py
Expand Up @@ -291,9 +291,8 @@ def upgradeMaster(config):
# check web files: index.html, default.css, robots.txt
webdir = os.path.join(basedir, "public_html")
m.upgrade_public_html({
'index.html' : util.sibpath(__file__, "../status/web/index.html"),
'bg_gradient.jpg' : util.sibpath(__file__, "../status/web/bg_gradient.jpg"),
'buildbot.css' : util.sibpath(__file__, "../status/web/default.css"),
'default.css' : util.sibpath(__file__, "../status/web/default.css"),
'robots.txt' : util.sibpath(__file__, "../status/web/robots.txt"),
})
m.populate_if_missing(os.path.join(basedir, "master.cfg.sample"),
Expand Down Expand Up @@ -373,9 +372,8 @@ def createMaster(config):
m.makeTAC(contents)
m.sampleconfig(util.sibpath(__file__, "sample.cfg"))
m.public_html({
'index.html' : util.sibpath(__file__, "../status/web/index.html"),
'bg_gradient.jpg' : util.sibpath(__file__, "../status/web/bg_gradient.jpg"),
'buildbot.css' : util.sibpath(__file__, "../status/web/default.css"),
'default.css' : util.sibpath(__file__, "../status/web/default.css"),
'robots.txt' : util.sibpath(__file__, "../status/web/robots.txt"),
})
m.makefile()
Expand Down
9 changes: 4 additions & 5 deletions buildbot/status/web/base.py
Expand Up @@ -231,7 +231,7 @@ def getContext(self, request):
status = self.getStatus(request)
return dict(project_url = status.getProjectURL(),
project_name = status.getProjectName(),
stylesheet = self.path_to_root(request) + 'buildbot.css',
stylesheet = self.path_to_root(request) + 'default.css',
path_to_root = self.path_to_root(request),
version = version,
time = time.strftime("%a %d %b %Y %H:%M:%S",
Expand Down Expand Up @@ -276,8 +276,8 @@ def fillTemplate(self, template, request):
s = request.site.buildbot_service
values = s.template_values.copy()
values['root'] = self.path_to_root(request)
# e.g. to reference the top-level 'buildbot.css' page, use
# "%(root)sbuildbot.css"
# e.g. to reference the top-level 'default.css' page, use
# "%(root)sdefault.css"
values['title'] = self.getTitle(request)
return template % values

Expand Down Expand Up @@ -325,7 +325,7 @@ def render(self, request):

cxt = dict(project_url = status.getProjectURL(),
project_name = status.getProjectName(),
stylesheet = path_to_root(request) + 'buildbot.css',
stylesheet = path_to_root(request) + 'default.css',
version = version,
time = time.strftime("%a %d %b %Y %H:%M:%S",
time.localtime(util.now())),
Expand Down Expand Up @@ -408,7 +408,6 @@ def get_line_values(self, req, build, include_builder=True):
rev = str(rev)
if len(rev) > 40:
rev = rev[0:40] + "..."
root = self.path_to_root(req)
css_class = css_classes.get(results, "")
values = {'class': css_class,
'builder_name': builder_name,
Expand Down
17 changes: 9 additions & 8 deletions buildbot/status/web/baseweb.py
Expand Up @@ -272,15 +272,15 @@ def body(self, req):

HEAD_ELEMENTS = [
'<title>%(title)s</title>',
'<link href="%(root)sbuildbot.css" rel="stylesheet" type="text/css" />',
'<link href="%(root)sdefault.css" rel="stylesheet" type="text/css" />',
]
BODY_ATTRS = {
'vlink': "#800080",
}

FOOTER = '''
</html>
'''
'''

class AlmostStrictUndefined(jinja2.StrictUndefined):
''' An undefined that allows boolean testing but
Expand Down Expand Up @@ -345,7 +345,7 @@ class WebStatus(service.MultiService):
All URLs for pages which are not defined here are used to look
for files in PUBLIC_HTML, which defaults to BASEDIR/public_html.
This means that /robots.txt or /buildbot.css or /favicon.ico can
This means that /robots.txt or /default.css or /favicon.ico can
be placed in that directory.
If an index file (index.html, index.htm, or index, in that order) is
Expand All @@ -358,7 +358,7 @@ class WebStatus(service.MultiService):
bottom.
This webserver defines class attributes on elements so they can be styled
with CSS stylesheets. All pages pull in PUBLIC_HTML/buildbot.css, and you
with CSS stylesheets. All pages pull in PUBLIC_HTML/default.css, and you
can cause additional stylesheets to be loaded by adding a suitable <link>
to the WebStatus instance's .head_elements attribute.
Expand Down Expand Up @@ -582,6 +582,7 @@ def setupSite(self):
os.mkdir(htmldir)

root = StaticFile(htmldir)
root.putChild("", RootPage())

for name, child_resource in self.childrenToBeAdded.iteritems():
root.putChild(name, child_resource)
Expand Down Expand Up @@ -664,7 +665,7 @@ class Waterfall(WebStatus):
# all 'data' files are in the directory of our executable
here = os.path.dirname(sys.executable)
buildbot_icon = os.path.abspath(os.path.join(here, "buildbot.png"))
buildbot_css = os.path.abspath(os.path.join(here, "classic.css"))
buildbot_css = os.path.abspath(os.path.join(here, "default.css"))
else:
# running from source
# the icon is sibpath(__file__, "../buildbot.png") . This is for
Expand All @@ -673,7 +674,7 @@ class Waterfall(WebStatus):
buildbot_icon = os.path.abspath(os.path.join(up(up(up(__file__))),
"buildbot.png"))
buildbot_css = os.path.abspath(os.path.join(up(__file__),
"classic.css"))
"default.css"))

compare_attrs = ["http_port", "distrib_port", "allowForce",
"categories", "css", "favicon", "robots_txt"]
Expand All @@ -690,12 +691,12 @@ def __init__(self, http_port=None, distrib_port=None, allowForce=True,
WebStatus.__init__(self, http_port, distrib_port, allowForce)
self.css = css
if css:
if os.path.exists(os.path.join("public_html", "buildbot.css")):
if os.path.exists(os.path.join("public_html", "default.css")):
# they've upgraded, so defer to that copy instead
pass
else:
data = open(css, "rb").read()
self.putChild("buildbot.css", static.Data(data, "text/css"))
self.putChild("default.css", static.Data(data, "text/css"))
self.favicon = favicon
self.robots_txt = robots_txt
if favicon:
Expand Down
2 changes: 1 addition & 1 deletion buildbot/status/web/console_html.py
Expand Up @@ -196,7 +196,7 @@
<div class="footer">
[ <a href="$welcomeUrl">welcome</a> ]
<br />
<a href="http://buildbot.sourceforge.net/">Buildbot - $version</a> working for the <a href="$projectUrl"> $projectName </a> project.
<a href="http://buildbot.net/">Buildbot - $version</a> working for the <a href="$projectUrl"> $projectName </a> project.
<br />
Page built: $time
<br />
Expand Down
42 changes: 0 additions & 42 deletions buildbot/status/web/templates/base.html

This file was deleted.

7 changes: 6 additions & 1 deletion buildbot/status/web/templates/layout.html
Expand Up @@ -18,7 +18,12 @@
<div class="header">
</div>
{% endblock %}
{%- block content -%} {%- endblock -%}

<div class="content">
{%- block content -%}
{%- endblock -%}
</div>

{%- block footer -%}
<div class="footer">
<hr/>
Expand Down
7 changes: 5 additions & 2 deletions buildbot/status/web/templates/root.html
@@ -1,6 +1,6 @@
{% include 'base.html' %}
{% extends 'layout.html' %}

{% block 'content' %}
{% block content %}

<h1>Welcome to the Buildbot!</h1>

Expand All @@ -14,6 +14,9 @@ <h1>Welcome to the Buildbot!</h1>
<li>the <a href="tgrid">Transposed Grid Display</a> presents
the same information as the grid, but lists the revisions down the side.</li>

<li>the <a href="console">Console</a> presents
a user-oriented status page (works best for SCMs with linear integer revision ids).</li>

<li>The <a href="one_box_per_builder">Latest Build</a> for each builder is
here.</li>

Expand Down
152 changes: 76 additions & 76 deletions contrib/windows/setup.py
@@ -1,83 +1,83 @@
# setup.py
# A distutils setup script to create py2exe binaries for buildbot.
# Both a service and standard executable are created.
# Usage:
# % setup.py py2exe

# setup.py
# A distutils setup script to create py2exe binaries for buildbot.
# Both a service and standard executable are created.
# Usage:
# % setup.py py2exe

import sys
import os
import tempfile
import shutil
import py2exe

from os.path import dirname, join, abspath, exists, splitext

this_dir = abspath(dirname(__file__))
bb_root_dir = abspath(join(this_dir, "..", ".."))

from distutils.core import setup

includes = []

# We try and bundle *all* modules in the following packages:
for package in ["buildbot.changes", "buildbot.process", "buildbot.status"]:
__import__(package)
p = sys.modules[package]
for fname in os.listdir(p.__path__[0]):
base, ext = splitext(fname)
if not fname.startswith("_") and ext == ".py":
includes.append(p.__name__ + "." + base)

# Other misc modules dynamically imported, so missed by py2exe
includes.extend("""
buildbot.scheduler
buildbot.slave.bot
buildbot.master
twisted.internet.win32eventreactor
twisted.web.resource""".split())

# Turn into "," sep py2exe requires
includes = ",".join(includes)

py2exe_options = {"bundle_files": 1,
"includes": includes,
}

# Each "target" executable we create
buildbot_target = {
from os.path import dirname, join, abspath, exists, splitext

this_dir = abspath(dirname(__file__))
bb_root_dir = abspath(join(this_dir, "..", ".."))

from distutils.core import setup

includes = []

# We try and bundle *all* modules in the following packages:
for package in ["buildbot.changes", "buildbot.process", "buildbot.status"]:
__import__(package)
p = sys.modules[package]
for fname in os.listdir(p.__path__[0]):
base, ext = splitext(fname)
if not fname.startswith("_") and ext == ".py":
includes.append(p.__name__ + "." + base)

# Other misc modules dynamically imported, so missed by py2exe
includes.extend("""
buildbot.scheduler
buildbot.slave.bot
buildbot.master
twisted.internet.win32eventreactor
twisted.web.resource""".split())

# Turn into "," sep py2exe requires
includes = ",".join(includes)

py2exe_options = {"bundle_files": 1,
"includes": includes,
}

# Each "target" executable we create
buildbot_target = {
"script": join(bb_root_dir, "bin", "buildbot"),
}
# Due to the way py2exe works, we need to rebuild the service code as a
# normal console process - this will be executed by the service itself.

service_target = {
"modules": ["buildbot_service"],
"cmdline_style": "custom",
}

# We use the py2exe "bundle" option, so servicemanager.pyd
# (which has the message resources) does not exist. Take a copy
# of it with a "friendlier" name. The service runtime arranges for this
# to be used.
import servicemanager

msg_file = join(tempfile.gettempdir(), "buildbot.msg")
shutil.copy(servicemanager.__file__, msg_file)

data_files = [
["", [msg_file]],
["", [join(bb_root_dir, "buildbot", "status", "web", "classic.css")]],
["", [join(bb_root_dir, "buildbot", "buildbot.png")]],
]

try:
setup(name="buildbot",
# The buildbot script as a normal executable
console=[buildbot_target],
service=[service_target],
options={'py2exe': py2exe_options},
data_files = data_files,
zipfile = "buildbot.library", # 'library.zip' invites trouble :)
)
finally:
os.unlink(msg_file)
}
# Due to the way py2exe works, we need to rebuild the service code as a
# normal console process - this will be executed by the service itself.

service_target = {
"modules": ["buildbot_service"],
"cmdline_style": "custom",
}

# We use the py2exe "bundle" option, so servicemanager.pyd
# (which has the message resources) does not exist. Take a copy
# of it with a "friendlier" name. The service runtime arranges for this
# to be used.
import servicemanager

msg_file = join(tempfile.gettempdir(), "buildbot.msg")
shutil.copy(servicemanager.__file__, msg_file)

data_files = [
["", [msg_file]],
["", [join(bb_root_dir, "buildbot", "status", "web", "default.css")]],
["", [join(bb_root_dir, "buildbot", "buildbot.png")]],
]

try:
setup(name="buildbot",
# The buildbot script as a normal executable
console=[buildbot_target],
service=[service_target],
options={'py2exe': py2exe_options},
data_files = data_files,
zipfile = "buildbot.library", # 'library.zip' invites trouble :)
)
finally:
os.unlink(msg_file)
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -207,8 +207,8 @@ def finalize_options(self):
'data_files': [("buildbot", ["buildbot/buildbot.png"]),
("buildbot/clients", ["buildbot/clients/debug.glade"]),
("buildbot/status/web",
["buildbot/status/web/classic.css",
"buildbot/status/web/index.html",
["buildbot/status/web/default.css",
"buildbot/status/web/bg_gradient.jpg",
"buildbot/status/web/robots.txt",
]),
include("buildbot/status/web/templates", '*.html'),
Expand Down

0 comments on commit 3694085

Please sign in to comment.