changeset 490:73a2e603a23b

sawmill: Prepared detail view for syndication: Added anchors for each build and added render rel link if RSS file exists next to treepkg.xml.
author Sascha Teichmann <teichmann@intevation.de>
date Wed, 29 Sep 2010 19:25:52 +0000
parents e7114ac643c3
children f1be9657c1d2
files contrib/sawmill/web/details.py contrib/sawmill/web/templates/details.html contrib/sawmill/web/templates/header.inc
diffstat 3 files changed, 45 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/sawmill/web/details.py	Sun Sep 26 08:53:16 2010 +0000
+++ b/contrib/sawmill/web/details.py	Wed Sep 29 19:25:52 2010 +0000
@@ -24,6 +24,8 @@
 
 UNDER_SCORE = re.compile(r"_+(\w)")
 
+INVALID_LABEL = re.compile(r"[^a-zA-Z0-9_]")
+
 def _create_time(s, format="%Y-%m-%d %H:%M:%S"):
     return datetime.datetime(*(time.strptime(s, format)[0:6]))
 
@@ -31,6 +33,9 @@
     log = log.replace(".txt", "").replace(".gz", "").capitalize()
     return UNDER_SCORE.sub(lambda x: " %s" % x.group(1).upper(), log)
 
+def _make_valid_label(label):
+    return INVALID_LABEL.sub("_", label)
+
 class TrackItem(object):
 
     def __init__(self, treepkg, track, revision, status_file):
@@ -78,6 +83,15 @@
         self.check_loaded()
         return self.tags
 
+    def get_label(self):
+        self.check_loaded()
+        out = [
+            _make_valid_label(self.track),
+            _make_valid_label(self.revision) ]
+        if self.start:
+            out.append(self.start.strftime("%Y%m%d%H%M%S"))
+        return ''.join(out)
+
     def log_path(self, log):
         return "%s/tracks/%s/pkg/%s/log/%s" % (
             self.treepkg, self.track, self.revision, log)
@@ -99,6 +113,7 @@
     build_stop   = property(get_build_stop)
     build_logs   = property(get_build_logs)
     build_tags   = property(get_tags)
+    build_label  = property(get_label)
 
 
 def __scan_track_items(treepkg, path):
@@ -139,28 +154,35 @@
 def index(req, treepkg=''):
     if not treepkg: util.redirect(req, "index.py")
 
-    found = None
+    package_dir = None
     for d in os.listdir(TREEPKG_DIR):
         dp = os.path.join(TREEPKG_DIR, d)
         if d == treepkg and os.path.isdir(dp):
-            found = dp
+            package_dir = dp
             break
 
-    if not found:
+    if not package_dir:
         req.status = apache.HTTP_NOT_FOUND
         return "requested TreePkg not found"
 
-    description, header = __description_header(found)
+    description, header = __description_header(package_dir)
 
-    track_items = __scan_track_items(treepkg, found)
+    track_items = __scan_track_items(treepkg, package_dir)
 
-    req.content_type = 'text/html;charset=utf-8'
-    template = psp.PSP(req, filename='templates/details.html')
-    template.run({
+    parameters = {
         'page_title' : description,
         'back_link'  : 'index.py',
         'base_dir'   : BASE_DIR,
         'description': description,
         'header'     : header,
         'track_items': track_items
-    })
+    }
+
+    if os.path.isfile(os.path.join(package_dir, "rss.xml")):
+        parameters['syndicate'] = (
+            'Build error feed',
+            'treepkgs/%s/rss.xml' % treepkg)
+
+    req.content_type = 'text/html;charset=utf-8'
+    template = psp.PSP(req, filename='templates/details.html')
+    template.run(parameters)
--- a/contrib/sawmill/web/templates/details.html	Sun Sep 26 08:53:16 2010 +0000
+++ b/contrib/sawmill/web/templates/details.html	Wed Sep 29 19:25:52 2010 +0000
@@ -86,21 +86,17 @@
     curr_date = date_from_datetime(track_item.build_start)
     if curr_date != last_date:
         last_date = curr_date
-%>
-<tr class="date_row"><td colspan="7"><%= pretty_time(last_date, "%Y-%m-%d") %> (times in UTC)</td></tr>
-<%
+%><tr class="date_row"><td colspan="7"><%= pretty_time(last_date, "%Y-%m-%d") %> (times in UTC)</td></tr><%
     # date changed
 %>
 <tr class="<%= STATUS2CLASS.get(track_item.build_status, 'error') %>">
-<td><%= STATUS2MSG.get(track_item.build_status, 'error') %></td>
-<td style="font-weight:bold;"><%= nn(track_item.track) %></td>
+<td><a name=<%= quoteattr(track_item.build_label) %>><%= STATUS2MSG.get(track_item.build_status, 'error') %></a></td>
+<td><b><%= nn(track_item.track) %></b></td>
 <td align="right"><%
     tags = track_item.build_tags
     if tags:
         # a tag
-%>
-<a href=<%= create_tags_link(tags) %>><strong><%= nn(track_item.revision) %></strong></a>
-<%
+%><a href=<%= create_tags_link(tags) %>><strong><%= nn(track_item.revision) %></strong></a><%
     else:
         # not a tag
 %><%= nn(track_item.revision) %><%
@@ -109,17 +105,13 @@
 <td align="right"><%= pretty_time(track_item.build_start) %></td>
 <td align="right"><%= pretty_time(track_item.build_stop) %></td>
 <td align="right"><%= pretty_timedelta(track_item.stop, track_item.build_start) %></td>
-<td>
-<%
+<td><%
     for log_desc, log_path in track_item.build_logs:
         # for all logs
-%>
-[<a href=<%= quoteattr("%s/%s" % (base_dir, log_path)) %>><%= nn(log_desc) %></a>]
+%>[<a href=<%= quoteattr("%s/%s" % (base_dir, log_path)) %>><%= nn(log_desc) %></a>]
 <%
     # for all logs
-%></td>
-</tr>
-<%
+%></td></tr><%
 # for all track itemes
 %>
 
--- a/contrib/sawmill/web/templates/header.inc	Sun Sep 26 08:53:16 2010 +0000
+++ b/contrib/sawmill/web/templates/header.inc	Wed Sep 29 19:25:52 2010 +0000
@@ -5,7 +5,13 @@
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <link rel="icon" href="img/favicon.ico" type="image/x-icon">
-  <link rel="stylesheet" href="styles/style.css" type="text/css" media="screen">
+  <link rel="stylesheet" href="styles/style.css" type="text/css" media="screen"><%
+if 'syndicate' in locals():
+    # generate syndication link
+%>
+  <link rel="alternate" type="application/rss+xml" title=<%= quoteattr(syndicate[0]) %> href=<%= quoteattr(syndicate[1])%>><%
+# no syndication
+%>
   <title>S&auml;gewerk - <%= escape(page_title) %></title>
 </head>
 <body>
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)