Commit 5cdd7db7bc5a51ebd4b0c1022cd9331d1b0cc394
1 parent
53ccf362
Exists in
master
and in
29 other branches
folder: let word wrap work (do not short filenames)
This also removes short_filename as it is now unused
Showing
7 changed files
with
5 additions
and
79 deletions
Show diff stats
app/helpers/folder_helper.rb
| 1 | -require 'short_filename' | ||
| 2 | - | ||
| 3 | module FolderHelper | 1 | module FolderHelper |
| 4 | 2 | ||
| 5 | - include ShortFilename | ||
| 6 | include ArticleHelper | 3 | include ArticleHelper |
| 7 | 4 | ||
| 8 | def list_contents(configure={}) | 5 | def list_contents(configure={}) |
| @@ -10,8 +7,8 @@ module FolderHelper | @@ -10,8 +7,8 @@ module FolderHelper | ||
| 10 | configure[:list_type] ||= :folder | 7 | configure[:list_type] ||= :folder |
| 11 | if !configure[:contents].blank? | 8 | if !configure[:contents].blank? |
| 12 | configure[:contents] = configure[:contents].paginate( | 9 | configure[:contents] = configure[:contents].paginate( |
| 13 | - :order => "updated_at DESC", | ||
| 14 | - :per_page => 10, | 10 | + :order => "name ASC", |
| 11 | + :per_page => 30, | ||
| 15 | :page => params[:npage] | 12 | :page => params[:npage] |
| 16 | ) | 13 | ) |
| 17 | 14 |
app/models/uploaded_file.rb
| 1 | -require 'short_filename' | ||
| 2 | - | ||
| 3 | # Article type that handles uploaded files. | 1 | # Article type that handles uploaded files. |
| 4 | # | 2 | # |
| 5 | # Limitation: only file metadata are versioned. Only the latest version | 3 | # Limitation: only file metadata are versioned. Only the latest version |
| @@ -14,8 +12,6 @@ class UploadedFile < Article | @@ -14,8 +12,6 @@ class UploadedFile < Article | ||
| 14 | 12 | ||
| 15 | track_actions :upload_image, :after_create, :keep_params => ["view_url", "thumbnail_path", "parent.url", "parent.name"], :if => Proc.new { |a| a.published? && a.image? && !a.parent.nil? && a.parent.gallery? }, :custom_target => :parent | 13 | track_actions :upload_image, :after_create, :keep_params => ["view_url", "thumbnail_path", "parent.url", "parent.name"], :if => Proc.new { |a| a.published? && a.image? && !a.parent.nil? && a.parent.gallery? }, :custom_target => :parent |
| 16 | 14 | ||
| 17 | - include ShortFilename | ||
| 18 | - | ||
| 19 | def title | 15 | def title |
| 20 | if self.name.present? then self.name else self.filename end | 16 | if self.name.present? then self.name else self.filename end |
| 21 | end | 17 | end |
app/views/shared/_content_item.html.erb
| @@ -4,8 +4,8 @@ | @@ -4,8 +4,8 @@ | ||
| 4 | <%= display_content_icon(content) %> | 4 | <%= display_content_icon(content) %> |
| 5 | </div> | 5 | </div> |
| 6 | <span class="item-description"> | 6 | <span class="item-description"> |
| 7 | - <%= link_to(short_filename_upper_ext(content.name), content.url) %> | 7 | + <%= link_to(content.name, content.url) %> |
| 8 | </span> | 8 | </span> |
| 9 | <span class="item-date"><%= _("Published at: #{show_date(content.updated_at)}") %></span> | 9 | <span class="item-date"><%= _("Published at: #{show_date(content.updated_at)}") %></span> |
| 10 | </div> | 10 | </div> |
| 11 | -</div> | ||
| 12 | \ No newline at end of file | 11 | \ No newline at end of file |
| 12 | +</div> |
lib/short_filename.rb
| @@ -1,21 +0,0 @@ | @@ -1,21 +0,0 @@ | ||
| 1 | -module ShortFilename | ||
| 2 | - | ||
| 3 | - def short_filename(filename, limit_chars = 43) | ||
| 4 | - extname = File.extname(filename) | ||
| 5 | - basename = File.basename(filename,extname) | ||
| 6 | - return shrink(basename, extname, limit_chars) + extname | ||
| 7 | - end | ||
| 8 | - | ||
| 9 | - def short_filename_upper_ext(filename, limit_chars = 43) | ||
| 10 | - extname = File.extname(filename) | ||
| 11 | - display_name = shrink(File.basename(filename, extname), extname, limit_chars) | ||
| 12 | - return extname.present? ? (display_name + ' - ' + extname.upcase.delete(".")) : display_name | ||
| 13 | - end | ||
| 14 | - | ||
| 15 | - def shrink(filename, extname, limit_chars) | ||
| 16 | - return filename if filename.size <= limit_chars | ||
| 17 | - str_complement = '(...)' | ||
| 18 | - return filename[0..(limit_chars - extname.size - str_complement.size - 1)] + str_complement | ||
| 19 | - end | ||
| 20 | - | ||
| 21 | -end |
plugins/context_content/views/blocks/context_content.html.erb
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | <%= instance_eval(&block.content_image(content)) if block.show_image %> | 6 | <%= instance_eval(&block.content_image(content)) if block.show_image %> |
| 7 | </div> | 7 | </div> |
| 8 | <% if block.show_name %> | 8 | <% if block.show_name %> |
| 9 | - <div class="name"><%= short_filename(content.name, 30) %></div> | 9 | + <div class="name"><%= content.name %></div> |
| 10 | <% end %> | 10 | <% end %> |
| 11 | </a> | 11 | </a> |
| 12 | </span> | 12 | </span> |
test/unit/application_helper_test.rb
| @@ -564,18 +564,6 @@ class ApplicationHelperTest < ActionView::TestCase | @@ -564,18 +564,6 @@ class ApplicationHelperTest < ActionView::TestCase | ||
| 564 | assert_equal environment.theme, current_theme | 564 | assert_equal environment.theme, current_theme |
| 565 | end | 565 | end |
| 566 | 566 | ||
| 567 | - should 'trunc to 15 chars the big filename' do | ||
| 568 | - assert_equal 'AGENDA(...).mp3', short_filename('AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA.mp3',15) | ||
| 569 | - end | ||
| 570 | - | ||
| 571 | - should 'trunc to default limit the big filename' do | ||
| 572 | - assert_equal 'AGENDA_CULTURA_-_FESTA_DE_VAQUEIRO(...).mp3', short_filename('AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA.mp3') | ||
| 573 | - end | ||
| 574 | - | ||
| 575 | - should 'does not trunc short filename' do | ||
| 576 | - assert_equal 'filename.mp3', short_filename('filename.mp3') | ||
| 577 | - end | ||
| 578 | - | ||
| 579 | should 'return nil when :show_balloon_with_profile_links_when_clicked is not enabled in environment' do | 567 | should 'return nil when :show_balloon_with_profile_links_when_clicked is not enabled in environment' do |
| 580 | env = Environment.default | 568 | env = Environment.default |
| 581 | env.stubs(:enabled?).with(:show_balloon_with_profile_links_when_clicked).returns(false) | 569 | env.stubs(:enabled?).with(:show_balloon_with_profile_links_when_clicked).returns(false) |
test/unit/short_filename_test.rb
| @@ -1,34 +0,0 @@ | @@ -1,34 +0,0 @@ | ||
| 1 | -require_relative "../test_helper" | ||
| 2 | - | ||
| 3 | -class NoosferoFilenamesTest < ActiveSupport::TestCase | ||
| 4 | - | ||
| 5 | - include ShortFilename | ||
| 6 | - | ||
| 7 | - should 'trunc to 15 chars the big filename' do | ||
| 8 | - assert_equal 'AGENDA(...).mp3', short_filename('AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA.mp3',15) | ||
| 9 | - end | ||
| 10 | - | ||
| 11 | - should 'trunc to default limit the big filename' do | ||
| 12 | - assert_equal 'AGENDA_CULTURA_-_FESTA_DE_VAQUEIRO(...).mp3', short_filename('AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA.mp3') | ||
| 13 | - end | ||
| 14 | - | ||
| 15 | - should 'does not trunc short filename' do | ||
| 16 | - assert_equal 'filename.mp3', short_filename('filename.mp3') | ||
| 17 | - end | ||
| 18 | - | ||
| 19 | - should 'highlight the file extansion' do | ||
| 20 | - assert_equal 'AGENDA(...) - MP3', short_filename_upper_ext('AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA.mp3',15) | ||
| 21 | - | ||
| 22 | - assert_equal 'AGENDA - MP3', short_filename_upper_ext('AGENDA.mp3',15) | ||
| 23 | - end | ||
| 24 | - | ||
| 25 | - should 'return the full filename if its size is smaller than the limit' do | ||
| 26 | - assert_equal 'AGENDA', shrink('AGENDA', 'mp3', 15) | ||
| 27 | - end | ||
| 28 | - | ||
| 29 | - should 'shrink the filename if its size is bigger than the limit' do | ||
| 30 | - assert_equal 'AGENDA(...)', shrink('AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA', 'mp3', 14) | ||
| 31 | - end | ||
| 32 | - | ||
| 33 | -end | ||
| 34 | - |