1 31 package org.blojsom.plugin.wiki; 32 33 import org.apache.commons.logging.Log; 34 import org.apache.commons.logging.LogFactory; 35 import org.blojsom.blog.Blog; 36 import org.blojsom.blog.Entry; 37 import org.blojsom.plugin.Plugin; 38 import org.blojsom.plugin.PluginException; 39 import org.blojsom.util.BlojsomUtils; 40 import org.radeox.EngineManager; 41 import org.radeox.api.engine.RenderEngine; 42 import org.radeox.api.engine.context.RenderContext; 43 import org.radeox.engine.context.BaseRenderContext; 44 45 import javax.servlet.http.HttpServletRequest ; 46 import javax.servlet.http.HttpServletResponse ; 47 import java.util.Map ; 48 49 56 public class WikiPlugin implements Plugin { 57 58 private Log _logger = LogFactory.getLog(WikiPlugin.class); 59 60 63 private static final String WIKI_EXTENSION = ".wiki"; 64 65 68 public static final String METADATA_RUN_WIKI = "run-wiki"; 69 70 75 public void init() throws PluginException { 76 } 77 78 89 public Entry[] process(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Blog blog, Map context, Entry[] entries) throws PluginException { 90 RenderEngine engine = EngineManager.getInstance(); 91 RenderContext renderContext = new BaseRenderContext(); 92 93 for (int i = 0; i < entries.length; i++) { 94 Entry entry = entries[i]; 95 if (entry.getPostSlug().endsWith(WIKI_EXTENSION) || BlojsomUtils.checkMapForKey(entry.getMetaData(), METADATA_RUN_WIKI)) { 96 if (_logger.isDebugEnabled()) { 97 _logger.debug("Wiki processing: " + entry.getId()); 98 } 99 100 String description = entry.getDescription(); 101 entry.setDescription(engine.render(description, renderContext)); 102 } 103 } 104 105 return entries; 106 } 107 108 113 public void cleanup() throws PluginException { 114 } 115 116 121 public void destroy() throws PluginException { 122 } 123 } 124 | Popular Tags |