Skip to content

Commit

Permalink
Merge pull request #553 from fatkodima/file-names-truncation
Browse files Browse the repository at this point in the history
Truncate long file names in web ui
  • Loading branch information
danmayer authored Oct 11, 2024
2 parents 83c55ce + c9fc2e9 commit ab80293
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/coverband/utils/html_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,16 @@ def shortened_filename(source_file)

def link_to_source_file(source_file)
data_loader_url = "#{base_path}load_file_details?filename=#{source_file.filename}"
%(<a href="##{id source_file}" class="src_link" title="#{shortened_filename source_file}" data-loader-url="#{data_loader_url}" onclick="src_link_click(this)">#{shortened_filename source_file}</a>)
%(<a href="##{id source_file}" class="src_link" title="#{shortened_filename source_file}" data-loader-url="#{data_loader_url}" onclick="src_link_click(this)">#{truncate(shortened_filename(source_file))}</a>)
end

def truncate(text, length: 50)
if text.length <= length
text
else
omission = "..."
"#{text[0, length - omission.length]}#{omission}"
end
end
end
end
Expand Down

0 comments on commit ab80293

Please sign in to comment.