From 22bc56ddf165a3a696895c3bfe328ca1cc837dd3 Mon Sep 17 00:00:00 2001 From: Elana Hashman Date: Sat, 20 Jun 2015 20:47:37 -0600 Subject: [PATCH] Fixes #1068, #1572: template page navigation bugs Updates the template logic for when page navigation is included in the generated HTML in the notmyidea theme, fixing: * Issue #1068: useless pagination controls should not be displayed when a single page is generated (i.e. "Page 1/1"). New logic prevents the generation of these superfluous page navigation controls. Tests updated accordingly. * Issue #1572: when multiple pages are generated and the last page contains only one item, the closing and tags are not generated, resulting in page breakage. We need to check if articles_page.has_other_pages(); if it does, a list has been generated per line 19 or 25 and the tags must be closed. --- pelican/tests/output/custom/category/bar.html | 3 --- pelican/tests/output/custom/category/cat1.html | 3 --- pelican/tests/output/custom/category/misc.html | 3 --- pelican/tests/output/custom/category/yeah.html | 3 --- pelican/tests/output/custom/tag/bar.html | 3 --- pelican/tests/output/custom/tag/foo.html | 3 --- pelican/tests/output/custom/tag/foobar.html | 3 --- pelican/tests/output/custom/tag/yeah.html | 3 --- .../tests/output/custom_locale/category/bar.html | 3 --- .../tests/output/custom_locale/category/cat1.html | 3 --- .../tests/output/custom_locale/category/misc.html | 3 --- .../tests/output/custom_locale/category/yeah.html | 3 --- pelican/tests/output/custom_locale/tag/bar.html | 3 --- pelican/tests/output/custom_locale/tag/foo.html | 3 --- pelican/tests/output/custom_locale/tag/foobar.html | 3 --- pelican/tests/output/custom_locale/tag/yeah.html | 3 --- pelican/themes/notmyidea/templates/index.html | 13 ++++--------- 17 files changed, 4 insertions(+), 57 deletions(-) diff --git a/pelican/tests/output/custom/category/bar.html b/pelican/tests/output/custom/category/bar.html index 0bc5b02e..9666d2e2 100644 --- a/pelican/tests/output/custom/category/bar.html +++ b/pelican/tests/output/custom/category/bar.html @@ -51,9 +51,6 @@ YEAH !

alternate text

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom/category/cat1.html b/pelican/tests/output/custom/category/cat1.html index 237943d7..d9132d10 100644 --- a/pelican/tests/output/custom/category/cat1.html +++ b/pelican/tests/output/custom/category/cat1.html @@ -120,9 +120,6 @@

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom/category/misc.html b/pelican/tests/output/custom/category/misc.html index 5fcde24b..fa71085d 100644 --- a/pelican/tests/output/custom/category/misc.html +++ b/pelican/tests/output/custom/category/misc.html @@ -131,9 +131,6 @@ pelican.conf, it ...

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom/category/yeah.html b/pelican/tests/output/custom/category/yeah.html index 127eac13..6d94c9ad 100644 --- a/pelican/tests/output/custom/category/yeah.html +++ b/pelican/tests/output/custom/category/yeah.html @@ -59,9 +59,6 @@

→ And now try with some utf8 hell: ééé

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom/tag/bar.html b/pelican/tests/output/custom/tag/bar.html index 2e0d047c..f462ffbd 100644 --- a/pelican/tests/output/custom/tag/bar.html +++ b/pelican/tests/output/custom/tag/bar.html @@ -110,9 +110,6 @@ YEAH !

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom/tag/foo.html b/pelican/tests/output/custom/tag/foo.html index 7c38c24c..9c58956b 100644 --- a/pelican/tests/output/custom/tag/foo.html +++ b/pelican/tests/output/custom/tag/foo.html @@ -80,9 +80,6 @@ as well as inline markup.

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom/tag/foobar.html b/pelican/tests/output/custom/tag/foobar.html index 42705281..7d17d1fb 100644 --- a/pelican/tests/output/custom/tag/foobar.html +++ b/pelican/tests/output/custom/tag/foobar.html @@ -59,9 +59,6 @@

