Bildergallerie auf Kurs

Für alle mit löschrechten: 2 Buttons, einer zeigt auf originaldatei,
einer löscht das bild.
This commit is contained in:
Thomas Blazek
2015-01-16 14:41:37 +01:00
parent 9c6038d6dd
commit b7f9cf942b
4 changed files with 92 additions and 57 deletions

View File

@@ -87,10 +87,11 @@ class FotosController < ApplicationController
# DELETE /fotos/1.json # DELETE /fotos/1.json
def destroy def destroy
@foto = Foto.find(params[:id]) @foto = Foto.find(params[:id])
gallery = @foto.gallery_id
@foto.destroy @foto.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to galleries_url } format.html { redirect_to gallery_path(gallery) }
format.json { head :no_content } format.json { head :no_content }
end end
end end

View File

@@ -22,13 +22,19 @@ class GalleriesController < ApplicationController
@pppage_array = [ 25 , 50 , 100, "all"] #defines number & size of picture chunks @pppage_array = [ 25 , 50 , 100, "all"] #defines number & size of picture chunks
@pppage = 0 #starting index of pppage_array @pppage = 0 #starting index of pppage_array
if !params[:pppage].nil? && params[:pppage].to_i <= 2 && params[:pppage].to_i >= 0 if !params[:pppage].nil? && params[:pppage].to_i <= 3 && params[:pppage].to_i >= 0
@pppage = params[:pppage].to_i @pppage = params[:pppage].to_i
end end
@page = params[:page].nil? ? 1 : params[:page].to_i @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)) # @fotos = Foto.where(:gallery_id => params[:id]).limit(@pppage_array[@pppage]).offset(@pppage_array[@pppage]*(@page-1))
@fotos = Foto.where(:gallery_id => params[:id]) @fotos = Foto.where(:gallery_id => params[:id])
if @fotos.nil? || @fotos.empty?
@fotos_p = []
@fotos_n = []
@pages = 1
else
if @pppage_array[@pppage] != "all" if @pppage_array[@pppage] != "all"
@fotos_p = @fotos.page(@page).per(@pppage_array[@pppage]) @fotos_p = @fotos.page(@page).per(@pppage_array[@pppage])
@@ -41,12 +47,13 @@ class GalleriesController < ApplicationController
@fotos_n = [] @fotos_n = []
@pages = 1 @pages = 1
end end
end
@showind=[]
# Hier ausrechnen welche angezeigt werden sollen # Hier ausrechnen welche angezeigt werden sollen
@toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('fotos.new-fotos'), :path=>new_gallery_foto_path(@gallery)} @toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('fotos.new-fotos'), :path=>new_gallery_foto_path(@gallery)}
@toolbar_elements << {:hicon=>'icon-pencil', :text => I18n.t('common.edit'), :path=>edit_gallery_path(@gallery)} @toolbar_elements << {:hicon=>'icon-pencil', :text => I18n.t('common.edit'), :path=>edit_gallery_path(@gallery)}
@toolbar_elements << {:hicon=>'icon-arrow-left', :text=>I18n.t('common.back'), :path=>galleries_path()} @toolbar_elements << {:hicon=>'icon-arrow-left', :text=>I18n.t('common.back'), :path=>galleries_path()}
@toolbar_elements << {:hicon => 'icon-remove-circle', :text => I18n.t('common.delete'), :path => gallery_path(@gallery),:confirm=>'Sure?', :method=>:delete} if can? :delete, Gallery
respond_to do |format| respond_to do |format|
format.html # show.html.erb format.html # show.html.erb

View File

@@ -38,7 +38,7 @@
</div> </div>
<div style="clear:both"></div> <div style="clear:both"></div>
<!-- The Bootstrap Image Gallery lightbox, should be a child element of the document body --> <!-- The Bootstrap Image Gallery lightbox, should be a child element of the document body -->
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls"> <div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls">
<!-- The container for the modal slides --> <!-- The container for the modal slides -->
<div class="slides"></div> <div class="slides"></div>
@@ -72,21 +72,45 @@
</div> </div>
</div> </div>
</div> </div>
<div id="links"> <p></p>
<div class="row-fluid"> <div class="row-fluid">
<div class="span12"> <div class="span12">
<% @fotos_p.each do |f| %> <% @fotos_p.each do |f| %>
<div class="left">
<div id="links">
<a href="<%= f.datei.resized.url%>" title="<%=f.title%>" data-gallery> <a href="<%= f.datei.resized.url%>" title="<%=f.title%>" data-gallery>
<%=image_tag(f.datei.thumb.url,{:class=>"img-polaroid img-rounded"}) %></a> <%=image_tag(f.datei.thumb.url,{:class=>"img-polaroid img-rounded"}) %></a>
</div>
<%= link_to ff_icon('icon-circle-arrow-down').html_safe, f.datei.url,
:class=>"btn-small",title: I18n.t('fotos.download')+': '+f.title, rel: 'tooltip' %>
<%= link_to ff_icon('icon-remove-circle').html_safe, gallery_foto_path(@gallery, f),
:method => :delete, :class=>"btn-small btn-danger",title: I18n.t('fotos.delete')+': '+f.title, rel: 'tooltip', confirm: I18n.t('fotos.delete')+': '+f.title+', Sicher?'%>
<p></p>
</div>
<% end %> <% end %>
<% @fotos_n.each do |f| %> <% @fotos_n.each do |f| %>
<div id="links">
<a href="<%= f.datei.resized.url%>" title="<%=f.title%>" data-gallery></a> <a href="<%= f.datei.resized.url%>" title="<%=f.title%>" data-gallery></a>
<% end %> <% end %>
</div> </div>
</div> </div>
</div>
<div class="row-fluid">
<% if can? :delete,@gallery %>
<div class="span12">
<%= link_to ff_icon('icon-circle-arrow-down').html_safe, '',
:class=>"btn-small"%>: <%= I18n.t('fotos.download_long')%><br>
<%= link_to ff_icon('icon-remove-circle').html_safe, '',
:class=>"btn-small btn-danger"%>: <%= I18n.t('fotos.delete')%>
<p></p>
</div> </div>
<% end %>
<%= javascript_include_tag "blueimp-gallery-all" %>
<%= render 'layouts/pretty_toolbar' %> <%= render 'layouts/pretty_toolbar' %>
</div>
<%= @pppage_array[@pppage] %>
<%= javascript_include_tag "blueimp-gallery-all" %>

View File

@@ -1,5 +1,8 @@
de: de:
fotos: fotos:
delete: "Foto löschen"
download: "Link zu Originaldatei"
download_long: "Link zu Originaldatei. Für Download Rechtsklick->speichern unter."
galleries: "Bildergalerien" galleries: "Bildergalerien"
new-gallery: "Neue Galerie" new-gallery: "Neue Galerie"
new-fotos: "Fotos hinzufügen" new-fotos: "Fotos hinzufügen"