forked from bofh/fetsite
foto gallery - schema.org und download button
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -27,8 +27,17 @@ 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])
|
||||
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 = []
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,31 +1,14 @@
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<%= 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) ) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<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">
|
||||
<%= 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) ) %>
|
||||
<div style="position:absolute; bottom:0">
|
||||
<%= 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=>"" %>
|
||||
<p id="notice"><%= notice %></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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>
|
||||
<div>
|
||||
<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>
|
||||
<h1>
|
||||
<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 itemprop="name">
|
||||
<%= @gallery.name %>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<meta itemprop="sameAs" content="<%= gallery_path(@gallery) %>"/>
|
||||
<p itemprop="description">
|
||||
<%= @gallery.desc %>
|
||||
</p>
|
||||
|
||||
|
||||
<style>
|
||||
.blueimp-gallery > .slides > .slide > .text-content {
|
||||
overflow: auto;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
<div class="fluid-row">
|
||||
<div class="span9"> <!-- pagination-->
|
||||
<div class="pagination pull_left" style="margin:0px 0px 0px 0px">
|
||||
@@ -80,6 +88,15 @@
|
||||
<div id="links">
|
||||
<a href="<%= f.datei.resized.url%>" title="<%=f.title%>" data-gallery>
|
||||
<%=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>
|
||||
<%= 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' %>
|
||||
@@ -112,5 +129,29 @@
|
||||
</div>
|
||||
<%= @pppage_array[@pppage] %>
|
||||
<%= 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>
|
||||
|
||||
Reference in New Issue
Block a user