NIHVIVO-1562 Modify help methods on existing template directives and methods to align with new dump directive requirements

This commit is contained in:
ryounes 2011-04-22 21:42:08 +00:00
parent 9aa6c17dd9
commit b6ea045503
7 changed files with 21 additions and 45 deletions

View file

@ -22,17 +22,7 @@ public abstract class BaseTemplateDirectiveModel implements TemplateDirectiveMod
private static final Log log = LogFactory.getLog(BaseTemplateDirectiveModel.class);
public String help(String name, Environment env) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", name);
return mergeToHelpTemplate(map, env);
}
protected String mergeToHelpTemplate(Map<String, Object> map, Environment env) {
return processTemplateToString("help-directive.ftl", map, env);
}
public abstract Map<String, Object> help(String name);
public static String processTemplateToString(String templateName, Map<String, Object> map, Environment env) {
Template template = getTemplate(templateName, env);

View file

@ -60,24 +60,22 @@ public class UrlDirective extends BaseTemplateDirectiveModel {
out.write(url);
}
public String help(String name, Environment env) {
public Map<String, Object> help(String name) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", name);
map.put("effect", "Generate a full url from a path by prepending the servlet context path. Use for generating src attribute of image tags, href attribute of anchor tags, etc.");
map.put("comments", "The path should be an absolute path, starting with \"/\".");
Map<String, String> params = new HashMap<String, String>();
params.put("path", "path");
map.put("params", params);
map.put("parameters", params);
List<String> examples = new ArrayList<String>();
examples.add("&lt;img src=\"<@url path=\"/images/placeholders/person.thumbnail.jpg\" />\" /&gt;" );
map.put("examples", examples);
return mergeToHelpTemplate(map, env);
return map;
}

View file

@ -93,11 +93,9 @@ public class WidgetDirective extends BaseTemplateDirectiveModel {
}
public String help(String name, Environment env) {
public Map<String, Object> help(String name) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", name);
map.put("effect", "Add a reuseable block of markup and functionality to the template, with associated scripts and stylesheets injected into the page &lt;head&gt; element.");
map.put("comments", "From a body template, insert widget directive in desired location with no include value or include=\"markup\". Both assets and markup will be included. " +
@ -108,7 +106,7 @@ public class WidgetDirective extends BaseTemplateDirectiveModel {
params.put("name", "name of widget");
params.put("include", "values: \"assets\" to include scripts and stylesheets associated with the widget; \"markup\" to include the markup. " +
"\"markup\" is default value, so does not need to be specified.");
map.put("params", params);
map.put("parameters", params);
List<String> examples = new ArrayList<String>();
examples.add("<@" + name + " name=\"login\" /> (use in body and page templates where markup should be inserted)");
@ -117,7 +115,7 @@ public class WidgetDirective extends BaseTemplateDirectiveModel {
map.put("examples", examples);
return mergeToHelpTemplate(map, env);
return map;
}
}

View file

@ -19,13 +19,7 @@ public abstract class BaseTemplateMethodModel implements TemplateMethodModel {
private static final Log log = LogFactory.getLog(BaseTemplateMethodModel.class);
public String help(String name, Environment env) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", name);
return mergeToHelpTemplate(map, env);
}
public abstract Map<String, Object> help(String name);
protected String mergeToHelpTemplate(Map<String, Object> map, Environment env) {
return processTemplateToString("help-method.ftl", map, env);

View file

@ -36,22 +36,20 @@ public class IndividualLocalNameMethod extends BaseTemplateMethodModel {
}
@Override
public String help(String name, Environment env) {
public Map<String, Object> help(String name) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", name);
map.put("returnValue", "The local name of the individual");
map.put("return value", "The local name of the individual");
List<String>params = new ArrayList<String>();
params.add("Uri of individual");
map.put("params", params);
map.put("parameters", params);
List<String> examples = new ArrayList<String>();
examples.add(name + "(individual.uri)");
map.put("examples", examples);
return mergeToHelpTemplate(map, env);
return map;
}
}

View file

@ -33,21 +33,19 @@ public class IndividualProfileUrlMethod extends BaseTemplateMethodModel {
}
@Override
public String help(String name, Environment env) {
public Map<String, Object> help(String name) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", name);
map.put("returnValue", "The profile url of the individual");
map.put("return value", "The profile url of the individual");
List<String>params = new ArrayList<String>();
params.add("Uri of individual");
map.put("params", params);
map.put("parameters", params);
List<String> examples = new ArrayList<String>();
examples.add(name + "(individual.uri)");
map.put("examples", examples);
return mergeToHelpTemplate(map, env);
return map;
}
}

View file

@ -166,9 +166,9 @@ div.dump {
<li>
<#local value = help[key]>
<@divValue>
<#if value?is_string><p><strong>${key?capitalize}:</strong> ${value}</p>
<#if value?is_string><p><strong>${key?cap_first}:</strong> ${value}</p>
<#else>
<p><strong>${key?capitalize}:</strong></p>
<p><strong>${key?cap_first}:</strong></p>
<ul>
<#if value?is_sequence>
<#list value as item>