Generate data_table.html

This patch updates reviewday so that it generates
both an index.html and a separate data_table.html
which can be used for importing the reviewday HTML
table into an externally styled website.

The existing reviewday OpenStack style remains the same.
This patch should prove useful for sites wishing
to re-use the "data table" format as-is inside of a
separately themed web site.

Change-Id: If9a69235484038e4b10ee8a2c66ed834f5f6a8d2
This commit is contained in:
Dan Prince 2015-09-27 21:38:37 -04:00
parent 540225b34d
commit 6caf710a79
3 changed files with 139 additions and 118 deletions

116
reviewday/data_table.html Normal file
View File

@ -0,0 +1,116 @@
<div class="yui-d0">
<link href="combo.css" media="screen,print" rel="stylesheet" type="text/css"/>
<script src="sorting.js" type="text/javascript"/>
#for $project in $helper.sort($projects.keys()):
#set $mergeprops = $projects[$project]
<a name="$project">
</a>
<div class="flowed-block wide">
<h1>
$project branch reviews
</h1>
<ol class="breadcrumbs">
<li>
Page refreshed at $dts UTC
</li>
<li>
$len($mergeprops) active reviews
</li>
</ol>
<br/>
</div>
<table class="listing sortable" summary="$project reviews">
<thead>
<tr>
<th>
<a class="sortheader" href="#" onclick="ts_resortTable(this); return false;">
Type
<img class="sortarrow" height="6" src="arrowBlank" width="9"/>
</a>
</th>
<th>
<a class="sortheader" href="#" onclick="ts_resortTable(this); return false;">
Subject
<img class="sortarrow" height="6" src="arrowBlank" width="9"/>
</a>
</th>
<!--
<th><a href="#" class="sortheader"
onclick="ts_resortTable(this); return false;">Patchsize<img
class="sortarrow" src="arrowBlank" height="6" width="9"></a></th>
<th><a href="#" class="sortheader"
onclick="ts_resortTable(this); return false;">Age<img
class="sortarrow" src="arrowBlank" height="6" width="9"></a></th>
-->
<th>
<a class="sortheader" href="#" onclick="ts_resortTable(this); return false;">
Registrant
<img class="sortarrow" height="6" src="arrowBlank" width="9"/>
</a>
</th>
<th>
<a class="sortheader" href="#" id="$project-sortscore" onclick="ts_resortTable(this); return false;" title="Score">
S
<img class="sortarrow" height="6" src="arrowBlank" width="9"/>
</a>
</th>
<th>
<a class="sortheader" href="#" onclick="ts_resortTable(this); return false;" title="Feedback">
F
<img class="sortarrow" height="6" src="arrowBlank" width="9"/>
</a>
</th>
</tr>
</thead>
<tbody>
#for $mp in $mergeprops
<tr>
<td>
<img src="${mp.cause.replace(' ', '').upper()}.png" title="$mp.cause"/>
<span class="sortkey">
$mp.rank
</span>
</td>
<td>
<span class="sortkey">
12
</span>
#filter WebSafe
<a href="$mp.url" title="${mp.subject, also='"'}">
${mp.subject[:60], also='"'}
</a>
#end filter
</td>
<!--
<td>
<span class="sortkey">3176</span>
3176 lines
</td>
<td>
<span class="sortkey">60</span>
60 days
</td>
-->
<td>
$mp.owner_name
</td>
<td>
<a title="$helper.review_score($mp)">
$mp.score
</a>
</td>
<td>
<a title="$helper.review_feedback($mp)">
$helper.display_feedback($mp)
</a>
</td>
</tr>
#end for
</tbody>
</table>
<script type="text/javascript">
ts_resortTable(document.getElementById("$project-sortscore"))
ts_resortTable(document.getElementById("$project-sortscore"))
</script>
#end for
</div>

View File

