moseley 2002/06/30 08:16:15 Modified: src/search make.pl tmpl/custom/html search Log: This patch changes the way the search widget sets the select options in the drop down menu, and how it sets the "selected" item in that list. It maps the current path "doc.dir.path_from_base" to the longest section path as defined in src/search/make.pl. Each path defined in make.pl is assigned a unique section e.g. "SecA". These section IDs make it possible to limit searches to just the specific section. Revision Changes Path 1.4 +13 -0 modperl-docs/src/search/make.pl Index: make.pl =================================================================== RCS file: /home/cvs/modperl-docs/src/search/make.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- make.pl 30 Jun 2002 05:45:16 -0000 1.3 +++ make.pl 30 Jun 2002 15:16:15 -0000 1.4 @@ -27,6 +27,9 @@ maps the section names to nice descriptions. This data is used to create the select box on the side bar during site generation (by running bin/build). +It also creates a hash to use in a TT plugin to map the file's path while running bin/build into +section IDs. + =item checkboxes.storable A perl data structure used for use in the F<search.cgi> script to generate the nested @@ -114,6 +117,11 @@ my $spaces = ' ' x (( $_->{indent}+2 ) * 4); qq[$spaces"$_->{section}" => "$dots$_->{short}" ] } @items_flat; + + my $path_map = join "\n", map { + qq[ { path => "^$_->{path}", section => "$_->{section}" } ] + } sort { length $b->{path} <=> length $a->{path} } @items_flat; + @@ -147,7 +155,12 @@ "" => 'Whole Site' $hash_values } + + search_path_map = [ +$path_map + ] -%] + EOF close FH || warn "Failed to close '$SEARCH_OPTIONS': $!"; 1.26 +17 -1 modperl-docs/tmpl/custom/html/search Index: search =================================================================== RCS file: /home/cvs/modperl-docs/tmpl/custom/html/search,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- search 30 Jun 2002 06:20:07 -0000 1.25 +++ search 30 Jun 2002 15:16:15 -0000 1.26 @@ -107,16 +107,32 @@ <input type="text" name="query" size="12" maxlength="200" value="" class="inp-text"> [% END %] + [%- section = PROCESS map_path_to_section path = doc.dir.path_from_base -%] + [% search_options = BLOCK %] + [% CGI.popup_menu( { Name => 'sbm', Values => search_areas, Labels => search_labels, - Default => doc.dir.path_from_base, + Default => section, Class => 'inp-select', }) %] [% END %] [% END %] + +[%- BLOCK map_path_to_section -%] + [%- + FOR item = search_path_map; + IF path.search( item.path ); + item.section; + RETURN; + END; + END; + -%] +[%- END -%] + +
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]