Messages limit
This commit is contained in:
parent
bc39e57ba0
commit
a257a159df
72
II/Render.pm
72
II/Render.pm
@ -8,9 +8,9 @@ use Data::Dumper;
|
|||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
|
|
||||||
my $db = II::DB->new();
|
my $db = II::DB->new();
|
||||||
my $t = II::T->new();
|
my $t = II::T->new();
|
||||||
my $c = II::Config->new();
|
my $c = II::Config->new();
|
||||||
my $config = $c->load();
|
my $config = $c->load();
|
||||||
|
|
||||||
my $self = {
|
my $self = {
|
||||||
@ -25,14 +25,14 @@ sub new {
|
|||||||
|
|
||||||
sub thread {
|
sub thread {
|
||||||
my ( $self, $subg, $echo ) = @_;
|
my ( $self, $subg, $echo ) = @_;
|
||||||
my $db = $self->{_db};
|
my $db = $self->{_db};
|
||||||
my $t = $self->{_template};
|
my $t = $self->{_template};
|
||||||
my $config = $self->{_config};
|
my $config = $self->{_config};
|
||||||
|
|
||||||
my @post = $db->thread( $subg, $echo );
|
my @post = $db->thread( $subg, $echo );
|
||||||
|
|
||||||
# Render header
|
# Render header
|
||||||
my $render = $t->head("ii ". $config->{name} ." :: $echo");
|
my $render = $t->head( "ii " . $config->{name} . " :: $echo" );
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
while ( $count < @post ) {
|
while ( $count < @post ) {
|
||||||
$render .= $t->post( @post[$count] );
|
$render .= $t->post( @post[$count] );
|
||||||
@ -54,7 +54,9 @@ sub out {
|
|||||||
|
|
||||||
# Render header
|
# Render header
|
||||||
my $render
|
my $render
|
||||||
= $t->head('ii '. $config->{name} .' :: неотправленные сообщения');
|
= $t->head( 'ii '
|
||||||
|
. $config->{name}
|
||||||
|
. ' :: неотправленные сообщения' );
|
||||||
|
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
while ( $count < @post ) {
|
while ( $count < @post ) {
|
||||||
@ -69,14 +71,14 @@ sub out {
|
|||||||
|
|
||||||
sub echo_mes {
|
sub echo_mes {
|
||||||
my ( $self, $echo, $view ) = @_;
|
my ( $self, $echo, $view ) = @_;
|
||||||
my $db = $self->{_db};
|
my $db = $self->{_db};
|
||||||
my $t = $self->{_template};
|
my $t = $self->{_template};
|
||||||
my $config = $self->{_config};
|
my $config = $self->{_config};
|
||||||
|
|
||||||
my @post = $db->echoes($echo);
|
my @post = $db->echoes($echo);
|
||||||
|
|
||||||
# Render header
|
# Render header
|
||||||
my $render = $t->head("ii ". $config->{name} ." :: $echo");
|
my $render = $t->head( "ii " . $config->{name} . " :: $echo" );
|
||||||
$render .= $t->echo($echo);
|
$render .= $t->echo($echo);
|
||||||
|
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
@ -91,11 +93,23 @@ sub echo_mes {
|
|||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
elsif ( $view eq 'all' ) {
|
||||||
while ( $count < @post ) {
|
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] );
|
$render .= $t->post( @post[$count] );
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
|
$render .= $t->all($echo);
|
||||||
}
|
}
|
||||||
$render .= $t->foot();
|
$render .= $t->foot();
|
||||||
|
|
||||||
@ -105,15 +119,16 @@ sub echo_mes {
|
|||||||
|
|
||||||
sub to_me {
|
sub to_me {
|
||||||
my ( $self, $config ) = @_;
|
my ( $self, $config ) = @_;
|
||||||
my $db = $self->{_db};
|
my $db = $self->{_db};
|
||||||
my $t = $self->{_template};
|
my $t = $self->{_template};
|
||||||
my $config = $self->{_config};
|
my $config = $self->{_config};
|
||||||
|
|
||||||
my @post = $db->to_me($config);
|
my @post = $db->to_me($config);
|
||||||
my @post_from_me = $db->from_me($config);
|
my @post_from_me = $db->from_me($config);
|
||||||
|
|
||||||
# Render header
|
# Render header
|
||||||
my $render = $t->head('ii '. $config->{name} .' :: Моя переписка');
|
my $render = $t->head(
|
||||||
|
'ii ' . $config->{name} . ' :: Моя переписка' );
|
||||||
|
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
while ( $count < @post ) {
|
while ( $count < @post ) {
|
||||||
@ -143,7 +158,7 @@ sub index {
|
|||||||
my @hashes = $db->select_index(50);
|
my @hashes = $db->select_index(50);
|
||||||
|
|
||||||
# Render header
|
# Render header
|
||||||
my $render = $t->head('ii '. $config->{name} .' :: Лента');
|
my $render = $t->head( 'ii ' . $config->{name} . ' :: Лента' );
|
||||||
$render .= $t->index($echoareas);
|
$render .= $t->index($echoareas);
|
||||||
|
|
||||||
while (<@hashes>) {
|
while (<@hashes>) {
|
||||||
@ -161,13 +176,15 @@ sub index {
|
|||||||
# Messages from user
|
# Messages from user
|
||||||
sub user {
|
sub user {
|
||||||
my ( $self, $user ) = @_;
|
my ( $self, $user ) = @_;
|
||||||
my $db = $self->{_db};
|
my $db = $self->{_db};
|
||||||
my $t = $self->{_template};
|
my $t = $self->{_template};
|
||||||
my $config = $self->{_config};
|
my $config = $self->{_config};
|
||||||
|
|
||||||
# Render header
|
# Render header
|
||||||
my $render
|
my $render
|
||||||
= $t->head("ii ". $config->{name} ." :: Сообщения пользователя $user");
|
= $t->head( "ii "
|
||||||
|
. $config->{name}
|
||||||
|
. " :: Сообщения пользователя $user" );
|
||||||
|
|
||||||
my @post = $db->select_user($user);
|
my @post = $db->select_user($user);
|
||||||
|
|
||||||
@ -185,10 +202,11 @@ sub user {
|
|||||||
# Render new message form
|
# Render new message form
|
||||||
sub send_new {
|
sub send_new {
|
||||||
my ( $self, $echo ) = @_;
|
my ( $self, $echo ) = @_;
|
||||||
my $t = $self->{_template};
|
my $t = $self->{_template};
|
||||||
my $config = $self->{_config};
|
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->new_mes($echo);
|
||||||
$render .= $t->foot();
|
$render .= $t->foot();
|
||||||
@ -199,11 +217,12 @@ sub send_new {
|
|||||||
# Render send form
|
# Render send form
|
||||||
sub send {
|
sub send {
|
||||||
my ( $self, $hash ) = @_;
|
my ( $self, $hash ) = @_;
|
||||||
my $db = $self->{_db};
|
my $db = $self->{_db};
|
||||||
my $t = $self->{_template};
|
my $t = $self->{_template};
|
||||||
my $config = $self->{_config};
|
my $config = $self->{_config};
|
||||||
|
|
||||||
my $render = $t->head("ii". $config->{name} ." :: Ответ на $hash");
|
my $render
|
||||||
|
= $t->head( "ii" . $config->{name} . " :: Ответ на $hash" );
|
||||||
|
|
||||||
# Render post
|
# Render post
|
||||||
my $data = $db->select_new($hash);
|
my $data = $db->select_new($hash);
|
||||||
@ -217,11 +236,12 @@ sub send {
|
|||||||
# Render new messages
|
# Render new messages
|
||||||
sub new_mes {
|
sub new_mes {
|
||||||
my ( $self, $msgs ) = @_;
|
my ( $self, $msgs ) = @_;
|
||||||
my $db = $self->{_db};
|
my $db = $self->{_db};
|
||||||
my $t = $self->{_template};
|
my $t = $self->{_template};
|
||||||
my $config = $self->{_config};
|
my $config = $self->{_config};
|
||||||
|
|
||||||
my $render = $t->head('ii '. $config->{name} .' :: Новые сообщения');
|
my $render = $t->head(
|
||||||
|
'ii ' . $config->{name} . ' :: Новые сообщения' );
|
||||||
|
|
||||||
# Render posts
|
# Render posts
|
||||||
if ( defined($msgs) ) {
|
if ( defined($msgs) ) {
|
||||||
|
25
II/T.pm
25
II/T.pm
@ -147,7 +147,7 @@ sub send {
|
|||||||
|
|
||||||
# Preparsing before input to SQL
|
# Preparsing before input to SQL
|
||||||
sub in_pre {
|
sub in_pre {
|
||||||
my ($self, $post) = @_;
|
my ( $self, $post ) = @_;
|
||||||
|
|
||||||
$post =~ s/'/\\'/g;
|
$post =~ s/'/\\'/g;
|
||||||
$post =~ s/"/\\"/g;
|
$post =~ s/"/\\"/g;
|
||||||
@ -167,18 +167,20 @@ sub pre {
|
|||||||
$post =~ s/>(.+)/<font color='green'>>$1<\/font>/g;
|
$post =~ s/>(.+)/<font color='green'>>$1<\/font>/g;
|
||||||
$post =~ s/--/—/g;
|
$post =~ s/--/—/g;
|
||||||
$post =~ s/.?\*(.+)\*.?/ <b>$1<\/b> /g;
|
$post =~ s/.?\*(.+)\*.?/ <b>$1<\/b> /g;
|
||||||
|
|
||||||
# Images
|
# 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
|
# ii uri
|
||||||
$post =~ s/ii:\/\/(.{20})\s/<a href="\/send?hash=$1">$1<\/a>/g;
|
$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/ii:\/\/(.+\.\d+)/<a href="\/e?echo=$1&view=thread">$1<\/a>/g;
|
||||||
|
|
||||||
$post =~ s/^$/<br>\n/g;
|
$post =~ s/^$/<br>\n/g;
|
||||||
$post =~ s/(.?)\n/$1<br>\n/g;
|
$post =~ s/(.?)\n/$1<br>\n/g;
|
||||||
$post =~ s/\*(.+)/<li>$1<\/li>\n/g;
|
$post =~ s/\*(.+)/<li>$1<\/li>\n/g;
|
||||||
|
|
||||||
# Not are regexp parsing
|
# Not are regexp parsing
|
||||||
my $pre = 0;
|
my $pre = 0;
|
||||||
my $txt;
|
my $txt;
|
||||||
@ -186,6 +188,7 @@ sub pre {
|
|||||||
while (<$fh>) {
|
while (<$fh>) {
|
||||||
my $line = $_;
|
my $line = $_;
|
||||||
if ( ( $line =~ /^====/ ) and ( $pre == 0 ) ) {
|
if ( ( $line =~ /^====/ ) and ( $pre == 0 ) ) {
|
||||||
|
|
||||||
# $txt .= $_;
|
# $txt .= $_;
|
||||||
$line =~ s/====/<pre class="pre">/g;
|
$line =~ s/====/<pre class="pre">/g;
|
||||||
$pre = 1;
|
$pre = 1;
|
||||||
@ -197,10 +200,20 @@ sub pre {
|
|||||||
$txt .= $line;
|
$txt .= $line;
|
||||||
}
|
}
|
||||||
close $fh;
|
close $fh;
|
||||||
|
|
||||||
return $txt;
|
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
|
# Footer
|
||||||
sub foot {
|
sub foot {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
@ -158,3 +158,20 @@ margin-bottom: 0%;
|
|||||||
background-color: #C9C9C9;
|
background-color: #C9C9C9;
|
||||||
margin-right: 5%;
|
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
3
t/all.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<a class='all_link' href="e?echo=<TMPL_VAR NAME=ECHO>&view=all">
|
||||||
|
Все сообщения
|
||||||
|
</a>
|
Loading…
Reference in New Issue
Block a user