ljr/local/htdocs/mobile/friends.bml

97 lines
2.8 KiB
Plaintext

<html>
<head>
<title>Friends Page</title>
<meta name="viewport" content="width = 320" />
</head>
<body>
<p><?_code
{
use vars qw (%GET);
my $u = LJ::get_remote();
return "<?needlogin?>"
unless $u;
my $itemsperpage = 50;
my $ret;
my $skip = $GET{skip}+0 || 0;
my $prevcount = $skip + $itemsperpage;
my $nextcount = $skip ? $skip - $itemsperpage : -1;
my $nextlink = $nextcount != -1 ? " | <a href='?skip=$nextcount'>Next $itemsperpage &gt;&gt;</a>" : '';
my $prevlink = "<a href='?skip=$prevcount'>&lt;&lt; Previous $itemsperpage</a>";
# Filter first to a "Mobile View" friends group if they have one,
# then fall back to "Default View", and then just show them everything
my $filter;
my $groupname = "All friends";
foreach ("Mobile View", "Default View") {
if (my $grp = LJ::get_friend_group($u, { 'name' => $_ })) {
$groupname = $_;
$filter = 1 << $grp->{'groupnum'};
last;
}
}
$ret = qq {
<a href='./'>&lt;&lt; Back</a> to LiveJournal Mobile.
<div style="font-size: 16pt; font-weight: bold; margin: 0.8em;">Friends Page</div>
<div style="margin: 1em;">
<div style="font-weight: bold;">Viewing: $groupname</div>
<div>$prevlink$nextlink</div><br/>
</div>
};
sub New;
my %friends;
my @items = LJ::get_friend_items({
'remote' => $u,
'itemshow' => $itemsperpage,
'skip' => $skip,
'showtypes' => 'PYC',
'u' => $u,
'filter' => $filter,
'friends_u' => \%friends,
});
# how many characters to truncate entry at
my $max_entry_length = 400;
foreach my $ei (@items) {
next unless $ei;
# my $entry;
# if ($ei->{'ditemid'}) {
# $entry = LJ::Entry->new($ei->{'journalid'},
# ditemid => $ei->{'ditemid'});
# } elsif ($ei->{'jitemid'} && $ei->{'anum'}) {
# $entry = LJ::Entry->new($ei->{'journalid'},
# jitemid => $ei->{'jitemid'},
# anum => $ei->{'anum'});
# }
# next unless $entry;
# my $pu = $entry->poster;
# my $ju = $entry->journal;
# my $url = $entry->url;
# $url .= "?format=light";
# my $who = "<a href='" . $pu->journal_base . "/'><b>$pu->{user}</b></a>";
# if ($pu->{userid} != $ju->{userid}) {
# $who .= " in " . "<a href='" . $ju->journal_base . "/'><b>$ju->{user}</b></a>";
# }
# $ret .= "$who: " . "<a href='$url'>" . ($entry->subject_text || "(no subject)") . "</a><br />";
}
return $ret;
}
_code?>
</body>
</html>