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 {
|
||||
my $class = shift;
|
||||
|
||||
my $db = II::DB->new();
|
||||
my $t = II::T->new();
|
||||
my $c = II::Config->new();
|
||||
my $db = II::DB->new();
|
||||
my $t = II::T->new();
|
||||
my $c = II::Config->new();
|
||||
my $config = $c->load();
|
||||
|
||||
my $self = {
|
||||
@ -25,14 +25,14 @@ sub new {
|
||||
|
||||
sub thread {
|
||||
my ( $self, $subg, $echo ) = @_;
|
||||
my $db = $self->{_db};
|
||||
my $t = $self->{_template};
|
||||
my $db = $self->{_db};
|
||||
my $t = $self->{_template};
|
||||
my $config = $self->{_config};
|
||||
|
||||
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 ) {
|
||||
@ -69,14 +71,14 @@ sub out {
|
||||
|
||||
sub echo_mes {
|
||||
my ( $self, $echo, $view ) = @_;
|
||||
my $db = $self->{_db};
|
||||
my $t = $self->{_template};
|
||||
my $db = $self->{_db};
|
||||
my $t = $self->{_template};
|
||||
my $config = $self->{_config};
|
||||
|
||||
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();
|
||||
|
||||
@ -105,15 +119,16 @@ sub echo_mes {
|
||||
|
||||
sub to_me {
|
||||
my ( $self, $config ) = @_;
|
||||
my $db = $self->{_db};
|
||||
my $t = $self->{_template};
|
||||
my $db = $self->{_db};
|
||||
my $t = $self->{_template};
|
||||
my $config = $self->{_config};
|
||||
|
||||
my @post = $db->to_me($config);
|
||||
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>) {
|
||||
@ -161,13 +176,15 @@ sub index {
|
||||
# Messages from user
|
||||
sub user {
|
||||
my ( $self, $user ) = @_;
|
||||
my $db = $self->{_db};
|
||||
my $t = $self->{_template};
|
||||
my $db = $self->{_db};
|
||||
my $t = $self->{_template};
|
||||
my $config = $self->{_config};
|
||||
|
||||
# Render header
|
||||
my $render
|
||||
= $t->head("ii ". $config->{name} ." :: Сообщения пользователя $user");
|
||||
= $t->head( "ii "
|
||||
. $config->{name}
|
||||
. " :: Сообщения пользователя $user" );
|
||||
|
||||
my @post = $db->select_user($user);
|
||||
|
||||
@ -185,10 +202,11 @@ sub user {
|
||||
# Render new message form
|
||||
sub send_new {
|
||||
my ( $self, $echo ) = @_;
|
||||
my $t = $self->{_template};
|
||||
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();
|
||||
@ -199,11 +217,12 @@ sub send_new {
|
||||
# Render send form
|
||||
sub send {
|
||||
my ( $self, $hash ) = @_;
|
||||
my $db = $self->{_db};
|
||||
my $t = $self->{_template};
|
||||
my $db = $self->{_db};
|
||||
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);
|
||||
@ -217,11 +236,12 @@ sub send {
|
||||
# Render new messages
|
||||
sub new_mes {
|
||||
my ( $self, $msgs ) = @_;
|
||||
my $db = $self->{_db};
|
||||
my $t = $self->{_template};
|
||||
my $db = $self->{_db};
|
||||
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
17
II/T.pm
@ -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/.?\*(.+)\*.?/ <b>$1<\/b> /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) = @_;
|
||||
|
@ -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
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