Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getnikola/nikola
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4cbb8510f668
Choose a base ref
...
head repository: getnikola/nikola
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f78a4be769a8
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Dec 5, 2016

  1. Avoiding name clash.

    felixfontein committed Dec 5, 2016
    Copy the full SHA
    4418e54 View commit details
  2. Copy the full SHA
    f78a4be View commit details
19 changes: 2 additions & 17 deletions nikola/data/themes/base-jinja/templates/index.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{# -*- coding: utf-8 -*- #}
{% import 'index_helper.tmpl' as helper with context %}
{% import 'comments_helper.tmpl' as comments with context %}
{% import 'pagination_helper.tmpl' as pagination with context %}
{% extends 'base.tmpl' %}

{% block extra_head %}
@@ -10,29 +11,13 @@
{% endif %}
{% endblock %}

{% block page_navigation %}
<div class="page-navigation">
{% for i, link in enumerate(page_links) %}
{% if abs(i - current_page) <= 3 or i == 0 or i == page_links|length - 1 %}
{% if i == current_page %}
<span class="current-page">{{ i+1 }}</span>
{% else %}
<a href="{{ page_links[i] }}">{{ i+1 }}</a>
{% endif %}
{% elif i == current_page - 4 or i == current_page + 4 %}
<span class="ellipsis">&#x22EF;</span>
{% endif %}
{% endfor %}
</div>
{% endblock %}

{% block content %}
{% block content_header %}{% endblock %}
{% if 'main_index' in pagekind %}
{{ front_index_header }}
{% endif %}
{% if page_links %}
{{ page_navigation() }}
{{ pagination.page_navigation(current_page, page_links, prevlink, nextlink) }}
{% endif %}
<div class="postindex">
{% for post in posts %}
16 changes: 16 additions & 0 deletions nikola/data/themes/base-jinja/templates/pagination_helper.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{# -*- coding: utf-8 -*- #}
{% macro page_navigation(current_page, page_links, prevlink, nextlink) %}
<div class="page-navigation">
{% for i, link in enumerate(page_links) %}
{% if abs(i - current_page) <= 3 or i == 0 or i == page_links|length - 1 %}
{% if i == current_page %}
<span class="current-page">{{ i+1 }}</span>
{% else %}
<a href="{{ page_links[i] }}">{{ i+1 }}</a>
{% endif %}
{% elif i == current_page - 4 or i == current_page + 4 %}
<span class="ellipsis">&#x22EF;</span>
{% endif %}
{% endfor %}
</div>
{% endmacro %}
19 changes: 2 additions & 17 deletions nikola/data/themes/base/templates/index.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## -*- coding: utf-8 -*-
<%namespace name="helper" file="index_helper.tmpl"/>
<%namespace name="comments" file="comments_helper.tmpl"/>
<%namespace name="pagination" file="pagination_helper.tmpl"/>
<%inherit file="base.tmpl"/>

<%block name="extra_head">
@@ -10,29 +11,13 @@
% endif
</%block>

<%block name="page_navigation">
<div class="page-navigation">
% for i, link in enumerate(page_links):
% if abs(i - current_page) <= 3 or i == 0 or i == len(page_links) - 1:
% if i == current_page:
<span class="current-page">${i+1}</span>
% else:
<a href="${page_links[i]}">${i+1}</a>
% endif
% elif i == current_page - 4 or i == current_page + 4:
<span class="ellipsis">&#x22EF;</span>
% endif
% endfor
</div>
</%block>

<%block name="content">
<%block name="content_header"></%block>
% if 'main_index' in pagekind:
${front_index_header}
% endif
% if page_links:
${page_navigation()}
${pagination.page_navigation(current_page, page_links, prevlink, nextlink)}
% endif
<div class="postindex">
% for post in posts:
16 changes: 16 additions & 0 deletions nikola/data/themes/base/templates/pagination_helper.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## -*- coding: utf-8 -*-
<%def name="page_navigation(current_page, page_links, prevlink, nextlink)">
<div class="page-navigation">
% for i, link in enumerate(page_links):
% if abs(i - current_page) <= 3 or i == 0 or i == len(page_links) - 1:
% if i == current_page:
<span class="current-page">${i+1}</span>
% else:
<a href="${page_links[i]}">${i+1}</a>
% endif
% elif i == current_page - 4 or i == current_page + 4:
<span class="ellipsis">&#x22EF;</span>
% endif
% endfor
</div>
</%def>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{# -*- coding: utf-8 -*- #}
{% macro page_navigation(current_page, page_links, prevlink, nextlink) %}
<nav aria-label="Page navigation">
<ul class="pagination">
{% if prevlink %}
<li><a href="{{ prevlink }}" aria-label="{{ messages("Newer posts") }}"><span aria-hidden="true">&laquo;</span></a></li>
{% else %}
<li class="disabled"><a href="#" aria-label="{{ messages("Newer posts") }}"><span aria-hidden="true">&laquo;</span></a></li>
{% endif %}
{% for i, link in enumerate(page_links) %}
<li {{ ' class="active"' if i == current_page else '' }}><a href="{{ link }}">{{ i + 1 }}{{ ' <span class="sr-only">(current)</span>' if i == current_page else '' }}</a></li>
{% endfor %}
{% if nextlink %}
<li><a href="{{ nextlink }}" aria-label="{{ messages("Older posts") }}"><span aria-hidden="true">&raquo;</span></a></li>
{% else %}
<li class="disabled"><a href="#" aria-label="{{ messages("Older posts") }}"><span aria-hidden="true">&raquo;</span></a></li>
{% endif %}
</ul>
</nav>
{% endmacro %}
20 changes: 20 additions & 0 deletions nikola/data/themes/bootstrap3/templates/pagination_helper.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## -*- coding: utf-8 -*-
<%def name="page_navigation(current_page, page_links, prevlink, nextlink)">
<nav aria-label="Page navigation">
<ul class="pagination">
% if prevlink:
<li><a href="${prevlink}" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&laquo;</span></a></li>
% else:
<li class="disabled"><a href="#" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&laquo;</span></a></li>
% endif
% for i, link in enumerate(page_links):
<li ${' class="active"' if i == current_page else ''}><a href="${link}">${i + 1}${' <span class="sr-only">(current)</span>' if i == current_page else ''}</a></li>
% endfor
% if nextlink:
<li><a href="${nextlink}" aria-label="${messages("Older posts")}"><span aria-hidden="true">&raquo;</span></a></li>
% else:
<li class="disabled"><a href="#" aria-label="${messages("Older posts")}"><span aria-hidden="true">&raquo;</span></a></li>
% endif
</ul>
</nav>
</%def>
4 changes: 2 additions & 2 deletions nikola/nikola.py
Original file line number Diff line number Diff line change
@@ -2379,8 +2379,8 @@ def generic_index_renderer(self, lang, posts, indexes_title, template_name, cont
displayed_page_numbers = [utils.get_displayed_page_number(i, num_pages, self) for i in range(max(num_pages, 1))]
page_links = [page_link(i, displayed_page_numbers[i], num_pages, False) for i in range(max(num_pages, 1))]
if kw['show_index_page_navigation']:
map = {page_number - 1: link for page_number, link in zip(displayed_page_numbers, page_links)}
page_links_context = [map[i] for i in range(num_pages)]
temp_map = {page_number - 1: link for page_number, link in zip(displayed_page_numbers, page_links)}
page_links_context = [temp_map[i] for i in range(num_pages)]
for i, post_list in enumerate(lists):
context = context_source.copy()
if 'pagekind' not in context: