cirandas.net

ref: master

app/views/search/_image.html.erb


<% if image.is_a? UploadedFile and image.filename %> <% extension = image.extension %> <% if ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'svg'].include? extension %> <%= link_to '', image.view_url, :class => "search-image-pic", :style => 'background-image: url(%s)'% image.public_filename(:thumb) %> <% if image.width && image.height %> <%= javascript_tag do %> image = jQuery('script').last().parent().find('.search-image-pic'); des_width = parseInt(image.css('width')); des_height = parseInt(image.css('height')); width = <%= image.width %>; height = <%= image.height %>; scale_factor = width > height ? des_width/width : des_height/height; image.css({'width' : scale_factor*width +'px', 'height' : scale_factor*height+'px'}); <% end %> <% end %> <% elsif ['pdf'].include? extension %> <%= link_to '', image.view_url, :class => 'icon-application-pdf' %> <% elsif ['doc', 'docx', 'odt', 'rtf', 'txt', 'html', 'htm'].include? extension %> <%= link_to '', image.view_url, :class => 'icon-application-vnd-oasis-opendocument-text' %> <% elsif ['xls', 'xlsx', 'ods', 'csv', 'tsv', 'tab'].include? extension %> <%= link_to '', image.view_url, :class => 'icon-application-vnd-oasis-opendocument-spreadsheet' %> <% end %> <% elsif image.is_a? Gallery %> <% else %>
<% end %>