Customizing Results Output

  1. Installing the custom output module

  2. Controlling output text using wgoutput.cfg

  3. NEW in 1.7.4: Using patterns from the document in results output

Installing the custom output module

If you installed a commercial version of Webglimpse, you already have the custom output module installed. To use variable substitution, you must have v1.7.4 or higher.

If you are installing or upgrading the commercial modules separately, follow the instructions in the INSTALL_MODULES file included with the package. You can get Modules for 1.X versions or Modules for 2.X. The main difference is that with 2.X, you can get a toolbar for groups of N hits at the bottom of the page, for cases where more than the maximum # of hits are returned.

Controlling output text

Using wgoutput.cfg , you have control over each piece of text output by webglimpse in the results page. Here is a sample wgoutput.cfg file. This file is shipped as the default output configuration in version 1.7.4. Note, however, that in versions prior to 2.1 the file is named .wgoutput.cfg so it is hidden from the directory listing. Each line in the wgoutput.cfg file starts with a special variable name or a + character to continue the previous record. The variables are used as follows to generate results output:
begin_html		output once at the beginning of results

neigh_msg		output once if this is a neighborhood search
noneigh_msg		output once if not a neighborhood search

lines_msg		output once if using jump to line
nolines_msg		output once if not using jump to line

begin_files		output once if any files match query

begin_file_marker	output at start of each file match, 
			before the actual link to the file

begin_lines		output before first matching line of each file,
			but after the actual link to the file

begin_single_line	output before each matching line of each file

end_single_line		output after each matching line of each file

end_lines		output after all matching lines of each file

end_file_marker		output after end_lines

end_files		output after all matching files (if any)

end_html		output at end of results page

Using patterns in Results output

Starting in version 1.7.4, it is also possible to substitute user-defined and pre-defined variables from the matched document into the results set. Variables are denoted by
	[VARNAME]
in the wgoutput.cfg file.

Pre-defined variables are as follows:

[QUERY]			The original user query

[SEARCHTITLE]		Optional form variable in wgindex.html 

[MATCHED_LINES]		Number of matching lines 
			(Can ONLY be used in end_html variable above)

[MATCHED_FILES]		Number of matching files
			(Can ONLY be used in end_html variable above)			
User-defined variables are set up in the .wgoutputfields file. The format is
TYPE<tab>NAME<tab>REGEXP
where TYPE may be FILE, to look for value in the actual matching file, or PATH, to look for the value in the directory path

NAME should match a variable [NAME] in the wgoutput.cfg file in the archive directory. TITLE is a special name, and will be used for the linked text.

The value will be set to the first matching ()'s (using the $1 variable after a match)

For example, the .wgoutputfields line:

FILE   REFNO   ^Reference Number:\s+(.+)$
will cause each file returned by Glimpse to be parsed for the regular expression /^Reference Number:\s+(.+)$/, and if a match occurs, the subexpression corresponding to the ()'s is substituted for
[REFNO]
wherever that variable appears in the output text specified in wgoutput.cfg. Note, only one subexpression should be enclosed in parentheses.


Here is an example of a path-based variable. This line in .wgoutputfields:
PATH   LASTSUBDIR      \/([^\/]+)\/[^\/]+$
will cause the path to each returned file, to be parsed for the regular expression /\/([^\/]+)\/[^\/]+$/. If a match occurs, the subexpression corresponding to the ()'s, in this case the last subdirectory containing the file, is substituted for
[LASTSUBDIR]
as it appears in wgoutput.cfg.
Questions, comments & support requests contact us


Docs and Howtos