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-11-09 04:21 am

[dw-free] Remove LJ::M::* files, unused

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

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

Remove old LJ::M(odel) modules we've long since deprecated.

Patch by [staff profile] mark.

Files modified:
  • cgi-bin/LJ/M/FriendsOf.pm
  • cgi-bin/LJ/M/ProfilePage.pm
  • cgi-bin/weblib.pl
--------------------------------------------------------------------------------
diff -r 6bc8ab85cd66 -r 20e2f020b631 cgi-bin/LJ/M/FriendsOf.pm
--- a/cgi-bin/LJ/M/FriendsOf.pm	Sun Nov 08 18:02:27 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,208 +0,0 @@
-package LJ::M::FriendsOf;
-use strict;
-use Carp qw(croak);
-
-sub new {
-    my ($pkg, $u, %args) = @_;
-    my $self = bless {
-        u => $u,
-        fo_ids => undef,  # if loaded, arrayref of userids that friend this user.
-        friends => {},    # hashref of userid => 1, for users that $u friends.
-        mutual_friendids => undef, # once loaded, arrayref of mutual friendids
-    }, $pkg;
-
-    # whether or not we can be sloppy with results on things that would
-    # otherwise be unbounded.  see also:  load_cap.
-    $self->{sloppy}   = delete $args{sloppy};
-    # don't load more than 5,000 LJ::User objects when
-    # returning sloppy lists.
-    $self->{load_cap} = delete $args{load_cap} || 5000;
-
-    # should we exclude mutual friends from 'friend_ofs'?
-    $self->{mutualsep} = delete $args{mutuals_separate};
-
-    # TODO: lame that we have to pass this in, but currently
-    # it's not cached on the $u singleton.  in future, remove this.
-    # it's a hashref of { $userid => 1 }, for user's friends
-    $self->{friends}  = delete $args{friends};
-
-    # let them provide a callback to remove userids from lists.
-    $self->{hide_test} = delete $args{hide_test_cb} || sub { 0 };
-
-    croak "unknown params" if %args;
-    return $self;
-}
-
-# returns scalar number of readers watching this (used mostly/only for syndicated feeds)
-sub reader_count {
-    my $self = shift;
-    return scalar @{ $self->_friendof_ids };
-}
-
-# in scalar context, number of mutual friends.
-# in list context, LJ::User objects (sorted by display name)
-sub mutual_friends {
-    my $fom = shift;
-    if (wantarray) {
-        return @{ $fom->_mutual_friends };
-    }
-    return scalar @{ $fom->_mutual_friends };
-}
-
-# returns just inbound people/identity users (removing mutuals if specified)
-# in scalar context, number of friend-ofs
-# in list context, LJ::User objects
-sub friend_ofs {
-    my $fom = shift;
-    if (wantarray) {
-        return @{ $fom->_friend_ofs };
-    }
-
-    # scalar context
-    my $ct = scalar @{ $fom->_friend_ofs };
-    if ($fom->{sloppy_friendofs}) {
-        # we got sloppy results, so scalar $ct above isn't good.
-        # skip all filtering and just set their friend-of count to
-        # total edges in, less their mutual friend count if necessary
-        # (which generally includes all communities they're a member of,
-        # as people watch those)
-        $ct = scalar @{ $fom->_friendof_ids };
-        if ($fom->{mutualsep}) {
-            $ct -= scalar @{ $fom->_mutual_friendids };
-        } else {
-            # TODO: load their outbound friends.  find communities.  remove those
-            # incoming counts.  that should account for almost all incoming
-            # community edges because most people watch communities they're
-            # a member of.  with this, we just err on the side of too high a
-            # friend-of count when we're 5000+ friend-ofs
-        }
-
-    }
-    return $ct;
-
-}
-
-# in scalar context, number of community memberships
-# in list context, LJ::User objects
-sub member_of {
-    my $fom = shift;
-    if (wantarray) {
-        return @{ $fom->_member_of };
-    }
-    return scalar @{ $fom->_member_of };
-}
-
-
-# --------------------------------------------------------------------------
-# Internals
-# --------------------------------------------------------------------------
-
-# return arrayref of userids with friendof edges to this user.
-sub _friendof_ids {
-    my $fom = shift;
-    return $fom->{fo_ids} ||= [ $fom->{u}->friendof_uids ];
-}
-
-# returns arrayref of LJ::User mutual friends, filter (visible people), and sorted by display name
-sub _mutual_friends {
-    my $fom = shift;
-    return $fom->{mutual_friends} if $fom->{mutual_friends};
-
-    # because friends outbound are capped, so then is this load_userids call
-    my @ids = grep { ! $fom->{hide_test}->($_) } @{ $fom->_mutual_friendids };
-    my $us = LJ::load_userids(@ids);
-    return $fom->{mutual_friends} = [
-                                     sort { $a->display_name cmp $b->display_name }
-                                     grep { $_->statusvis =~ /[VML]/ && $_->is_individual }
-                                     map  { $us->{$_} ? ($us->{$_}) : () }
-                                     @ids
-                                    ];
-}
-
-# returns arrayref of mutual friendids.  sorted by username
-sub _mutual_friendids {
-    my $fom = shift;
-    return $fom->{mutual_friendids} if $fom->{mutual_friendids};
-    my @mut;
-    foreach my $uid (@{ $fom->_friendof_ids }) {
-        push @mut, $uid if $fom->{friends}{$uid};
-    }
-    @mut = sort { $a <=> $b } @mut;
-    return $fom->{mutual_friendids} = \@mut;
-}
-
-# returns arrayref of inbound people/identity LJ::User objects, not communities.  which means we gotta
-# load them to filter, if it's not too much work.  returns in sorted order.
-sub _friend_ofs {
-    my $fom = shift;
-    return $fom->{_friendof_us} if $fom->{_friendof_us};
-
-    # two options to filter them: a) it's less than load_cap, so we
-    # load all users and just look.  b) it's too many, so we load at
-    # least the mutual friends + whatever's left in the load cap space
-    my @to_load;
-    my @uids = grep { ! $fom->{hide_test}->($_) } @{ $fom->_friendof_ids };
-
-    # remove mutuals now, if mutual separation has been required
-    if ($fom->{mutualsep}) {
-        @uids = grep { ! $fom->{friends}{$_} } @uids;
-    }
-
-    if (@uids <= $fom->{load_cap} || !$fom->{sloppy}) {
-        @to_load = @uids;
-    } else {
-        # too big.  we have to only load some.  result will be limited.
-        # we'll always include mutual friends in our inbound load, unless we're
-        # separating them out anyway, in which case it's not important to make
-        # sure they're not forgotten, as they'll be included in the other list.
-        my %is_mutual;
-        unless ($fom->{mutualsep}) {
-            @to_load = @{ $fom->_mutual_friendids };
-            $is_mutual{$_} = 1 foreach @to_load;
-        }
-
-        my $remain = $fom->{load_cap} - @to_load;
-        while ($remain > 0 && @uids) {
-            my $uid = shift @uids;
-            next if $is_mutual{$uid};  # already in mutual list
-            push @to_load, $uid;
-            $remain--;
-        }
-        $fom->{sloppy_friendofs} = 1;
-    }
-
-    my $us = LJ::load_userids(@to_load);
-    return $fom->{_friendof_us} = [
-                                   sort { $a->display_name cmp $b->display_name }
-                                   grep { $_->statusvis =~ /[VML]/ && $_->is_individual }
-                                   map { $us->{$_} ? ($us->{$_}) : () }
-                                   @to_load
-                                  ];
-
-}
-
-# return arrayref of LJ::User objects for community/shared memberships, sorted.
-sub _member_of {
-    my $fom = shift;
-    return $fom->{_member_of_us} if $fom->{_member_of_us};
-
-    # need to check all inbound edges to see if they're communities.
-    my @to_load = grep { ! $fom->{hide_test}->($_) } @{ $fom->_friendof_ids };
-
-    # but if there's too many, we'll assume you also read communities that
-    # you're a member of, so we'll find them all in your mutual friendids.
-    if (@to_load > $fom->{load_cap} && $fom->{sloppy}) {
-        @to_load = @{ $fom->_mutual_friendids };
-    }
-
-    my $us = LJ::load_userids(@to_load);
-    return $fom->{_member_of_us} = [
-                                    sort { $a->display_name cmp $b->display_name }
-                                    grep { $_->is_visible && $_->is_community }
-                                    map { $us->{$_} ? ($us->{$_}) : () }
-                                    @to_load
-                                   ];
-
-}
-
-1;
diff -r 6bc8ab85cd66 -r 20e2f020b631 cgi-bin/LJ/M/ProfilePage.pm
--- a/cgi-bin/LJ/M/ProfilePage.pm	Sun Nov 08 18:02:27 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-package LJ::M::ProfilePage;
-
-use strict;
-use warnings;
-
-use Carp qw(croak);
-
-sub new {
-    my $class = shift;
-    my $u = shift || die;
-    my $self = bless {
-        u => $u,
-        max_friends_show => 500,
-        max_friendof_show => 150,
-    }, (ref $class || $class);
-    $self->_init;
-    return $self;
-}
-
-sub _init {
-    my $self = shift;
-
-    $self->{banned_userids} = {};
-    if (my $uidlist = LJ::load_rel_user($self->{u}, 'B')) {
-        $self->{banned_userids}{$_} = 1 foreach @$uidlist;
-    }
-
-    my $u = $self->{u};
-
-    my $remote = LJ::get_remote();
-    $self->{remote_isowner} = ($remote && $remote->id == $u->id);
-
-    ### load user props.  some don't apply to communities
-    {
-        my @props = qw(country state city zip renamedto
-                       journaltitle journalsubtitle public_key
-                       url urlname opt_hidefriendofs dont_load_members
-                       opt_blockrobots adult_content
-                       opt_showmutualfriends opt_showschools);
-        if ($u->is_community) {
-            push @props, qw(moderated comm_theme);
-        } elsif ($u->is_syndicated) {
-            push @props, qw(rssparseerror);
-        } else {
-            push @props, qw(gizmo aolim icq yahoo msn gender jabber google_talk skype last_fm_user);
-        }
-        LJ::load_user_props($u, @props);
-    }
-}
-
-
-sub max_friends_show { $_[0]{max_friends_show} }
-sub max_friendof_show { $_[0]{max_friendof_show} }
-
-sub should_hide_friendof {
-    my ($self, $uid) = @_;
-    return $self->{banned_userids}{$uid};
-}
-
-sub head_meta_tags {
-    my $self = shift;
-    my $u = $self->{u};
-    my $jbase = $u->journal_base;
-    my $remote = LJ::get_remote();
-    my $ret;
-
-    $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS' href='$jbase/data/rss' />\n";
-    $ret .= "<link rel='alternate' type='application/atom+xml' title='Atom' href='$jbase/data/atom' />\n";
-    $ret .= "<link rel='alternate' type='application/rdf+xml' title='FOAF' href='$jbase/data/foaf' />\n";
-    if ($u->email_visible($remote)) {
-        my $digest = Digest::SHA1::sha1_hex('mailto:' . $u->email_raw);
-        $ret .= "<meta name=\"foaf:maker\" content=\"foaf:mbox_sha1sum '$digest'\" />\n";
-    }
-
-    return $ret;
-}
-
-sub has_journal {
-    my $pm = shift;
-    return ! $pm->{u}->is_identity && ! $pm->{u}->is_syndicated;
-}
-
-sub remote_isowner { $_[0]{remote_isowner} }
-
-sub remote_can_post {
-    my $pm = shift;
-    my $remote = LJ::get_remote()
-        or return 0;
-    return 0 unless $pm->has_journal;
-    return 0 if $remote->is_identity;
-    return LJ::can_use_journal($remote->id, $pm->{u}->user);
-}
-
-sub header_bar_links {
-    my $pm = shift;
-    my @ret;
-    my $label = $pm->{u}->is_community ? $BML::ML{'.monitor.comm2'} : $BML::ML{'.monitor.user'};
-
-    my $user = $pm->{u}->user;
-    push @ret, "<a href='$LJ::SITEROOT/manage/circle/add?user=$user'><img src='$LJ::IMGPREFIX/silk/profile/subscription_add.png' width='16' height='16' alt='$label' title='$label' align='middle' border='0' /></a>";
-
-    my $remote = LJ::get_remote();
-
-    if ($pm->remote_can_post) {
-        if ($pm->remote_isowner) {
-            $label = $BML::ML{'.label.postalt'};
-        } else {
-            $label = BML::ml('.label.post', {'journal' => $user});
-        }
-
-        $label = LJ::ehtml($label);
-        push @ret, "<a href='$LJ::SITEROOT/update?usejournal=$user'><img src='$LJ::IMGPREFIX/silk/profile/post.png' width='16' height='16' alt='$label' title='$label' align='middle' border='0' /></a>";
-    }
-
-    unless ($pm->{u}->is_identity || $pm->{u}->is_syndicated) {
-        $label = LJ::ehtml($BML::ML{'.label.memories'});
-        push @ret, "<a href='$LJ::SITEROOT/tools/memories?user=$user'><img src='$LJ::IMGPREFIX/silk/profile/memories.png' width='16' height='16' alt='$label' title='$label' align='middle' border='0' /></a>";
-    }
-
-     if ( LJ::is_enabled('tellafriend') && !$pm->{u}->is_identity ) {
-         push @ret, "<a href='$LJ::SITEROOT/tools/tellafriend?user=$user'><img align='middle' hspace='2' vspace='2' src='$LJ::IMGPREFIX/silk/profile/tellafriend.png' width='16' height='16' alt='$BML::ML{'.tellafriend'}' title='$BML::ML{'.tellafriend'}' border='0' /></a>";
-     }
-
-     if ( LJ::is_enabled('offsite_journal_search') && $pm->has_journal ) {
-         push @ret, "<a href='$LJ::SITEROOT/tools/search?journal=$user'><img align='middle' hspace='2' vspace='2' src='$LJ::IMGPREFIX/btn_search.gif' width='22' height='20' alt='$BML::ML{'.label.searchjournal'}' title='$BML::ML{'.label.searchjournal'}' border='0' /></a>";
-     }
-
-     if ($remote && !$pm->{u}->is_syndicated && $remote->can_use_esn) {
-         push @ret, "<a href='$LJ::SITEROOT/manage/subscriptions/user?journal=$user'>" .
-             LJ::img("track", "", { 'align' => 'middle' }) . "</a>";
-     }
-
-    foreach my $row (LJ::run_hooks("userinfo_linkele", $pm->{u}, $remote)) {
-        push @ret, @$row;
-    }
-
-    return @ret;
-}
-
-1;
diff -r 6bc8ab85cd66 -r 20e2f020b631 cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl	Sun Nov 08 18:02:27 2009 +0000
+++ b/cgi-bin/weblib.pl	Mon Nov 09 04:21:16 2009 +0000
@@ -13,10 +13,8 @@ use DW::Request;
 use DW::Request;
 use LJ::Event;
 use LJ::Subscription::Pending;
-use LJ::M::ProfilePage;
 use LJ::Directory::Search;
 use LJ::Directory::Constraint;
-use LJ::M::FriendsOf;
 
 # <LJFUNC>
 # name: LJ::img
--------------------------------------------------------------------------------