Commit d5b1ae1c0fcec2bd762f99c2f0bc16cd57d223ea

Authored by Aurelio A. Heckert
Committed by Daniela Feitosa
1 parent 54bc64ec

Correct gallery images overflow

(ActionItem1894)
app/helpers/content_viewer_helper.rb
@@ -31,8 +31,7 @@ module ContentViewerHelper @@ -31,8 +31,7 @@ module ContentViewerHelper
31 end 31 end
32 32
33 def image_label(image) 33 def image_label(image)
34 - text = image.abstract || image.title  
35 - text && (text.first(40) + (text.size > 40 ? '…' : '')) 34 + image.title.first(40) + (image.title.size > 40 ? '…' : '')
36 end 35 end
37 36
38 def article_translations(article) 37 def article_translations(article)
app/views/content_viewer/_uploaded_file.rhtml
1 <% if uploaded_file.image? %> 1 <% if uploaded_file.image? %>
2 - <%= link_to content_tag(:span, uploaded_file.display_title), uploaded_file.view_url, :class => 'image', :style => 'background-image: url(%s)'% uploaded_file.public_filename(:thumb) %>  
3 - <span><%= image_label(uploaded_file) %></span> 2 + <%= link_to '',
  3 + uploaded_file.view_url,
  4 + :class => 'image',
  5 + :style => 'background-image: url(%s)'% uploaded_file.public_filename(:thumb)
  6 + %>
  7 + <span><%=h uploaded_file.title %></span>
4 <% else %> 8 <% else %>
5 <%= render :partial => 'article', :object => uploaded_file %> 9 <%= render :partial => 'article', :object => uploaded_file %>
6 <% end %> 10 <% end %>
app/views/content_viewer/image_gallery.rhtml
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 <% end %> 10 <% end %>
11 <ul> 11 <ul>
12 <% @images.each do |a| %> 12 <% @images.each do |a| %>
13 - <% content_tag('li', :title => a.abstract, :class => 'image-gallery-item' ) do %> 13 + <% content_tag('li', :title => a.title, :class => 'image-gallery-item' ) do %>
14 <%= render :partial => partial_for_class(a.class), :object => a %> 14 <%= render :partial => partial_for_class(a.class), :object => a %>
15 <% end %> 15 <% end %>
16 <% end %> 16 <% end %>
public/stylesheets/application.css
@@ -3361,13 +3361,15 @@ div.with_media_panel .formfield input { @@ -3361,13 +3361,15 @@ div.with_media_panel .formfield input {
3361 .image-gallery ul { 3361 .image-gallery ul {
3362 padding: 0px; 3362 padding: 0px;
3363 text-align: center; 3363 text-align: center;
  3364 + width: 486px;
  3365 + margin: auto;
3364 } 3366 }
3365 3367
3366 .image-gallery-item { 3368 .image-gallery-item {
3367 width: 142px; 3369 width: 142px;
3368 height: 170px; 3370 height: 170px;
3369 list-style: none; 3371 list-style: none;
3370 - margin: 5px; 3372 + margin: 10px;
3371 float: left; 3373 float: left;
3372 overflow: hidden; 3374 overflow: hidden;
3373 background-repeat: no-repeat; 3375 background-repeat: no-repeat;
test/integration/gallery_test.rb 0 → 100644
@@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +
  3 +class GalleryTest < ActionController::IntegrationTest
  4 +
  5 + def setup
  6 + p = create_user('test_user').person
  7 + g = fast_create(Gallery, :profile_id => p.id, :path => 'pics')
  8 + image = UploadedFile.create!(
  9 + :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'),
  10 + :parent => g,
  11 + :profile => p,
  12 + :title => 'my img1 title',
  13 + :abstract => 'my img1 <b>long description</b>'
  14 + )
  15 + image = UploadedFile.create!(
  16 + :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg'),
  17 + :parent => g,
  18 + :profile => p,
  19 + :title => '<b must scape title>',
  20 + :abstract => 'that is my picture description'
  21 + )
  22 + get '/test_user/pics'
  23 + end
  24 +
  25 + should 'display the title of the images when listing' do
  26 + assert_tag :tag => 'li', :attributes => { :title => 'my img1 title' }
  27 + assert_select '.image-gallery-item span', 'my img1 title'
  28 + assert_no_match(/my img1 <b>long description/, @response.body)
  29 + end
  30 +
  31 + should 'scape the title of the images' do
  32 + assert_select '.image-gallery-item:first-child span',
  33 + '&lt;b must scape title&gt;'
  34 + end
  35 +
  36 +end