From debfb97fa73b502fffd5c05c8162b03f946835ed Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Wed, 9 Apr 2014 03:31:42 -0700 Subject: [PATCH] Move display sizing logic out of linklisting template. --- r2/r2/models/listing.py | 7 +++++++ r2/r2/templates/linklisting.html | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/r2/r2/models/listing.py b/r2/r2/models/listing.py index 0ad278288..00795f1c4 100644 --- a/r2/r2/models/listing.py +++ b/r2/r2/models/listing.py @@ -277,6 +277,13 @@ class LinkListing(Listing): self.show_nums = kw.get('show_nums', False) + def listing(self, *args, **kwargs): + wrapped = Listing.listing(self, *args, **kwargs) + self.rank_width = len(str(self.max_num)) * 1.1 + self.midcol_width = max(len(str(self.max_score)), 2) + 1.1 + return wrapped + + class NestedListing(Listing): def __init__(self, *a, **kw): Listing.__init__(self, *a, **kw) diff --git a/r2/r2/templates/linklisting.html b/r2/r2/templates/linklisting.html index 9e87b8621..955ee7f2f 100644 --- a/r2/r2/templates/linklisting.html +++ b/r2/r2/templates/linklisting.html @@ -24,10 +24,10 @@ ## without late rendering or blasting style attributes everywhere <%include file="listing.html"/>