only 12 photos per page instead and actually put in the pagination links

master
Coleman 2008-06-27 21:03:57 -05:00
parent 399ff5beaa
commit b05bc6818c
3 changed files with 16 additions and 24 deletions

View File

@ -19,10 +19,11 @@ class Albums < Application
pcount = @album.photos.size
@page = params[:page].to_i
per_page = 20
per_page = 12
@page_count = (pcount.to_f / per_page.to_f).ceil.to_i
@page = 0 if @page >= @page_count
@url_key = :photos
@url_key = :album
@paginate_id = @album.name.gsub(/ /, '_')
@photos = @album.photos.find(:all, :limit => per_page, :offset => (@page * per_page), :order => 'filename ASC')

View File

@ -9,8 +9,7 @@
.photo_collection_item {
word-wrap: break-word;
width: 150px;
min-height: 150px;
max-width: 150px;
max-height: 150px;
margin-top: 15px;
margin-bottom: 15px;
@ -20,20 +19,9 @@
position: relative;
}
.col_1 {
margin-left: 5px;
}
.col_2 {
margin-left: 5px;
}
.col_3 {
margin-left: 5px;
}
.col_0 {
margin-left: 5px;
.col_1, .col_2, .col_0 {
margin-left: 15px;
margin-right: 15px;
}
<% end -%>
@ -41,8 +29,9 @@
<div class="hentry">
<h1><%= @album.name -%></h1>
<% @album.photos.each_with_index do |photo, idx| -%>
<div class="photo_collection_item col_<%= (idx + 1) % 4 -%>"><a href="<%= url(:photo, photo) -%>" rel="nofollow" onclick="window.open(this.href);return false;"><img src="<%= thumbnail_photo_url(photo) -%>" /></a></div>
<% @photos.each_with_index do |photo, idx| -%>
<div class="photo_collection_item col_<%= (idx + 1) % 3 -%>"><a href="<%= url(:photo, photo) -%>" rel="nofollow" onclick="window.open(this.href);return false;"><img src="<%= thumbnail_photo_url(photo) -%>" /></a></div>
<% if (idx + 1) % 3 == 0 or @photos.last == photo -%><br style="clear:both" /><% end -%>
<% end -%>
<% unless @album.tags.empty? -%>
@ -52,3 +41,5 @@
</ul>
<% end -%>
</div>
<%= partial 'shared/pagination_links' %>

View File

@ -2,22 +2,22 @@
<div id="pagination_links">
<% if @page > 0 -%>
<a href="<%= url(@url_key, :page => 0) -%>"><img src="/images/go-first.png" alt="First Page" /></a> <a href="<%= url(@url_key, :page => 0) -%>"><img src="/images/go-previous.png" alt="Previous Page" /></a>
<a href="<%= url(@url_key, :page => 0, :id => @paginate_id) -%>"><img src="/images/go-first.png" alt="First Page" /></a> <a href="<%= url(@url_key, :page => 0, :id => @paginate_id) -%>"><img src="/images/go-previous.png" alt="Previous Page" /></a>
<% end -%>
<% if @page_count > 1 -%>
<% (@page - 5).upto(@page - 1) do |i| ; next if i < 0 -%>
<a href="<%= url(@url_key, :page => i) -%>"><%= i + 1 -%></a>
<a href="<%= url(@url_key, :page => i, :id => @paginate_id) -%>"><%= i + 1 -%></a>
<% end %>
<%= @page + 1 %>
<% (@page + 1).upto(@page + 5) do |i| ; next if i >= @page_count -%>
<a href="<%= url(@url_key, :page => i) -%>"><%= i + 1 -%></a>
<a href="<%= url(@url_key, :page => i, :id => @paginate_id) -%>"><%= i + 1 -%></a>
<% end %>
<% if @page < @page_count - 1 -%>
<a href="<%= url(@url_key, :page => @page + 1) -%>"><img src="/images/go-next.png" alt="Next Page" /></a> <a href="<%= url(@url_key, :page => @page_count - 1) -%>"><img src="/images/go-last.png" alt="Last Page" /></a>
<a href="<%= url(@url_key, :page => @page + 1, :id => @paginate_id) -%>"><img src="/images/go-next.png" alt="Next Page" /></a> <a href="<%= url(@url_key, :page => @page_count - 1) -%>"><img src="/images/go-last.png" alt="Last Page" /></a>
<% end -%>
<% end -%>