Compare commits
No commits in common. "master" and "v0.1pre" have entirely different histories.
@ -24,7 +24,6 @@ sub load {
|
|||||||
my $host = $config->{node}->{host};
|
my $host = $config->{node}->{host};
|
||||||
my @echoareas = split /,/, $config->{node}->{echoareas};
|
my @echoareas = split /,/, $config->{node}->{echoareas};
|
||||||
my $name = $config->{node}->{name};
|
my $name = $config->{node}->{name};
|
||||||
my $notify = $config->{notify}->{enabled};
|
|
||||||
|
|
||||||
$c = {
|
$c = {
|
||||||
nick => $nick,
|
nick => $nick,
|
||||||
@ -32,7 +31,6 @@ sub load {
|
|||||||
host => $host,
|
host => $host,
|
||||||
echoareas => [@echoareas],
|
echoareas => [@echoareas],
|
||||||
name => $name,
|
name => $name,
|
||||||
notify => $notify,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return $c;
|
return $c;
|
||||||
|
53
II/DB.pm
53
II/DB.pm
@ -2,7 +2,6 @@ package II::DB;
|
|||||||
|
|
||||||
use SQL::Abstract;
|
use SQL::Abstract;
|
||||||
use DBI;
|
use DBI;
|
||||||
use utf8;
|
|
||||||
|
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
@ -21,7 +20,6 @@ sub new {
|
|||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check message hash
|
|
||||||
sub check_hash {
|
sub check_hash {
|
||||||
my ( $self, $hash, $echo ) = @_;
|
my ( $self, $hash, $echo ) = @_;
|
||||||
my $dbh = $self->{_dbh};
|
my $dbh = $self->{_dbh};
|
||||||
@ -34,13 +32,13 @@ sub check_hash {
|
|||||||
my ($base_hash) = @h;
|
my ($base_hash) = @h;
|
||||||
if ( $hash eq $base_hash ) {
|
if ( $hash eq $base_hash ) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Begin transaction
|
|
||||||
sub begin {
|
sub begin {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my $dbh = $self->{_dbh};
|
my $dbh = $self->{_dbh};
|
||||||
@ -49,7 +47,6 @@ sub begin {
|
|||||||
$dbh->do('BEGIN');
|
$dbh->do('BEGIN');
|
||||||
}
|
}
|
||||||
|
|
||||||
# Commit transaction
|
|
||||||
sub commit {
|
sub commit {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my $dbh = $self->{_dbh};
|
my $dbh = $self->{_dbh};
|
||||||
@ -83,16 +80,6 @@ sub write_out {
|
|||||||
print "Message writed to DB!\n";
|
print "Message writed to DB!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub del_out {
|
|
||||||
my ( $self, $hash ) = @_;
|
|
||||||
my $dbh = $self->{_dbh};
|
|
||||||
|
|
||||||
my $q = "delete from output where hash='$hash' and send=0";
|
|
||||||
my $sth = $dbh->prepare($q);
|
|
||||||
$sth->execute();
|
|
||||||
$sth->finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
sub update_out {
|
sub update_out {
|
||||||
my ( $self, $hash ) = @_;
|
my ( $self, $hash ) = @_;
|
||||||
my $dbh = $self->{_dbh};
|
my $dbh = $self->{_dbh};
|
||||||
@ -275,7 +262,7 @@ sub echoes {
|
|||||||
time => $time,
|
time => $time,
|
||||||
echo => "$echo",
|
echo => "$echo",
|
||||||
post => "$post",
|
post => "$post",
|
||||||
hash => $h,
|
h => $h,
|
||||||
};
|
};
|
||||||
push( @posts, $data );
|
push( @posts, $data );
|
||||||
}
|
}
|
||||||
@ -292,7 +279,7 @@ sub to_me {
|
|||||||
# print "NICK: $nick\n";
|
# print "NICK: $nick\n";
|
||||||
|
|
||||||
my $q
|
my $q
|
||||||
= "select from_user, to_user, subg, time, echo, post, hash from messages where to_user='$nick' order by time desc";
|
= "select from_user, to_user, subg, time, echo, post, hash from messages where to_user='$nick'";
|
||||||
|
|
||||||
my $sth = $dbh->prepare($q);
|
my $sth = $dbh->prepare($q);
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
@ -343,36 +330,4 @@ sub select_new {
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Search
|
|
||||||
sub do_search {
|
|
||||||
my ( $self, $query ) = @_;
|
|
||||||
my $dbh = $self->{_dbh};
|
|
||||||
|
|
||||||
my $q = "select from_user, to_user, subg, time, echo, post, hash
|
|
||||||
from messages where subg
|
|
||||||
like '\%$query\%' COLLATE NOCASE
|
|
||||||
order by time";
|
|
||||||
|
|
||||||
print "SQL: " . $q . "\n";
|
|
||||||
my $sth = $dbh->prepare($q);
|
|
||||||
$sth->execute();
|
|
||||||
|
|
||||||
my @posts;
|
|
||||||
while ( my @hash = $sth->fetchrow_array() ) {
|
|
||||||
my ( $from, $to, $subg, $time, $echo, $post, $h ) = @hash;
|
|
||||||
my $data = {
|
|
||||||
from => "$from",
|
|
||||||
to => "$to",
|
|
||||||
subg => "$subg",
|
|
||||||
time => $time,
|
|
||||||
echo => "$echo",
|
|
||||||
post => "$post",
|
|
||||||
hash => "$h",
|
|
||||||
};
|
|
||||||
push( @posts, $data );
|
|
||||||
}
|
|
||||||
|
|
||||||
return @posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -145,12 +145,6 @@ sub get_echo {
|
|||||||
# Commit transaction
|
# Commit transaction
|
||||||
$db->commit();
|
$db->commit();
|
||||||
print localtime() . ": messages writed to DB!\n";
|
print localtime() . ": messages writed to DB!\n";
|
||||||
|
|
||||||
# Notify
|
|
||||||
my @notify_cmd = ('notify-send', 'Сеть ii', 'Есть новые сообщения');
|
|
||||||
if ($notify == 1) {
|
|
||||||
system(@notify_cmd) == 0 or warn "Cannot send notify: $!\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $msgs;
|
return $msgs;
|
||||||
}
|
}
|
||||||
|
62
II/Render.pm
62
II/Render.pm
@ -32,7 +32,7 @@ sub thread {
|
|||||||
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,9 +54,7 @@ sub out {
|
|||||||
|
|
||||||
# Render header
|
# Render header
|
||||||
my $render
|
my $render
|
||||||
= $t->head( 'ii '
|
= $t->head('ii '. $config->{name} .' :: неотправленные сообщения');
|
||||||
. $config->{name}
|
|
||||||
. ' :: неотправленные сообщения' );
|
|
||||||
|
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
while ( $count < @post ) {
|
while ( $count < @post ) {
|
||||||
@ -78,7 +76,7 @@ sub echo_mes {
|
|||||||
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;
|
||||||
@ -93,23 +91,11 @@ sub echo_mes {
|
|||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ( $view eq 'all' ) {
|
|
||||||
while ( $count < @post ) {
|
|
||||||
|
|
||||||
# Render post
|
|
||||||
if ( !( @post[$count]->{subg} =~ /Re.+/ ) ) {
|
|
||||||
$render .= $t->post( @post[$count] );
|
|
||||||
}
|
|
||||||
|
|
||||||
$count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
while ( ( $count < @post ) and ( $count < 50 ) ) {
|
while ( $count < @post ) {
|
||||||
$render .= $t->post( @post[$count] );
|
$render .= $t->post( @post[$count] );
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
$render .= $t->all($echo);
|
|
||||||
}
|
}
|
||||||
$render .= $t->foot();
|
$render .= $t->foot();
|
||||||
|
|
||||||
@ -127,8 +113,7 @@ sub to_me {
|
|||||||
my @post_from_me = $db->from_me($config);
|
my @post_from_me = $db->from_me($config);
|
||||||
|
|
||||||
# Render header
|
# Render header
|
||||||
my $render = $t->head(
|
my $render = $t->head('ii '. $config->{name} .' :: Моя переписка');
|
||||||
'ii ' . $config->{name} . ' :: Моя переписка' );
|
|
||||||
|
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
while ( $count < @post ) {
|
while ( $count < @post ) {
|
||||||
@ -158,7 +143,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>) {
|
||||||
@ -182,9 +167,7 @@ sub user {
|
|||||||
|
|
||||||
# Render header
|
# Render header
|
||||||
my $render
|
my $render
|
||||||
= $t->head( "ii "
|
= $t->head("ii ". $config->{name} ." :: Сообщения пользователя $user");
|
||||||
. $config->{name}
|
|
||||||
. " :: Сообщения пользователя $user" );
|
|
||||||
|
|
||||||
my @post = $db->select_user($user);
|
my @post = $db->select_user($user);
|
||||||
|
|
||||||
@ -205,8 +188,7 @@ sub send_new {
|
|||||||
my $t = $self->{_template};
|
my $t = $self->{_template};
|
||||||
my $config = $self->{_config};
|
my $config = $self->{_config};
|
||||||
|
|
||||||
my $render = $t->head(
|
my $render = $t->head("ii ". $config->{name} ." :: Новое сообщение");
|
||||||
"ii " . $config->{name} . " :: Новое сообщение" );
|
|
||||||
|
|
||||||
$render .= $t->new_mes($echo);
|
$render .= $t->new_mes($echo);
|
||||||
$render .= $t->foot();
|
$render .= $t->foot();
|
||||||
@ -221,8 +203,7 @@ sub send {
|
|||||||
my $t = $self->{_template};
|
my $t = $self->{_template};
|
||||||
my $config = $self->{_config};
|
my $config = $self->{_config};
|
||||||
|
|
||||||
my $render
|
my $render = $t->head("ii". $config->{name} ." :: Ответ на $hash");
|
||||||
= $t->head( "ii" . $config->{name} . " :: Ответ на $hash" );
|
|
||||||
|
|
||||||
# Render post
|
# Render post
|
||||||
my $data = $db->select_new($hash);
|
my $data = $db->select_new($hash);
|
||||||
@ -240,8 +221,7 @@ sub new_mes {
|
|||||||
my $t = $self->{_template};
|
my $t = $self->{_template};
|
||||||
my $config = $self->{_config};
|
my $config = $self->{_config};
|
||||||
|
|
||||||
my $render = $t->head(
|
my $render = $t->head('ii '. $config->{name} .' :: Новые сообщения');
|
||||||
'ii ' . $config->{name} . ' :: Новые сообщения' );
|
|
||||||
|
|
||||||
# Render posts
|
# Render posts
|
||||||
if ( defined($msgs) ) {
|
if ( defined($msgs) ) {
|
||||||
@ -263,26 +243,4 @@ sub new_mes {
|
|||||||
return $render;
|
return $render;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Search results
|
|
||||||
sub search {
|
|
||||||
my ( $self, @post ) = @_;
|
|
||||||
my $t = $self->{_template};
|
|
||||||
|
|
||||||
# Render header
|
|
||||||
my $render
|
|
||||||
= $t->head(
|
|
||||||
"ii " . $config->{name} . " :: Результаты поиска" );
|
|
||||||
|
|
||||||
my $count = 0;
|
|
||||||
while ( $count < @post ) {
|
|
||||||
|
|
||||||
# Render post
|
|
||||||
$render .= $t->post( @post[$count] );
|
|
||||||
$count++;
|
|
||||||
}
|
|
||||||
$render .= $t->foot();
|
|
||||||
|
|
||||||
return $render;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -31,7 +31,7 @@ sub send {
|
|||||||
my $host = $config->{host};
|
my $host = $config->{host};
|
||||||
my $auth = $config->{key};
|
my $auth = $config->{key};
|
||||||
$host .= "u/point";
|
$host .= "u/point";
|
||||||
my $ua = LWP::UserAgent->new(agent => 'Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0');
|
my $ua = LWP::UserAgent->new();
|
||||||
my $response
|
my $response
|
||||||
= $ua->post( $host, { 'pauth' => $auth, 'tmsg' => $base64 } );
|
= $ua->post( $host, { 'pauth' => $auth, 'tmsg' => $base64 } );
|
||||||
|
|
||||||
|
54
II/T.pm
54
II/T.pm
@ -1,8 +1,6 @@
|
|||||||
package II::T;
|
package II::T;
|
||||||
|
|
||||||
use HTML::Template;
|
use HTML::Template;
|
||||||
use HTML::FromText ();
|
|
||||||
use Encode;
|
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -149,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;
|
||||||
@ -164,37 +162,22 @@ sub in_pre {
|
|||||||
sub pre {
|
sub pre {
|
||||||
my ( $self, $post ) = @_;
|
my ( $self, $post ) = @_;
|
||||||
|
|
||||||
my $t2h = HTML::FromText->new(
|
$post =~ s/</</g;
|
||||||
{ paras => 1,
|
$post =~ s/>/>/g;
|
||||||
bullets => 1,
|
|
||||||
lines => 1,
|
|
||||||
blockcode => 1,
|
|
||||||
tables => 0,
|
|
||||||
numbers => 0,
|
|
||||||
urls => 0,
|
|
||||||
email => 1,
|
|
||||||
bold => 1,
|
|
||||||
underline => 1,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$post = $t2h->parse( decode_utf8($post) );
|
|
||||||
$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;
|
||||||
# Lists
|
|
||||||
$post =~ s/\*(.+)/<li>$1<\/li>/g;
|
|
||||||
|
|
||||||
# Images
|
# Images
|
||||||
$post
|
$post =~ s/\[img (.+)\]/<a href="$1"><img src="$1" width="15%" height="15%" \/><\/a>/g;
|
||||||
=~ s/\[img (.+)\]/<a href="$1"><img src="$1" width="15%" height="15%" \/><\/a>/g;
|
|
||||||
|
|
||||||
# ii uri
|
# ii uri
|
||||||
$post =~ s/ii:\/\/(\w+(\.)?\w+\.\d{2,4})/<a href="\/e?echo=$1&view=thread">$1<\/a>/g;
|
$post =~ s/ii:\/\/(.{20})/<a href="\/send?hash=$1">$1<\/a>/g;
|
||||||
$post =~ s/ii:\/\/(\w{20})/<a href="\/send?hash=$1">$1<\/a>/g;
|
# $post =~ s/ii:\/\/(.+\.\d+)/<a href="\/e?echo=$1&view=thread">$1<\/a>/g;
|
||||||
|
|
||||||
# Users
|
$post =~ s/^$/<br>\n/g;
|
||||||
# $post =~ s/.+? \@(\w+)(.?.+)/<a href="\/u?user=$1">$1<\/a>$2/g;
|
$post =~ s/(.?)\n/$1<br>\n/g;
|
||||||
|
$post =~ s/\*(.+)/<li>$1<\/li>\n/g;
|
||||||
|
|
||||||
# Not are regexp parsing
|
# Not are regexp parsing
|
||||||
my $pre = 0;
|
my $pre = 0;
|
||||||
@ -203,7 +186,7 @@ sub pre {
|
|||||||
while (<$fh>) {
|
while (<$fh>) {
|
||||||
my $line = $_;
|
my $line = $_;
|
||||||
if ( ( $line =~ /^====/ ) and ( $pre == 0 ) ) {
|
if ( ( $line =~ /^====/ ) and ( $pre == 0 ) ) {
|
||||||
|
# $txt .= $_;
|
||||||
$line =~ s/====/<pre class="pre">/g;
|
$line =~ s/====/<pre class="pre">/g;
|
||||||
$pre = 1;
|
$pre = 1;
|
||||||
}
|
}
|
||||||
@ -212,27 +195,12 @@ sub pre {
|
|||||||
$pre = 0;
|
$pre = 0;
|
||||||
}
|
}
|
||||||
$txt .= $line;
|
$txt .= $line;
|
||||||
$txt =~ s/<br \/>//g if $pre == 1;
|
|
||||||
$txt =~ s/<li>//g if $pre == 1;
|
|
||||||
$txt =~ s/<\/li>//g if $pre == 1;
|
|
||||||
$txt =~ s/<font.+>(>.+)<\/font>/$1/g if $pre == 1;
|
|
||||||
}
|
}
|
||||||
close $fh;
|
close $fh;
|
||||||
$txt =~ s/\n/<br>/g;
|
|
||||||
|
|
||||||
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) = @_;
|
||||||
|
@ -19,9 +19,13 @@ Install packages.
|
|||||||
On Debian based systems:
|
On Debian based systems:
|
||||||
|
|
||||||
apt-get install libplack-perl libhtml-template-perl libsql-abstract-perl \
|
apt-get install libplack-perl libhtml-template-perl libsql-abstract-perl \
|
||||||
libdbd-sqlite3-perl libconfig-tiny-perl libhtml-fromtext-perl
|
libdbd-sqlite3-perl libconfig-tiny-perl
|
||||||
|
|
||||||
## Run
|
## Run
|
||||||
|
|
||||||
cd /path/to/iiplc
|
cd /path/to/iiplc
|
||||||
./run.sh
|
./run.sh
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
|
||||||
|
* Check link before send
|
60
iiplc.app
Executable file → Normal file
60
iiplc.app
Executable file → Normal file
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
# Copyright © 2014-2015 Difrex <difrex.punk@gmail.com>
|
# Copyright © 2014 Difrex <difrex.punk@gmail.com>
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
@ -19,7 +19,6 @@ use warnings;
|
|||||||
use Plack::Builder;
|
use Plack::Builder;
|
||||||
use Plack::Request;
|
use Plack::Request;
|
||||||
use Plack::Response;
|
use Plack::Response;
|
||||||
|
|
||||||
# Static files
|
# Static files
|
||||||
use Plack::App::File;
|
use Plack::App::File;
|
||||||
|
|
||||||
@ -30,9 +29,13 @@ use II::Render;
|
|||||||
use II::DB;
|
use II::DB;
|
||||||
use II::Enc;
|
use II::Enc;
|
||||||
|
|
||||||
|
# Debug
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
my $c = II::Config->new();
|
my $c = II::Config->new();
|
||||||
my $config = $c->load();
|
my $config = $c->load();
|
||||||
|
|
||||||
|
my $GET = II::Get->new($config);
|
||||||
my $render = II::Render->new();
|
my $render = II::Render->new();
|
||||||
|
|
||||||
my $echo = sub {
|
my $echo = sub {
|
||||||
@ -61,21 +64,8 @@ my $thread = sub {
|
|||||||
return [ 200, [ 'Content-type' => 'text/html' ], ["$thread"], ];
|
return [ 200, [ 'Content-type' => 'text/html' ], ["$thread"], ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Get new messages
|
|
||||||
my $get = sub {
|
my $get = sub {
|
||||||
$config = $c->reload();
|
my $msgs = $GET->get_echo();
|
||||||
my $msgs;
|
|
||||||
if ( $config->{host} =~ m/.+\,.+/ ) {
|
|
||||||
my @hosts = split( /,/, $config->{host} );
|
|
||||||
foreach my $host (@hosts) {
|
|
||||||
$config->{host} = $host;
|
|
||||||
my $GET = II::Get->new($config);
|
|
||||||
$msgs .= $GET->get_echo();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
my $GET = II::Get->new($config);
|
|
||||||
$msgs .= $GET->get_echo();
|
|
||||||
}
|
|
||||||
my $new_mes = $render->new_mes($msgs);
|
my $new_mes = $render->new_mes($msgs);
|
||||||
return [ 200, [ 'Content-type' => 'text/html' ], ["$new_mes"], ];
|
return [ 200, [ 'Content-type' => 'text/html' ], ["$new_mes"], ];
|
||||||
};
|
};
|
||||||
@ -165,10 +155,6 @@ my $push = sub {
|
|||||||
my $hash = $req->param('hash');
|
my $hash = $req->param('hash');
|
||||||
|
|
||||||
$config = $c->reload();
|
$config = $c->reload();
|
||||||
if ( $config->{host} =~ m/.+\,.+/ ) {
|
|
||||||
my @hosts = split( /,/, $config->{host} );
|
|
||||||
$config->{host} = $hosts[0];
|
|
||||||
}
|
|
||||||
my $s = II::Send->new( $config, $echo, $base64 );
|
my $s = II::Send->new( $config, $echo, $base64 );
|
||||||
$s->send($hash);
|
$s->send($hash);
|
||||||
|
|
||||||
@ -189,40 +175,9 @@ my $user = sub {
|
|||||||
return [ 200, [ 'Content-type' => 'text/html' ], [$mes_from], ];
|
return [ 200, [ 'Content-type' => 'text/html' ], [$mes_from], ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Search
|
|
||||||
########
|
|
||||||
my $search = sub {
|
|
||||||
my $env = shift;
|
|
||||||
|
|
||||||
my $req = Plack::Request->new($env);
|
|
||||||
my $query = $req->param('q');
|
|
||||||
|
|
||||||
my $db = II::DB->new();
|
|
||||||
my @post = $db->do_search($query);
|
|
||||||
|
|
||||||
my $result = $render->search(@post);
|
|
||||||
|
|
||||||
return [ 200, [ 'Content-type' => 'text/html' ], [$result], ];
|
|
||||||
};
|
|
||||||
|
|
||||||
# Delete out message
|
|
||||||
####################
|
|
||||||
my $del = sub {
|
|
||||||
my $env = shift;
|
|
||||||
|
|
||||||
my $req = Plack::Request->new($env);
|
|
||||||
my $hash = $req->param('hash');
|
|
||||||
|
|
||||||
my $db = II::DB->new();
|
|
||||||
$db->del_out($hash);
|
|
||||||
|
|
||||||
return [301, ['Location' => '/out'], [], ];
|
|
||||||
};
|
|
||||||
|
|
||||||
# Mountpoints
|
# Mountpoints
|
||||||
builder {
|
builder {
|
||||||
mount "/static" => Plack::App::File->new( root => './s/' )->to_app;
|
mount "/static" => Plack::App::File->new(root => './s/')->to_app;
|
||||||
mount "/search" => $search;
|
|
||||||
mount '/' => $root;
|
mount '/' => $root;
|
||||||
mount '/e' => $echo;
|
mount '/e' => $echo;
|
||||||
mount '/s' => $thread;
|
mount '/s' => $thread;
|
||||||
@ -235,5 +190,4 @@ builder {
|
|||||||
mount '/out' => $out;
|
mount '/out' => $out;
|
||||||
mount '/push' => $push;
|
mount '/push' => $push;
|
||||||
mount '/new' => $new;
|
mount '/new' => $new;
|
||||||
mount '/del' => $del;
|
|
||||||
};
|
};
|
||||||
|
1
run.sh
1
run.sh
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
# Debug server
|
# Debug server
|
||||||
screen -S ii plackup iiplc.app
|
screen -S ii plackup iiplc.app
|
||||||
# plackup iiplc.app
|
|
||||||
|
|
||||||
# Production
|
# Production
|
||||||
# starman -l 127.0.0.1:5000 run.pl whatever
|
# starman -l 127.0.0.1:5000 run.pl whatever
|
||||||
|
@ -39,15 +39,6 @@ padding-bottom: 0.15em;
|
|||||||
padding-left: 5pt;
|
padding-left: 5pt;
|
||||||
padding-top: 5pt;
|
padding-top: 5pt;
|
||||||
}
|
}
|
||||||
.msg_hash {
|
|
||||||
float: right;
|
|
||||||
margin-right: 1.5em;
|
|
||||||
margin-top: 2em;
|
|
||||||
color: #222;
|
|
||||||
opacity: 0.4;
|
|
||||||
font-family: monospace;
|
|
||||||
font-size: 8pt;
|
|
||||||
}
|
|
||||||
.subg a {
|
.subg a {
|
||||||
color: #222;
|
color: #222;
|
||||||
}
|
}
|
||||||
@ -158,34 +149,3 @@ 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%;
|
|
||||||
}
|
|
||||||
/* Search */
|
|
||||||
.search {
|
|
||||||
position: fixed;
|
|
||||||
top: 2em;
|
|
||||||
left: 0.5em;
|
|
||||||
opacity: 0.4;
|
|
||||||
transition-duration: 0.5s;
|
|
||||||
-webkit-transition-duration: 0.5s;
|
|
||||||
}
|
|
||||||
.search:hover {
|
|
||||||
opacity: 1;
|
|
||||||
transition-duration: 0.5s;
|
|
||||||
-webkit-transition-duration: 0.5s;
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
<a class='all_link' href="e?echo=<TMPL_VAR NAME=ECHO>&view=all">
|
|
||||||
Все сообщения
|
|
||||||
</a>
|
|
@ -15,10 +15,4 @@
|
|||||||
<b>[</b> <a href="/out">неотправленные сообщения</a> <b>]</b> 
|
<b>[</b> <a href="/out">неотправленные сообщения</a> <b>]</b> 
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class='search'>
|
|
||||||
<form action='/search' method='POST'>
|
|
||||||
<input type='text' name='q'><br>
|
|
||||||
<input type='submit' value='Искать'>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<!-- <hr> -->
|
<!-- <hr> -->
|
||||||
|
@ -12,6 +12,5 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class=answer>
|
<div class=answer>
|
||||||
<a href="/push?echo=<TMPL_VAR NAME=ECHO>&base64=<TMPL_VAR NAME=BASE64>&hash=<TMPL_VAR NAME=HASH>">Отправить</a>
|
<a href="/push?echo=<TMPL_VAR NAME=ECHO>&base64=<TMPL_VAR NAME=BASE64>&hash=<TMPL_VAR NAME=HASH>">Отправить</a>
|
||||||
<a href="/del?hash=<TMPL_VAR NAME=HASH>">Удалить</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@ -1,7 +1,4 @@
|
|||||||
<div class=post>
|
<div class=post>
|
||||||
<div class='msg_hash'>
|
|
||||||
MsgID: <TMPL_VAR NAME=HASH>
|
|
||||||
</div>
|
|
||||||
<a style="text-decoration:none;" href="/s?subg=<TMPL_VAR NAME=CUT>&echo=<TMPL_VAR NAME=ECHO>"><h2><TMPL_VAR NAME=SUBG></h2></a>
|
<a style="text-decoration:none;" href="/s?subg=<TMPL_VAR NAME=CUT>&echo=<TMPL_VAR NAME=ECHO>"><h2><TMPL_VAR NAME=SUBG></h2></a>
|
||||||
<div class=mail>
|
<div class=mail>
|
||||||
<i><TMPL_VAR NAME=TIME></i><br>
|
<i><TMPL_VAR NAME=TIME></i><br>
|
||||||
|
Loading…
Reference in New Issue
Block a user