Changeset - b56aa0ea3531
[Not reviewed]
default
0 14 0
Mads Kiilerich - 8 years ago 2017-06-25 18:49:21
mads@kiilerich.com
pagination: avoid superfluous margins - especially when pages are short and pagination isn't shown

Change our webhelpers paginator wrapper to emit full UL (or nothing) instead of
just ILs.

(Browsers still render extra space below the paginator - that is an artifact of
how Bootstrap use inline on the ILs.)
14 files changed with 20 insertions and 42 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/page.py
Show inline comments
 
@@ -14,25 +14,25 @@
 
"""
 
Custom paging classes
 
"""
 

	
 
import math
 
import re
 
from kallithea.config.routing import url
 
from webhelpers.html import literal, HTML
 
from webhelpers.paginate import Page as _Page
 

	
 
class Page(_Page):
 
    """
 
    Custom pager to match rendering style with YUI paginator
 
    Custom pager to match rendering style with YUI paginator emitting Bootstrap paginators
 
    """
 

	
 
    def __init__(self, *args, **kwargs):
 
        kwargs.setdefault('url', url.current)
 
        _Page.__init__(self, *args, **kwargs)
 

	
 
    def _get_pos(self, cur_page, max_page, items):
 
        edge = (items / 2) + 1
 
        if (cur_page <= edge):
 
            radius = max(items / 2, items - cur_page)
 
        elif (max_page - cur_page) < edge:
 
            radius = (items - 1) - (max_page - cur_page)
 
@@ -105,25 +105,25 @@ class Page(_Page):
 
            nav_items.append(HTML.li(text_))
 

	
 
        # Create a link to the very last page (unless we are on the last
 
        # page or there would be no need to insert '..' spacers)
 
        if self.page != self.last_page and rightmost_page < self.last_page:
 
            nav_items.append(HTML.li(self._pagerlink(self.last_page, self.last_page)))
 

	
 
        #_page_link = url.current()
 
        #nav_items.append(literal('<link rel="prerender" href="%s?page=%s">' % (_page_link, str(int(self.page)+1))))
 
        #nav_items.append(literal('<link rel="prefetch" href="%s?page=%s">' % (_page_link, str(int(self.page)+1))))
 
        return self.separator.join(nav_items)
 

	
 
    def pager(self, format='$link_previous ~2~ $link_next', page_param='page', partial_param='partial',
 
    def pager(self, format='<ul class="pagination">$link_previous ~2~ $link_next</ul>', page_param='page', partial_param='partial',
 
        show_if_single_page=False, separator=' ', onclick=None,
 
        symbol_first='<<', symbol_last='>>',
 
        symbol_previous='<', symbol_next='>',
 
        link_attr=None,
 
        curpage_attr=None,
 
        dotdot_attr=None, **kwargs):
 
        self.curpage_attr = curpage_attr or {'class': 'active'}
 
        self.separator = separator
 
        self.pager_kwargs = kwargs
 
        self.page_param = page_param
 
        self.partial_param = partial_param
 
        self.onclick = onclick
kallithea/public/css/style.css
Show inline comments
 
@@ -668,24 +668,28 @@ div.panel.panel-default div.panel-headin
 
}
 

	
 
#content div.panel div.action select {
 
    font-size: 11px;
 
    margin: 0;
 
}
 

	
 
#content div.panel div.action .ui-selectmenu {
 
    margin: 0;
 
    padding: 0;
 
}
 

	
 
#content div.panel ul.pagination {
 
    margin: 10px 0 0 0;
 
}
 

	
 
#content div.panel ul.pagination > li > a,
 
#content div.panel ul.pagination > li > span {
 
    background: #ebebeb url("../images/pager.png") repeat-x;
 
    color: #4A4A4A;
 
    font-weight: 700;
 
    border-top: 1px solid #dedede;
 
    border-left: 1px solid #cfcfcf;
 
    border-bottom: 1px solid #c4c4c4;
 
    border-right: 1px solid #cfcfcf;
 
}
 

	
 

	
kallithea/templates/admin/admin_log.html
Show inline comments
 
@@ -46,18 +46,17 @@
 
        tooltip_activate();
 
      });
 
      e.preventDefault();
 
    });
 
    $user_log.on('click','.show_more',function(e){
 
      var el = e.target;
 
      $('#'+el.id.substring(1)).show();
 
      $(el.parentNode).hide();
 
    });
 
  });
 
</script>
 

	
 
<ul class="pagination">
 
    ${c.users_log.pager()}
 
</ul>
 
${c.users_log.pager()}
 

	
 
%else:
 
    ${_('No actions yet')}
 
%endif
kallithea/templates/admin/gists/index.html
Show inline comments
 
