[Buildbot-devel] CSS changes

Brian Warner warner-buildbot at lothar.com
Wed Apr 5 18:38:44 UTC 2006


Hi all.. I'm evaluating a patch sent in by Stefan Seefeld to improve the CSS
tags generated for the Waterfall display, and I realized that I'm not
qualified to pass judgement on anything related to CSS. Could someone else
who is using custom CSS right now look at this and tell us what you think?
I've attached the patch below, the sf.net issue number is #1461675.

The main question I have is the change from class="command rebuild" to
class="rebuild". Now, it seems to me that the original intent of "command
rebuild" was to specify two classes, like a kind of multiple inheritance, so
that your CSS could either provide a style for all "commands", or individual
ones for the various kinds of commands like rebuild, pingbuilder, forcebuild,
etc. The trouble is, I haven't been able to find any evidence that the class=
attribute can be used this way: it doesn't seem to allow spaces, and I've
seen a few pages say that you can't have multiple classes on a single node.

Would it make sense to have nested nodes, one on the outside with
class="command", and another on the inside with class="rebuild" ? Or should
be give up the "command" class altogether?


thanks,
 -Brian


--- old-local-css-1461675/buildbot/status/html.py	2006-04-05 14:33:55.000000000 -0400
+++ new-local-css-1461675/buildbot/status/html.py	2006-04-05 14:33:55.000000000 -0400
@@ -321,7 +321,8 @@
         b = self.build
         buildbotURL = self.status.getBuildbotURL()
         projectName = self.status.getProjectName()
-        data = "<a href=\"%s\">%s</a>\n" % (buildbotURL, projectName)
+        data = '<div class="title"><a href="%s">%s</a></div>\n'%(buildbotURL,
+                                                                 projectName)
         # the color in the following line gives python-mode trouble
         data += ("<h1>Build <a href=\"%s\">%s</a>:#%d</h1>\n"
                  "<h2>Reason:</h2>\n%s\n"
@@ -356,7 +357,7 @@
             if self.control is not None:
                 stopURL = urllib.quote(request.childLink("stop"))
                 data += """
-                <form action="%s" class='command stopbuild'>
+                <form action="%s" class="stopbuild">
                 <p>To stop this build, fill out the following fields and
                 push the 'Stop' button</p>\n""" % stopURL
                 data += make_row("Your name:",
@@ -384,8 +385,7 @@
                          "after this build was started <b>will</b> be \n"
                          "included in a rebuild.</p>\n")
             rebuildURL = urllib.quote(request.childLink("rebuild"))
-            data += ('<form action="%s" class="command rebuild">\n'
-                     % rebuildURL)
+            data += ('<form action="%s" class="rebuild">\n' % rebuildURL)
             data += make_row("Your name:",
                              "<input type='text' name='username' />")
             data += make_row("Reason for re-running build:",
@@ -523,7 +523,7 @@
             forceURL = urllib.quote(request.childLink("force"))
             data += (
                 """
-                <form action='%(forceURL)s' class='command forcebuild'>
+                <form action='%(forceURL)s' class='forcebuild'>
                 <p>To force a build, fill out the following fields and
                 push the 'Force Build' button</p>"""
                 + make_row("Your name:",
@@ -547,7 +547,7 @@
         if self.control is not None:
             pingURL = urllib.quote(request.childLink("ping"))
             data += """
-            <form action="%s" class='command pingbuilder'>
+            <form action="%s" class='pingbuilder'>
             <p>To ping the buildslave(s), push the 'Ping' button</p>
 
             <input type="submit" value="Ping Builder" />
@@ -890,7 +890,7 @@
             #  ['building', 'ETA in', '2 secs', 'at 22:12:50']
             # consider swapping one of these to make them look the same. also
             # consider leaving them reversed to make them look different.
-        return Box(text, color=color, class_="Activity " + state)
+        return Box(text, color=color, class_=state)
 
 components.registerAdapter(CurrentBox, builder.BuilderStatus, ICurrentBox)
 
@@ -988,7 +988,7 @@
         assert interfaces.IBuilderStatus(self.original)
         b = self.original.getLastFinishedBuild()
         if not b:
-            return Box(["none"], "white", class_="LastBuild")
+            return Box(["none"], "white")
         name = b.getBuilder().getName()
         number = b.getNumber()
         url = "%s/builds/%d" % (name, number)
@@ -997,7 +997,7 @@
         # TODO: add link to the per-build page at 'url'
         c = b.getColor()
         class_ = build_get_class(b)
-        return Box(text, c, class_="LastBuild %s" % class_)
+        return Box(text, c, class_=class_)
 components.registerAdapter(BuildTopBox, builder.BuilderStatus, ITopBox)
 
 class Spacer(builder.Event):
@@ -1071,6 +1071,16 @@
 
     def body(self, request):
         "This method builds the main waterfall display."
+
+        data = ''
+
+        projectName = self.status.getProjectName()
+        projectURL = self.status.getProjectURL()
+        if projectName and projectURL:
+            # TODO: add optional logo here ?
+            data += ('<div class="title"><a href="%s">%s</a></div>\n'
+                     % (projectURL, projectName))
+
         phase = request.args.get("phase",["2"])
         phase = int(phase[0])
 
@@ -1097,27 +1107,17 @@
             return self.phase0(request, (changeNames + builderNames),
                                timestamps, eventGrid)
         # start the table: top-header material
-        data = "<table class=\"table\" border=\"0\" cellspacing=\"0\">\n"
-        #data = "<table frame=\"rhs\" rules=\"all\" class=\"table\">\n"
+        data = "<table border=\"0\" cellspacing=\"0\">\n"
 
-        data += " <tr>\n"
-        projectName = self.status.getProjectName()
-        projectURL = self.status.getProjectURL()
-        if projectName and projectURL:
-            # TODO: this is going to look really ugly
-            topleft = "<a href=\"%s\">%s</a><br />last build" % \
-                      (projectURL, projectName)
-        else:
-            topleft = "last build"
-        data += td(topleft, align="right", colspan=2, class_="Project")
+        data += ' <tr class="lastbuild">\n'
+        data += td("last build", align='right', colspan=2, class_='Project')
         for b in builders:
             box = ITopBox(b).getBox()
             data += box.td(align="center")
         data += " </tr>\n"
 
-        data += " <tr>\n"
-        data += td("current activity", align="right", colspan=2,
-                   class_="Activity")
+        data += ' <tr class="activity">\n'
+        data += td('current activity', align='right', colspan=2)
         for b in builders:
             box = ICurrentBox(b).getBox(self.status)
             data += box.td(align="center")
@@ -1173,9 +1173,7 @@
                 urllib.quote(request.childLink("waterfall"))
         data += " for the waterfall display</p>\n"
                 
-        #data += "<table border=\"1\">\n"
-        #data += "<table frame=\"rhs\" rules=\"all\" class=\"table\">\n"
-        data += "<table class=\"table\" border=\"0\" cellspacing=\"0\">\n"
+        data += '<table border="0" cellspacing="0">\n'
         names = map(lambda builder: builder.name, builders)
 
         # the top row is two blank spaces, then the top-level status boxes






More information about the devel mailing list