From 61f90dd1e6180302bd55a91030ffb4c8412e63c2 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Tue, 5 Jul 2016 17:52:03 +0100 Subject: [PATCH] [VIVO-1237] Add ability to generate meta tags --- .../webapp/controller/freemarker/FreemarkerHttpServlet.java | 1 + .../cornell/mannlib/vitro/webapp/web/widgets/Widget.java | 2 ++ .../main/webapp/templates/freemarker/page/partials/head.ftl | 4 ++++ webapp/src/main/webapp/themes/vitro/templates/head.ftl | 6 +++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java index 491aec56c..51ea8b896 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java @@ -464,6 +464,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet { map.put("stylesheets", new Tags().wrap()); map.put("scripts", new Tags().wrap()); map.put("headScripts", new Tags().wrap()); + map.put("metaTags", new Tags().wrap()); return map; } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/Widget.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/Widget.java index 9f82c1910..acb8e16ba 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/Widget.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/web/widgets/Widget.java @@ -12,6 +12,7 @@ import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; +import edu.cornell.mannlib.vitro.webapp.web.templatemodels.Tags; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -46,6 +47,7 @@ public abstract class Widget { map.put("stylesheets", dataModel.get("stylesheets")); map.put("scripts", dataModel.get("scripts")); map.put("headScripts", dataModel.get("headScripts")); + map.put("metaTags", new Tags().wrap()); map.put("urls", dataModel.get("urls")); } catch (TemplateModelException e) { log.error("Error getting asset values from data model."); diff --git a/webapp/src/main/webapp/templates/freemarker/page/partials/head.ftl b/webapp/src/main/webapp/templates/freemarker/page/partials/head.ftl index f5e3d90dc..e99bdcec3 100644 --- a/webapp/src/main/webapp/templates/freemarker/page/partials/head.ftl +++ b/webapp/src/main/webapp/templates/freemarker/page/partials/head.ftl @@ -10,6 +10,10 @@ <#include "headScripts.ftl"> +<#if metaTags??> + ${metaTags.list()} + + <#-- Inject head content specified in the controller. Currently this is used only to generate an rdf link on an individual profile page. --> ${headContent!} \ No newline at end of file diff --git a/webapp/src/main/webapp/themes/vitro/templates/head.ftl b/webapp/src/main/webapp/themes/vitro/templates/head.ftl index 6bd70bf0c..10b7af235 100644 --- a/webapp/src/main/webapp/themes/vitro/templates/head.ftl +++ b/webapp/src/main/webapp/themes/vitro/templates/head.ftl @@ -15,7 +15,11 @@ -<#-- Inject head content specified in the controller. Currently this is used only to generate an rdf link on +<#if metaTags??> + ${metaTags.list()} + + +<#-- Inject head content specified in the controller. Currently this is used only to generate an rdf link on an individual profile page. --> ${headContent!}