treebird/perl/search.pm
nekobit 19b19b900b Chat
FossilOrigin-Name: 7129d3c344032bab229fdc356df7522608a95af3696d92d22ec8f40d557c5734
2022-08-06 05:06:27 +00:00

83 lines
1.5 KiB
Perl

package search;
use strict;
use warnings;
use Exporter 'import';
our @EXPORTS = qw( content_search search_tags search_accounts search_statuses );
use template_helpers 'to_template';
use constant
{
SEARCH_CAT_STATUSES => 0,
SEARCH_CAT_ACCOUNTS => 1,
SEARCH_CAT_TAGS => 2
};
sub search_page
{
my ($ssn, $data, $tab, $content) = @_;
my %vars = (
prefix => '',
ssn => $ssn,
tab => $tab,
content => $content,
);
to_template(\%vars, \$data->{'search.tt'});
}
sub search_tags
{
my ($ssn, $data, $tags) = @_;
my %vars = (
prefix => '',
ssn => $ssn,
statuses => $statuses,
);
search_page($ssn, $data, SEARCH_CAT_STATUSES, to_template(\%vars, \$data->{'search_tags.tt'}));
}
sub search_accounts
{
my ($ssn, $data, $statuses) = @_;
my %vars = (
prefix => '',
ssn => $ssn,
statuses => $statuses,
);
search_page($ssn, $data, SEARCH_CAT_STATUSES, to_template(\%vars, \$data->{'search_accounts.tt'}));
}
sub search_statuses
{
my ($ssn, $data, $statuses) = @_;
my %vars = (
prefix => '',
ssn => $ssn,
statuses => $statuses,
);
search_page($ssn, $data, SEARCH_CAT_STATUSES, to_template(\%vars, \$data->{'search_statuses.tt'}));
}
sub content_search
{
my ($ssn, $data, $search) = @_;
my %vars = (
prefix => '',
ssn => $ssn,
search => $search,
);
to_template(\%vars, \$data->{'content_search.tt'});
}