1. Oben Sonne
  2. poole
  3. Issues


Issue #3 resolved


Anonymous created an issue

Does Poole handle Paging ? I mean, if I have more than 10 blog posts, I would like to see link in the bottom of the page to let me navigate to the desired page..

Is there any options to activate, or direction on how to add this feature...


Comments (7)

  1. Oben Sonne repo owner

    If I get you right, you want to create virtual/new pages during the build, depending on the number of blog posts, right? This is currently not possible. A solution independent of Poole would be to add some JavaScript to the page listing the posts, which dynamically hides/shows only a subset of all posts.

    Of course Poole could be extended to create new pages in the build process, but I'm not sure if this matches Poole's focus on simple sites. However, if you have an idea how to implement this feature in an unobtrusive manner, feel free to start working on it :)

  2. Tom Novelli

    New/virtual pages would be nice, but I think anon just wants "Next post" and "Previous post" links on each blog post. Here's a quick implementation:

    1. Add this to macros.py

    from datetime import datetime
    posts = None
    def blogpost():
        # Previous/Next Post links
        global posts
        if posts is None:
            # Get all blog posts and sort by date
            posts = [p for p in pages if "post" in p]
            posts.sort(key=lambda p: p.get("date"), reverse=True)
        n = posts.index(page)
        if n < len(posts)-1:
            p = posts[n+1]
            print "**[Previous post](%s)** - " % p.url
            #print "Previous: **[%s](%s)** (%s)" % (p.title, p.url, p.date)
        if n > 0:
            p = posts[n-1]
            print "**[Next post](%s)**" % p.url
            #print "Next: **[%s](%s)** (%s)" % (p.title, p.url, p.date)
        # Heading for post
        print "## %s" % page.title
        print "*Posted on %s*" % datetime.strptime(page["date"], "%Y-%m-%d").strftime("%B %d, %Y")

    2. Put this at the top of each blog post (this replaces the boilerplate embedded code from the examples)

    {% blogpost() %}

    Poole's blog feature could use a little work... so far it looks like it'll work for me, without any major changes to Poole itself. This is a sweet little 400-LoC script!

  3. Oben Sonne repo owner


    Yes, the built-in blog features are rather basic, actually more a proof of concept. I decided to not implement more sophisticated blog features as Poole targets simple sites in general, which often don't need blog features. Furthermore, I guess almost everyone using Poole for a blog has individual ideas how the blog should look/work. That's why there is a macros.py, which allows to add all the stuff not built-in -- exactly what you did ;)

  4. Anonymous

    sorry for the delay.

    No, what I want, is a virtual page as obensonne said in his post.

    Imagine you got 20 post, and you want to display 5 posts per page, how should you handle this situation ?


  5. Log in to comment