Added truncation side-wide for too long strings;
This commit is contained in:
@@ -41,13 +41,25 @@ module ApplicationHelper
|
||||
|
||||
|
||||
# STRING HELPER
|
||||
def trimString str, length
|
||||
truncate str, :length => length.to_i, :omission => "…"
|
||||
end
|
||||
|
||||
def camelCaseString phrase
|
||||
phrase.gsub!(/^[a-z]|\s+[a-z]/) { |a| a.upcase }
|
||||
return phrase
|
||||
end
|
||||
|
||||
def trimString str, length
|
||||
truncate str, :length => length.to_i, :omission => "…"
|
||||
end
|
||||
|
||||
def trimTrack track, artist
|
||||
returnValue = track
|
||||
desiredLength = 60
|
||||
actualLength = track.length + artist.length
|
||||
overflow = actualLength - desiredLength
|
||||
|
||||
if actualLength > desiredLength
|
||||
returnValue = trimString track, track.length - overflow
|
||||
end
|
||||
return returnValue
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
module ArtistsHelper
|
||||
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
- @tracks.track.each do |track|
|
||||
- artist = track.artist.respond_to?(:name) ? track.artist.name : track.artist
|
||||
%li{:artist=>artist,:track=>track.name}
|
||||
= track.name
|
||||
= trimTrack(track.name, artist)
|
||||
%span by
|
||||
= link_to trimString(artist, 50), "#!/artists/#{CGI.escape(artist)}"
|
||||
@@ -3,6 +3,6 @@
|
||||
- @link = "#!/artists/#{CGI.escape(artist.name)}"
|
||||
.img= link_to image_tag(validate_img_url(artist.image, "artist", :large)), @link
|
||||
.text
|
||||
%h2= link_to artist.name, @link
|
||||
%h2= link_to trimString(artist.name, 55), @link
|
||||
%p
|
||||
= artist.listeners+" Listeners"
|
||||
@@ -44,7 +44,6 @@ function favourite_request(link, params){
|
||||
|
||||
function load_site_request(link, params){
|
||||
params = (typeof params == "undefined" || typeof params == "boolean") ? "" : params;
|
||||
|
||||
show_flash(false);
|
||||
|
||||
if(link != user_path)
|
||||
|
||||
@@ -91,7 +91,7 @@ function remove_links_from_description(){
|
||||
|
||||
function new_albums(){
|
||||
album_hover();
|
||||
album_add_show_songs_button();
|
||||
//album_add_show_songs_button();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
overflow: hidden;
|
||||
float: left;
|
||||
|
||||
|
||||
img {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ArtistsHelperTest < ActionView::TestCase
|
||||
end
|
||||
Reference in New Issue
Block a user