]> git.imager.perl.org - bse.git/commitdiff
add default prefix/suffix search highlight cfg option
authorAdrian Oldham <adriann@visualthought.com.au>
Sat, 31 May 2014 03:59:36 +0000 (13:59 +1000)
committerAdrian Oldham <adriann@visualthought.com.au>
Sat, 31 May 2014 04:10:30 +0000 (14:10 +1000)
site/cgi-bin/modules/BSE/UI/Search.pm
site/cgi-bin/modules/Generate.pm
site/docs/config.pod

index f6f549a128c35c4d721ac240454babae1def6ca0..5f18f3b74e04697d4f4332fd04a341a3cf3435b9 100644 (file)
@@ -11,7 +11,7 @@ use BSE::Util::HTML qw':default popup_menu';
 use BSE::Util::Tags qw(tag_article);
 use BSE::Request;
 
 use BSE::Util::Tags qw(tag_article);
 use BSE::Request;
 
-our $VERSION = "1.002";
+our $VERSION = "1.003";
 
 my %actions =
   (
 
 my %actions =
   (
@@ -126,9 +126,9 @@ sub req_search {
   for my $type (qw(keyword author pageTitle file_displayName 
                  file_description file_notes summary description product_code)) {
     $highlight_prefix{$type} = 
   for my $type (qw(keyword author pageTitle file_displayName 
                  file_description file_notes summary description product_code)) {
     $highlight_prefix{$type} = 
-      $cfg->entry('search highlight', "${type}_prefix", "<b>");
+      $cfg->entry('search highlight', "${type}_prefix", $cfg->entry('search highlight', "prefix", "<b>"));
     $highlight_suffix{$type} = 
     $highlight_suffix{$type} = 
-      $cfg->entry('search highlight', "${type}_suffix", "</b>");
+      $cfg->entry('search highlight', "${type}_suffix", $cfg->entry('search highlight', "suffix", "</b>"));
   }
   
   my $page_num_iter = 0;
   }
   
   my $page_num_iter = 0;
@@ -301,8 +301,8 @@ sub tag_highlight_result {
 
   $text = escape_html($text);
 
 
   $text = escape_html($text);
 
-  my $prefix = $cfg->entry('search highlight', "${arg}_prefix", "<b>");
-  my $suffix = $cfg->entry('search highlight', "${arg}_suffix", "</b>");
+  my $prefix = $cfg->entry('search highlight', "${arg}_prefix", $cfg->entry('search highlight', "prefix", "<b>"));
+  my $suffix = $cfg->entry('search highlight', "${arg}_suffix", $cfg->entry('search highlight', "suffix", "</b>"));
 
   $text =~ s/$words_re/$prefix$1$suffix/g;
 
 
   $text =~ s/$words_re/$prefix$1$suffix/g;
 
index c51b6a40d9d2d07307128a96548f0d395ff4690a..d676bd2d8863f42463ab5cf2d4eb00f4478b0af9 100644 (file)
@@ -313,7 +313,7 @@ Conditional tag, true if the current article is being embedded.
 
 =cut
 
 
 =cut
 
-our $VERSION = "1.020";
+our $VERSION = "1.021";
 
 my $excerptSize = 300;
 
 
 my $excerptSize = 300;
 
@@ -1477,9 +1477,9 @@ sub excerpt {
   }
 
   my $highlight_prefix = 
   }
 
   my $highlight_prefix = 
-    $cfg->entry('search highlight', "${type}_prefix", "<b>");
+    $cfg->entry('search highlight', "${type}_prefix", $cfg->entry('search highlight', "prefix", "<b>"));
   my $highlight_suffix =
   my $highlight_suffix =
-    $cfg->entry('search highlight', "${type}_suffix", "</b>");
+    $cfg->entry('search highlight', "${type}_suffix", $cfg->entry('search highlight', "suffix", "</b>"));
   my $termSize = $excerptSize / @found;
   my $result = '';
   for my $term (@found) {
   my $termSize = $excerptSize / @found;
   my $result = '';
   for my $term (@found) {
index 7a8a54a6a94ceff9e6832bf0ded289d1c6869cb2..4cc5356d0529814517a57755626870291c3f4b53 100644 (file)
@@ -856,6 +856,12 @@ For example you can do:
   [search highlight]
   body_prefix=<span class="searchfound">
   body_suffix=</span>
   [search highlight]
   body_prefix=<span class="searchfound">
   body_suffix=</span>
+  
+The default prefix and suffix can also be redefined:
+
+  [search highlight]
+  prefix=<mark>
+  suffix=</mark>
 
 =head2 [shop]
 
 
 =head2 [shop]