From b6ea045503c6d3768b021c491d4ec7584331e132 Mon Sep 17 00:00:00 2001 From: ryounes Date: Fri, 22 Apr 2011 21:42:08 +0000 Subject: [PATCH] NIHVIVO-1562 Modify help methods on existing template directives and methods to align with new dump directive requirements --- .../web/directives/BaseTemplateDirectiveModel.java | 12 +----------- .../vitro/webapp/web/directives/UrlDirective.java | 10 ++++------ .../vitro/webapp/web/directives/WidgetDirective.java | 8 +++----- .../webapp/web/methods/BaseTemplateMethodModel.java | 8 +------- .../web/methods/IndividualLocalNameMethod.java | 12 +++++------- .../web/methods/IndividualProfileUrlMethod.java | 12 +++++------- .../templates/freemarker/body/partials/dump/dump.ftl | 4 ++-- 7 files changed, 21 insertions(+), 45 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/BaseTemplateDirectiveModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/BaseTemplateDirectiveModel.java index daa48b0a3..41536e766 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/BaseTemplateDirectiveModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/BaseTemplateDirectiveModel.java @@ -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 map = new HashMap(); - - map.put("name", name); - - return mergeToHelpTemplate(map, env); - } - - protected String mergeToHelpTemplate(Map map, Environment env) { - return processTemplateToString("help-directive.ftl", map, env); - } + public abstract Map help(String name); public static String processTemplateToString(String templateName, Map map, Environment env) { Template template = getTemplate(templateName, env); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/UrlDirective.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/UrlDirective.java index ba9fffd8d..5ad4bad22 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/UrlDirective.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/UrlDirective.java @@ -60,24 +60,22 @@ public class UrlDirective extends BaseTemplateDirectiveModel { out.write(url); } - public String help(String name, Environment env) { + public Map help(String name) { Map map = new HashMap(); - - 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 params = new HashMap(); params.put("path", "path"); - map.put("params", params); + map.put("parameters", params); List examples = new ArrayList(); examples.add("<img src=\"<@url path=\"/images/placeholders/person.thumbnail.jpg\" />\" />" ); map.put("examples", examples); - return mergeToHelpTemplate(map, env); + return map; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/WidgetDirective.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/WidgetDirective.java index 9dd949a3f..1a84c3282 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/WidgetDirective.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/WidgetDirective.java @@ -93,11 +93,9 @@ public class WidgetDirective extends BaseTemplateDirectiveModel { } - public String help(String name, Environment env) { + public Map help(String name) { Map map = new HashMap(); - 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 <head> 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 examples = new ArrayList(); 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; } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/BaseTemplateMethodModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/BaseTemplateMethodModel.java index c0934fd01..63f180506 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/BaseTemplateMethodModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/BaseTemplateMethodModel.java @@ -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 map = new HashMap(); - - map.put("name", name); - - return mergeToHelpTemplate(map, env); - } + public abstract Map help(String name); protected String mergeToHelpTemplate(Map map, Environment env) { return processTemplateToString("help-method.ftl", map, env); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/IndividualLocalNameMethod.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/IndividualLocalNameMethod.java index b2d44220d..833fff918 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/IndividualLocalNameMethod.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/IndividualLocalNameMethod.java @@ -36,22 +36,20 @@ public class IndividualLocalNameMethod extends BaseTemplateMethodModel { } @Override - public String help(String name, Environment env) { + public Map help(String name) { Map map = new HashMap(); - - map.put("name", name); - - map.put("returnValue", "The local name of the individual"); + + map.put("return value", "The local name of the individual"); Listparams = new ArrayList(); params.add("Uri of individual"); - map.put("params", params); + map.put("parameters", params); List examples = new ArrayList(); examples.add(name + "(individual.uri)"); map.put("examples", examples); - return mergeToHelpTemplate(map, env); + return map; } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/IndividualProfileUrlMethod.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/IndividualProfileUrlMethod.java index a3871bdd5..b031779c0 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/IndividualProfileUrlMethod.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/methods/IndividualProfileUrlMethod.java @@ -33,21 +33,19 @@ public class IndividualProfileUrlMethod extends BaseTemplateMethodModel { } @Override - public String help(String name, Environment env) { + public Map help(String name) { Map map = new HashMap(); - - map.put("name", name); - - map.put("returnValue", "The profile url of the individual"); + + map.put("return value", "The profile url of the individual"); Listparams = new ArrayList(); params.add("Uri of individual"); - map.put("params", params); + map.put("parameters", params); List examples = new ArrayList(); examples.add(name + "(individual.uri)"); map.put("examples", examples); - return mergeToHelpTemplate(map, env); + return map; } } diff --git a/webapp/web/templates/freemarker/body/partials/dump/dump.ftl b/webapp/web/templates/freemarker/body/partials/dump/dump.ftl index 2a5ecdd9a..80ac8470b 100644 --- a/webapp/web/templates/freemarker/body/partials/dump/dump.ftl +++ b/webapp/web/templates/freemarker/body/partials/dump/dump.ftl @@ -166,9 +166,9 @@ div.dump {
  • <#local value = help[key]> <@divValue> - <#if value?is_string>

    ${key?capitalize}: ${value}

    + <#if value?is_string>

    ${key?cap_first}: ${value}

    <#else> -

    ${key?capitalize}:

    +

    ${key?cap_first}:

      <#if value?is_sequence> <#list value as item>