.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "SEARCH.CGI 7"
.TH SEARCH.CGI 7 "2014-09-03" "perl v5.20.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
search.cgi \-\- Example Perl program for searching with Swish\-e and SWISH::API
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This is a very simple program that shows how to use the \s-1SWISH::API\s0 module
in a \s-1CGI\s0 script or mod_perl handler using Template-Toolkit to generate
output. This program is intended for programmers that want to create a custom
search script.
.PP
Unlike \fIswish.cgi\fR this script does not have many features, and provides no
external configuration (with the execption of a few config options under
mod_perl). So don't ask why it doesn't do something. The point is that this
script is used as a starting point that \s-1YOU\s0 customize.
.SH "REQUIREMENTS"
.IX Header "REQUIREMENTS"
You must have swish-e and the \s-1SWISH::API\s0 module installed. See the \s-1README\s0
and \s-1INSTALL\s0 documents in the swish-e distribution. As of this writing \s-1SWISH::API\s0
is part of the swish-e distribution, but in the future may be provided as a separate
package (provided on the \s-1CPAN\s0). In either case \s-1SWISH::API\s0 is a separate installation
procedure from installing swish-e. The Storable module is also required if using mod_perl.
.PP
This program does require that some modules are installed from \s-1CPAN.\s0
You will need Template-Toolkit and HTML::FillInForm (which depends on HTML::Parser).
How those are installed depends on your computer's packaging system.
.PP
You will need a web server, obviously. The discussion below assumes Apache is used.
If you are using \s-1MS IIS\s0 take note that \s-1IIS\s0 works differently in a number of ways.
.SH "OVERVIEW"
.IX Header "OVERVIEW"
The \fIsearch.cgi\fR script and related templates are installed when swish-e is installed.
\&\fIsearch.cgi\fR is installed in \f(CW$prefix\fR/lib/swish\-e/ and templates are installed
in \f(CW$prefix\fR/share/swish\-e/templates/. \f(CW$prefix\fR is /usr/local by default
but can be changed when running the swish-e \fIconfigure\fR script. Upon
installation \fIsearch.cgi\fR is updated with correct paths to your perl binary and
.PP
When running as a \s-1CGI\s0 script \fIsearch.cgi\fR is copied or symlinked to the location
of your \s-1CGI\s0 scripts (or any directory that allows \s-1CGI\s0 scripts). By default,
the \fIsearch.cgi\fR script looks for the index \fIindex.swish\-e\fR in the current
directory (that's what the web server considers the current directory). On Apache
running mod-cgi that's the same place as the script. On \s-1IIS\s0 it's not. If your
index is elsewhere you will need to modify the script.
.PP
The script works by parsing the query, calling \s-1SWISH::API\s0 to run the actual search, then
calls Template-Toolkit to generate the ouput.
.PP
The script calls the \fIsearch.tt\fR template. This template generates the query
form and the search results. The \fIsearch.tt\fR template uses a
Template-Toolkit \*(L"\s-1WRAPPER\*(R"\s0 function to wrap the search form and results in your
site's design. This design is in the \fIpage_layout\fR template. The idea is
if you use Template-Toolkit to manage your entire site then your entire site
would be formatted by the same \fIpage_layout\fR template. The \fIpage_layout\fR template
calls two other templates \fIcommon_header\fR and \fIcommon_footer\fR to generate a common
header and footer for the site. Those are just demonstrating Template-Toolkit's
features.
.PP
The \fIpage_layout\fR page only defines the basic structure of the site. The true
design of the site is managed by style sheets. \fIstyle.css\fR defines the basic
layout and \fImarkup.css\fR sets fonts and colors.
.PP
Note: these style sheets are included directly in the output of the \s-1CGI\s0 script.
In production the style sheets would be stored as separate style
sheet files and imported by the browser instead of directly included in the
search results page.
.PP
See the section \s-1MOD_PERL\s0 below for more on templates.
.PP
Highlighting of search terms is provided by the SWISH::PhraseHighlight module.
That is a very slow module, so you may wish to disable it if you expect a lot
of traffic.
.SH "INSTALLATION EXAMPLE"
.IX Header "INSTALLATION EXAMPLE"
Enough talking, sometimes it's nice to see a complete example. Below swish-e
is installed in the default location (/usr/local). The \*(L"$\*(R" is a normal user
prompt, where \*(L"#\*(R" is a root prompt. Use ./configure \-\-prefix to install in another
location (e.g. if you do not have root access).
.PP
Download and install swish-e
.PP
.Vb 8
\& $ wget \-q http://swish\-e.org/Download/latest.tar.gz
\& $ tar zxf latest.tar.gz
\& $ cd swish\-e\-2.x.x
\& $ (./configure && make) >/dev/null
\& $ make check
\& $ su
\& # make install
\& # exit
.Ve
.PP
Install \s-1SWISH::API\s0
.PP
.Vb 5
\& $ cd perl
\& $ perl Makefile.PL && make && make test
\& $ su
\& # make install
\& $ exit
.Ve
.PP
Install requried Perl modules. You can install via RPMs, Debs or directly from the \s-1CPAN\s0
or by using the \s-1CPAN\s0 shell.
.PP
.Vb 4
\& # su
\& # perl \-MCPAN \-e \*(Aqinstall Template\*(Aq
\& # perl \-MCPAN \-e \*(Aqinstall HTML::FillInForm\*(Aq
\& # exit
.Ve
.PP
Now setup the script in someplace that allows \s-1CGI\s0 scripts.
.PP
.Vb 9
\& $ cd $HOME/apache
\& $ ln \-s /usr/local/lib/swish\-e/search.cgi .
\& $ cat .htaccess
\& deny from all
\&