web: big cleanup of URL generation, to use relative links everywhere
[buildbot.git] / buildbot / status / web / changes.py
blobd6b4110ff71326d485fc3cebe28c651ef6b84b64
2 from zope.interface import implements
3 from twisted.python import components
4 from twisted.web.error import NoResource
6 from buildbot.changes.changes import Change
7 from buildbot.status.web.base import HtmlResource, StaticHTML, IBox, Box
9 # /changes/NN
10 class ChangesResource(HtmlResource):
12 def body(self, req):
13 data = ""
14 data += "Change sources:\n"
15 sources = self.getStatus(req).getChangeSources()
16 if sources:
17 data += "<ol>\n"
18 for s in sources:
19 data += "<li>%s</li>\n" % s.describe()
20 data += "</ol>\n"
21 else:
22 data += "none (push only)\n"
23 return data
25 def getChild(self, path, req):
26 num = int(path)
27 c = self.getStatus(req).getChange(num)
28 if not c:
29 return NoResource("No change number '%d'" % num)
30 return StaticHTML(c.asHTML(), "Change #%d" % num)
33 class ChangeBox(components.Adapter):
34 implements(IBox)
36 def getBox(self, req):
37 url = req.childLink("../changes/%d" % self.original.number)
38 text = self.original.get_HTML_box(url)
39 return Box([text], color="white", class_="Change")
40 components.registerAdapter(ChangeBox, Change, IBox)