Browse Source

Merge pull request #292 from jd/jd-paginator

paginator: no fail if no meta
main
Lakshmi 9 years ago
parent
commit
bef0f54d6c
3 changed files with 7 additions and 1 deletions
  1. +2
    -1
      hyde/ext/plugins/structure.py
  2. +4
    -0
      hyde/tests/ext/test_paginator.py
  3. +1
    -0
      hyde/tests/sites/test_paginator/content/empty.txt

+ 2
- 1
hyde/ext/plugins/structure.py View File

@@ -336,7 +336,8 @@ class PaginatorPlugin(Plugin):
for node in self.site.content.walk():
added_resources = []
paged_resources = (res for res in node.resources
if hasattr(res.meta, 'paginator'))
if hasattr(res, "meta")
and hasattr(res.meta, 'paginator'))
for resource in paged_resources:
paginator = Paginator(resource.meta.paginator)
added_resources += paginator.walk_paged_resources(


+ 4
- 0
hyde/tests/ext/test_paginator.py View File

@@ -31,6 +31,10 @@ class TestPaginator(object):
def tearDown(self):
TEST_SITE.delete()

def test_page_no_paginator(self):
f = File(self.deploy.child('empty.txt'))
assert f.exists

def test_pages_of_one(self):
pages = ['pages_of_one.txt', 'page2/pages_of_one.txt',
'page3/pages_of_one.txt', 'page4/pages_of_one.txt']


+ 1
- 0
hyde/tests/sites/test_paginator/content/empty.txt View File

@@ -0,0 +1 @@
Foo

Loading…
Cancel
Save