01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
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.business.WeblogEntryPlugin;
28:
29: /**
30: * Render text using textile engine.
31: */
32: public class TextilePlugin implements WeblogEntryPlugin {
33:
34: private static Log mLogger = LogFactory.getLog(TextilePlugin.class);
35:
36: public String name = "Textile Formatter";
37: public String description = "Allows use of Textile formatting to easily "
38: + "generate HTML. See the <a href='http://textism.com/tools/textile' target='textile'>Textile</a> site.";
39:
40: private net.sf.textile4j.Textile mTextile = new net.sf.textile4j.Textile();
41:
42: public TextilePlugin() {
43: mLogger.debug("Textile Plugin instantiated.");
44: }
45:
46: public String getName() {
47: return name;
48: }
49:
50: public String getDescription() {
51: return StringEscapeUtils.escapeJavaScript(description);
52: }
53:
54: /**
55: * Init.
56: */
57: public void init(WebsiteData website) {
58: // no-op
59: }
60:
61: /**
62: * Convert an input string that contains text that uses the Textile
63: * syntax to an output string in HTML format.
64: *
65: * @param src Input string that uses Textile syntax
66: * @return Output string in HTML format.
67: */
68: public String render(WeblogEntryData entry, String src) {
69: return mTextile.process(src);
70: }
71:
72: }
|