forked from bofh/fetsite
NEW: Pictures per Site Feature + Pagination + improved SQL query
This commit is contained in:
@@ -18,9 +18,21 @@ class GalleriesController < ApplicationController
|
||||
# GET /galleries/1.json
|
||||
def show
|
||||
@gallery = Gallery.find(params[:id])
|
||||
|
||||
@pppage_array = [ 5 , 50 , 100 ] #defines number & size of picture chunks
|
||||
@pppage = 0 #starting index of pppage_array
|
||||
|
||||
if params[:pppage].to_i <= 2 && params[:pppage].to_i >= 0
|
||||
@pppage = params[:pppage].to_i
|
||||
end
|
||||
|
||||
@page = params[:page].nil? ? 1 : params[:page].to_i
|
||||
@fotos = Foto.where(:gallery_id => params[:id]).limit(@pppage_array[@pppage]).offset(@pppage_array[@pppage]*(@page-1))
|
||||
@pages = (Foto.where(:gallery_id => params[:id]).count/5)+1
|
||||
@toolbar_elements << {:hicon=>'icon-plus', :text=> "NewFoto", :path=>new_gallery_foto_path(@gallery)}
|
||||
@toolbar_elements << {:hicon=>'icon-pencil', :text => I18n.t('common.edit'), :path=>edit_gallery_path(@gallery)}
|
||||
@toolbar_elements << {:text=>"Back", :path=>galleries_path()}
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @gallery }
|
||||
|
||||
@@ -11,33 +11,61 @@
|
||||
<p>
|
||||
<%= @gallery.desc %>
|
||||
</p>
|
||||
</br>
|
||||
|
||||
<!-- modal-gallery is the modal dialog used for the image gallery -->
|
||||
<div id="modal-gallery" class="modal hide fade modal-gallery modal-fullscreen modal-loading" tabindex="-1">
|
||||
<div class="modal-header">
|
||||
<a class="close" data-dismiss="modal">×</a>
|
||||
<h3 class="modal-title"></h3>
|
||||
|
||||
<div class="fluid-row">
|
||||
<div class="span9"> <!-- pagination-->
|
||||
<div class="pagination pull_left">
|
||||
<ul>
|
||||
<li><a href="<%= gallery_path @gallery, {:pppage => @pppage, :page => (@page==1 ? @page : @page-1)} %>"><%=I18n.t('fotos.prev')%></a></li>
|
||||
<% for i in 1..@pages do %>
|
||||
<li><a href="<%= gallery_path @gallery, {:pppage => @pppage, :page => i} %>"><%=i%></a></li>
|
||||
<% end %>
|
||||
<li><a href="<%= gallery_path @gallery, {:pppage => @pppage, :page => (@page==@pages ? @page : @page+1)} %>"><%=I18n.t('fotos.next')%></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body"><div class="modal-image"></div></div>
|
||||
<div class="modal-footer">
|
||||
<a class="btn btn-primary modal-next">Next <i class="icon-arrow-right icon-white"></i></a>
|
||||
<a class="btn btn-info modal-prev"><i class="icon-arrow-left icon-white"></i> Previous</a>
|
||||
<a class="btn btn-success modal-play modal-slideshow" data-slideshow="5000"><i class="icon-play icon-white"></i> Slideshow</a>
|
||||
<a class="btn modal-download" target="_blank"><i class="icon-download"></i> Download</a>
|
||||
<div class="span3"> <!-- size selector -->
|
||||
<div class="pull-right" style="margin-top:20px">
|
||||
<div class="btn-group" data-toggle="buttons-radio">
|
||||
<button class="btn" disabled><%=I18n.t('fotos.pictures_per_site')%></button>
|
||||
<% for i in 0..@pppage_array.size-1 %>
|
||||
<a class="btn" href="<%= gallery_path @gallery, {:pppage => i} %>"><%=@pppage_array[i]%></a>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="gallery" data-toggle="modal-gallery" data-target="#modal-gallery">
|
||||
<% @gallery.fotos.each do |f| %>
|
||||
<div style="clear:both"></div>
|
||||
|
||||
<a href="<%= f.datei.resized.url%>" title="<%=f.title%>" data-gallery="gallery">
|
||||
<%=image_tag(f.datei.thumb.url,{:class=>"img-polaroid"}) %></a>
|
||||
<div class="fluid-row" style="margin-bottom:20px">
|
||||
<!-- modal-gallery is the modal dialog used for the image gallery -->
|
||||
<div id="modal-gallery" class="modal hide fade modal-gallery modal-fullscreen modal-loading" tabindex="-1">
|
||||
<div class="modal-header">
|
||||
<a class="close" data-dismiss="modal">×</a>
|
||||
<h3 class="modal-title"></h3>
|
||||
</div>
|
||||
<div class="modal-body"><div class="modal-image"></div></div>
|
||||
<div class="modal-footer">
|
||||
<a class="btn btn-info modal-prev"><i class="icon-arrow-left icon-white"></i></a>
|
||||
<a class="btn btn-primary modal-next"><i class="icon-arrow-right icon-white"></i></a>
|
||||
<a class="btn btn-success modal-play modal-slideshow" data-slideshow="5000"><i class="icon-play icon-white"></i> <%=I18n.t('fotos.slideshow')%></a>
|
||||
<a class="btn modal-download" target="_blank"><i class="icon-download"></i> Download</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="gallery" data-toggle="modal-gallery" data-target="#modal-gallery">
|
||||
<% @fotos.each do |f| %>
|
||||
|
||||
<a href="<%= f.datei.resized.url%>" title="<%=f.title%>" data-gallery="gallery">
|
||||
<%=image_tag(f.datei.thumb.url,{:class=>"img-polaroid"}) %></a>
|
||||
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</br>
|
||||
|
||||
<%= render 'layouts/pretty_toolbar' %>
|
||||
|
||||
|
||||
|
||||
@@ -2,4 +2,8 @@ de:
|
||||
fotos:
|
||||
galleries: "Bildergalerien"
|
||||
new-gallery: "neue Galerie"
|
||||
bilder: "Bilder"
|
||||
bilder: "Bilder"
|
||||
prev: "Vorherige"
|
||||
next: "Nächste"
|
||||
slideshow: "Diaschau"
|
||||
pictures_per_site: "Bilder pro Seite"
|
||||
@@ -2,4 +2,8 @@ en:
|
||||
fotos:
|
||||
galleries: "Picture Gallery"
|
||||
new-gallery: "new gallery"
|
||||
bilder: "pictures"
|
||||
bilder: "pictures"
|
||||
prev: "Previous"
|
||||
next: "Next"
|
||||
slideshow: "Slideshow"
|
||||
pictures_per_site: "Pictures per site"
|
||||
Reference in New Issue
Block a user