mourningdove/htdocs/mobile/read.bml

146 lines
5.3 KiB
Text
Raw Normal View History

2026-05-24 01:03:05 +00:00
<?_c
# This code was forked from the LiveJournal project owned and operated
# by Live Journal, Inc. The code has been modified and expanded by
# Dreamwidth Studios, LLC. These files were originally licensed under
# the terms of the license supplied by Live Journal, Inc, which can
# currently be found at:
#
# http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
#
# In accordance with the original license, this code and all its
# modifications are provided under the GNU General Public License.
# A copy of that license can be found in the LICENSE file included as
# part of this distribution.
_c?>
<html>
<head>
<title><?_ml .page.title _ml?></title>
<meta name="viewport" content="width = 320" />
</head>
<body>
<p><?_code
{
use vars qw (%GET);
my $u = LJ::User->remote
or return BML::ml( '.read.login', { aopts => "href='login'" } );
my $itemsperpage = 50;
my $ret;
my $skip = $GET{skip}+0 || 0;
my $view = $GET{view};
my $showtypes = '';
my $reqfilter;
if ( $view && $view =~ /^[CPY]$/ ) {
$showtypes = $view;
} elsif ( defined $view ) {
$reqfilter = int $view;
}
my $cf;
# Filters to check for: specified filter ID, then "Mobile", "Mobile View",
# "Default", "Default View" - if none of these exist, then no filter.
# However, don't load default filters if all subscriptions were requested.
# an id of zero or undef would return all the user's filters
$cf = $u->content_filters( id => $reqfilter ) if $reqfilter;
$cf ||= $u->content_filters( name => "Mobile" ) ||
$u->content_filters( name => "Mobile View" ) ||
$u->content_filters( name => "Default" ) ||
$u->content_filters( name => "Default View" )
unless defined $view && $view == 0;
my @entries = $u->watch_items(
'remote' => $u->{'userid'},
'itemshow' => $itemsperpage,
'skip' => $skip,
'showtypes' => $showtypes,
'u' => $u,
'userid' => $u->{'userid'},
'content_filter' => $cf,
);
my $numentries = @entries;
my $prevcount = $skip + $itemsperpage;
my $nextcount = $skip ? $skip - $itemsperpage : -1;
my $nextlink = $skip ? BML::ml( '.items.next', { aopts => "href='?skip=$nextcount'", items => $itemsperpage } ) : '';
my $prevlink = ( $numentries < $itemsperpage ) ? '' : BML::ml( '.items.previous', { aopts => "href='?skip=$prevcount'", items => $itemsperpage } );
my @filters = ( "0", $BML::ML{'web.controlstrip.select.friends.all'},
"P", $BML::ML{'web.controlstrip.select.friends.journals'},
"C", $BML::ML{'web.controlstrip.select.friends.communities'},
"Y", $BML::ML{'web.controlstrip.select.friends.feeds'} );
push @filters, $_->id, $_->name foreach $u->content_filters;
# showtypes overrides default filters, but reqfilter overrides showtypes
my $selected = "0";
$selected = $cf->id if $cf;
$selected = $showtypes if $showtypes;
$selected = $cf->id if $reqfilter;
$ret .= BML::ml( '.read.back', { aopts => "href='./'", sitename => $LJ::SITENAMESHORT } );
$ret .= qq(<div style="font-size: 16pt; font-weight: bold; margin: 0.8em;">);
$ret .= qq($ML{'.page.title'}</div><div style="margin: 1em;"><div style="font-weight: bold;">);
$ret .= $BML::ML{'web.controlstrip.select.friends.label'} . " ";
$ret .= "<form method='get' style='display: inline;' action='$LJ::SITEROOT/mobile/read'>\n";
$ret .= LJ::html_select( { name => "view", selected => $selected }, @filters ) . " ";
$ret .= LJ::html_submit( $BML::ML{'web.controlstrip.btn.view'} );
$ret .= "</form>";
$ret .= qq(</div><div>$prevlink$nextlink</div><br/></div>);
# how many characters to truncate entry at
my $max_entry_length = 400;
foreach my $ei (@entries) {
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>";
}
my $subject = $entry->subject_text;
unless ( $subject ) {
$subject = $entry->event_text;
my $truncated = 0;
LJ::CleanHTML::clean_and_trim_subject( \$subject, undef, \$truncated );
$subject .= "..." if $truncated;
}
# say the entry was all HTML, and we thus have nothing, one more fallback
$subject ||= "(no subject)";
$ret .= "$who: " . "<a href='$url'>$subject</a><br />";
}
$ret .= BML::ml( '.read.noneleft' ) unless $numentries;
return $ret;
}
_code?>
</body>
</html>