Issue #3 resolved

Paging

Anonymous avatarAnonymous 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...

Thanks

Comments (7)

  1. Oben Sonne

    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)
        print
        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

    Tom

    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 ?

    Thnaks

  5. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.