only 12 photos per page instead and actually put in the pagination links
parent
399ff5beaa
commit
b05bc6818c
|
@ -19,10 +19,11 @@ class Albums < Application
|
||||||
|
|
||||||
pcount = @album.photos.size
|
pcount = @album.photos.size
|
||||||
@page = params[:page].to_i
|
@page = params[:page].to_i
|
||||||
per_page = 20
|
per_page = 12
|
||||||
@page_count = (pcount.to_f / per_page.to_f).ceil.to_i
|
@page_count = (pcount.to_f / per_page.to_f).ceil.to_i
|
||||||
@page = 0 if @page >= @page_count
|
@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')
|
@photos = @album.photos.find(:all, :limit => per_page, :offset => (@page * per_page), :order => 'filename ASC')
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
|
|
||||||
.photo_collection_item {
|
.photo_collection_item {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
width: 150px;
|
max-width: 150px;
|
||||||
min-height: 150px;
|
|
||||||
max-height: 150px;
|
max-height: 150px;
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
|
@ -20,20 +19,9 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.col_1 {
|
.col_1, .col_2, .col_0 {
|
||||||
margin-left: 5px;
|
margin-left: 15px;
|
||||||
}
|
margin-right: 15px;
|
||||||
|
|
||||||
.col_2 {
|
|
||||||
margin-left: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.col_3 {
|
|
||||||
margin-left: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.col_0 {
|
|
||||||
margin-left: 5px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
@ -41,8 +29,9 @@
|
||||||
<div class="hentry">
|
<div class="hentry">
|
||||||
<h1><%= @album.name -%></h1>
|
<h1><%= @album.name -%></h1>
|
||||||
|
|
||||||
<% @album.photos.each_with_index do |photo, idx| -%>
|
<% @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>
|
<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 -%>
|
<% end -%>
|
||||||
|
|
||||||
<% unless @album.tags.empty? -%>
|
<% unless @album.tags.empty? -%>
|
||||||
|
@ -52,3 +41,5 @@
|
||||||
</ul>
|
</ul>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= partial 'shared/pagination_links' %>
|
||||||
|
|
|
@ -2,22 +2,22 @@
|
||||||
<div id="pagination_links">
|
<div id="pagination_links">
|
||||||
|
|
||||||
<% if @page > 0 -%>
|
<% 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 -%>
|
<% end -%>
|
||||||
|
|
||||||
<% if @page_count > 1 -%>
|
<% if @page_count > 1 -%>
|
||||||
<% (@page - 5).upto(@page - 1) do |i| ; next if i < 0 -%>
|
<% (@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 %>
|
<% end %>
|
||||||
|
|
||||||
<%= @page + 1 %>
|
<%= @page + 1 %>
|
||||||
|
|
||||||
<% (@page + 1).upto(@page + 5) do |i| ; next if i >= @page_count -%>
|
<% (@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 %>
|
<% end %>
|
||||||
|
|
||||||
<% if @page < @page_count - 1 -%>
|
<% 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 -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
|
|
Reference in New Issue