Committer: amyshkin
LJSUP-8514: Create widgets for verticals on portal's homepageU trunk/bin/upgrading/en.dat U trunk/cgi-bin/LJ/S2.pm U trunk/cgi-bin/LJ/TimeUtil.pm U trunk/cgi-bin/ljlang.pl U trunk/cgi-bin/ljlib.pl
Modified: trunk/bin/upgrading/en.dat =================================================================== --- trunk/bin/upgrading/en.dat 2011-06-23 06:03:53 UTC (rev 19345) +++ trunk/bin/upgrading/en.dat 2011-06-23 06:39:38 UTC (rev 19346) @@ -989,50 +989,74 @@ date.month.april.short=Apr +date.month.april.genitive=April + date.month.august.long=August date.month.august.short=Aug +date.month.august.genitive=August + date.month.december.long=December date.month.december.short=Dec +date.month.december.genitive=December + date.month.february.long=February date.month.february.short=Feb +date.month.february.genitive=February + date.month.january.long=January date.month.january.short=Jan +date.month.january.genitive=January + date.month.july.long=July date.month.july.short=Jul +date.month.july.genitive=July + date.month.june.long=June date.month.june.short=Jun +date.month.june.genitive=June + date.month.march.long=March date.month.march.short=Mar +date.month.march.genitive=March + date.month.may.long=May date.month.may.short=May +date.month.may.genitive=May + date.month.november.long=November date.month.november.short=Nov +date.month.november.genitive=November + date.month.october.long=October date.month.october.short=Oct +date.month.october.genitive=October + date.month.september.long=September date.month.september.short=Sep +date.month.september.genitive=September + Email=Email email.newacct.body<< @@ -4815,6 +4839,8 @@ time.ago.week=[[num]] [[?num|week|weeks]] ago +time.preposition=at + tos.error=You must read and agree to the terms of service. tos.haveread=I have read and agree to the Terms of Service. Modified: trunk/cgi-bin/LJ/S2.pm =================================================================== --- trunk/cgi-bin/LJ/S2.pm 2011-06-23 06:03:53 UTC (rev 19345) +++ trunk/cgi-bin/LJ/S2.pm 2011-06-23 06:39:38 UTC (rev 19346) @@ -4176,14 +4176,17 @@ $S2::pout->($ad_html) if $ad_html; } -my %approved_widget_classes = map { $_ => $_ } qw (TopEntries TopUsers FaceBookILike PublicStats OnLivejournal MySuperWidget); - +#my %approved_widget_classes = map { $_ => $_ } qw (TopEntries TopUsers FaceBookILike PublicStats OnLivejournal MySuperWidget); + sub Page__widget { my ($ctx, $this, $opts) = @_; my $class = $opts->{'class'}; - return '' unless $approved_widget_classes{$class}; + return '' unless exists $LJ::APPROVED_WIDGET_CLASSES{$class}; + unless ( exists $LJ::APPROVED_WIDGET_CLASSES{$class}->{'*'} ) { + return '' unless exists $LJ::APPROVED_WIDGET_CLASSES{$class}->{ $LJ::S2::CURR_PAGE->{'journal'}->{'_u'}->{'user'} } + } # if $opts->{'journal'} specified, try use it as name to load LJ::User object, # else get current journal. Modified: trunk/cgi-bin/LJ/TimeUtil.pm =================================================================== --- trunk/cgi-bin/LJ/TimeUtil.pm 2011-06-23 06:03:53 UTC (rev 19345) +++ trunk/cgi-bin/LJ/TimeUtil.pm 2011-06-23 06:39:38 UTC (rev 19346) @@ -57,6 +57,20 @@ return HTTP::Date::str2time($string); } +sub mysqldate_to_ljtime { + my ($class, $string) = @_; + return undef unless $string =~ /^(\d\d\d\d)-(\d\d)-(\d\d)(?: (\d\d):(\d\d)(?::(\d\d))?)?$/; + + my ($y, $mon, $d, $h, $min, $s) = ($1, $2, $3, $4, $5, $6); + return undef unless ($d + 0) and ($mon + 0); # '00' is string and is true value + + $mon -= 1; + return undef if $mon < 0; + + return "$d " . LJ::Lang::ml( LJ::Lang::month_long_genitive_langcode( $mon )) . ' ' . LJ::Lang::ml('time.preposition') . " $h:$min"; + +} + sub mysqldate_to_time { my ($class, $string, $gmt) = @_; return undef unless $string =~ /^(\d\d\d\d)-(\d\d)-(\d\d)(?: (\d\d):(\d\d)(?::(\d\d))?)?$/; Modified: trunk/cgi-bin/ljlang.pl =================================================================== --- trunk/cgi-bin/ljlang.pl 2011-06-23 06:03:53 UTC (rev 19345) +++ trunk/cgi-bin/ljlang.pl 2011-06-23 06:39:38 UTC (rev 19346) @@ -36,6 +36,7 @@ sub day_long_langcode { return "date.day." . lc(LJ::Lang::day_long(@_)) . ".long"; } sub month_short_langcode { return "date.month." . lc(LJ::Lang::month_long(@_)) . ".short"; } sub month_long_langcode { return "date.month." . lc(LJ::Lang::month_long(@_)) . ".long"; } +sub month_long_genitive_langcode { return "date.month." . lc(LJ::Lang::month_long(@_)) . ".genitive"; } ## ordinal suffix sub day_ord { Modified: trunk/cgi-bin/ljlib.pl =================================================================== --- trunk/cgi-bin/ljlib.pl 2011-06-23 06:03:53 UTC (rev 19345) +++ trunk/cgi-bin/ljlib.pl 2011-06-23 06:39:38 UTC (rev 19346) @@ -1005,7 +1005,6 @@ # -- userid # -- remote: remote user's $u # -- remoteid: id of remote user -# -- clusterid: clusterid of userid # -- tagids: arrayref of tagids to return entries with # -- security: (public|friends|private) or a group number # -- clustersource: if value 'slave', uses replicated databases @@ -1042,6 +1041,8 @@ my $err = $opts->{'err'}; my $userid = $opts->{'userid'}+0; + my $u = LJ::load_userid($userid) + or die "No such userid: $userid"; # 'remote' opt takes precendence, then 'remoteid' my $remote = $opts->{'remote'}; @@ -1054,7 +1055,7 @@ my $max_hints = $LJ::MAX_SCROLLBACK_LASTN; # temporary my $sort_key = "revttime"; - my $clusterid = $opts->{'clusterid'}+0; + my $clusterid = $u->{'clusterid'}+0; my @sources = ("cluster$clusterid"); if (my $ab = $LJ::CLUSTER_PAIR_ACTIVE{$clusterid}) { @sources = ("cluster${clusterid}${ab}"); @@ -1272,9 +1273,28 @@ # construct an LJ::Entry singleton my $entry = LJ::Entry->new($userid, jitemid => $li->{itemid}); $entry->absorb_row($li); + push @{$opts->{'entry_objects'}}, $entry; } + $flush->(); + if ( exists $opts->{load_props} && $opts->{load_props} ) { + my %logprops = (); + LJ::load_log_props2($userid, $opts->{'itemids'}, \%logprops); + + for my $Entry ( @{$opts->{'entry_objects'}} ) { + $Entry->handle_prefetched_props($logprops{$Entry->{jitemid}}); + } + } + + if ( exists $opts->{load_text} && $opts->{load_text} ) { + my $texts = LJ::get_logtext2($u, @{$opts->{'itemids'}}); + + for my $Entry ( @{$opts->{'entry_objects'}} ) { + $Entry->handle_prefetched_text( $texts->{ $Entry->{jitemid} }->[0], $texts->{ $Entry->{jitemid} }->[1] ); + } + } + return @items; }