KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > ui > rendering > plugins > TextilePlugin


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. The ASF licenses this file to You
4  * under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License. For additional information regarding
15  * copyright in this work, please see the NOTICE file in the top level
16  * directory of this distribution.
17  */

18
19 package org.apache.roller.ui.rendering.plugins;
20
21 import java.util.Map JavaDoc;
22 import org.apache.commons.lang.StringEscapeUtils;
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.apache.roller.pojos.WeblogEntryData;
26 import org.apache.roller.pojos.WebsiteData;
27 import org.apache.roller.model.WeblogEntryPlugin;
28
29
30 /**
31  * Render text using textile engine.
32  */

33 public class TextilePlugin implements WeblogEntryPlugin {
34     
35     private static Log mLogger = LogFactory.getLog(TextilePlugin.class);
36     
37     public String JavaDoc name = "Textile Formatter";
38     public String JavaDoc description = "Allows use of Textile formatting to easily " +
39             "generate HTML. See the <a HREF='http://textism.com/tools/textile' target='textile'>Textile</a> site.";
40     
41     private net.sf.textile4j.Textile mTextile = new net.sf.textile4j.Textile();
42     
43     
44     public TextilePlugin() {
45         mLogger.debug("Textile Plugin instantiated.");
46     }
47     
48     
49     public String JavaDoc getName() {
50         return name;
51     }
52     
53     
54     public String JavaDoc getDescription() {
55         return StringEscapeUtils.escapeJavaScript(description);
56     }
57     
58     
59     /**
60      * Init.
61      */

62     public void init(WebsiteData website) {
63         // no-op
64
}
65     
66     
67     /**
68      * Convert an input string that contains text that uses the Textile
69      * syntax to an output string in HTML format.
70      *
71      * @param src Input string that uses Textile syntax
72      * @return Output string in HTML format.
73      */

74     public String JavaDoc render(WeblogEntryData entry, String JavaDoc src ) {
75         return mTextile.process(src);
76     }
77     
78 }
79
Popular Tags