search route
This commit is contained in:
parent
8be1c614f1
commit
52503dfebf
2
II/DB.pm
2
II/DB.pm
@ -20,6 +20,7 @@ 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};
|
||||||
@ -39,6 +40,7 @@ sub check_hash {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Begin transaction
|
||||||
sub begin {
|
sub begin {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my $dbh = $self->{_dbh};
|
my $dbh = $self->{_dbh};
|
||||||
|
44
iiplc.app
44
iiplc.app
@ -19,6 +19,7 @@ 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;
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ my $thread = sub {
|
|||||||
|
|
||||||
my $get = sub {
|
my $get = sub {
|
||||||
$config = $c->reload();
|
$config = $c->reload();
|
||||||
my $GET = II::Get->new($config);
|
my $GET = II::Get->new($config);
|
||||||
my $msgs = $GET->get_echo();
|
my $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"], ];
|
||||||
@ -176,19 +177,34 @@ 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 $result = $db->do_search($q);
|
||||||
|
|
||||||
|
return [ 200, [ 'Content-type' => 'text/html' ], [$result], ];
|
||||||
|
};
|
||||||
|
|
||||||
# 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 '/' => $root;
|
mount "/search" => $search;
|
||||||
mount '/e' => $echo;
|
mount '/' => $root;
|
||||||
mount '/s' => $thread;
|
mount '/e' => $echo;
|
||||||
mount '/u' => $user;
|
mount '/s' => $thread;
|
||||||
mount '/me' => $me;
|
mount '/u' => $user;
|
||||||
mount '/tree' => $tree;
|
mount '/me' => $me;
|
||||||
mount '/get/' => $get;
|
mount '/tree' => $tree;
|
||||||
mount '/send' => $send;
|
mount '/get' => $get;
|
||||||
mount '/enc' => $enc;
|
mount '/send' => $send;
|
||||||
mount '/out' => $out;
|
mount '/enc' => $enc;
|
||||||
mount '/push' => $push;
|
mount '/out' => $out;
|
||||||
mount '/new' => $new;
|
mount '/push' => $push;
|
||||||
|
mount '/new' => $new;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user