afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-07-19 07:55 am

[dw-free] fold more pages into user-space

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

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

Redirect allpics.bml to /icons

Patch by [personal profile] afuna.

Files modified:
  • cgi-bin/Apache/LiveJournal.pm
  • cgi-bin/DW/Logic/ProfilePage.pm
  • cgi-bin/LJ/Event/NewUserpic.pm
  • cgi-bin/LJ/S2.pm
  • cgi-bin/LJ/User.pm
  • cgi-bin/ljfeed.pl
  • cgi-bin/ljlib.pl
  • cgi-bin/talklib.pl
  • cgi-bin/weblib.pl
  • htdocs/allpics.bml
  • htdocs/support/see_request.bml
  • htdocs/tools/endpoints/multisearch.bml
--------------------------------------------------------------------------------
diff -r af27432f0c0f -r 2a309f4e27e2 cgi-bin/Apache/LiveJournal.pm
--- a/cgi-bin/Apache/LiveJournal.pm	Sun Jul 19 07:34:30 2009 +0000
+++ b/cgi-bin/Apache/LiveJournal.pm	Sun Jul 19 07:54:57 2009 +0000
@@ -575,6 +575,11 @@ sub trans
                 or return 404;
 
             return redir($r, "$LJ::SITEROOT/update.bml?usejournal=".$u->{'user'});
+        }
+        
+        if ( $opts->{mode} eq "icons" ) {
+            $r->notes->{_journal} = $opts->{user};
+            return $bml_handler->( "$LJ::HOME/htdocs/allpics.bml" );
         }
 
         %RQ = %$opts;
