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 31 end
32 32  
33 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 35 end
37 36  
38 37 def article_translations(article)
... ...
app/views/content_viewer/_uploaded_file.rhtml
1 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 8 <% else %>
5 9 <%= render :partial => 'article', :object => uploaded_file %>
6 10 <% end %>
... ...
app/views/content_viewer/image_gallery.rhtml
... ... @@ -10,7 +10,7 @@
10 10 <% end %>
11 11 <ul>
12 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 14 <%= render :partial => partial_for_class(a.class), :object => a %>
15 15 <% end %>
16 16 <% end %>
... ...
public/stylesheets/application.css
... ... @@ -3361,13 +3361,15 @@ div.with_media_panel .formfield input {
3361 3361 .image-gallery ul {
3362 3362 padding: 0px;
3363 3363 text-align: center;
  3364 + width: 486px;
  3365 + margin: auto;
3364 3366 }
3365 3367  
3366 3368 .image-gallery-item {
3367 3369 width: 142px;
3368 3370 height: 170px;
3369 3371 list-style: none;
3370   - margin: 5px;
  3372 + margin: 10px;
3371 3373 float: left;
3372 3374 overflow: hidden;
3373 3375 background-repeat: no-repeat;
... ...
test/integration/gallery_test.rb 0 → 100644
... ... @@ -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
... ...