summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--devel/views.py9
-rw-r--r--media/archweb.js27
-rw-r--r--templates/devel/packages.html1
3 files changed, 36 insertions, 1 deletions
diff --git a/devel/views.py b/devel/views.py
index 6907de2..9c523f0 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -10,6 +10,7 @@ from django.db.models import Q
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.template import loader, Context
+from django.template.defaultfilters import filesizeformat
from django.views.decorators.cache import never_cache
from django.views.generic.simple import direct_to_template
@@ -140,7 +141,13 @@ def report(request, report):
cutoff = 50 * 1024 * 1024
packages = packages.filter(compressed_size__gte=cutoff).order_by('-compressed_size')
names = [ 'Compressed Size', 'Installed Size' ]
- attrs = [ 'compressed_size', 'installed_size' ]
+ attrs = [ 'compressed_size_pretty', 'installed_size_pretty' ]
+ # Format the compressed and installed sizes with MB/GB/etc suffixes
+ for package in packages:
+ package.compressed_size_pretty = filesizeformat(
+ package.compressed_size)
+ package.installed_size_pretty = filesizeformat(
+ package.installed_size)
elif report == 'uncompressed-man':
title = 'Packages with uncompressed manpages'
# magic going on here! Checking for all '.1'...'.9' extensions
diff --git a/media/archweb.js b/media/archweb.js
index 03358fa..78b1567 100644
--- a/media/archweb.js
+++ b/media/archweb.js
@@ -67,6 +67,33 @@ if (typeof $.tablesorter !== 'undefined') {
},
type: 'numeric'
});
+ $.tablesorter.addParser({
+ id: 'filesize',
+ re: /^(\d+(?:\.\d+)?) (bytes?|KB|MB|GB|TB)$/,
+ is: function(s) {
+ return this.re.test(s);
+ },
+ format: function(s) {
+ var matches = this.re.exec(s);
+ var size = parseFloat(matches[1]);
+ var suffix = matches[2];
+
+ switch(suffix) {
+ case 'byte':
+ case 'bytes':
+ return size;
+ case 'KB':
+ return size * 1024;
+ case 'MB':
+ return size * 1024 * 1024;
+ case 'GB':
+ return size * 1024 * 1024 * 1024;
+ case 'TB':
+ return size * 1024 * 1024 * 1024 * 1024;
+ }
+ },
+ type: 'numeric'
+ });
}
/* news/add.html */
diff --git a/templates/devel/packages.html b/templates/devel/packages.html
index 32cdf21..e0988c0 100644
--- a/templates/devel/packages.html
+++ b/templates/devel/packages.html
@@ -49,6 +49,7 @@
</div>
{% load cdn %}{% jquery %}
<script type="text/javascript" src="/media/jquery.tablesorter.min.js"></script>
+<script type="text/javascript" src="/media/archweb.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".results").tablesorter({widgets: ['zebra']});