- Timestamp:
- 10/21/15 14:13:00 (9 years ago)
- Location:
- vlo/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/trunk
- Property svn:mergeinfo changed
/vlo/branches/vlo-3.3 merged: 6691,6694
- Property svn:mergeinfo changed
-
vlo/trunk/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/HighlightSearchTermScriptFactory.java
r6690 r6695 18 18 19 19 import com.google.common.collect.ImmutableSet; 20 import java.io.Serializable; 20 21 import java.util.Collection; 21 22 … … 24 25 * @author Twan Goosen <twan.goosen@mpi.nl> 25 26 */ 26 public class HighlightSearchTermScriptFactory {27 public class HighlightSearchTermScriptFactory implements Serializable { 27 28 28 p rivate static final String HIGHLIGHT_FUNCTION = "$('%s').highlight(%s, {className:'%s'})";29 public static final String HIGHLIGHT_FUNCTION = "$('%s').highlight(%s, {className:'%s', wordsOnly: %s})"; 29 30 30 private static final Collection<String> DEFAULT_EXCLUDE_WORDS = ImmutableSet.of("and", "or", "not", "to"); 31 public static final Collection<String> DEFAULT_EXCLUDE_WORDS = ImmutableSet.of("and", "or", "not", "to"); 32 33 public static final String DEFAULT_CSS_CLASS = "searchword"; 31 34 32 35 public String createScript(String componentSelector, final String words) { 36 return createScript(componentSelector, words, DEFAULT_CSS_CLASS); 37 } 38 39 public String createScript(String componentSelector, final String words, String cssClass) { 33 40 return String.format(HIGHLIGHT_FUNCTION, 34 41 componentSelector, 35 42 makeWordListArray(words), 36 getSearchWordClass() 43 cssClass, 44 matchWordsOnly(words) 37 45 ); 46 } 47 48 protected boolean matchWordsOnly(String query) { 49 // string with asterixes or question marks should match by character 50 return !query.matches(".*[\\*\\?].*"); 38 51 } 39 52 … … 77 90 //or boosting values 78 91 + "|['\"]?\\^.*" 79 + ")$", 92 + ")$" 93 //also remove wildcard characters 94 + "|[\\?\\*]", 80 95 //replace with empty string 81 96 ""); 82 }83 84 /**85 *86 * @return CSS class to mark matches with87 */88 protected String getSearchWordClass() {89 return "searchword";90 97 } 91 98
Note: See TracChangeset
for help on using the changeset viewer.