Penn Computing
Computing Menu Computing A-Z
Computing Home Information Systems & Computing Penn

Simple Search

Simple Search is a generic CGI search utility, based on Matt Wright's Simple Search but modified for web providers on the host www.upenn.edu. It is not based on AltaVista, but rather is a complementary search utility to give providers extended capability on web sites that are less than 500 pages. With Simple Search, you can set up a search form that enables your users to search the areas of your site that you specify in a configuration file. The instructions below will lead you through the process of using the Simple Search utility.


Creating a configuration file

To use the Simple Search utility, you must create a configuration file and place it in the directory that you want searched. The configuration file can be named whatever you want, but should end with the extension .cfg. It is recommended that you name your file search.cfg.

  1. Open a new file in your HTML editor and save it as "search.cfg".
  2. In your search.cfg file, type the title of the directory you want to search. This is the only variable that is required in the configuration file. The title is used on the search results page as textual links that allow users to return to your home directory and your search form. The syntax is:

    title=Name of Your Directory

    For example, if the name of the directory that you want to search is called "Computing Job Opportunities" the line would be

    title=Computing Job Opportunities

    If you specify only the title of the directory that you want searched in your configuration file, Simple Search will make the following assumptions:

    • That only HTML files in the directory where search.cfg resides are to be searched, i.e., there are no subdirectories you want to search
    • That an index.html file funtioning as a home page exists in the directory where the search.cfg resides
    • That a search.html form exists in the directory where the search.cfg resides
  3. If all HTML files to be searched reside in same directory as the configuration file, AND if your home page is called index.html, then you are ready to create your search form. FTP the search.cfg file up to your directory and go to the section "Creating a search form".

    If you have subdirectories that you would also like to be included in the search, if your home page is not called index.html, OR if you will not have a separate file called search.html, you need to set additional variables in your configuration file. Go to the section "Setting additional variables in a configuration file".


Setting additional variables in a configuration file

If any of the following is true, you need to set additional variables in your configuration file:

  • You want to allow non-HTML file searching
  • You want to allow subdirectory searching
  • Your home page is not called index.html
  • Your search form is not named search.html; i.e., you don't have a separate HTML file for your search form, but rather have the form on one of your existing pages
  • You want to customize the results page by adding your own header and footer
  • You don't want to display the search option with your results
  • You don't want to include a navigational bar at the bottom of your search results

To set variables to control these situations, consult the table below. Customers using Server-Side Includes or frames have special variables that they can set. When you are finished setting additional variables in your configuration file, FTP the search.cfg file up to your directory.

title_url The optional "title_url" variable specifies the URL of your home page. If no title_url is specified, the title_url defaults to the index.html in your home directory (for example, www.upenn.edu/mysite/index.html).

