Skip to main content.
home | support | download

Back to List Archive

swish.cgi script

From: <jinche04(at)not-real.quicksilver.net.nz>
Date: Thu Feb 27 2003 - 23:22:30 GMT
Thanks Peggy and Bill. Finally I can come to the list, I post my question
again. 

Jim Chen wrote: 

> I set up my swish-e in windows 2000, I can run simple cgi to get result
> with title, rank, url etc. I try to use swish.cgi script to get more
> complex result(like highlight keywords), but get an "Internal Server
> Error". 
>
> my error log file is: 
>
> [Thu Feb 27 21:38:45 2003] [error] [client 127.0.0.1] Premature end of
> script headers: c:/wwwroot/cgi-bin/mytest.cgi
> [Thu Feb 27 21:38:45 2003] [error] [client 127.0.0.1] Undefined
> subroutine &TemplateDefault::page_header called at
> c:/wwwroot/cgi-bin/example/modules/TemplateDefault.pm line 16. 
>
>
> I only make some changes( change the path) on this swish.cgi file: 
>
>
> #------------------swish.cgi-----------
> #!c:/perl/bin/perl
>  package SwishSearch;
>   use strict;
>   use lib qw( c:/wwwroot/cgi-bin/example/modules ); 
>
> my $DEFAULT_CONFIG_FILE = ''; 
>
> # Run the script -- entry point if running as a CGI script 
>
>     unless ( $ENV{MOD_PERL} ) {
>        my $config = default_config();
>         # Merge with disk config file.
>         $config = merge_read_config( $config );
>         process_request( $config );
>     }
> #---------------------------------------------------------------------------
> sub default_config {
>     return {
>         title           => 'Search our site',
>         swish_binary    => 'swish-e',
>        config_file     => $DEFAULT_CONFIG_FILE,
>         swish_index     => 'C:/wwwroot/indexing/swish.index',
>         page_size       => 15,
>         title_property => 'swishtitle',
>         description_prop    => 'swishdescription',
>         display_props   => [qw/swishlastmodified swishdocsize
> swishdocpath/],
>         sorts           => [qw/swishrank swishlastmodified swishtitle
> swishdocpath/],
>         secondary_sort  => [qw/swishlastmodified desc/],
>         metanames       => [qw/swishdefault swishtitle swishdocpath /],
>         meta_groups => {
>             all =>  [qw/swishdefault swishtitle swishdocpath/],
>         }, 
>
>         name_labels => {
>             swishdefault        => 'Title & Body',
>             swishtitle          => 'Title',
>             swishrank           => 'Rank',
>             swishlastmodified   => 'Last Modified Date',
>             swishdocpath        => 'Document Path',
>             swishdocsize        => 'Document Size',
>             all                 => 'All',              # group of metanames
>             subject             => 'Message Subject',  # other examples
>             name                => "Poster's Name",
>             email               => "Poster's Email",
>             sent                => 'Message Date',
>         },
>         timeout         => 10,
>         max_chars       => 500,
>         highlight       => {
>             package         =>
> 'C:/wwwroot/cgi-bin/example/modules/PhraseHighlight',
>             show_words      => 10,
>             max_words       => 100,
>             occurrences     => 6,
>             highlight_on    => '<font style="background:#FFFF99">',
>             highlight_off   => '</font>',
>             meta_to_prop_map => {
>                 swishdefault    => [ qw/swishtitle swishdescription/ ],
>                 swishtitle      => [ qw/swishtitle/ ],
>                 swishdocpath    => [ qw/swishdocpath/ ],
>                 all             => [ qw/swishtitle swishdescription
> swishdocpath/ ],
>             },
>         }, 
>
>         Xselect_indexes  => {
>            method  => 'checkbox_group',
>             columns => 3,
>             labels  => [ 'Main Index', 'Other Index', qw/ two three
> four/ ],  # Must match up one-to-one
>             description => 'Select Site: ',
>         },
>         Xselect_by_meta  => {
>             #method      => 'radio_group',
>             method      => 'checkbox_group',
>             #method      => 'popup_menu',
>             columns     => 3,
>             metaname    => 'site',     # Can't be a metaname used elsewhere!
>             values      => [qw/misc mod vhosts other/],
>             labels  => {
>                 misc    => 'General Apache docs',
>                 mod     => 'Apache Modules',
>                 vhosts  => 'Virutal hosts',
>             },
>             description => 'Limit search to these areas: ',
>         },
>         xtemplate => {
>             package     =>
> 'C:/wwwroot/cgi-bin/example/modules/TemplateDefault',
>         },
>         xtemplate => {
>             package     =>
> 'C:/wwwroot/cgi-bin/example/modules/TemplateDumper',
>         },
>         xtemplate => {
>             package         =>
> 'C:/wwwroot/cgi-bin/example/modules/TemplateToolkit',
>             file            => 'C:/wwwroot/cgi-bin/example/search.tt',
>             options         => {
>                 #INCLUDE_PATH    => 'C:\wwwroot\cgi-bin\example\',
>                 #PRE_PROCESS     => 'config',
>             },
>         },
>         xtemplate => {
>             package         =>
> 'C:/wwwroot/cgi-bin/example/modules/TemplateHTMLTemplate',
>             options         => {
>                 filename            => 'swish.tmpl',
>                 die_on_bad_params   => 0,
>                 loop_context_vars   => 1,
>                 cache               => 1,
>             },
>         }, 
>
>         on_intranet => 0,
>         no_first_page_navigation   => 0,
>         no_last_page_navigation    => 0,
>         date_ranges     => {
>             property_name   => 'swishlastmodified',
>             time_periods    => [
>                 'All',
>                 'Today',
>                 'Yesterday',
>                 #'Yesterday onward',
>                 'This Week',
>                 'Last Week',
>                 'Last 90 Days',
>                 'This Month',
>                 'Last Month',
>                 #'Past',
>                 #'Future',
>                 #'Next 30 Days',
>             ],
>             line_break      => 0,
>             default         => 'All',
>             date_range      => 1,
>         },
>     }; 
>
> } 
>
> #^^^^^^^^^^^^^^^^^^^^^^^^^ end of user config
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
>
> #---------------I didnt change anything on the rest of code
> --------------------- 
>
> 
>
> I dont know much about perl, is anything wrong with TemplateDefault.pm ?
> but I didnt change anything on it. 
>
> how can i get results with highlight keyword and a little description,
> and also paging. 
>
>
> With many thanks in advance
 

 

On 28 Feb 2003, Bill Moseley moseley@hank.org: 

>>Jim, that's an odd error.  It's saying it can't find page_header() from
>>within the same module.  e.g it calling a function from line 16 and can't
>>see the function just a few lines below.

So does it mean something wrong with the script? 

>>What happens when you do this:

>>moseley@bumby:~/swish-e/example/modules$ perl -MTemplateDefault -e
>>'TemplateDefault::page_header()'
>>Can't call method "config" on an undefined value at TemplateDefault.pm
>>line 41.

>>There's it's aborting within that function.

How can I run it on windows? sorry I cant understand this. 


Jim 
Received on Thu Feb 27 23:22:57 2003