halostatue

halostatue

TableauPaginationExtension - Paginated Indexes for Tableau

Over the last several months, I’ve been using Tableau to rebuild my long-neglected website. Tableau is part of the Elixir Tools project headed by @mhanberg, and is built on top of MDEx by @leandrocp. This library is one of ten libraries and Elixir extensions that I built. Most of these were built with the assistance of Kiro.

TableauPaginationExtension is an extension for Tableau that helps with the creation of paginated indexes for collections of posts, tags, or other data.

A configuration like

config :tableau, TableauPaginationExtension,
  enabled: true,
  collections: [
    posts: [
      permalink: "/posts/:page?",
      layout: MySite.RootLayout,
      template: MySite.PostsPage,
      per_page: 5
    ]
  ]

will generate paginated posts like this:

/posts      → Page 1 (5 posts)
/posts/2    → Page 2 (5 posts)
/posts/3    → Page 3 (5 posts)

Map-like collections (such as tags) can be paginated both on keys (tag names) and on key/value pairs (paginated pages within a tag).

Simple Lists

Paginate simple lists like posts or pages:

posts: [
  permalink: "/posts/:page?",
  layout: MySite.RootLayout,
  template: MySite.PostsPage,
  per_page: 10
]

Tag Index

Paginate list of all tags (map keys):

tag_index: [
  key_path: [:tags],
  permalink: "/tags/:page?",
  layout: MySite.RootLayout,
  template: MySite.TagIndexPage,
  per_page: 50
]

Tag Pages

Paginate posts within each tag (values):

tag_pages: [
  key_path: [:tags],
  permalink: "/tags/:tag/:page?",
  layout: MySite.RootLayout,
  template: MySite.TagPage,
  per_page: 20
]

Permalink Patterns

Collection permalink strings have to end with /:page or /:page?, where /:page? omits the first page number, so that /prefix/:page? becomes /prefix, /prefix/2, etc. instead of /prefix/1, /prefix/2, etc.

Template Variables

When rendering the index page templates, the following are made available as assigns:

  • @posts: Items for current page
  • @page_number: Current page (1-indexed)
  • @total_pages: Total number of pages
  • @prev_page_url / @next_page_url: Navigation URLs
  • @first_page_url / @last_page_url: Jump to endpoints

https://github.com/halostatue/tableau_pagination_extension

Where Next?

Popular in Announcing Top

mtrudel
Bandit is an HTTP server for Plug and WebSock apps. Bandit is written entirely in Elixir and is built atop Thousand Island. It can serve...
New
bryanjos
Hi, I just published version 0.23.0 of Elixirscript. https://github.com/bryanjos/elixirscript/blob/master/CHANGELOG.md Most of the chan...
New
nikokozak
Hello all, I’ve been working on Svonix - a library for quickly integrating Svelte components into Phoenix views. It’s a much-needed succ...
New
kip
Image is an image processing library for Elixir. It is based upon the fabulous vix library that provides a libvips wrapper for Elixir. I...
622 18934 194
New
cjen07
parameterized pipe in elixir: |n> edit: negative index in |n> and mixed usage with |> are supported example: use ParamPipe ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
josevalim
Hello everyone, We have just released NimbleCSV which is a small and fast CSV parsing library for Elixir. It allows developers to define...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
198 10954 107
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement