KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > presentation > velocity > plugins > radeox > WikiPlugin


1
2 package org.roller.presentation.velocity.plugins.radeox;
3
4 import org.apache.commons.lang.StringEscapeUtils;
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7 import org.apache.velocity.context.Context;
8 import org.radeox.EngineManager;
9 import org.radeox.engine.context.BaseRenderContext;
10 import org.radeox.engine.context.RenderContext;
11 import org.roller.pojos.WeblogEntryData;
12 import org.roller.presentation.RollerRequest;
13 import org.roller.presentation.velocity.PagePlugin;
14
15 /**
16  * @author David M Johnson
17  */

18 public class WikiPlugin implements PagePlugin
19 {
20     protected String JavaDoc name = "Radeox Wiki";
21     protected String JavaDoc description = "Allows use of Radeox formatting to generate HTML. " +
22         "See the <a HREF='http://radeox.org/space/snipsnap-help' target='radeox'>Radeox</a> site.";
23     
24     private static Log mLogger =
25        LogFactory.getFactory().getInstance(WikiPlugin.class);
26     
27     public WikiPlugin()
28     {
29         mLogger.debug("Radeox WikiPlugin instantiated.");
30     }
31     
32     public String JavaDoc toString() { return name; }
33     
34     /**
35      * Put plugin into the page context so templates may access it.
36      */

37     public void init(RollerRequest rreq, Context ctx)
38     {
39         ctx.put("wikiRenderer",this);
40     }
41     
42     /**
43      * Convert an input string that contains text that uses the Radeox Wiki
44      * syntax to an output string in HTML format.
45      * @param src Input string that uses Radeox Wiki syntax
46      * @return Output string in HTML format.
47      */

48     public String JavaDoc render( String JavaDoc src )
49     {
50         RenderContext context = new BaseRenderContext();
51         return EngineManager.getInstance().render(src, context);
52     }
53     
54     public String JavaDoc render( WeblogEntryData entry, boolean skipFlag)
55     {
56         return render( entry.getText() );
57     }
58
59     public String JavaDoc getName() { return name; }
60     public String JavaDoc getDescription() { return StringEscapeUtils.escapeJavaScript(description); }
61 }
62
Popular Tags