Index: plugins/src/org/blojsom/plugin/markdown/MarkdownPlugin.java =================================================================== RCS file: /cvsroot/blojsom/blojsom-3.0/plugins/src/org/blojsom/plugin/markdown/MarkdownPlugin.java,v retrieving revision 1.3 diff -u -r1.3 MarkdownPlugin.java --- plugins/src/org/blojsom/plugin/markdown/MarkdownPlugin.java 17 Jan 2007 02:35:11 -0000 1.3 +++ plugins/src/org/blojsom/plugin/markdown/MarkdownPlugin.java 28 May 2007 17:41:48 -0000 @@ -39,12 +39,13 @@ import org.blojsom.util.BlojsomConstants; import org.blojsom.util.BlojsomUtils; -import javax.servlet.ServletConfig; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.util.Map; +import com.petebevin.markdown.MarkdownProcessor; + /** * MarkdownPlugin *
@@ -70,35 +71,11 @@ private static final String MARKDOWN_EXTENSION = ".markdown"; /** - * Initialization parameter for the command to start a Markdown session - */ - private static final String PLUGIN_MARKDOWN_EXECUTION_IP = "plugin-markdown-execution"; - - private String _markdownExecution; - private ServletConfig _servletConfig; - - /** * Initialize this plugin. This method only called when the plugin is instantiated. * * @throws PluginException If there is an error initializing the plugin */ public void init() throws PluginException { - _markdownExecution = _servletConfig.getInitParameter(PLUGIN_MARKDOWN_EXECUTION_IP); - - if (BlojsomUtils.checkNullOrBlank(_markdownExecution)) { - if (_logger.isErrorEnabled()) { - _logger.error("No Markdown execution string provided. Use initialization parameter: " + PLUGIN_MARKDOWN_EXECUTION_IP); - } - } - } - - /** - * Set the {@link ServletConfig} - * - * @param servletConfig {@link ServletConfig} - */ - public void setServletConfig(ServletConfig servletConfig) { - _servletConfig = servletConfig; } /** @@ -113,33 +90,14 @@ * @throws PluginException If there is an error processing the blog entries */ public Entry[] process(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Blog blog, Map context, Entry[] entries) throws PluginException { - if (!BlojsomUtils.checkNullOrBlank(_markdownExecution)) { - for (int i = 0; i < entries.length; i++) { - Entry entry = entries[i]; - - if ((entry.getPostSlug().endsWith(MARKDOWN_EXTENSION) || BlojsomUtils.checkMapForKey(entry.getMetaData(), METADATA_RUN_MARKDOWN))) - { - try { - Process process = Runtime.getRuntime().exec(_markdownExecution); - BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(process.getOutputStream(), BlojsomConstants.UTF8)); - BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), BlojsomConstants.UTF8)); - bw.write(entry.getDescription()); - bw.close(); - String input; - StringBuffer collectedDescription = new StringBuffer(); - - while ((input = br.readLine()) != null) { - collectedDescription.append(input).append(BlojsomConstants.LINE_SEPARATOR); - } - - entry.setDescription(collectedDescription.toString()); - br.close(); - } catch (IOException e) { - if (_logger.isErrorEnabled()) { - _logger.error(e); - } - } - } + for (int i = 0; i < entries.length; i++) { + Entry entry = entries[i]; + + if ((entry.getPostSlug().endsWith(MARKDOWN_EXTENSION) || BlojsomUtils.checkMapForKey(entry.getMetaData(), METADATA_RUN_MARKDOWN))) + { + String originalDescription = entry.getDescription(); + String convertedDescription = new MarkdownProcessor().markdown(originalDescription); + entry.setDescription(convertedDescription); } }