From 5eb177b8e623084701ff944660f40a850678865f Mon Sep 17 00:00:00 2001 From: Tim Worrall Date: Tue, 10 Feb 2015 16:34:12 -0500 Subject: [PATCH] VIVO-928: added microformats to non persons. Typing goes two levels down in some cases for organizations. Some info content entities covered, though many types not covered by schema.org --- .../individual--foaf-person-2column.ftl | 6 +- .../individual--foaf-person-quickview.ftl | 6 +- .../freemarker/lib/lib-microformats.ftl | 72 +++++++++++++++++++ .../individual/IndividualTemplateModel.java | 5 ++ 4 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 productMods/templates/freemarker/lib/lib-microformats.ftl diff --git a/productMods/templates/freemarker/body/individual/individual--foaf-person-2column.ftl b/productMods/templates/freemarker/body/individual/individual--foaf-person-2column.ftl index 38560fa2..b078c739 100644 --- a/productMods/templates/freemarker/body/individual/individual--foaf-person-2column.ftl +++ b/productMods/templates/freemarker/body/individual/individual--foaf-person-2column.ftl @@ -49,7 +49,7 @@

${relatedSubject.relatingPredicateDomainPublic} ${i18n().for} ${relatedSubject.name}

← ${i18n().return_to(relatedSubject.name)}

<#else> -

style="float:left;border-right:1px solid #A6B1B0;"> +

style="float:left;border-right:1px solid #A6B1B0;"> <#-- Label --> <@p.label individual editable labelCount localesCount/>

@@ -64,9 +64,9 @@ <#list title.statements as statement> <#if !editable > -
${statement.preferredTitle}
+
${statement.preferredTitle}
<#else> - ${statement.preferredTitle} + ${statement.preferredTitle} <@p.editingLinks "${title.localName}" "${title.name}" statement editable title.rangeUri /> diff --git a/productMods/templates/freemarker/body/individual/individual--foaf-person-quickview.ftl b/productMods/templates/freemarker/body/individual/individual--foaf-person-quickview.ftl index b6ef6911..7f92e23e 100644 --- a/productMods/templates/freemarker/body/individual/individual--foaf-person-quickview.ftl +++ b/productMods/templates/freemarker/body/individual/individual--foaf-person-quickview.ftl @@ -60,7 +60,7 @@ <#else> <#-- Image -->
${individualImage}
-

style="float:left;border-right:1px solid #A6B1B0;"> +

style="float:left;border-right:1px solid #A6B1B0;"> <#-- Label --> <@p.label individual editable labelCount localesCount/>

@@ -75,9 +75,9 @@ <#list title.statements as statement> <#if !editable > -
${statement.preferredTitle}
+
${statement.preferredTitle}
<#else> - ${statement.preferredTitle} + ${statement.preferredTitle} <@p.editingLinks "${title.localName}" "${title.name}" statement editable title.rangeUri /> diff --git a/productMods/templates/freemarker/lib/lib-microformats.ftl b/productMods/templates/freemarker/lib/lib-microformats.ftl new file mode 100644 index 00000000..7c9db40f --- /dev/null +++ b/productMods/templates/freemarker/lib/lib-microformats.ftl @@ -0,0 +1,72 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#-- Macros used to insert microformats into non-foaf person profiles via the individual-vitro.ftl template. --> +<#macro sectionSchema individual> + <#if individual.organization() > + <#list individual.mostSpecificTypes as type > + <#assign mst = type /> + <#break> + + <@getItemType mst "organization"/> + <#elseif individual.event()> + itemscope itemtype="http://schema.org/Event" + <#elseif individual.infoContentEntity()> + <#list individual.mostSpecificTypes as type > + <#assign mst = type /> + <#break> + + <@getItemType mst "infoContentEntity"/> + + + +<#macro getItemType type class > + <#-- The itemscope and full itemtype element and value are included here because Freemarker appends leading + and trailing white space to the returned value. --> + <#switch type> + <#case "Article"> + itemscope itemtype="http://schema.org/Article" + <#break> + <#case "Academic Article"> + itemscope itemtype="http://schema.org/ScholarlyArticle" + <#break> + <#case "Blog"> + itemscope itemtype="http://schema.org/Blog" + <#break> + <#case "Blog Posting"> + itemscope itemtype="http://schema.org/BlogPosting" + <#break> + <#case "Book"> + itemscope itemtype="http://schema.org/Book" + <#break> + <#case "Dataset"> + itemscope itemtype="http://schema.org/Dataset" + <#break> + <#case "Periodical"> + itemscope itemtype="http://schema.org/Periodical" + <#break> + <#case "Review"> + itemscope itemtype="http://schema.org/Review" + <#break> + <#case "Series"> + itemscope itemtype="http://schema.org/Series" + <#break> + <#case "Webpage"> + itemscope itemtype="http://schema.org/WebPage" + <#break> + <#case "Website"> + itemscope itemtype="http://schema.org/WebSite" + <#break> + <#case "College"> + itemscope itemtype="http://schema.org/CollegeOrUniversity" + <#break> + <#case "University"> + itemscope itemtype="http://schema.org/CollegeOrUniversity" + <#break> + <#default> + <#if class == "organization" > + itemscope itemtype="http://schema.org/Organization" + <#else> + <#-- don't return anything if the info content entity has no matching subclass --> + + + \ No newline at end of file diff --git a/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java b/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java index 1332876e..984cd393 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java +++ b/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java @@ -38,6 +38,7 @@ public class IndividualTemplateModel extends BaseIndividualTemplateModel { private static final String DTP_CLASS = "http://vivoweb.org/ontology/core#DateTimeValuePrecision"; private static final String ORGANIZATION_CLASS = FOAF + "Organization"; private static final String EVENT_CLASS = "http://purl.org/NET/c4dm/event.owl#Event"; + private static final String INFO_CONTENT_ENTITY_CLASS = "http://purl.obolibrary.org/obo/IAO_0000030"; private static final String BASE_VISUALIZATION_URL = UrlBuilder.getUrl(Route.VISUALIZATION_SHORT.path()); @@ -84,6 +85,10 @@ public class IndividualTemplateModel extends BaseIndividualTemplateModel { return isVClass(EVENT_CLASS); } + public boolean infoContentEntity() { + return isVClass(INFO_CONTENT_ENTITY_CLASS); + } + public String coAuthorVisUrl() { String url = BASE_VISUALIZATION_URL + "/" + VisualizationFrameworkConstants.COAUTHORSHIP_VIS_SHORT_URL + "/"; return getVisUrl(url);