行番号付きソース表示プラグイン
JSPWikiのプラグイン内でfile.eachLineを使うとなぜかJasperExceptionになってしまいます*1。とりあえず、使わないように書き直したのですがGroovyらしくなくなってしまいました(涙)。
#!/usr/bin/env groovy import com.ecyrd.jspwiki.plugin.WikiPlugin; import com.ecyrd.jspwiki.WikiContext; import java.util.Map; import java.io.File; import java.io.FileReader; import java.io.BufferedReader; class Miki implements WikiPlugin { public String execute(WikiContext context, Map params ) throws PluginException { servletContext = context.getEngine().getServletContext(); src = params.get("src"); fileName = servletContext.getRealPath(src); file = new File(fileName); buf = new StringBuffer("<pre>"); i=1; br = new BufferedReader(new FileReader(file)); try { line = br.readLine(); while (line != null) { buf.append(i++); buf.append(":"); buf.append(line); buf.append('\n'); line = br.readLine(); } } finally { br.close(); } buf.append("<pre>"); return buf.toString(); } }