Commit 75507403 authored by Vincent Pelletier's avatar Vincent Pelletier

Provide W3C names for status codes.

parent 15e1a7f2
...@@ -34,6 +34,7 @@ from operator import itemgetter ...@@ -34,6 +34,7 @@ from operator import itemgetter
from urllib import splittype, splithost from urllib import splittype, splithost
import argparse import argparse
import gzip import gzip
import httplib
import itertools import itertools
import json import json
import math import math
...@@ -312,11 +313,18 @@ class GenericSiteStats(object): ...@@ -312,11 +313,18 @@ class GenericSiteStats(object):
append('</tr>') append('</tr>')
def hitTd(hit, status): def hitTd(hit, status):
return '<td class="%s">%s</td>' % (getClassForStatusHit(hit, status), hit) return '<td class="%s">%s</td>' % (getClassForStatusHit(hit, status), hit)
def statusAsHtml(status):
try:
definition = httplib.responses[int(status)]
except KeyError:
return status
else:
return '<abbr title="%s">%s</abbr>' % (definition, status)
has_errors = False has_errors = False
for status, data_dict in sorted(filtered_status.iteritems(), for status, data_dict in sorted(filtered_status.iteritems(),
key=ITEMGETTER0): key=ITEMGETTER0):
has_errors |= statusIsError(status) has_errors |= statusIsError(status)
append('<tr><th>%s</th>' % status) append('<tr><th>%s</th>' % statusAsHtml(status))
append(hitTd(sum(data_dict.itervalues()), status)) append(hitTd(sum(data_dict.itervalues()), status))
for date in column_list: for date in column_list:
append(hitTd(data_dict[date], status)) append(hitTd(data_dict[date], status))
...@@ -334,7 +342,8 @@ class GenericSiteStats(object): ...@@ -334,7 +342,8 @@ class GenericSiteStats(object):
'<th>hits</th><th>url</th><th>referers</th></tr>') '<th>hits</th><th>url</th><th>referers</th></tr>')
for status, url_list in sorted(filtered_status_url.iteritems(), for status, url_list in sorted(filtered_status_url.iteritems(),
key=ITEMGETTER0): key=ITEMGETTER0):
append('<tr><th rowspan="%s">%s</th>' % (len(url_list), status)) append('<tr><th rowspan="%s">%s</th>' % (len(url_list),
statusAsHtml(status)))
first_url = True first_url = True
for url, referer_counter in url_list: for url, referer_counter in url_list:
if first_url: if first_url:
......
...@@ -116,3 +116,8 @@ h2 { ...@@ -116,3 +116,8 @@ h2 {
.tooltip .x br { .tooltip .x br {
display: none; display: none;
} }
abbr {
border-bottom: 1px dotted #000;
cursor: help;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment