Skip to content

Commit

Permalink
[2375] Update the pagination in helpers.py
Browse files Browse the repository at this point in the history
No longer wrapping the ".." link in a span to output valid HTML. Also
added the "pagination-centered" class.
  • Loading branch information
aron committed May 14, 2012
1 parent b805fa2 commit f588587
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ckan/lib/helpers.py
Expand Up @@ -541,8 +541,8 @@ class Page(paginate.Page):
# our custom layout set as default.
def pager(self, *args, **kwargs):
kwargs.update(
format=u"<div class='pagination'><ul>$link_previous ~2~ $link_next</ul></div>",
symbol_previous=u'« Prev', symbol_next=u'Next »',
format=u"<div class='pagination pagination-centered'><ul>$link_previous ~2~ $link_next</ul></div>",
symbol_previous=u'«', symbol_next=u'»',
curpage_attr={'class':'active'}, link_attr={}
)
return super(Page, self).pager(*args, **kwargs)
Expand All @@ -559,9 +559,10 @@ def _pagerlink(self, page, text, extra_attributes=None):
def _range(self, regexp_match):
html = super(Page, self)._range(regexp_match)
# Convert ..
dotdot = '\.\.'
dotdot = '<span class="pager_dotdot">..</span>'
dotdot_link = HTML.li(HTML.a('...', href='#'), class_='disabled')
html = re.sub(dotdot, dotdot_link, html)

# Convert current page
text = '%s' % self.page
current_page_span = str(HTML.span(c=text, **self.curpage_attr))
Expand Down

2 comments on commit f588587

@tobes
Copy link
Contributor

@tobes tobes commented on f588587 May 15, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aron

is there something we can do here that doesn't touch helpers.py? this is common code for all ckan users so I'm keen to remove any specifics from it as this leads to 'fights'. I'd be nice if we could add stuff via parameters or templates to avoid these problems.

cheers

@aron
Copy link
Contributor Author

@aron aron commented on f588587 May 15, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobes absolutely, if we could split it out into a snippet that would be amazing. Not 100% sure how to go about this.

The change on line 562 actually fixes a bug that was causing a <li> element to be inserted inside a <span>. So that can stay.

Also you can comment directly on lines of code in these GitHub pages by clicking the little comment button that appears when you hover over a line. This makes it easier to see what you're talking about.

Please sign in to comment.