diff -r af27432f0c0f -r 2a309f4e27e2 cgi-bin/DW/Logic/ProfilePage.pm
--- a/cgi-bin/DW/Logic/ProfilePage.pm	Sun Jul 19 07:34:30 2009 +0000
+++ b/cgi-bin/DW/Logic/ProfilePage.pm	Sun Jul 19 07:54:57 2009 +0000
@@ -107,7 +107,7 @@ sub userpic {
         # now determine what caption text to show
         if ( $remote && $remote->can_manage( $u ) ) {
             if ( LJ::userpic_count( $u ) ) {
-                $ret->{userpic_url} = "$LJ::SITEROOT/allpics.bml?user=$user";
+                $ret->{userpic_url} = $u->allpics_base;
                 $ret->{caption_text} = LJ::Lang::ml( '.section.edit' );
                 $ret->{caption_url} = "$LJ::SITEROOT/editpics.bml?authas=$user"
             } else {
@@ -117,7 +117,7 @@ sub userpic {
             }
         } else {
             if ( LJ::userpic_count( $u ) ) {
-                $ret->{userpic_url} = "$LJ::SITEROOT/allpics.bml?user=$user";
+                $ret->{userpic_url} = $u->allpics_base;
             }
         }
     }
@@ -294,7 +294,7 @@ sub userpic_stats {
     push @ret, LJ::Lang::ml( '.details.userpics', {
         num_raw => $ct,
         num_comma => LJ::commafy( $ct ),
-        aopts => "href='$LJ::SITEROOT/allpics.bml?user=" . $u->user . "'",
+        aopts => "href='" . $u->allpics_base . "'",
     } )
         unless $u->is_syndicated;
     
diff -r af27432f0c0f -r 2a309f4e27e2 cgi-bin/LJ/Event/NewUserpic.pm
--- a/cgi-bin/LJ/Event/NewUserpic.pm	Sun Jul 19 07:34:30 2009 +0000
+++ b/cgi-bin/LJ/Event/NewUserpic.pm	Sun Jul 19 07:54:57 2009 +0000
@@ -40,6 +40,7 @@ sub as_email_string {
     my $poster = $self->userpic->owner->user;
     my $userpic = $self->userpic->url;
     my $journal_url = $self->userpic->owner->journal_base;
+    my $icons_url = $self->userpic->owner->allpics_base;
     my $profile = $self->userpic->owner->profile_url;
 
     my $email = "Hi $username,
@@ -50,7 +51,7 @@ You can:
 You can:
 
   - View all of $poster\'s userpics:
-    $LJ::SITEROOT/allpics.bml?user=$poster";
+    $icons_url";
 
     unless ( $u->watches( $self->userpic->owner ) ) {
         $email .= "
@@ -77,6 +78,7 @@ sub as_email_html {
     my $postername = $self->userpic->owner->user;
     my $userpic = $self->userpic->imgtag;
     my $journal_url = $self->userpic->owner->journal_base;
+    my $icons_url = $self->userpic->owner->allpics_base;
     my $profile = $self->userpic->owner->profile_url;
 
     my $email = "Hi $username,
@@ -85,7 +87,7 @@ sub as_email_html {
 <blockquote>$userpic</blockquote>
 You can:<ul>";
 
-    $email .= "<li><a href=\"$LJ::SITEROOT/allpics.bml?user=$postername\">View all of $postername\'s userpics</a></li>";
+    $email .= "<li><a href=\"$icons_url\">View all of $postername\'s userpics</a></li>";
     $email .= "<li><a href=\"$LJ::SITEROOT/manage/circle/add.bml?user=$postername&action=subscribe\">Add $postername to your reading list</a></li>"
         unless $u->watches( $self->userpic->owner );
     $email .= "<li><a href=\"$journal_url\">View their journal</a></li>";
diff -r af27432f0c0f -r 2a309f4e27e2 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm	Sun Jul 19 07:34:30 2009 +0000
+++ b/cgi-bin/LJ/S2.pm	Sun Jul 19 07:54:57 2009 +0000
@@ -2245,7 +2245,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'},
+        'userpic_listing_url' => $u->allpics_base,
         'data_link' => {
             'foaf' => Link("$LJ::SITEROOT/users/" . LJ::ehtml($u->{'user'}) . '/data/foaf',
                            "FOAF",
diff -r af27432f0c0f -r 2a309f4e27e2 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Sun Jul 19 07:34:30 2009 +0000
+++ b/cgi-bin/LJ/User.pm	Sun Jul 19 07:54:57 2009 +0000
@@ -5156,7 +5156,7 @@ sub activate_userpics {
 
 sub allpics_base {
     my $u = shift;
-    return "$LJ::SITEROOT/allpics.bml?user=" . $u->user;
+    return $u->journal_base . "/icons";;
 }
 
 
@@ -7172,7 +7172,7 @@ sub user_search_display {
         $ret .= "<table style='height: 105px'><tr>";
 
         $ret .= "<td style='width: 100px; text-align: center;'>";
-        $ret .= "<a href='/allpics.bml?user=$u->{user}'>";
+        $ret .= "<a href='" . $u->allpics_base . "'>";
         if (my $picid = $get_picid->($u)) {
             $ret .= "<img src='$LJ::USERPIC_ROOT/$picid/$u->{userid}' alt='$u->{user} userpic' style='border: 1px solid #000;' />";
         } else {
diff -r af27432f0c0f -r 2a309f4e27e2 cgi-bin/ljfeed.pl
--- a/cgi-bin/ljfeed.pl	Sun Jul 19 07:34:30 2009 +0000
+++ b/cgi-bin/ljfeed.pl	Sun Jul 19 07:54:57 2009 +0000
@@ -896,7 +896,7 @@ sub create_view_userpics {
     $feed->title( "$u->{user}'s userpics" );
 
     $feed->author( $author );
-    $feed->add_link( $make_link->( 'alternate', 'text/html', "$LJ::SITEROOT/allpics.bml?user=$u->{user}" ) );
+    $feed->add_link( $make_link->( 'alternate', 'text/html', $u->allpics_base ) );
     $feed->add_link( $make_link->( 'self', 'text/xml', $u->journal_base() . "/data/userpics" ) );
 
     # now start building all the userpic data
diff -r af27432f0c0f -r 2a309f4e27e2 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl	Sun Jul 19 07:34:30 2009 +0000
+++ b/cgi-bin/ljlib.pl	Sun Jul 19 07:54:57 2009 +0000
@@ -186,6 +186,9 @@ LJ::MemCache::init();
                      # within journal styles.
                      "des" => "Update Journal",
                  },
+                 "icons" => {
+                    "des" => "Icons",
+                 }
                  );
 
 ## we want to set this right away, so when we get a HUP signal later
diff -r af27432f0c0f -r 2a309f4e27e2 cgi-bin/talklib.pl
--- a/cgi-bin/talklib.pl	Sun Jul 19 07:34:30 2009 +0000
+++ b/cgi-bin/talklib.pl	Sun Jul 19 07:54:57 2009 +0000
@@ -1680,7 +1680,7 @@ sub talkform {
     if ($res{'pickw_count'}) {
         $ret .= BML::ml('.label.picturetouse2',
                         {
-                            'aopts'=>"href='$LJ::SITEROOT/allpics.bml?user=$remote->{'user'}'"}) . " ";
+                            'aopts'=>"href='" . $remote->allpics_base. "'"}) . " ";
         my @pics;
         for (my $i=1; $i<=$res{'pickw_count'}; $i++) {
             push @pics, $res{"pickw_$i"};
diff -r af27432f0c0f -r 2a309f4e27e2 cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl	Sun Jul 19 07:34:30 2009 +0000
+++ b/cgi-bin/weblib.pl	Sun Jul 19 07:54:57 2009 +0000
@@ -716,7 +716,7 @@ sub create_qr_div {
         if ($res{'pickw_count'}) {
             $qrhtml .= BML::ml('/talkpost.bml.label.picturetouse2',
                                {
-                                   'aopts'=>"href='$LJ::SITEROOT/allpics.bml?user=$remote->{'user'}'"});
+                                   'aopts'=>"href='" . $remote->allpics_base . "'"});
             my @pics;
             for (my $i=1; $i<=$res{'pickw_count'}; $i++) {
                 push @pics, $res{"pickw_$i"};
diff -r af27432f0c0f -r 2a309f4e27e2 htdocs/allpics.bml
--- a/htdocs/allpics.bml	Sun Jul 19 07:34:30 2009 +0000
+++ b/htdocs/allpics.bml	Sun Jul 19 07:54:57 2009 +0000
@@ -6,10 +6,20 @@
     use strict;
     use vars qw(%GET $title $body $head);
 
+    BML::set_language_scope( '/allpics.bml' );
+
     $title = "$ML{'.title'}";
     $body = "";
     $head = "";
- 
+
+    my $r = BML::get_request();
+
+    # if new-style URLs, get the GET{user} arg from the request notes,
+    # which was set by LiveJournal.pm
+    unless ( $GET{user} ) {
+        $GET{user} = $r->notes->{_journal};
+    }
+
     my $user = LJ::canonical_username($GET{'user'});
     my $remote = LJ::get_remote();
     my $u = ! $user || $remote && $remote->{'user'} eq $user ? $remote : LJ::load_user($user);
@@ -17,6 +27,19 @@
     unless ($u) {
         $body = "<?h1 $ML{'Error'} h1?><?p $ML{'.error.noparam'} p?>";
         return;
+    }
+
+    # redirect /icons to their subdomain urls
+    my $domain = BML::get_client_header( "Host" );
+    if ( $LJ::ONLY_USER_VHOSTS ) {
+        my $url = $u->journal_base . "/icons";
+
+        my $good_domain = $url;
+        $good_domain =~ s!^http://!!;
+        $good_domain =~ s!/.*!!;
+        if ( $domain ne $good_domain ) {
+            return BML::redirect( $url );
+        }
     }
 
     $u->preload_props("opt_blockrobots", "adult_content") if $u->is_visible;
diff -r af27432f0c0f -r 2a309f4e27e2 htdocs/support/see_request.bml
--- a/htdocs/support/see_request.bml	Sun Jul 19 07:34:30 2009 +0000
+++ b/htdocs/support/see_request.bml	Sun Jul 19 07:54:57 2009 +0000
@@ -305,7 +305,7 @@ body<=
         # db twice.
         LJ::load_userpics(\%pic, [ $u, $picid ]);
         my $userpic_obj = LJ::Userpic->new( $u, $picid );
-        $ret .= "<a href='$LJ::SITEROOT/allpics.bml?user=$u->{'user'}'>";
+        $ret .= "<a href='" . $u->allpics_base . "'>";
         $ret .= $userpic_obj->imgtag;
         $ret .= "</a>";
     }
diff -r af27432f0c0f -r 2a309f4e27e2 htdocs/tools/endpoints/multisearch.bml
--- a/htdocs/tools/endpoints/multisearch.bml	Sun Jul 19 07:34:30 2009 +0000
+++ b/htdocs/tools/endpoints/multisearch.bml	Sun Jul 19 07:54:57 2009 +0000
@@ -32,7 +32,7 @@
         if ($user) {
             if (my $u = LJ::load_user($user)) {
                 if ($what eq "pics") {
-                    $url = "$LJ::SITEROOT/allpics.bml?user=$user";
+                    $url = $u->allpics_base;
                 } elsif ($output eq "foaf") {
                     $url = LJ::journal_base($user) . '/data/foaf';
                 } else {
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org