Committer: ailyin
LJSUP-8564 (bring identity users back to journal after authentication)U trunk/bin/upgrading/s2layers/core1.s2 U trunk/cgi-bin/LJ/Identity.pm U trunk/cgi-bin/LJ/S2/EntryPage.pm U trunk/cgi-bin/LJ/S2/RecentPage.pm U trunk/cgi-bin/LJ/S2.pm U trunk/htdocs/identity/login.bml
Modified: trunk/bin/upgrading/s2layers/core1.s2 =================================================================== --- trunk/bin/upgrading/s2layers/core1.s2 2011-04-12 09:05:48 UTC (rev 18854) +++ trunk/bin/upgrading/s2layers/core1.s2 2011-04-12 09:27:55 UTC (rev 18855) @@ -479,6 +479,9 @@ (if one of views == \$.view, already looking at that view)"; var readonly string[] views_order "An array of view identifiers which can be used to order the views hash."; + + var readonly string page_id "The page identifier- what to pass to /identity/login.bml so that it returns to this page after a successfull authorization."; + var readonly string head_content "Extra tags supplied by the server to go in the <head> section of the output HTML document. Layouts should include this in the head section if they are writing HTML."; Modified: trunk/cgi-bin/LJ/Identity.pm =================================================================== --- trunk/cgi-bin/LJ/Identity.pm 2011-04-12 09:05:48 UTC (rev 18854) +++ trunk/cgi-bin/LJ/Identity.pm 2011-04-12 09:27:55 UTC (rev 18855) @@ -212,6 +212,46 @@ } elsif ($forwhat eq 'external') { $returl = "$LJ::SITEROOT/gadgets/external-landing.bml?success"; $returl_fail = "$LJ::SITEROOT/gadgets/external-landing.bml?fail"; + } elsif ( $forwhat =~ /^journal\-([a-z_]+)(?:-(.*))?$/i ) { + my ( $journal, $extra ) = ( $1, $2 ); + my $journalu = LJ::load_user($journal); + + unless ($journalu) { + warn 'invalid journal'; + die; + } + + if ( !$extra ) { + # the journal itself + $returl = $returl_fail = $journalu->journal_base; + } elsif ( $extra =~ /^\d+$/ ) { + # an entry in the journal + + my $entry = LJ::Entry->new( $journalu, 'ditemid' => $extra ); + + unless ($entry) { + warn 'invalid entry'; + die; + } + + $returl = $returl_fail = $entry->url; + } elsif ( $extra =~ /^tags-(or|and)-([\d\-]+)$/ ) { + my ( $mode, $tagspec ) = ( $1, $2 ); + + my @tagids = split /-/, $tagspec; + + my $tags = LJ::Tags::get_usertags($journalu); + my @tagnames = map { LJ::eurl( $tags->{$_}->{'name'} ) } @tagids; + + $returl = $journalu->journal_base . '/tag/' + . join( ',', @tagnames ) + . '?mode=' . $mode; + + $returl_fail = $returl; + } else { + warn 'invalid format ' . $extra; + die; + } } else { # the warning will sit in error logs, and the exception # will be handled Modified: trunk/cgi-bin/LJ/S2/EntryPage.pm =================================================================== --- trunk/cgi-bin/LJ/S2/EntryPage.pm 2011-04-12 09:05:48 UTC (rev 18854) +++ trunk/cgi-bin/LJ/S2/EntryPage.pm 2011-04-12 09:27:55 UTC (rev 18855) @@ -31,6 +31,9 @@ } my ($entry, $s2entry) = EntryPage_entry($u, $remote, $opts); + + $p->{'page_id'} = 'journal-' . $u->username . '-' . $entry->ditemid; + return if $opts->{'suspendeduser'}; return if $opts->{'suspendedentry'}; return if $opts->{'readonlyremote'}; Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm =================================================================== --- trunk/cgi-bin/LJ/S2/RecentPage.pm 2011-04-12 09:05:48 UTC (rev 18854) +++ trunk/cgi-bin/LJ/S2/RecentPage.pm 2011-04-12 09:27:55 UTC (rev 18855) @@ -42,6 +42,10 @@ Image("$LJ::IMGPREFIX/data_$what.gif", 32, 15, $caption)); }; + if ( $opts->{'tagids'} ) { + $p->{'page_id'} = 'journal-' . $u->username . '-tags-' . $opts->{'tagmode'} . '-' . join( '-', @{ $opts->{'tagids'} } ); + } + $p->{'data_link'} = { 'rss' => $datalink->('rss', 'RSS'), 'atom' => $datalink->('atom', 'Atom'), Modified: trunk/cgi-bin/LJ/S2.pm =================================================================== --- trunk/cgi-bin/LJ/S2.pm 2011-04-12 09:05:48 UTC (rev 18854) +++ trunk/cgi-bin/LJ/S2.pm 2011-04-12 09:27:55 UTC (rev 18855) @@ -2056,6 +2056,8 @@ 'data_links_order' => [], 'showspam' => $remote && ($remote->can_manage($u) || $remote->can_moderate($u)) && LJ::is_enabled('spam_button') && $get->{mode} eq 'showspam', + + 'page_id' => 'journal-' . $u->username, }; if ($LJ::UNICODE && $opts && $opts->{'saycharset'}) { Modified: trunk/htdocs/identity/login.bml =================================================================== --- trunk/htdocs/identity/login.bml 2011-04-12 09:05:48 UTC (rev 18854) +++ trunk/htdocs/identity/login.bml 2011-04-12 09:27:55 UTC (rev 18855) @@ -15,7 +15,10 @@ $title = LJ::Lang::ml('.title'); my $thispage = "$LJ::SITEROOT/identity/login.bml"; - return LJ::Widget::LoginMulti->render(thispage => $thispage); + return LJ::Widget::LoginMulti->render( + 'thispage' => $thispage, + 'forwhat' => LJ::Request->post_param('forwhat'), + ); } _code?>