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-10 05:50 am

[dw-free] No way to get the userpic URL for OpenID users (comment posters) via S2

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

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

Expose URL to get userpics for all account types.

Patch by [personal profile] afuna.

Files modified:
  • bin/upgrading/s2layers/core2.s2
  • cgi-bin/LJ/S2.pm
--------------------------------------------------------------------------------
diff -r eb838ee08a5e -r c6605f3a5ac7 bin/upgrading/s2layers/core2.s2
--- a/bin/upgrading/s2layers/core2.s2	Sun May 10 05:41:22 2009 +0000
+++ b/bin/upgrading/s2layers/core2.s2	Sun May 10 05:50:44 2009 +0000
@@ -272,6 +272,7 @@ class UserLite
     var readonly string username "Canonical Username, ex: johnqpub.  Note that if journal_type is an external identity, there will be no username, so this field will be a display version of their URL, longer than 25 characters, and with characters other than a-z, 0-9 and underscore.";
     var readonly string name "User's formatted name, ex: John Q. Public";
     var readonly string journal_type "Type of account: P (personal), C (community), Y (syndicated), I (external identity) etc";
+    var readonly string userpic_listing_url "URL of a page listing this user's userpics";
 
     var Link{} data_link "Links to various machine-readable data sources relating to this user";
     var string[] data_links_order "An array of data views which can be used to order the data_link hash";
@@ -452,7 +453,6 @@ class User extends UserLite
 "A more information-rich userinfo structure"
 {
     var Image default_pic "Information about default userpic";
-    var readonly string userpic_listing_url "URL of a page listing this user's userpics";
     var readonly string website_url "URL pointer to user's website";
     var readonly string website_name "'pretty' name of user's website";
     function print_userpic() [fixed] "Print the userpic for this user";
@@ -3658,20 +3658,9 @@ function EntryLite::print_userpic() [fix
     print "<div class=\"userpic\">";
     if ( defined $this.userpic )
     {
-        if ( $this.poster.journal_type == "I" )
-        {
-            # link to openid users' allpics.bml is in the form of
-            #    /allpics.bml?user=ext_####
-            # but their username is their remote URL. 
-            # AFAIK, the ext_#### form is not exposed through S2
-            $this.userpic->print();
-        }
-        else
-        {
-            print """<a href="$*SITEROOT/allpics.bml?user=$this.poster.username">""";
-            $this.userpic->print();
-            print "</a>";
-        }
+        print """<a href="$this.poster.userpic_listing_url">""";
+        $this.userpic->print();
+        print "</a>";
     }
     println "</div>";
 }
diff -r eb838ee08a5e -r c6605f3a5ac7 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm	Sun May 10 05:41:22 2009 +0000
+++ b/cgi-bin/LJ/S2.pm	Sun May 10 05:50:44 2009 +0000
@@ -2188,7 +2188,6 @@ sub User
     my $o = UserLite($u);
     $o->{'_type'} = "User";
     $o->{'default_pic'} = Image_userpic($u, $u->{'defaultpicid'});
-    $o->{'userpic_listing_url'} = "$LJ::SITEROOT/allpics.bml?user=".$u->{'user'};
     $o->{'website_url'} = LJ::ehtml($u->{'url'});
     $o->{'website_name'} = LJ::ehtml($u->{'urlname'});
     return $o;
@@ -2222,6 +2221,7 @@ sub UserLite
         'username' => LJ::ehtml($u->display_name),
         'name' => LJ::ehtml($u->{'name'}),
         'journal_type' => $u->{'journaltype'},
+        'userpic_listing_url' => "$LJ::SITEROOT/allpics.bml?user=".$u->{'user'},
         'data_link' => {
             'foaf' => Link("$LJ::SITEROOT/users/" . LJ::ehtml($u->{'user'}) . '/data/foaf',
                            "FOAF",
--------------------------------------------------------------------------------