gmnifaq

Unnamed repository; edit this file 'description' to name the repository.
git clone git://code.clttr.info/gmnifaq.git
Log | Files | Refs | README | LICENSE

commit ac99b4092b057be8aeb3237c92a32329d931aa01
parent 0cfdd64ea47cf0d24b3280ba8b821dff01a849d9
Author: René Wagner <rwagner@rw-net.de>
Date:   Mon, 18 Jan 2021 20:42:01 +0100

use relative links

small cosmetic improvements

Diffstat:
Mfaqs.pl | 3+--
Mlib/gmnifaq.pm | 2+-
Msearch.pl | 16+++++++++-------
3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/faqs.pl b/faqs.pl @@ -61,8 +61,7 @@ sub faqs else { foreach (@rows) { push @return, sprintf("### %s", @$_[1]); - push @return, ''; - push @return, @$_[2]; + push @return, ('', @$_[2], ''); } } push @return, ''; diff --git a/lib/gmnifaq.pm b/lib/gmnifaq.pm @@ -51,7 +51,7 @@ sub config sub footer { - return ('', '=> ./index.pl Home', '=> https://src.clttr.info/rwa/gmnifaq powered by gmnifaq'); + return ('', '=> ./index.pl [home]', '=> https://src.clttr.info/rwa/gmnifaq powered by gmnifaq'); } sub write_response diff --git a/search.pl b/search.pl @@ -22,9 +22,9 @@ if (!defined($ENV{'SERVER_PROTOCOL'}) || $ENV{'SERVER_PROTOCOL'} ne 'GEMINI') { } my $query = lc(uri_unescape($ENV{'QUERY_STRING'})); -if ($query eq '') +if ($query eq '' || $query !~ /^[0-9a-z]*$/i) { - write_response('INPUT', 'Search faqs for the following terms (blank-space separated):', undef); + write_response('INPUT', 'Search faqs for the following terms (separate by blank)', undef); } my @body = (); @@ -46,9 +46,12 @@ sub search my @matchingfaqs = $dbh->selectall_array("SELECT * FROM questions WHERE question LIKE '%$term%' OR answer LIKE '%$term%'"); $dbh->disconnect(); + if ( !scalar(@matchingtags) && !scalar(@matchingfaqs)) { + push @result, ('Sorry, we can\'t find an entry that matches your search data.', ''); + } + if ( scalar(@matchingtags)) { - push @result, '## matching tags'; - push @result, ''; + push @result, ('## matching tags', ''); foreach (@matchingtags) { push @result, sprintf("=> ./faqs.pl?tag=%d %s (%d entrys)", @$_[0], @$_[1], @$_[2]); } @@ -56,13 +59,12 @@ sub search } if ( scalar(@matchingfaqs)) { - push @result, '## matching FAQs'; - push @result, ''; + push @result, ('## matching FAQs', ''); foreach (@matchingfaqs) { push @result, sprintf("=> ./faqs.pl?faq=%d %s", @$_[0], @$_[1]); } } - push @result, ''; + push @result, ('', '=> ./search.pl search again'); return @result; }