In the default package for convenience -- MaxVoelkel

Please note that this is extremely insecure; anyone with write access to the pages can read ANY page that the web server is able to read. NEVER install this on a public Wiki system. --JanneJalkanen

package com.ecyrd.jspwiki.plugin;
import java.util.Map;

import com.ecyrd.jspwiki.WikiContext;
import com.ecyrd.jspwiki.TranslatorReader;
 *  Displays a text block in TT and with WikiWords enabled.
 *  <P>
 *  <B>Parameters</B>
 *  <UL>
 *    <LI>filename - The name of the text fle to be formatted.
 *  </UL>
public class LinkedCodePlugin implements WikiPlugin {
	public static final String PARAM_NAME = "filename";
	public String execute(WikiContext context, Map params)
		throws PluginException {
		//  Parse parameters.
		String filename = "";

		if ((filename = (String) params.get(PARAM_NAME)) == null)
			return "Please tell me: filename=???";
		// We should now have a code-string.

		File f = new File(filename);
		try {
			BufferedReader r = new BufferedReader(new FileReader(f));
			String s = r.readLine();
			StringBuffer sb = new StringBuffer();
			while(s != null)
				// escape HTML-Tags
				String clean = s.replaceAll( "<", "&lt;");
				clean = clean.replaceAll( ">", "&gt;");
				// make every line in TT
				sb.append("{{"+ clean + "}}\\\\");
				s = r.readLine();
			String wikirendered = 
				context.getEngine().textToHTML( context, sb.toString() );

			return wikirendered;
		} catch (FileNotFoundException e) {
			return "File "+filename+" not found.";
		} catch (IOException e) {
			return "Error reading "+filename;

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-3) was last changed on 02-Feb-2005 12:26 by JanneJalkanen