@ -18,8 +18,6 @@
<!-- Page Specific CSS -->
<link href="http://openstack.org/themes/openstack/css/home.css" media="screen, projection, print" rel="stylesheet" type="text/css"/>
<link href="http://openstack.org/themes/openstack/css/main.css" rel="stylesheet" type="text/css"/>
<link href="combo.css" media="screen,print" rel="stylesheet" type="text/css"/>
<script src="sorting.js" type="text/javascript">
</script>
</head>
<body class="tab-specifications" id="document">
@ -36,120 +34,9 @@
</a>
</p>
</div>
<div class="yui-d0">
#for $project in $helper.sort($projects.keys()):
#set $mergeprops = $projects[$project]
<a name="$project">
</a>
<div class="flowed-block wide">
<h1>
$project branch reviews
</h1>
<ol class="breadcrumbs">
<li>
Page refreshed at $dts UTC
</li>
<li>
$len($mergeprops) active reviews
</li>
</ol>
<br/>
</div>
<table class="listing sortable" summary="$project reviews">
<thead>
<tr>
<th>
<a class="sortheader" href="#" onclick="ts_resortTable(this); return false;">
Type
<img class="sortarrow" height="6" src="arrowBlank" width="9"/>
</a>
</th>
<th>
<a class="sortheader" href="#" onclick="ts_resortTable(this); return false;">
Subject
<img class="sortarrow" height="6" src="arrowBlank" width="9"/>
</a>
</th>
<!--
<th><a href="#" class="sortheader"
onclick="ts_resortTable(this); return false;">Patchsize<img
class="sortarrow" src="arrowBlank" height="6" width="9"></a></th>
<th><a href="#" class="sortheader"
onclick="ts_resortTable(this); return false;">Age<img
class="sortarrow" src="arrowBlank" height="6" width="9"></a></th>
-->
<th>
<a class="sortheader" href="#" onclick="ts_resortTable(this); return false;">
Registrant
<img class="sortarrow" height="6" src="arrowBlank" width="9"/>
</a>
</th>
<th>
<a class="sortheader" href="#" id="$project-sortscore" onclick="ts_resortTable(this); return false;" title="Score">
S
<img class="sortarrow" height="6" src="arrowBlank" width="9"/>
</a>
</th>
<th>
<a class="sortheader" href="#" onclick="ts_resortTable(this); return false;" title="Feedback">
F
<img class="sortarrow" height="6" src="arrowBlank" width="9"/>
</a>
</th>
</tr>
</thead>
<tbody>
#for $mp in $mergeprops
<tr>
<td>
<img src="${mp.cause.replace(' ', '').upper()}.png" title="$mp.cause"/>
<span class="sortkey">
$mp.rank
</span>
</td>
<td>
<span class="sortkey">
12
</span>
#filter WebSafe
<a href="$mp.url" title="${mp.subject, also='"'}">
${mp.subject[:60], also='"'}
</a>
#end filter
</td>
<!--
<td>
<span class="sortkey">3176</span>
3176 lines
</td>
<td>
<span class="sortkey">60</span>
60 days
</td>
-->
<td>
$mp.owner_name
</td>
<td>
<a title="$helper.review_score($mp)">
$mp.score
</a>
</td>
<td>
<a title="$helper.review_feedback($mp)">
$helper.display_feedback($mp)
</a>
</td>
</tr>
#end for
</tbody>
</table>
<script type="text/javascript">
ts_resortTable(document.getElementById("$project-sortscore"))
ts_resortTable(document.getElementById("$project-sortscore"))
</script>
#end for
</div>
$data
<script type="text/javascript">
footer();
</script>

View File

@ -36,14 +36,32 @@ def _create_json(out_dir, name_space={}):
os.rename(f.name, os.path.join(out_dir, 'reviewday.json'))
def create_report(out_dir, name_space={}):
filename = os.path.join(os.path.dirname(__file__), 'report.html')
def _create_data_html(out_dir, name_space={}):
# create the full report
filename = os.path.join(os.path.dirname(__file__), 'data_table.html')
report_text = open(filename).read()
name_space['helper'] = html_helper
t = Template(report_text, searchList=[name_space])
prep_out_dir(out_dir)
data_table_text = str(t)
with open(os.path.join(out_dir, 'data_table.html.tmp'), "w") as f:
f.write(data_table_text)
os.rename(f.name, os.path.join(out_dir, 'data_table.html'))
return data_table_text
def create_report(out_dir, name_space={}):
# create html partial with just the unstyled data
data_table_text = _create_data_html(out_dir, name_space)
# create the full report
report_name_space = {'data': data_table_text, 'helper': html_helper}
filename = os.path.join(os.path.dirname(__file__), 'report.html')
report_text = open(filename).read()
t = Template(report_text, searchList=[report_name_space])
with open(os.path.join(out_dir, 'index.html.tmp'), "w") as f:
f.write(str(t))
os.rename(f.name, os.path.join(out_dir, 'index.html'))