@@ -52,22 +52,19 @@
 
                <span class="text-muted">
 
                  %if gist.gist_expires == -1:
 
                   ${_('Expires')}: ${_('Never')}
 
                  %else:
 
                   ${_('Expires')}: ${h.age(h.time_to_datetime(gist.gist_expires))}
 
                  %endif
 
                </span>
 
            </div>
 

	
 
            <div class="text-muted">${gist.gist_description}</div>
 
          </div>
 
        % endfor
 

	
 
        <ul class="pagination">
 
            ${c.gists_pager.pager(**request.GET.mixed())}
 
        </ul>
 
        ${c.gists_pager.pager(**request.GET.mixed())}
 
      %else:
 
        <div>${_('There are no gists yet')}</div>
 
      %endif
 
    </div>
 
</div>
 
</%def>
kallithea/templates/admin/notifications/notifications_data.html
Show inline comments
 
@@ -7,20 +7,16 @@
 
        ${h.gravatar_div(notification.notification.created_by_user.email, size=24)}
 
        <a href="${url('notification', notification_id=notification.notification.notification_id)}">${notification.notification.description}</a>
 
      </span>
 
      <span class="pull-right">
 
        %if not notification.read:
 
          <span id="${notification.notification.notification_id}" class="btn btn-default btn-xs read-notification"><i class="icon-ok"></i>${_('Mark as read')}</span>
 
        %endif
 
        <span id="${notification.notification.notification_id}" class="btn btn-default btn-xs delete-notification"><i class="icon-minus-circled"></i>${_('Delete')}</span>
 
      </span>
 
  </div>
 
%endfor
 
</div>
 

	
 
<ul class="pagination">
 
    ${c.notifications.pager(controller='admin/notifications', **request.GET.mixed())}
 
</ul>
 

	
 
${c.notifications.pager(controller='admin/notifications', **request.GET.mixed())}
 
%else:
 
    <div>${_('No notifications here yet')}</div>
 
%endif
kallithea/templates/changelog/changelog.html
Show inline comments
 