Syntax: title_url=[url of the provider's homepage]

Default: [providerdir]/index.html

Example: title_url=http://www.upenn.edu/computing/jobs/home.html

files The optional "files" variable specifies the file types, directories, and subdirectories to be included in the search. If the files variable is not supplied, only HTML files in your home directory will be searched; subdirectories and non-HTML files will be excluded from the search.

Syntax: files=[files to be searched]

Default: *.html

If you want your home directory and a few subdirectories searched, you need to specify the names of the subdirectories, using the synax subdir1/*.html,subdir2/*.html. You also need to include *.txt and *.html to search files on the home directory.

Example: files=*.txt,*.html,ait/*.html,net/*.html,sos/*.html

If you want your home directory and ALL subdirectories searched, you need to use the syntax */*.html for HTML files and */*.txt for text files in subdirectories. You also need to include *.txt and *.html to search files on the home directory.

Example: files=*.txt,*.html,*/*.txt,*/*.html

excludes

If there are files or subdirectories that you do not want included in the search, you need to use the exclude option.

Syntax: excludes=[files or subdirectories to be excluded]

Example: excludes=index*,subdir1/*.html,testing.html

search_url The optional "search_url" specifies the location of your search form. If no search_url is specified, the search_url defaults to the search.html file in your home directory. You need to use this variable if your search form is on any page other than a page named search.html.

Syntax: search_url=[url of the search form]

Default: [providerdir]/search.html

Example: search_url=http://www.upenn.edu/computing/jobs/index.html

header The optional "header" specifies the location of your header file. If no header is specified, the header of the search results page will default to
<head>
<title>Results of Search</title>
</head>
<body bgcolor="#FFFFF">
&lt:blockquote> &lt:blockquote>
You header file must include the <head>, <title>, and <body> tags. Any links included in your header file must use paths beginning with the absolute HTML root like
<img src="/computing/img/computing.img">
rather than
<img src="img/computing.img">
Since this is a CGI script that is dynamically producing the search results page, you cannot use Server-Side Includes within your header file.

Syntax: header=[location of your header file]

Example: header=/computing/lib/inc/v0/compmenuhead.html

footer The optional "footer" specifies the location of your footer file. If no footer is specified, the footer of the search results page will default to
</blockquote> </blockquote>
You footer file must include a closing </body> tag. Any links included in your footer file must use paths beginning with the absolute HTML root like
<img src="/computing/img/computing.img">
rather than
<img src="img/computing.img">
Since this is a CGI script that is dynamically producing the search results page, you cannot use Server-Side Includes within your footer file.

Syntax: footer=[location of your footer file]

Example: footer=/computing/lib/inc/v0/compfoot.html

searchargs The optional "searchargs" specifies whether you want the search arguments to be displayed with your search results. If no searchargs is specified, the top of the search results page will default to something like
Search Terms: franklin
Boolean Used: AND
Case: INSENSITIVE

Results:

If you turn off the display of the search arguments, the top of the search results page will look something like
Search Terms: franklin

Results:

This is useful if you have not included search arguments in your search form and are instead defaulting to Boolean=AND and case=INSENSITIVE for all searches.

Syntax: searchargs=off

Default: searchargs=on

navbar The optional "navbar" specifies whether you want a navigational bar to be displayed with your search results and what that navigational bar will be. If no navbar is specified, the bottom of the search results page will include links back to your homepage, your search form and to the central Penn Web search.

You can set the navbar to "off" and no links will appear at the bottom of your search results page.

You can also set navbar to be your own file containing navigational links. Any links included in your navigational file must use paths beginning with the absolute HTML root like

<img src="/computing/img/computing.img">
rather than
<img src="img/computing.img">
Since this is a CGI script that is dynamically producing the search results page, you cannot use Server-Side Includes within your navigational file.

Syntax: navbar=on | off | [location of your navigational file]

Example: navbar=off
Example: navbar=/computing/lib/inc/v0/navbar.html

Default: navbar=on

striptitle When a user searches your site, the script will look through the files specified in your search configuration for the terms the user has input. The script will use the <title> tag from your HTML file as the link back to the HTML document in the search results.

Often a site will include an identifying phrase in the <title> tag of all documents on the site. This is useful when viewing any one page but can be quite redundant when a list of files is displayed in the search results.

The optional "striptitle" specifies a string of characters that is to be stripped from the <title> tag when displaying the list of search results.

Syntax: striptitle=[string]

Example: A document's <title> tag looks like

<title>Computing Help - Email clients</title>
You want to strip out "Computing Help -" from the search results.
striptitle=Computing Help -


Creating a search form

There are several ways to use a search form:

  • On a web page of its own, called "search.html"
  • On a web page of its own, NOT called "search.html"
  • On an already existing page within your site NOT called "search.html"

To create a search form on a page of its own, called "search.html":

  1. Open a new file in your HTML editor and save it as "search.html".
  2. Point your web browser to the search form template (www.upenn.edu/computing/web/webdev/simplesearch/search.txt).
  3. Copy the code from the search form template and paste it into your search.html page.
  4. Change the text that you see in [brackets] to customize this form for your directory. Remember to delete the brackets when you are finished.

  5. FTP the search.html file up to your directory.

    Here is an example of a search.html page with the form created by the template.

To create a search form on a page of its own, NOT called "search.html":

  1. Open a new file in your HTML editor and save it as an .html file with whatever name you want.
  2. Point your web browser to the search form template (www.upenn.edu/computing/web/webdev/simplesearch/search.txt).
  3. Copy the code from the search form template and paste it into your HTML file.
  4. Change the text that you see in [brackets] to customize this form for your directory. Remember to delete the brackets when you are finished.

  5. FTP the file up to your directory.

    Note: Be sure to set the search_url variable in your configuration file to reflect the name and location of the HTML file with your search form.

    Here is an example of a search.html page with the form created by the template.

To create a search form on an already existing page within your site, NOT called "search.html:

  1. Open the file on which you want to put a search form in your HTML editor.
  2. Point your web browser to the search form template (www.upenn.edu/computing/web/webdev/simplesearch/search2.txt).
  3. Copy the code from the search form template and paste it into your HTML file where you want the form to appear (usually at the bottom of a page).
  4. Change the text that you see in [brackets] to customize this form for your directory. Remember to delete the brackets when you are finished.

  5. FTP the file up to your directory.

    Note: Be sure to set the search_url variable in your configuration file to reflect the name and location of the HTML file with your search form.

    Here is an example of a page that uses the search form created by the template.



penn web developers
top

Information Systems and Computing
University of Pennsylvania
Comments & Questions


University of Pennsylvania Penn Computing University of Pennsylvania Information Systems & Computing (ISC)
Information Systems and Computing, University of Pennsylvania