Use sortable.js to sort some tables.
This sorts tables on the authors and files pages. Slightly modifies the sortable.js to ignore additional info in parentheses after a number. Signed-off-by: Heikki Hokkanen <hoxu@users.sf.net>master
parent
7b61c4ba5b
commit
072723fb71
22
gitstats
22
gitstats
|
@ -436,10 +436,11 @@ class HTMLReportCreator(ReportCreator):
|
|||
ReportCreator.create(self, data, path)
|
||||
self.title = data.projectname
|
||||
|
||||
# copy the CSS if it does not exist
|
||||
if not os.path.exists(path + '/gitstats.css'):
|
||||
basedir = os.path.dirname(os.path.abspath(__file__))
|
||||
shutil.copyfile(basedir + '/gitstats.css', path + '/gitstats.css')
|
||||
# copy static files if they do not exist
|
||||
for file in ('gitstats.css', 'sortable.js', 'arrow-up.gif', 'arrow-down.gif', 'arrow-none.gif'):
|
||||
if not os.path.exists(path + '/' + file):
|
||||
basedir = os.path.dirname(os.path.abspath(__file__))
|
||||
shutil.copyfile(basedir + '/' + file, path + '/' + file)
|
||||
|
||||
f = open(path + "/index.html", 'w')
|
||||
format = '%Y-%m-%d %H:%m:%S'
|
||||
|
@ -605,8 +606,8 @@ class HTMLReportCreator(ReportCreator):
|
|||
# Authors :: List of authors
|
||||
f.write(html_header(2, 'List of Authors'))
|
||||
|
||||
f.write('<table class="authors">')
|
||||
f.write('<tr><th>Author</th><th>Commits (%)</th><th>First commit</th><th>Last commit</th><th>Age</th><th># by commits</th></tr>')
|
||||
f.write('<table class="authors sortable" id="authors">')
|
||||
f.write('<tr><th>Author</th><th>Commits (%)</th><th>First commit</th><th>Last commit</th><th class="unsortable">Age</th><th># by commits</th></tr>')
|
||||
for author in sorted(data.getAuthors()):
|
||||
info = data.getAuthorInfo(author)
|
||||
f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td></tr>' % (author, info['commits'], info['commits_frac'], info['date_first'], info['date_last'], info['timedelta'], info['place_by_commits']))
|
||||
|
@ -614,8 +615,8 @@ class HTMLReportCreator(ReportCreator):
|
|||
|
||||
# Authors :: Author of Month
|
||||
f.write(html_header(2, 'Author of Month'))
|
||||
f.write('<table>')
|
||||
f.write('<tr><th>Month</th><th>Author</th><th>Commits (%)</th><th>Next top 5</th></tr>')
|
||||
f.write('<table class="sortable" id="aom">')
|
||||
f.write('<tr><th>Month</th><th>Author</th><th>Commits (%)</th><th class="unsortable">Next top 5</th></tr>')
|
||||
for yymm in reversed(sorted(data.author_of_month.keys())):
|
||||
authordict = data.author_of_month[yymm]
|
||||
authors = getkeyssortedbyvalues(authordict)
|
||||
|
@ -627,7 +628,7 @@ class HTMLReportCreator(ReportCreator):
|
|||
f.write('</table>')
|
||||
|
||||
f.write(html_header(2, 'Author of Year'))
|
||||
f.write('<table><tr><th>Year</th><th>Author</th><th>Commits (%)</th><th>Next top 5</th></tr>')
|
||||
f.write('<table class="sortable" id="aoy"><tr><th>Year</th><th>Author</th><th>Commits (%)</th><th class="unsortable">Next top 5</th></tr>')
|
||||
for yy in reversed(sorted(data.author_of_year.keys())):
|
||||
authordict = data.author_of_year[yy]
|
||||
authors = getkeyssortedbyvalues(authordict)
|
||||
|
@ -667,7 +668,7 @@ class HTMLReportCreator(ReportCreator):
|
|||
|
||||
# Files :: Extensions
|
||||
f.write(html_header(2, 'Extensions'))
|
||||
f.write('<table><tr><th>Extension</th><th>Files (%)</th><th>Lines (%)</th><th>Lines/file</th></tr>')
|
||||
f.write('<table class="sortable" id="ext"><tr><th>Extension</th><th>Files (%)</th><th>Lines (%)</th><th>Lines/file</th></tr>')
|
||||
for ext in sorted(data.extensions.keys()):
|
||||
files = data.extensions[ext]['files']
|
||||
lines = data.extensions[ext]['lines']
|
||||
|
@ -850,6 +851,7 @@ plot 'lines_of_code.dat' using 1:2 w lines
|
|||
<title>GitStats - %s</title>
|
||||
<link rel="stylesheet" href="gitstats.css" type="text/css" />
|
||||
<meta name="generator" content="GitStats" />
|
||||
<script type="text/javascript" src="sortable.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
""" % self.title)
|
||||
|
|
10
gitstats.css
10
gitstats.css
|
@ -37,6 +37,10 @@ th {
|
|||
background-color: #ddf;
|
||||
}
|
||||
|
||||
th a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
tr:hover {
|
||||
background-color: #ddf;
|
||||
}
|
||||
|
@ -85,6 +89,12 @@ img {
|
|||
background-color: white;
|
||||
}
|
||||
|
||||
th img {
|
||||
border: 0px;
|
||||
padding: 0px;
|
||||
background-color: #ddf;
|
||||
}
|
||||
|
||||
h1 a, h2 a {
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
|
|
13
sortable.js
13
sortable.js
|
@ -9,10 +9,10 @@ Version 1.5.7
|
|||
*/
|
||||
|
||||
/* You can change these values */
|
||||
var image_path = "http://www.joostdevalk.nl/code/sortable-table/";
|
||||
var image_up = "arrowup.gif";
|
||||
var image_down = "arrowdown.gif";
|
||||
var image_none = "arrownone.gif";
|
||||
var image_path = "";
|
||||
var image_up = "arrow-up.gif";
|
||||
var image_down = "arrow-down.gif";
|
||||
var image_none = "arrow-none.gif";
|
||||
var europeandate = true;
|
||||
var alternate_row_colors = true;
|
||||
|
||||
|
@ -91,7 +91,7 @@ function ts_resortTable(lnk, clid) {
|
|||
// Work out a type for the column
|
||||
if (t.rows.length <= 1) return;
|
||||
var itm = "";
|
||||
var i = 0;
|
||||
var i = 1;
|
||||
while (itm == "" && i < t.tBodies[0].rows.length) {
|
||||
var itm = ts_getInnerText(t.tBodies[0].rows[i].cells[column]);
|
||||
itm = trim(itm);
|
||||
|
@ -105,7 +105,8 @@ function ts_resortTable(lnk, clid) {
|
|||
if (itm.match(/^\d\d[\/\.-][a-zA-z][a-zA-Z][a-zA-Z][\/\.-]\d\d\d\d$/)) sortfn = ts_sort_date;
|
||||
if (itm.match(/^\d\d[\/\.-]\d\d[\/\.-]\d\d\d{2}?$/)) sortfn = ts_sort_date;
|
||||
if (itm.match(/^-?[£$€Û¢´]\d/)) sortfn = ts_sort_numeric;
|
||||
if (itm.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?%?$/)) sortfn = ts_sort_numeric;
|
||||
// ignore stuff in () after the numbers.
|
||||
if (itm.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?%?( \(.*\))?$/)) sortfn = ts_sort_numeric;
|
||||
SORT_COLUMN_INDEX = column;
|
||||
var firstRow = new Array();
|
||||
var newRows = new Array();
|
||||
|
|
Loading…
Reference in New Issue