Messages limit

This commit is contained in:
Difrex(Denis Zheleztsov) 2014-08-10 21:16:39 +04:00
parent bc39e57ba0
commit a257a159df
4 changed files with 85 additions and 32 deletions

View File

@ -32,7 +32,7 @@ sub thread {
my @post = $db->thread( $subg, $echo );
# Render header
my $render = $t->head("ii ". $config->{name} ." :: $echo");
my $render = $t->head( "ii " . $config->{name} . " :: $echo" );
my $count = 0;
while ( $count < @post ) {
$render .= $t->post( @post[$count] );
@ -54,7 +54,9 @@ sub out {
# Render header
my $render
= $t->head('ii '. $config->{name} .' :: неотправленные сообщения');
= $t->head( 'ii '
. $config->{name}
. ' :: неотправленные сообщения' );
my $count = 0;
while ( $count < @post ) {
@ -76,7 +78,7 @@ sub echo_mes {
my @post = $db->echoes($echo);
# Render header
my $render = $t->head("ii ". $config->{name} ." :: $echo");
my $render = $t->head( "ii " . $config->{name} . " :: $echo" );
$render .= $t->echo($echo);
my $count = 0;
@ -91,11 +93,23 @@ sub echo_mes {
$count++;
}
}
else {
elsif ( $view eq 'all' ) {
while ( $count < @post ) {
# Render post
if ( !( @post[$count]->{subg} =~ /Re.+/ ) ) {
$render .= $t->post( @post[$count] );
}
$count++;
}
}
else {
while ( ( $count < @post ) and ( $count < 50 ) ) {
$render .= $t->post( @post[$count] );
$count++;
}
$render .= $t->all($echo);
}
$render .= $t->foot();
@ -113,7 +127,8 @@ sub to_me {
my @post_from_me = $db->from_me($config);
# Render header
my $render = $t->head('ii '. $config->{name} .' :: Моя переписка');
my $render = $t->head(
'ii ' . $config->{name} . ' :: Моя переписка' );
my $count = 0;
while ( $count < @post ) {
@ -143,7 +158,7 @@ sub index {
my @hashes = $db->select_index(50);
# Render header
my $render = $t->head('ii '. $config->{name} .' :: Лента');
my $render = $t->head( 'ii ' . $config->{name} . ' :: Лента' );
$render .= $t->index($echoareas);
while (<@hashes>) {
@ -167,7 +182,9 @@ sub user {
# Render header
my $render
= $t->head("ii ". $config->{name} ." :: Сообщения пользователя $user");
= $t->head( "ii "
. $config->{name}
. " :: Сообщения пользователя $user" );
my @post = $db->select_user($user);
@ -188,7 +205,8 @@ sub send_new {
my $t = $self->{_template};
my $config = $self->{_config};
my $render = $t->head("ii ". $config->{name} ." :: Новое сообщение");
my $render = $t->head(
"ii " . $config->{name} . " :: Новое сообщение" );
$render .= $t->new_mes($echo);
$render .= $t->foot();
@ -203,7 +221,8 @@ sub send {
my $t = $self->{_template};
my $config = $self->{_config};
my $render = $t->head("ii". $config->{name} ." :: Ответ на $hash");
my $render
= $t->head( "ii" . $config->{name} . " :: Ответ на $hash" );
# Render post
my $data = $db->select_new($hash);
@ -221,7 +240,8 @@ sub new_mes {
my $t = $self->{_template};
my $config = $self->{_config};
my $render = $t->head('ii '. $config->{name} .' :: Новые сообщения');
my $render = $t->head(
'ii ' . $config->{name} . ' :: Новые сообщения' );
# Render posts
if ( defined($msgs) ) {

17
II/T.pm
View File

@ -147,7 +147,7 @@ sub send {
# Preparsing before input to SQL
sub in_pre {
my ($self, $post) = @_;
my ( $self, $post ) = @_;
$post =~ s/'/\\'/g;
$post =~ s/"/\\"/g;
@ -169,10 +169,12 @@ sub pre {
$post =~ s/.?\*(.+)\*.?/&nbsp<b>$1<\/b>&nbsp/g;
# Images
$post =~ s/\[img (.+)\]/<a href="$1"><img src="$1" width="15%" height="15%" \/><\/a>/g;
$post
=~ s/\[img (.+)\]/<a href="$1"><img src="$1" width="15%" height="15%" \/><\/a>/g;
# ii uri
$post =~ s/ii:\/\/(.{20})\s/<a href="\/send?hash=$1">$1<\/a>/g;
# $post =~ s/ii:\/\/(.+\.\d+)/<a href="\/e?echo=$1&view=thread">$1<\/a>/g;
$post =~ s/^$/<br>\n/g;
@ -186,6 +188,7 @@ sub pre {
while (<$fh>) {
my $line = $_;
if ( ( $line =~ /^====/ ) and ( $pre == 0 ) ) {
# $txt .= $_;
$line =~ s/====/<pre class="pre">/g;
$pre = 1;
@ -201,6 +204,16 @@ sub pre {
return $txt;
}
# All messages footer
sub all {
my ( $self, $echo ) = @_;
my $a = HTML::Template->new( filename => 't/all.html' );
$a->param( ECHO => $echo );
return $a->output();
}
# Footer
sub foot {
my ($self) = @_;

View File

@ -158,3 +158,20 @@ margin-bottom: 0%;
background-color: #C9C9C9;
margin-right: 5%;
}
.all_link {
display: block;
border-style: solid;
border-width: 1px;
border-color: #999;
border-radius: 5px;
background-color: #C9C9C9;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
text-align: center;
text-decoration: underline;
font-size: 12pt;
color: #222;
width: 8em;
padding: 0.2em;
margin-left: 45%;
margin-right: 55%;
}

3
t/all.html Normal file
View File

@ -0,0 +1,3 @@
<a class='all_link' href="e?echo=<TMPL_VAR NAME=ECHO>&view=all">
Все сообщения
</a>