mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-05-18 12:28 am

[dw-free] Title text from userpics gone

[commit: http://hg.dwscoalition.org/dw-free/rev/59a3749375b7]

http://bugs.dwscoalition.org/show_bug.cgi?id=876

Add title text back to userpics on site scheme and some S2 pages.

Patch by [personal profile] afuna.

Files modified:
  • bin/upgrading/s2layers/core2.s2
  • cgi-bin/LJ/S2.pm
  • cgi-bin/LJ/Userpic.pm
  • htdocs/talkread.bml
--------------------------------------------------------------------------------
diff -r 02dc361587b1 -r 59a3749375b7 bin/upgrading/s2layers/core2.s2
--- a/bin/upgrading/s2layers/core2.s2	Mon May 18 00:16:19 2009 +0000
+++ b/bin/upgrading/s2layers/core2.s2	Mon May 18 00:28:26 2009 +0000
@@ -2535,7 +2535,7 @@ function Image::as_string(string alttext
 function Image::as_string(string alttext) [fixed] : string
 "You most likely want to use Image::print instead.  Prints HTML for the image with a given alttext. Using meaningful alttext is strongly recommended to improve the accessibility of your layout. Overriding this function is NOT RECOMMENDED. Overriding this function could prevent sitewide improvements to styles, accessibility, or other functionality from operating in your layout."
 {
-    return "<img src=\"$.url\" title=\"\" alt=\"" + $alttext + "\"" +
+    return "<img src=\"$.url\" title=\"$.extra{"title"}\" alt=\"$alttext\"" +
         htmlattr("height", $.height) +
         htmlattr("width", $.width) + " />";
 }
diff -r 02dc361587b1 -r 59a3749375b7 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm	Mon May 18 00:16:19 2009 +0000
+++ b/cgi-bin/LJ/S2.pm	Mon May 18 00:28:26 2009 +0000
@@ -2127,12 +2127,16 @@ sub Image_userpic
         $alttext = $kwstr;
     }
 
+    my $title = $u->display_name;
+    $title .= $kw ? ": $kw" : ": (default)";
+    
     return {
         '_type' => "Image",
         'url' => "$LJ::USERPIC_ROOT/$picid/$u->{'userid'}",
         'width' => $width,
         'height' => $height,
         'alttext' => LJ::ehtml( $alttext ),
+        'extra' => { title => LJ::ehtml( $title ) },
     };
 }
 
diff -r 02dc361587b1 -r 59a3749375b7 cgi-bin/LJ/Userpic.pm
--- a/cgi-bin/LJ/Userpic.pm	Mon May 18 00:16:19 2009 +0000
+++ b/cgi-bin/LJ/Userpic.pm	Mon May 18 00:28:26 2009 +0000
@@ -322,7 +322,7 @@ sub alttext {
 
 # returns an image tag of this userpic
 # optional parameters (which must be explicitly passed) include
-# width and keyword
+# width, keyword, and user (object)
 sub imgtag {
     my $self = shift;
     my %opts = @_;
@@ -340,8 +340,19 @@ sub imgtag {
 
     my $alttext = LJ::ehtml( $self->alttext( $keyword ) );
 
+    # if we passed in a user, format as if for entries or comments
+    # otherwise, print out keywords for additional context
+    my $title = "";
+    if ( $opts{user} ) {
+        $title = $opts{user}->display_name;
+        $title .= $opts{keyword} ? ": $opts{keyword}" : ": (default)";
+    } else {
+        $title = $keyword;
+    }    
+    $title = LJ::ehtml( $title );
+
     return '<img src="' . $self->url . '" width="' . $width .
-        '" alt="' . $alttext . '" class="userpic-img" />';
+        '" alt="' . $alttext . '" title="' . $title . '" class="userpic-img" />';
 }
 
 # FIXME: should have alt text, if it should be kept
diff -r 02dc361587b1 -r 59a3749375b7 htdocs/talkread.bml
--- a/htdocs/talkread.bml	Mon May 18 00:16:19 2009 +0000
+++ b/htdocs/talkread.bml	Mon May 18 00:28:26 2009 +0000
@@ -253,7 +253,7 @@ body<=
         my $apost = "</td>";
 
         # for each image, get the html imgtag
-        $ret .= $apre . $userpic->imgtag( keyword => $props->{picture_keyword} ) . $apost;
+        $ret .= $apre . $userpic->imgtag( keyword => $props->{picture_keyword}, user => $up ) . $apost;
     }
 
     $ret .= "<td class='attrib' valign='bottom'>";
@@ -554,8 +554,10 @@ body<=
                    my $postpic = LJ::Userpic->new( $pu, $post->{picid} );
 
                    # get the picture keyword from the comment properties
+                   # get the comment poster as well
                    my %kwopts = (
-                      keyword => $post->{props}->{'picture_keyword'}
+                      keyword => $post->{props}->{picture_keyword},
+                      user => $upost,
                    );
 
                    # build the imgtag for the userpic associated with the keyword
--------------------------------------------------------------------------------