<div class="grid"> <div class="column"> <h1> <%= humanize(@post_type) %>s </h1> </div> <div class="column admin-actions"> <%= link "New " <> humanize(@post_type), to: Routes.posts_path(@conn, :new, post_type: @post_type), class: "button" %> </div> </div> <table class="admin-table small"> <thead> <tr> <th>Title</th> <th>Author</th> <th>Categories</th> <th>Tags</th> <th>Comments</th> <th>Date</th> </tr> </thead> <tbody> <%= for post <- @posts do %> <tr> <td> <%= link post.post_title, to: Routes.posts_path(@conn, :edit, post) %> </td> <td> <%= if !is_nil(post.author) do %> <%= post.author.display_name %> <% end %> </td> <td> <%= post.categories |> Enum.map(&(&1.name)) |> Enum.join(", ") %> </td> <td> <%= post.tags |> Enum.map(&(&1.name)) |> Enum.join(", ") %> </td> <td> <%= post.comments |> Enum.count() %> </td> <td> <%= case post.post_status do %> <% "publish" -> %> <%= "Published" %> <% "future" -> %> <%= "Scheduled" %> <% "draft" -> %> <%= "Last Modified" %> <% "pending" -> %> <%= "Scheduled" %> <% "private" -> %> <%= "Published Privately" %> <% "inherit" -> %> <%= "Inherit" %> <% end %> <div> <%= post.post_date |> Timex.format!("%F", :strftime) %> </div> </td> </tr> <% end %> </tbody> </table> <hr /> <%= if @page > 1 do %> <%= link 1, to: Routes.admin_posts_path(@conn, :index, page: 1) %> <% end %> <%= if @page > 3 do %> ... <% end %> <%= if @page > 2 do %> <%= link @page - 1, to: Routes.admin_posts_path(@conn, :index, page: @page - 1) %> <% end %> <%= @page %> <%= if @page + 1 < @last_page do %> <%= link @page + 1, to: Routes.admin_posts_path(@conn, :index, page: @page + 1) %> <% end %> <%= if @page + 2 < @last_page do %> ... <% end %> <%= if @page < @last_page do %> <%= link @last_page, to: Routes.admin_posts_path(@conn, :index, page: @last_page) %> <% end %>