→ And now try with some utf8 hell: ééé

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom/tag/yeah.html b/pelican/tests/output/custom/tag/yeah.html index 4d7b506b..e3c765fa 100644 --- a/pelican/tests/output/custom/tag/yeah.html +++ b/pelican/tests/output/custom/tag/yeah.html @@ -51,9 +51,6 @@ YEAH !

alternate text

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom_locale/category/bar.html b/pelican/tests/output/custom_locale/category/bar.html index 7c8f947d..c416b358 100644 --- a/pelican/tests/output/custom_locale/category/bar.html +++ b/pelican/tests/output/custom_locale/category/bar.html @@ -51,9 +51,6 @@ YEAH !

alternate text

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom_locale/category/cat1.html b/pelican/tests/output/custom_locale/category/cat1.html index 25bc6179..871b2e3f 100644 --- a/pelican/tests/output/custom_locale/category/cat1.html +++ b/pelican/tests/output/custom_locale/category/cat1.html @@ -120,9 +120,6 @@

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom_locale/category/misc.html b/pelican/tests/output/custom_locale/category/misc.html index 8062c0d6..bb78a8cc 100644 --- a/pelican/tests/output/custom_locale/category/misc.html +++ b/pelican/tests/output/custom_locale/category/misc.html @@ -131,9 +131,6 @@ pelican.conf, it ...

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom_locale/category/yeah.html b/pelican/tests/output/custom_locale/category/yeah.html index d36c1608..c5e6c7f0 100644 --- a/pelican/tests/output/custom_locale/category/yeah.html +++ b/pelican/tests/output/custom_locale/category/yeah.html @@ -59,9 +59,6 @@

→ And now try with some utf8 hell: ééé

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom_locale/tag/bar.html b/pelican/tests/output/custom_locale/tag/bar.html index 8ba1aed2..c1f33e64 100644 --- a/pelican/tests/output/custom_locale/tag/bar.html +++ b/pelican/tests/output/custom_locale/tag/bar.html @@ -110,9 +110,6 @@ YEAH !

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom_locale/tag/foo.html b/pelican/tests/output/custom_locale/tag/foo.html index ed67ede0..288f1768 100644 --- a/pelican/tests/output/custom_locale/tag/foo.html +++ b/pelican/tests/output/custom_locale/tag/foo.html @@ -80,9 +80,6 @@ as well as inline markup.

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom_locale/tag/foobar.html b/pelican/tests/output/custom_locale/tag/foobar.html index a569b526..59dcede1 100644 --- a/pelican/tests/output/custom_locale/tag/foobar.html +++ b/pelican/tests/output/custom_locale/tag/foobar.html @@ -59,9 +59,6 @@

→ And now try with some utf8 hell: ééé

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/tests/output/custom_locale/tag/yeah.html b/pelican/tests/output/custom_locale/tag/yeah.html index ba767748..4dc36ce5 100644 --- a/pelican/tests/output/custom_locale/tag/yeah.html +++ b/pelican/tests/output/custom_locale/tag/yeah.html @@ -51,9 +51,6 @@ YEAH !

alternate text

There are comments.

-

- Page 1 / 1 -

diff --git a/pelican/themes/notmyidea/templates/index.html b/pelican/themes/notmyidea/templates/index.html index 3eac8a3a..6019987b 100644 --- a/pelican/themes/notmyidea/templates/index.html +++ b/pelican/themes/notmyidea/templates/index.html @@ -11,9 +11,6 @@

{{ article.title }}

{% include 'article_infos.html' %}{{ article.content }}{% include 'comments.html' %} - {% if loop.length == 1 %} - {% include 'pagination.html' %} - {% endif %} {% if loop.length > 1 %}
@@ -42,13 +39,11 @@ {% endif %} {% if loop.last %} - {% if loop.length > 1 %} + {% if loop.length > 1 or articles_page.has_other_pages() %} - {% endif %} - {% if articles_page.has_previous() or loop.length > 1 %} - {% include 'pagination.html' %} - {% endif %} - {% if loop.length > 1 %} + {% if articles_page.has_other_pages() %} + {% include 'pagination.html' %} + {% endif %}
{% endif %} {% endif %}