Hi,
Coming from PHP I’m a total ruby n00b and and playing around with middleman to generate a blog. To get things working nicely with bootstrap I’ve written my own pagination snippet:
<div class="pagination pagination-centered">
<ul>
<% if prev_page %>
<li><%= link_to '«', page_start %></li>
<li><%= link_to '‹', prev_page.url %></li>
<% else %>
<li class="disabled"><span>«</span></li>
<li class="disabled"><span>‹</span></li>
<% end %>
<% (page_number - 2 .. page_number + 2).select{|i| i > 0 && i <= num_pages}.each do |i| %>
<% p = nil %>
<% (i ... page_number).each do p = p ? p.metadata[:locals]['prev_page'] : prev_page; end %>
<% (page_number ... i).each do p = p ? p.metadata[:locals]['next_page'] : next_page; end %>
<% if i == page_number %>
<li class="active"><span><%= i %></span></li>
<% else %>
<li><%= link_to "#{i}", p && p.url %></li>
<% end %>
<% end %>
<% if next_page %>
<li><%= link_to '›', next_page.url %></li>
<li><%= link_to '»', path() %></li>
<% else %>
<li class="disabled"><span>›</span></li>
<li class="disabled"><span>»</span></li>
<% end %>
</ul>
</div>
The problem here of course, I have no idea how to link to the first and last page used in pagination (page_start and path() respectively). I know this is probably a stupid question. Could anyone point me in the right direction or link to a tutorial to get up to date with rail basics?