1 18 19 package org.apache.roller.ui.rendering.plugins; 20 21 import org.apache.commons.logging.Log; 22 import org.apache.commons.logging.LogFactory; 23 import org.apache.roller.model.WeblogEntryPlugin; 24 25 import java.text.MessageFormat ; 26 import java.util.regex.Pattern ; 27 28 40 public class GoogleLinkPlugin extends SearchPluginBase implements WeblogEntryPlugin { 41 private static final String version = "2.1"; 42 private static final Pattern pattern = Pattern.compile("google([:!])\"(.*?)\"(?:\\{(.*?)\\})?"); 43 private static final MessageFormat linkFormat = new MessageFormat ("<a HREF=\"http://www.google.com/search?ie=UTF-8&q={3}\">{2}</a>"); 44 private static final MessageFormat luckyLinkFormat = new MessageFormat ("<a HREF=\"http://www.google.com/search?ie=UTF-8&q={3}&btnI=on\">{2}</a>"); 45 46 private static final Log mLogger = LogFactory.getFactory().getInstance(GoogleLinkPlugin.class); 47 48 public GoogleLinkPlugin() { 49 } 50 51 public String getName() { 52 return "Google Links"; 53 } 54 55 public String getDescription() { 56 return "Replace google:"link text"{search text} with a link that performs a google search. With ! instead of :," + "creates a "I\\'m feeling lucky" search. With {search text} omitted, uses link text as the value of the search text."; 57 } 58 59 public String getVersion() { 60 return version; 61 } 62 63 public Pattern getPattern() { 64 return pattern; 65 } 66 67 public MessageFormat getLinkFormat() { 68 return linkFormat; 69 } 70 71 public MessageFormat getLuckyLinkFormat() { 72 return luckyLinkFormat; 73 } 74 75 public Log getLogger() { 76 return mLogger; 77 } 78 } 79 | Popular Tags |