All Projects → FunkyStudioHQ → phoenix_pagination

FunkyStudioHQ / phoenix_pagination

Licence: MIT license
Simple pagination for Ecto and Phoenix that uses plain EEx templates.

Programming Languages

elixir
2628 projects
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to phoenix pagination

Filterable
Filtering from incoming params in Elixir/Ecto/Phoenix with easy to use DSL.
Stars: ✭ 83 (+315%)
Mutual labels:  pagination, phoenix, ecto
Polymorphic embed
Polymorphic embeds in Ecto
Stars: ✭ 80 (+300%)
Mutual labels:  phoenix, ecto
Ecto morph
morph your Ecto capabilities into the s t r a t o s p h e r e !
Stars: ✭ 72 (+260%)
Mutual labels:  phoenix, ecto
Phoenix Ecto Encryption Example
🔐 A detailed example for how to encrypt data in a Phoenix (Elixir) App before inserting into a database using Ecto Types
Stars: ✭ 166 (+730%)
Mutual labels:  phoenix, ecto
algoliax
Algolia integration to elixir application
Stars: ✭ 38 (+90%)
Mutual labels:  phoenix, ecto
Query
Query adds tools to aid the use of Ecto in web settings.
Stars: ✭ 23 (+15%)
Mutual labels:  phoenix, ecto
Mipha
Proj Elixir Forum build with phoenix 1.5.
Stars: ✭ 153 (+665%)
Mutual labels:  phoenix, ecto
one plus n detector
Elixir library to help you detect 1+n queries in applications using Ecto
Stars: ✭ 20 (+0%)
Mutual labels:  phoenix, ecto
Params
Easy parameters validation/casting with Ecto.Schema, akin to Rails' strong parameters.
Stars: ✭ 239 (+1095%)
Mutual labels:  phoenix, ecto
flop
Filtering, ordering and pagination for Ecto
Stars: ✭ 56 (+180%)
Mutual labels:  pagination, ecto
Kaffy
Powerfully simple admin package for phoenix applications
Stars: ✭ 617 (+2985%)
Mutual labels:  phoenix, ecto
Rummage ecto
Search, Sort and Pagination for ecto queries
Stars: ✭ 190 (+850%)
Mutual labels:  pagination, ecto
Paper trail
Track and record all the changes in your database with Ecto. Revert back to anytime in history.
Stars: ✭ 380 (+1800%)
Mutual labels:  phoenix, ecto
Wallaby
Concurrent browser tests with elixir
Stars: ✭ 1,143 (+5615%)
Mutual labels:  phoenix, ecto
Machinery
State machine thin layer for structs (+ GUI for Phoenix apps)
Stars: ✭ 367 (+1735%)
Mutual labels:  phoenix, ecto
Phoenix live dashboard
Realtime dashboard with metrics, request logging, plus storage, OS and VM insights
Stars: ✭ 1,657 (+8185%)
Mutual labels:  phoenix, ecto
pretty print formatter
Pretty Print Formatter for Elixir Logger module -- Colorize Ecto's SQL ouput 🖌️
Stars: ✭ 22 (+10%)
Mutual labels:  phoenix, ecto
ecto generator
Generate Ecto schemas from existing database in Phoenix - Elixir
Stars: ✭ 20 (+0%)
Mutual labels:  phoenix, ecto
Formex
A better form library for Phoenix
Stars: ✭ 206 (+930%)
Mutual labels:  phoenix, ecto
Rummage phoenix
Full Phoenix Support for Rummage. It can be used for searching, sorting and paginating collections in phoenix.
Stars: ✭ 144 (+620%)
Mutual labels:  pagination, phoenix

Phoenix.Pagination

Simple pagination for Ecto and Phoenix using plaing EEx templates. It is based on a fork of Kerosene, we think that pagination markup should be handled in templates, rather than with helper functions. So, here it comes.

Installation

If available in Hex, can be installed as:

Add phoenix_pagination to your list of dependencies in mix.exs:

def deps do
  [{:phoenix_pagination, "~> 0.6.0"}]
end

Add Phoenix.Pagination to your repo.ex:

defmodule MyApp.Repo do
  use Ecto.Repo, otp_app: :testapp
  use Phoenix.Pagination, per_page: 15
end

Usage

Start paginating your queries

def index(conn, params) do
  {products, pagination} =  Product
  |> Product.with_lowest_price
  |> Repo.paginate(params)

  render(conn, "index.html", products: products, pagination: pagination)
end

Add view helpers to your view

defmodule MyAppWeb.ProductView do
  use MyAppWeb, :view
  import Phoenix.Pagination.HTML
end

Create your pagination template in lib/my_app_web/templates/pagination/pagination.html.eex

<%= pagination @conn, @pagination, [current_class: "is-current"], fn p -> %>
  <nav class="pagination" role="navigation" aria-label="pagination">
    <ul class="pagination-list">
      <li><%= pagination_link p, :first, label: gettext("First"), class: "pagination-link", force_show: true %></li>
      <%= for {pagenum, _, active} <- p.page_items do  %>
        <li><%= pagination_link p, pagenum, class: "pagination-link", current: active %></li>
      <% end %>
      <li><%= pagination_link p, :last, label: gettext("Last"), class: "pagination-link", force_show: true %></li>
    </ul>
  </nav>
<% end %>

You can have as many pagination templates as you want (even with custom filenames), and render it where you need:

<%= render MyAppWeb.PaginationView, "pagination.html", conn: @conn, pagination: @pagination %>

Building APIs or SPAs? no problem Phoenix.Pagination has support for Json.

defmodule MyAppWeb.ProductView do
  use MyAppWeb, :view
  import Phoenix.Pagination.JSON

  def render("index.json", %{products: products, pagination: pagination, conn: conn}) do
    %{data: render_many(products, MyAppWeb.ProductView, "product.json"),
      pagination: paginate(conn, pagination)}
  end

  def render("product.json", %{product: product}) do
    %{id: product.id,
      name: product.name,
      description: product.description,
      price: product.price}
  end
end

You can also send in options to paginate helper look at the docs for more details.

Contributing

Please do send pull requests and bug reports, positive feedback is always welcome.

We would like to thank

License

Please take a look at LICENSE.md

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].