From 67d0d19bd7dfea410466af91cd6595be9d0240ce Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Tue, 24 Feb 2015 13:46:43 +0100 Subject: [PATCH] foto gallery - schema.org und download button --- app/controllers/fotos_controller.rb | 9 +++- app/controllers/galleries_controller.rb | 11 ++++- app/models/ability.rb | 1 + app/views/fotos/show.html.erb | 37 +++++----------- app/views/galleries/show.html.erb | 57 +++++++++++++++++++++---- 5 files changed, 78 insertions(+), 37 deletions(-) diff --git a/app/controllers/fotos_controller.rb b/app/controllers/fotos_controller.rb index b97f105..b0f0e76 100644 --- a/app/controllers/fotos_controller.rb +++ b/app/controllers/fotos_controller.rb @@ -1,5 +1,6 @@ class FotosController < ApplicationController before_filter {@toolbar_elements=[]} + load_and_authorize_resource # GET /fotos # GET /fotos.json def index @@ -17,7 +18,13 @@ class FotosController < ApplicationController @foto = Foto.find(params[:id]) respond_to do |format| - format.html # show.html.erb + format.html { + if params[:plain] + render "show", layout: false + else + redirect_to gallery_path(@foto.gallery,:params=>{fotoid: @foto.id}) + end + } format.json { render json: @foto } end end diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 978f200..7a047ca 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -27,9 +27,18 @@ class GalleriesController < ApplicationController 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)) @fotos = Foto.where(:gallery_id => params[:id]) - if @fotos.nil? || @fotos.empty? + unless params[:fotoid].nil? + foto_ind = @fotos.find_index(Foto.find(params[:fotoid])) + # @page=(@fotos.count/foto_ind).to_i+1 + @openfotoid=params[:fotoid] + else +@openfotoid=0 + end + if @fotos.nil? || @fotos.empty? @fotos_p = [] @fotos_n = [] @pages = 1 diff --git a/app/models/ability.rb b/app/models/ability.rb index e00018d..8d8e51b 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -63,6 +63,7 @@ class Ability end if( user.has_role?("fetuser") || user.has_role?("fetadmin")) can :manage, Gallery + can :show, Foto end unless user.has_role?("fetadmin") cannot :delete, Gallery diff --git a/app/views/fotos/show.html.erb b/app/views/fotos/show.html.erb index 9183e5e..c33d0d4 100644 --- a/app/views/fotos/show.html.erb +++ b/app/views/fotos/show.html.erb @@ -1,31 +1,14 @@ -
- - -
-
- <%= link_to image_tag(@foto.datei.resized.url), gallery_foto_path(@foto.gallery, ((@foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].nil?) ? (@foto.gallery.fotos[0].try(:id).to_i) : @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].try(:id).to_i) ) %> -
-
- -
-
-

<%= @foto.title %>

-

<%= @foto.desc %>

-
-
-

- <%= link_to 'last' , gallery_foto_path(@foto.gallery, @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)-1].try(:id).to_i) unless @foto.gallery.fotos.index(@foto)==0 %> - <%= link_to 'next' , gallery_foto_path(@foto.gallery, @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].try(:id).to_i) unless @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].nil? %> - <%= link_to 'Edit', edit_foto_path(@foto) %> | - <%= link_to 'Back', gallery_path(@foto.gallery) %> -

-
-
-
-
+ <%= image_tag @foto.datei.resized.url, :style=>"margin: auto; +position: absolute; +left: 0; +right: 0; +bottom: 0; +top: 0;" %> +<% #, gallery_foto_path(@foto.gallery, ((@foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].nil?) ? (@foto.gallery.fotos[0].try(:id).to_i) : @foto.gallery.fotos[@foto.gallery.fotos.index(@foto)+1].try(:id).to_i) ) %> +
+<%= link_to ff_icon('icon-circle-arrow-down').html_safe, @foto.datei.url, + :class=>"btn",title: I18n.t('fotos.download')+': '+@foto.title,:target=>:blank, :style=>"" %>

<%= notice %>

-
-
diff --git a/app/views/galleries/show.html.erb b/app/views/galleries/show.html.erb index d7193ea..1f4a5a0 100644 --- a/app/views/galleries/show.html.erb +++ b/app/views/galleries/show.html.erb @@ -1,18 +1,26 @@ +<%= content_for :header do %> +Fet - Fotos: <%= @gallery.name %> +<% end %> +

<%= notice %>

<%= @gallery.fotos.size.to_s + " " + I18n.t('fotos.bilder')%> - <%=I18n.l(@gallery.try(:datum).try(:to_date)) unless @gallery.try(:datum).try(:to_date).nil? %>
-

+ <%=I18n.l(@gallery.try(:datum).try(:to_date)) unless @gallery.try(:datum).try(:to_date).nil? %>
+

<%= @gallery.name %>

- -

+ +

<%= @gallery.desc %>

- - +