Move display sizing logic out of linklisting template.

This commit is contained in:
Max Goodman
2014-04-09 03:31:42 -07:00
parent 8c85eb1fd3
commit debfb97fa7
2 changed files with 9 additions and 2 deletions

View File

@@ -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)

View File

@@ -24,10 +24,10 @@
## without late rendering or blasting style attributes everywhere
<style>
body > .content .link .rank {
width: ${len(str(thing.max_num)) * 1.1}ex
width: ${thing.rank_width}ex
}
body > .content .link .midcol {
width: ${max(len(str(thing.max_score)), 2) + 1.1}ex
width: ${thing.midcol_width}ex
}
</style>
<%include file="listing.html"/>