@@ -166,27 +166,25 @@ ${self.repo_context_bar('changelog', c.f
 
                                </div>
 
                            </div>
 
                        </td>
 
                    </tr>
 
                %endfor
 
                </tbody>
 
                </table>
 

	
 
                <input type="checkbox" id="singlerange" style="display:none"/>
 

	
 
                </div>
 

	
 
                <ul class="pagination">
 
                    ${c.pagination.pager()}
 
                </ul>
 
                ${c.pagination.pager()}
 

	
 
        <script type="text/javascript" src="${h.url('/js/graph.js', ver=c.kallithea_version)}"></script>
 
        <script type="text/javascript">
 
            var jsdata = ${h.js(c.jsdata)};
 
            var graph = new BranchRenderer('graph_canvas', 'graph_content', 'chg_');
 

	
 
            $(document).ready(function(){
 
                var $checkboxes = $('.changeset_range');
 

	
 
                pyroutes.register('changeset_home', ${h.js(h.url('changeset_home', repo_name='%(repo_name)s', revision='%(revision)s'))}, ['repo_name', 'revision']);
 

	
 
                var checkbox_checker = function(e) {
kallithea/templates/changelog/changelog_summary_data.html
Show inline comments
 
@@ -62,27 +62,26 @@
 
            %endfor
 
            %if cs.branch:
 
             <span class="branchtag" title="${_('Branch %s' % cs.branch)}">
 
                 ${h.link_to(cs.branch,h.url('changelog_home',repo_name=c.repo_name,branch=cs.branch))}
 
             </span>
 
            %endif
 
        </td>
 
    </tr>
 
%endfor
 

	
 
</table>
 

	
 
<ul class="pagination">
 
    ${c.repo_changesets.pager()}
 
</ul>
 
${c.repo_changesets.pager()}
 

	
 
%else:
 

	
 
%if h.HasRepoPermissionLevel('write')(c.repo_name):
 
<h4>${_('Add or upload files directly via Kallithea')}</h4>
 
<div>
 
  <div id="add_node_id" class="add_node">
 
      <a class="btn btn-default btn-xs" href="${h.url('files_add_home',repo_name=c.repo_name,revision=0,f_path='', anchor='edit')}">${_('Add New File')}</a>
 
  </div>
 
</div>
 
%endif
 

	
 

	
kallithea/templates/followers/followers_data.html
Show inline comments
 
@@ -3,15 +3,13 @@
 
% for f in c.followers_pager:
 
    <div>
 
        <div class="follower_user">
 
            ${h.gravatar_div(f.user.email, size=24)}
 
            <span> <b>${f.user.username}</b> (${f.user.name} ${f.user.lastname})</span>
 
        </div>
 
        <div class="follower_date">${_('Started following -')}
 
          <span data-toggle="tooltip" title="${f.follows_from}"> ${h.age(f.follows_from)}</span>
 
        </div>
 
    </div>
 
% endfor
 

	
 
<ul class="pagination">
 
    ${c.followers_pager.pager()}
 
</ul>
 
${c.followers_pager.pager()}
kallithea/templates/forks/forks_data.html
Show inline comments
 
@@ -10,18 +10,16 @@
 
                  ${h.link_to(f.repo_name,h.url('summary_home',repo_name=f.repo_name))}
 
                </span>
 
                <div>${f.description}</div>
 
            </div>
 
            <div class="follower_date">${_('Forked')} -
 
                <span data-toggle="tooltip" title="${h.fmt_date(f.created_on)}"> ${h.age(f.created_on)}</span>
 
                <a title="${_('Compare fork with %s') % c.repo_name}"
 
                   href="${h.url('compare_url',repo_name=c.repo_name, org_ref_type=c.db_repo.landing_rev[0],org_ref_name=c.db_repo.landing_rev[1],other_repo=f.repo_name,other_ref_type=c.db_repo.landing_rev[0],other_ref_name=c.db_repo.landing_rev[1], merge=1)}"
 
                   class="btn btn-default btn-sm"><i class="icon-git-compare"></i> ${_('Compare Fork')}</a>
 
            </div>
 
        </div>
 
    % endfor
 
    <ul class="pagination">
 
        ${c.forks_pager.pager()}
 
    </ul>
 
    ${c.forks_pager.pager()}
 
% else:
 
    ${_('There are no forks yet')}
 
% endif
kallithea/templates/journal/journal_data.html
Show inline comments
 
@@ -27,21 +27,18 @@
 
                            ${entry.repository_name}
 
                          %endif
 
                          </span>
 
                      </div>
 
                      <div class="journal_action_params">${h.literal(h.action_parser(entry)[1]())}</div>
 
                      <div class="date"><span data-toggle="tooltip" title="${h.fmt_date(entry.action_date)}">${h.age(entry.action_date)}</span></div>
 
                    </div>
 
                  </div>
 
                %endfor
 
            </div>
 
        %endfor
 
    %endfor
 

	
 
    <ul class="pagination">
 
        ${c.journal_pager.pager()}
 
    </ul>
 
    ${c.journal_pager.pager()}
 
%else:
 
  <div>
 
      ${_('No entries yet')}
 
  </div>
 
%endif
kallithea/templates/pullrequests/pullrequest_data.html
Show inline comments
 
@@ -71,18 +71,16 @@
 
                      ">
 
            <i class="icon-minus-circled"></i>
 
          </div>
 
          ${h.end_form()}
 
        %endif
 
      </td>
 
    </tr>
 
% endfor
 
  </table>
 
</div>
 

	
 
%if hasattr(pullrequests, 'pager'):
 
    <ul class="pagination">
 
        ${pullrequests.pager(**request.GET.mixed())}
 
    </ul>
 
    ${pullrequests.pager(**request.GET.mixed())}
 
%endif
 

	
 
</%def>
kallithea/templates/search/search_commit.html
Show inline comments
 
@@ -23,16 +23,14 @@
 
                %endif
 
            </div>
 
        </div>
 
    %else:
 
        %if cnt == 0:
 
            <div class="alert alert-warning" role="alert">
 
                ${_('Permission denied')}
 
            </div>
 
        %endif
 
    %endif
 
%endfor
 
%if c.cur_query and c.formated_results:
 
    <ul class="pagination">
 
        ${c.formated_results.pager()}
 
    </ul>
 
    ${c.formated_results.pager()}
 
%endif
kallithea/templates/search/search_content.html
Show inline comments
 
@@ -11,16 +11,14 @@
 
                <pre>${h.literal(sr['content_short_hl'])}</pre>
 
            </div>
 
        </div>
 
    %else:
 
        %if cnt == 0:
 
            <div class="alert alert-warning" role="alert">
 
                ${_('Permission denied')}
 
            </div>
 
        %endif
 
    %endif
 
%endfor
 
%if c.cur_query and c.formated_results:
 
    <ul class="pagination">
 
        ${c.formated_results.pager()}
 
    </ul>
 
    ${c.formated_results.pager()}
 
%endif
kallithea/templates/search/search_path.html
Show inline comments
 
@@ -8,16 +8,14 @@
 
                    h.url('files_home',repo_name=sr['repository'],revision='tip',f_path=sr['f_path']))}
 
            </div>
 
        </div>
 
    %else:
 
        %if cnt == 0:
 
            <div class="alert alert-warning" role="alert">
 
                ${_('Permission denied')}
 
            </div>
 
        %endif
 
    %endif
 
%endfor
 
%if c.cur_query and c.formated_results:
 
    <ul class="pagination">
 
        ${c.formated_results.pager()}
 
    </ul>
 
    ${c.formated_results.pager()}
 
%endif
0 comments (0 inline, 0 general)