[dw-free] Width/height attributes absent from non-DW userheads in email
[commit: http://hg.dwscoalition.org/dw-free/rev/ce0787149088]
http://bugs.dwscoalition.org/show_bug.cgi?id=3998
Write down the width/height attributes for external usernames.
Patch by
fu.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3998
Write down the width/height attributes for external usernames.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/DW/External/Site.pm
- cgi-bin/DW/External/Site/ArchiveofOurOwn.pm
- cgi-bin/DW/External/Site/DeadJournal.pm
- cgi-bin/DW/External/Site/Diigo.pm
- cgi-bin/DW/External/Site/Dreamwidth.pm
- cgi-bin/DW/External/Site/Etsy.pm
- cgi-bin/DW/External/Site/Inksome.pm
- cgi-bin/DW/External/Site/InsaneJournal.pm
- cgi-bin/DW/External/Site/JournalFen.pm
- cgi-bin/DW/External/Site/LiveJournal.pm
- cgi-bin/DW/External/Site/Tumblr.pm
- cgi-bin/DW/External/Site/Twitter.pm
- cgi-bin/DW/External/Site/Unknown.pm
- cgi-bin/DW/External/User.pm
-------------------------------------------------------------------------------- diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site.pm --- a/cgi-bin/DW/External/Site.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site.pm Fri Oct 28 19:14:26 2011 +0800 @@ -167,23 +167,32 @@ return $self->journal_url( $u ) . 'data/atom'; } -# returns the badge_image_url for this user on this site. -sub badge_image_url { +# returns the badge_image info for this user on this site. +sub badge_image { my ( $self, $u ) = @_; + croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; # override this on a site-by-site basis if needed my $type = $self->journaltype( $u ) || 'P'; my $gif = { - P => '/img/userinfo.gif', - C => '/img/community.gif', - Y => '/img/syndicated.gif', + # URL, width, height + P => [ '/img/userinfo.gif', 17, 17 ], + C => [ '/img/community.gif', 16, 16 ], + Y => [ '/img/syndicated.gif', 16, 16 ], }; + + my $img = $gif->{$type}; + return { # this will do the right thing for an lj-based site, # but it's better to override this with cached images # to avoid hammering the remote site with image requests. - return "http://$self->{hostname}$gif->{$type}"; + + url => "http://$self->{hostname}$img->[0]", + width => $img->[1], + height => $img->[2], + } } # adjust the request for any per-site limitations diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/ArchiveofOurOwn.pm --- a/cgi-bin/DW/External/Site/ArchiveofOurOwn.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/ArchiveofOurOwn.pm Fri Oct 28 19:14:26 2011 +0800 @@ -40,12 +40,18 @@ # argument: DW::External::User -# returns URL to the badge image (head icon) for this user -sub badge_image_url { +# returns info for the to the badge image (head icon) for this user +sub badge_image { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; - return 'http://archiveofourown.org/favicon.ico'; + + return { + url => 'http://archiveofourown.org/favicon.ico', + width => 16, + height => 16, + } + ; } 1; diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/DeadJournal.pm --- a/cgi-bin/DW/External/Site/DeadJournal.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/DeadJournal.pm Fri Oct 28 19:14:26 2011 +0800 @@ -38,19 +38,25 @@ # argument: DW::External::User -# returns URL to the badge image (head icon) for this user -sub badge_image_url { +# returns info for the badge image (head icon) for this user +sub badge_image { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; my $type = $self->journaltype( $u ) || 'P'; my $gif = { - P => '/external/dj-userinfo.gif', - C => '/external/dj-community.gif', - Y => '/external/dj-syndicated.gif', + P => [ '/external/dj-userinfo.gif', 17, 25 ], + C => [ '/external/dj-community.gif', 17, 17 ], + Y => [ '/external/dj-syndicated.gif', 17, 17 ] }; - return $LJ::IMGPREFIX . $gif->{$type}; + + my $img = $gif->{$type}; + return { + url => $LJ::IMGPREFIX . $img->[0], + width => $img->[1], + height => $img->[2], + } } diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/Diigo.pm --- a/cgi-bin/DW/External/Site/Diigo.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/Diigo.pm Fri Oct 28 19:14:26 2011 +0800 @@ -60,14 +60,18 @@ # argument: DW::External::User -# returns URL to the badge image (userhead icon) for this user -sub badge_image_url { +# returns info for the badge image (userhead icon) for this user +sub badge_imagel { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; # for lack of anything better, let's use the favicon - return "http://www.diigo.com/favicon.ico"; + return { + url => "http://www.diigo.com/favicon.ico", + width => 16, + height => 16, + } } diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/Dreamwidth.pm --- a/cgi-bin/DW/External/Site/Dreamwidth.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/Dreamwidth.pm Fri Oct 28 19:14:26 2011 +0800 @@ -51,19 +51,25 @@ # argument: DW::External::User -# returns URL to the badge image (head icon) for this user -sub badge_image_url { +# returns info for the badge image (head icon) for this user +sub badge_image { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; my $type = $self->journaltype( $u ) || 'P'; - my $img = { - P => '/silk/identity/user.png', - C => '/silk/identity/community.png', - Y => '/silk/identity/feed.png', + my $gif = { + P => [ '/silk/identity/user.png', 16, 16 ], + C => [ '/silk/identity/community.png', 16, 16 ], + Y => [ '/silk/identity/feed.png', 16, 16 ], }; - return $LJ::IMGPREFIX . $img->{$type}; + + my $img = $gif->{$type}; + return { + url => $LJ::IMGPREFIX . $img->[0], + width => $img->[1], + height => $img->[2], + } } sub canonical_username { diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/Etsy.pm --- a/cgi-bin/DW/External/Site/Etsy.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/Etsy.pm Fri Oct 28 19:14:26 2011 +0800 @@ -60,14 +60,18 @@ # argument: DW::External::User -# returns URL to the badge image (userhead icon) for this user -sub badge_image_url { +# returns info for the badge image (userhead icon) for this user +sub badge_image { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; # for lack of anything better, let's use the favicon - return "http://www.etsy.com/favicon.ico"; + return { + url => "http://www.etsy.com/favicon.ico", + width => 16, + height => 16, + } } diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/Inksome.pm --- a/cgi-bin/DW/External/Site/Inksome.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/Inksome.pm Fri Oct 28 19:14:26 2011 +0800 @@ -52,14 +52,18 @@ # argument: DW::External::User -# returns URL to the badge image (head icon) for this user -sub badge_image_url { +# returns info for the badge image (head icon) for this user +sub badge_image { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; # Inksome went away, so just assume every account is personal - return "$LJ::IMGPREFIX/external/ink-userinfo.gif"; + return { + url => "$LJ::IMGPREFIX/external/ink-userinfo.gif", + width => 17, + height => 17, + } } diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/InsaneJournal.pm --- a/cgi-bin/DW/External/Site/InsaneJournal.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/InsaneJournal.pm Fri Oct 28 19:14:26 2011 +0800 @@ -38,19 +38,26 @@ # argument: DW::External::User -# returns URL to the badge image (head icon) for this user -sub badge_image_url { +# returns info for the badge image (head icon) for this user +sub badge_image { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; my $type = $self->journaltype( $u ) || 'P'; my $gif = { - P => '/external/ij-userinfo.gif', - C => '/external/ij-community.gif', - Y => '/external/lj-syndicated.gif', + P => [ '/external/ij-userinfo.gif', 21, 20 ], + C => [ '/external/ij-community.gif', 18, 13 ], + Y => [ '/external/lj-syndicated.gif', 16, 16 ], }; - return $LJ::IMGPREFIX . $gif->{$type}; + + my $img = $gif->{$type}; + return { + url => $LJ::IMGPREFIX . $img->[0], + width => $img->[1], + height => $img->[2], + } + } diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/JournalFen.pm --- a/cgi-bin/DW/External/Site/JournalFen.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/JournalFen.pm Fri Oct 28 19:14:26 2011 +0800 @@ -38,19 +38,25 @@ # argument: DW::External::User -# returns URL to the badge image (head icon) for this user -sub badge_image_url { +# returns info for the badge image (head icon) for this user +sub badge_image { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; my $type = $self->journaltype( $u ) || 'P'; my $gif = { - P => '/external/lj-userinfo.gif', - C => '/external/lj-community.gif', - Y => '/external/lj-syndicated.gif', + P => [ '/external/lj-userinfo.gif', 17, 17 ], + C => [ '/external/lj-community.gif', 16, 16 ], + Y => [ '/external/lj-syndicated.gif', 16, 16 ], }; - return $LJ::IMGPREFIX . $gif->{$type}; + + my $img = $gif->{$type}; + return { + url => $LJ::IMGPREFIX . $img->[0], + width => $img->[1], + height => $img->[2], + } } sub canonical_username { diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/LiveJournal.pm --- a/cgi-bin/DW/External/Site/LiveJournal.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/LiveJournal.pm Fri Oct 28 19:14:26 2011 +0800 @@ -51,19 +51,25 @@ # argument: DW::External::User -# returns URL to the badge image (head icon) for this user -sub badge_image_url { +# returns info for the badge image (head icon) for this user +sub badge_image { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; my $type = $self->journaltype( $u ) || 'P'; my $gif = { - P => '/external/lj-userinfo.gif', - C => '/external/lj-community.gif', - Y => '/external/lj-syndicated.gif', + P => [ '/external/lj-userinfo.gif', 17, 17 ], + C => [ '/external/lj-community.gif', 16, 16 ], + Y => [ '/external/lj-syndicated.gif', 16, 16 ], }; - return $LJ::IMGPREFIX . $gif->{$type}; + + my $img = $gif->{$type}; + return { + url => $LJ::IMGPREFIX . $img->[0], + width => $img->[1], + height => $img->[2], + } } sub canonical_username { diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/Tumblr.pm --- a/cgi-bin/DW/External/Site/Tumblr.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/Tumblr.pm Fri Oct 28 19:14:26 2011 +0800 @@ -60,14 +60,18 @@ # argument: DW::External::User -# returns URL to the badge image ("t" icon) for this user -sub badge_image_url { +# returns info for the badge image ("t" icon) for this user +sub badge_image { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; # for lack of anything better, let's use the favicon - return "http://www.tumblr.com/favicon.ico"; + return { + url => "http://www.tumblr.com/favicon.ico", + width => 16, + height => 16, + }; } diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/Twitter.pm --- a/cgi-bin/DW/External/Site/Twitter.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/Twitter.pm Fri Oct 28 19:14:26 2011 +0800 @@ -59,14 +59,18 @@ # argument: DW::External::User -# returns URL to the badge image (head icon) for this user -sub badge_image_url { +# returns info for the badge image (head icon) for this user +sub badge_image { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; # for lack of anything better, let's use the favicon - return "http://twitter.com/favicon.ico"; + return { + url => "http://twitter.com/favicon.ico", + width => 16, + height => 16, + } } diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/Site/Unknown.pm --- a/cgi-bin/DW/External/Site/Unknown.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/Site/Unknown.pm Fri Oct 28 19:14:26 2011 +0800 @@ -48,14 +48,18 @@ # argument: DW::External::User -# returns URL to the badge image (head icon) for this user -sub badge_image_url { +# returns info for the badge image (head icon) for this user +sub badge_image { my ( $self, $u ) = @_; croak 'need a DW::External::User' unless $u && ref $u eq 'DW::External::User'; # since we don't know what site this is, they can have an "unknown" icon - return "$LJ::IMGPREFIX/silk/identity/user_other.png"; + return { + url => "$LJ::IMGPREFIX/silk/identity/user_other.png", + width => 16, + height => 16, + }; } diff -r 69063ffdba54 -r ce0787149088 cgi-bin/DW/External/User.pm --- a/cgi-bin/DW/External/User.pm Fri Oct 28 18:29:34 2011 +0800 +++ b/cgi-bin/DW/External/User.pm Fri Oct 28 19:14:26 2011 +0800 @@ -66,12 +66,12 @@ my $user = $self->user; my $profile_url = $self->site->profile_url( $self ); my $journal_url = $self->site->journal_url( $self ); - my $badge_image_url = $self->site->badge_image_url( $self ); + my $badge_image = $self->site->badge_image( $self ); my $display_class = $opts{no_ljuser_class} ? "" : " class='ljuser'"; my $domain = $self->site->{domain} ? $self->site->{domain} : $self->site->{hostname}; return "<span style='white-space: nowrap;'$display_class><a href='$profile_url'>" . - "<img src='$badge_image_url' alt='[$domain profile] ' style='vertical-align: bottom; border: 0; padding-right: 1px;' />" . + "<img src='$badge_image->{url}' alt='[$domain profile] ' style='vertical-align: bottom; border: 0; padding-right: 1px;' width='$badge_image->{width}' height='$badge_image->{height}'/>" . "</a><a href='$journal_url'><b>$user</b></a></span>"; } --------------------------------------------------------------------------------