_pagination.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <%
  2. # Testing pagination
  3. # <pre>
  4. # <%= @pagination.to_yaml %>
  5. # </pre>
  6. %>
  7. <% if @pagination %>
  8. <div class="pagination">
  9. <% if @pagination[:previous] then %>
  10. <a href="/<%= @pagination[:slug] %>-page-<%= @pagination[:page]-1 %>/"
  11. rel="previous" class="next_page">← Previous</a>
  12. <% else %>
  13. <span class="disabled previous_page">← Previous</span>
  14. <% end %>
  15. <% [*1..@pagination[:total_page]].each do |p| %>
  16. <% if p == @pagination[:page] then %>
  17. <em class="current"><%= p %></em>
  18. <% else %>
  19. <a href="/<%= @pagination[:slug] %>-page-<%= p %>/"
  20. <% if p == (@pagination[:page]-1) then %>
  21. rel="previous"
  22. <% elsif p == (@pagination[:page]+1) %>
  23. rel="next"
  24. <% end %>
  25. ><%= p %></a>
  26. <% end %>
  27. <% end %>
  28. <% #Not handled <span class="gap">…</span> %>
  29. <% if @pagination[:next] then %>
  30. <a href="/<%= @pagination[:slug] %>-page-<%= @pagination[:page]+1 %>/"
  31. rel="next" class="next_page">Next →</a>
  32. <% else %>
  33. <span class="disabled next_page">Next →</span>
  34. <% end %>
  35. </div>
  36. <% end %>