01: package ru.emdev.EmForge.wiki.plugins;
02:
03: import java.util.Map;
04:
05: import org.apache.commons.lang.StringUtils;
06:
07: import com.ecyrd.jspwiki.WikiContext;
08: import com.ecyrd.jspwiki.plugin.PluginException;
09: import com.ecyrd.jspwiki.plugin.WikiPlugin;
10:
11: /** Plugin to place Ohloh Widget in wiki-page */
12: public class OhlohPlugin implements WikiPlugin {
13: public static final String PARAM_PROJECT_ID = "projectId";
14: public static final String PARAM_WIDGET_NAME = "widgetName";
15:
16: public String execute(WikiContext i_context, Map i_params)
17: throws PluginException {
18: // get params
19: String widgetName = (String) i_params.get(PARAM_WIDGET_NAME);
20: if (StringUtils.isEmpty(widgetName)) {
21: widgetName = "project_thin_badge";
22: }
23:
24: String projectId = (String) i_params.get(PARAM_PROJECT_ID);
25:
26: String format = "<script type=\"text/javascript\" src=\"http://www.ohloh.net/projects/%s/widgets/%s\"></script>";
27:
28: String out = String.format(format, projectId, widgetName);
29:
30: return out;
31: }
32: }
|