foto gallery - schema.org und download button

This commit is contained in:
Andreas Stephanides
2015-02-24 13:46:43 +01:00
parent 742962255b
commit 67d0d19bd7
5 changed files with 78 additions and 37 deletions

View File

@@ -1,5 +1,6 @@
class FotosController < ApplicationController class FotosController < ApplicationController
before_filter {@toolbar_elements=[]} before_filter {@toolbar_elements=[]}
load_and_authorize_resource
# GET /fotos # GET /fotos
# GET /fotos.json # GET /fotos.json
def index def index
@@ -17,7 +18,13 @@ class FotosController < ApplicationController
@foto = Foto.find(params[:id]) @foto = Foto.find(params[:id])
respond_to do |format| 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 } format.json { render json: @foto }
end end
end end

View File

@@ -27,8 +27,17 @@ class GalleriesController < ApplicationController
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])
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? if @fotos.nil? || @fotos.empty?
@fotos_p = [] @fotos_p = []
@fotos_n = [] @fotos_n = []

View File

@@ -63,6 +63,7 @@ class Ability
end end
if( user.has_role?("fetuser") || user.has_role?("fetadmin")) if( user.has_role?("fetuser") || user.has_role?("fetadmin"))
can :manage, Gallery can :manage, Gallery
can :show, Foto
end end
unless user.has_role?("fetadmin") unless user.has_role?("fetadmin")
cannot :delete, Gallery cannot :delete, Gallery

View File

@@ -1,31 +1,14 @@
<div class="container-fluid"> <%= image_tag @foto.datei.resized.url, :style=>"margin: auto;
position: absolute;
left: 0;
<div class="row-fluid"> right: 0;
<div class="span12"> bottom: 0;
<%= 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) ) %> top: 0;" %>
</div> <% #, 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) ) %>
</div> <div style="position:absolute; bottom:0">
<%= link_to ff_icon('icon-circle-arrow-down').html_safe, @foto.datei.url,
<div class="row-fluid"> :class=>"btn",title: I18n.t('fotos.download')+': '+@foto.title,:target=>:blank, :style=>"" %>
<div class="span9">
<h2><%= @foto.title %></h2>
<p><%= @foto.desc %></p>
</div>
<div class="span3">
<p>
<%= 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) %>
</p>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<p id="notice"><%= notice %></p> <p id="notice"><%= notice %></p>
</div> </div>
</div>
</div>

View File

@@ -1,18 +1,26 @@
<%= content_for :header do %>
<title>Fet - Fotos: <%= @gallery.name %></title>
<% end %>
<div itemscope itemtype="http://schema.org/ImageGallery">
<p id="notice"><%= notice %></p> <p id="notice"><%= notice %></p>
<div> <div>
<small class="pull-left"><%= @gallery.fotos.size.to_s + " " + I18n.t('fotos.bilder')%> </small> <small class="pull-left"><%= @gallery.fotos.size.to_s + " " + I18n.t('fotos.bilder')%> </small>
<small class="pull-right"><%=I18n.l(@gallery.try(:datum).try(:to_date)) unless @gallery.try(:datum).try(:to_date).nil? %></small></br> <small class="pull-right" itemprop="dateCreated" datetime="<%= @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? %></small></br>
<h1> <h1 itemprop="name">
<%= @gallery.name %> <%= @gallery.name %>
</h1> </h1>
</div> </div>
<meta itemprop="sameAs" content="<%= gallery_path(@gallery) %>"/>
<p> <p itemprop="description">
<%= @gallery.desc %> <%= @gallery.desc %>
</p> </p>
<style>
.blueimp-gallery > .slides > .slide > .text-content {
overflow: auto;
text-align: left;
}
</style>
<div class="fluid-row"> <div class="fluid-row">
<div class="span9"> <!-- pagination--> <div class="span9"> <!-- pagination-->
<div class="pagination pull_left" style="margin:0px 0px 0px 0px"> <div class="pagination pull_left" style="margin:0px 0px 0px 0px">
@@ -80,6 +88,15 @@
<div id="links"> <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 <% if (@openfotoid.to_i==f.id) %> itemprop="primaryImageOfPage"<% else %> itemprop="hasPart" <% end %> itemscope itemtype="http://schema.org/ImageObject">
<a href="<%= gallery_foto_path(f.gallery, f,:params=>{plain: true}) %>" data-type="text/html" title="<%=f.title%>" data-gallery <% if (@openfotoid.to_i==f.id) %>id="openpic" <% end %>>
<%= image_tag(f.datei.thumb.url,{:class=>"img-polaroid img-rounded"}) %>
<meta itemprop="thumbnailUrl" content="<%= f.datei.thumb.url %>"/>
<meta itemprop="dateModified" content="<%= f.updated_at %>"/>
<meta itemprop="image" content="<%= f.datei.url %>"/>
<meta itemprop="sameAs" content="<%= gallery_foto_path(f.gallery, f,:params=>{:plain=>nil, :theme=>nil})%>"/>
</a>
</div>
</div> </div>
<%= link_to ff_icon('icon-circle-arrow-down').html_safe, f.datei.url, <%= 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' %> :class=>"btn-small",title: I18n.t('fotos.download')+': '+f.title, rel: 'tooltip' %>
@@ -112,5 +129,29 @@
</div> </div>
<%= @pppage_array[@pppage] %> <%= @pppage_array[@pppage] %>
<%= javascript_include_tag "blueimp-gallery-all" %> <%= javascript_include_tag "blueimp-gallery-all" %>
<script>
blueimp.Gallery.prototype.textFactory = function (obj, callback) {
var $element = $('<div>')
.addClass('slide-content')
.attr('title', obj.title);
$.get(obj.href)
.done(function (result) {
$element.html(result);
callback({
type: 'load',
target: $element[0]
});
})
.fail(function () {
callback({
type: 'error',
target: $element[0]
});
});
return $element[0];
};
$('#openpic').click()
</script>
</div>