From d61d54ce33022f0613c5e19e2f52be4ab77c4664 Mon Sep 17 00:00:00 2001 From: Gianluca Montecchi Date: Mon, 24 Jan 2011 22:47:32 +0100 Subject: [PATCH] New html output for html command --- libbe/command/html.py | 262 +++++++++++++++++++++++++++++++++--------- 1 file changed, 209 insertions(+), 53 deletions(-) diff --git a/libbe/command/html.py b/libbe/command/html.py index 5b0f84c..1ac6247 100644 --- a/libbe/command/html.py +++ b/libbe/command/html.py @@ -32,6 +32,7 @@ import libbe.command.util import libbe.comment import libbe.util.encoding import libbe.util.id +import libbe.command.depend class HTML (libbe.command.Command): @@ -163,11 +164,21 @@ class HTMLGen (object): bugs_active = [] bugs_inactive = [] + bugs_target = [] bugs = [b for b in self.bd] bugs.sort() - bugs_active = [b for b in bugs if b.active == True] - bugs_inactive = [b for b in bugs if b.active != True] - + + for b in bugs: + if b.active == True and b.severity != 'target': + bugs_active.append(b) + if b.active != True and b.severity != 'target': + bugs_inactive.append(b) + if b.severity == 'target': + bugs_target.append(b) +# bugs_active = [b for b in bugs if b.active == True and b.severity != 'target'] +# bugs_inactive = [b for b in bugs if b.active != True and b.severity != 'target'] +# bugs_target = [b for b in bugs if b.active == True and b.severity == 'target'] + self._create_output_directories(out_dir) self._write_css_file() for b in bugs: @@ -175,6 +186,7 @@ class HTMLGen (object): up_link = '../../index.html' else: up_link = '../../index_inactive.html' + self._write_bug_file(b, up_link) self._write_index_file( bugs_active, title=self.title, @@ -182,6 +194,9 @@ class HTMLGen (object): self._write_index_file( bugs_inactive, title=self.title, index_header=self.index_header, bug_type='inactive') + self._write_index_file( + bugs_target, title=self.title, + index_header=self.index_header, bug_type='target') def _truncated_bug_id(self, bug): return libbe.util.id._truncate( @@ -213,7 +228,15 @@ class HTMLGen (object): print >> self.stdout, '\tCreating bug file for %s' % bug.id.user() assert hasattr(self, 'out_dir_bugs'), \ 'Must run after ._create_output_directories()' - + index_type = '' + + if bug.active == True: + index_type = 'Active' + else : + index_type = 'Inactive' + if bug.severity == 'target': + index_type = 'Target' + bug.load_comments(load_full=True) comment_entries = self._generate_bug_comment_entries(bug) dirname = self._truncated_bug_id(bug) @@ -223,7 +246,8 @@ class HTMLGen (object): 'up_link':up_link, 'shortname':bug.id.user(), 'comment_entries':comment_entries, - 'generation_time':self.generation_time} + 'generation_time':self.generation_time, + 'index_type':index_type} for attr in ['uuid', 'severity', 'status', 'assigned', 'reporter', 'creator', 'time_string', 'summary']: template_info[attr] = self._escape(getattr(bug, attr)) @@ -366,13 +390,17 @@ class HTMLGen (object): print >> self.stdout, 'Writing %s index file for %d bugs' % (bug_type, len(bugs)) assert hasattr(self, 'out_dir'), 'Must run after ._create_output_directories()' esc = self._escape - - bug_entries = self._generate_index_bug_entries(bugs) + if (bug_type == 'target'): + bug_entries = self._generate_index_bug_entries_target(bugs) + else: + bug_entries = self._generate_index_bug_entries(bugs) if bug_type == 'active': filename = 'index.html' elif bug_type == 'inactive': filename = 'index_inactive.html' + elif bug_type == 'target': + filename = 'index_by_target.html' else: raise Exception, 'Unrecognized bug_type: "%s"' % bug_type template_info = {'title':title, @@ -380,17 +408,41 @@ class HTMLGen (object): 'charset':self.encoding, 'active_class':'tab sel', 'inactive_class':'tab nsel', + 'target_class':'tab nsel', 'bug_entries':bug_entries, 'generation_time':self.generation_time} if bug_type == 'inactive': template_info['active_class'] = 'tab nsel' template_info['inactive_class'] = 'tab sel' - + if bug_type == 'target': + template_info['active_class'] = 'tab nsel' + template_info['target_class'] = 'tab sel' self._write_file(self.index_file % template_info, [self.out_dir, filename]) + def _generate_index_bug_entries_target(self, targets): + + target_entries = [] + for target in targets: + bug_entries = [] + template_info_list = {'target':target.summary, 'bug_entries': '', 'status': target.status} + blocker = libbe.command.depend.get_blocked_by(self.bd, target) + for bug in blocker: + if self.verbose: + print >> self.stdout, '\tCreating bug entry for %s' % bug.id.user() + template_info = {'shortname':bug.id.user()} + for attr in ['uuid', 'severity', 'status', 'assigned', + 'reporter', 'creator', 'time_string', 'summary']: + template_info[attr] = self._escape(getattr(bug, attr)) + template_info['dir'] = self._truncated_bug_id(bug) + bug_entries.append(self.index_bug_entry % template_info) + template_info_list['bug_entries'] = '\n'.join(bug_entries) + target_entries.append(self.target_bug_list % template_info_list) + return '\n'.join(target_entries) + def _generate_index_bug_entries(self, bugs): bug_entries = [] + template_info_list = {'bug_entries': ''} for bug in bugs: if self.verbose: print >> self.stdout, '\tCreating bug entry for %s' % bug.id.user() @@ -400,7 +452,8 @@ class HTMLGen (object): template_info[attr] = self._escape(getattr(bug, attr)) template_info['dir'] = self._truncated_bug_id(bug) bug_entries.append(self.index_bug_entry % template_info) - return '\n'.join(bug_entries) + template_info_list['bug_entries'] = '\n'.join(bug_entries) + return self.bug_list % template_info_list def _escape(self, string): if string == None: @@ -463,6 +516,7 @@ class HTMLGen (object): self.css_file = """ body { font-family: "lucida grande", "sans serif"; + font-size: 14px; color: #333; width: auto; margin: auto; @@ -474,6 +528,8 @@ class HTMLGen (object): padding-top: 0; margin-top: 1em; background-color: #fcfcfc; + -moz-border-radius: 10px; + } div.footer { @@ -485,30 +541,71 @@ class HTMLGen (object): margin: auto; background: #305275; color: #fffee7; + -moz-border-radius: 10px; } - + + div.header { + font-size: xx-large; + padding-left: 20px; + padding-right: 20px; + padding-top: 10px; + font-weight:bold; + padding-bottom: 10px; + background: #305275; + color: #fffee7; + -moz-border-radius: 10px; + } + + div.target_name { + border: 1px solid; + border-color: #305275; + background-color: #305275; + color: #fff; + width: auto%; + -moz-border-radius-topleft: 8px; + -moz-border-radius-topright: 8px; + padding-left: 5px; + padding-right: 5px; + } + table { border-style: solid; - border: 10px #313131; - border-spacing: 0; + border: 1px #c3d9ff; + border-spacing: 0px 0px; width: auto; - } + padding: 0px; + + } tb { border: 1px; } tr { vertical-align: top; + border: 1px #c3d9ff; + border-style: dotted; width: auto; + padding: 0px; } - + + th { + border-width: 1px; + border-style: solid; + border-color: #c3d9ff; + border-collapse: collapse; + padding-left: 5px; + padding-right: 5px; + } + + td { - border-width: 0; - border-style: none; - padding-right: 0.5em; - padding-left: 0.5em; - width: auto; + border-width: 1px; + border-color: #c3d9ff; + border-collapse: collapse; + padding-left: 5px; + padding-right: 5px; + width: auto%; } - + img { border-style: none; } h1 { @@ -545,29 +642,68 @@ class HTMLGen (object): } td.sel.tab { - background-color: #afafaf; - border: 1px solid #afafaf; - font-weight:bold; + background-color: #c3d9ff ; + border: 1px solid #c3d9ff; + font-weight:bold; + -moz-border-radius-topleft: 15px; + -moz-border-radius-topright: 15px; } - td.nsel.tab { border: 0px; } + td.nsel.tab { + border: 1px solid #c3d9ff; + font-weight:bold; + -moz-border-radius-topleft: 5px; + -moz-border-radius-topright: 5px; + } table.bug_list { - background-color: #afafaf; - border: 2px solid #afafaf; + border-width: 1px; + border-style: solid; + border-color: #c3d9ff; + padding: 0px; + width: 100%; + border: 1px solid #c3d9ff; + } + + table.target_list { + border-width: 1px; + border-style: solid; + border-collapse: collapse; + border-color: #c3d9ff; + padding: 0px; + width: 100%; + margin-bottom: 10px; } - .bug_list tr { width: auto; } - tr.wishlist { background-color: #B4FF9B; } - tr.minor { background-color: #FCFF98; } - tr.serious { background-color: #FFB648; } - tr.critical { background-color: #FF752A; } - tr.fatal { background-color: #FF3300; } + table.target_list.td { + border-width: 1px; + } + tr.wishlist { background-color: #DCFAFF;} + tr.wishlist:hover { background-color: #C2DCE1; } + + tr.minor { background-color: #FFFFA6; } + tr.minor:hover { background-color: #E6E696; } + + tr.serious { background-color: #FF9077;} + tr.serious:hover { background-color: #E6826B; } + + tr.critical { background-color: #FF752A; } + tr.critical:hover { background-color: #D63905;} + + tr.fatal { background-color: #FF3300;} + tr.fatal:hover { background-color: #D60000;} + + td.uuid { text-align: center; width: 5%; border-style: dotted;} + td.status { text-align: center; width: 5%; border-style: dotted;} + td.severity { text-align: center; width: 5%; border-style: dotted;} + td.summary { border-style: dotted;} + td.date { text-align: center; width: 25%; border-style: dotted;} + /* bug detail pages */ - td.bug_detail_label { text-align: right; } - td.bug_detail { } + td.bug_detail_label { text-align: right; border: none;} + td.bug_detail { border: none;} td.bug_comment_label { text-align: right; vertical-align: top; } td.bug_comment { } @@ -596,26 +732,23 @@ class HTMLGen (object): +
%(index_header)s
-

%(index_header)s

+ - + -
Active Bugs Inactive BugsDivided by target
- - + %(bug_entries)s - -
- +