From 41aa28ed03a0f42f8bf22c59150abbe2e219c1b3 Mon Sep 17 00:00:00 2001 From: mbarbier Date: Thu, 7 Apr 2011 17:40:48 +0000 Subject: [PATCH] individual-qrCodeFoafPerson.ftl: add hasValidVCard function, remove tabs individual--foaf-person.ftl: use hasValidVCard function in commented-out QR code section --- .../individual/individual--foaf-person.ftl | 14 +- .../individual-qrCodeFoafPerson.ftl | 151 ++++++++++-------- 2 files changed, 92 insertions(+), 73 deletions(-) diff --git a/productMods/templates/freemarker/body/individual/individual--foaf-person.ftl b/productMods/templates/freemarker/body/individual/individual--foaf-person.ftl index 91d0e298..5eee6249 100644 --- a/productMods/templates/freemarker/body/individual/individual--foaf-person.ftl +++ b/productMods/templates/freemarker/body/individual/individual--foaf-person.ftl @@ -71,12 +71,14 @@ <@p.vitroLinks propertyGroups namespaces editable "individual-urls-people" /> <#-- -
- vCard QR What is this? - - <@qrCodeVCard qrCodeWidth="150" /> - -
+ <#if hasValidVCard()> +
+ vCard QR What is this? + + <@qrCodeVCard qrCodeWidth="150" /> + +
+ --> diff --git a/productMods/templates/freemarker/body/partials/individual/individual-qrCodeFoafPerson.ftl b/productMods/templates/freemarker/body/partials/individual/individual-qrCodeFoafPerson.ftl index c5fe1a00..a84023c3 100644 --- a/productMods/templates/freemarker/body/partials/individual/individual-qrCodeFoafPerson.ftl +++ b/productMods/templates/freemarker/body/partials/individual/individual-qrCodeFoafPerson.ftl @@ -4,103 +4,120 @@ <#macro qrCodeVCard qrCodeWidth> - <#local qrCodeUrl = getQrCodeUrlForVCard(qrCodeWidth)> - - <#if qrCodeUrl != ""> - - + <#local qrCodeUrl = getQrCodeUrlForVCard(qrCodeWidth)> + + <#if qrCodeUrl != ""> + + <#macro qrCodeLink qrCodeWidth> - <#local qrCodeUrl = getQrCodeUrlForLink(qrCodeWidth)> - - <#if qrCodeUrl != ""> - - + <#local qrCodeUrl = getQrCodeUrlForLink(qrCodeWidth)> + + <#if qrCodeUrl != ""> + + <#function getQrCodeUrlForVCard qrCodeWidth> - <#local qrData = individual.qrData > + <#local qrData = individual.qrData > - <#local core = "http://vivoweb.org/ontology/core#"> - <#local foaf = "http://xmlns.com/foaf/0.1/"> - <#local rdfs = "http://www.w3.org/2000/01/rdf-schema#"> + <#local core = "http://vivoweb.org/ontology/core#"> + <#local foaf = "http://xmlns.com/foaf/0.1/"> + <#local rdfs = "http://www.w3.org/2000/01/rdf-schema#"> - <#local firstName = qrData.firstName! > - <#local lastName = qrData.lastName! > - <#local org = "" > - <#local title = qrData.preferredTitle! > - <#local phoneNumber = qrData.phoneNumber! > - <#local email = qrData.email! > - <#local url = qrData.externalUrl! > - <#local photo = individual.thumbUrl! > - <#local rev = "" > + <#local firstName = qrData.firstName! > + <#local lastName = qrData.lastName! > + <#local org = "" > + <#local title = qrData.preferredTitle! > + <#local phoneNumber = qrData.phoneNumber! > + <#local email = qrData.email! > + <#local url = qrData.externalUrl! > + <#local photo = individual.thumbUrl! > + <#local rev = "" > - <#local qrCodeUrl = ""> - <#if firstName != "" && lastName != ""> - <#local vCard><#t> - BEGIN:VCARD<#lt> - VERSION:3.0<#lt> - N:${lastName};${firstName}<#lt> - FN:${firstName} ${lastName}<#lt> - <#if org != ""> ORG:${org}<#lt> - <#if title != "">TITLE:${title}<#lt> - <#if phoneNumber != "">TEL;TYPE=WORK,VOICE:${phoneNumber}<#lt> - <#if email != "">EMAIL;TYPE=PREF,INTERNET:${email}<#lt> - <#if url != "">URL:${url}<#lt> - <#if photo != "">PHOTO;VALUE=URL;TYPE=JPG:${photo}<#lt> - <#if rev != "">REV:${rev}<#lt> - END:VCARD<#t> - <#t> - - <#local vCard = (removeBlankLines(vCard))?url> + <#local qrCodeUrl = ""> + <#if firstName != "" && lastName != ""> + <#local vCard><#t> + BEGIN:VCARD<#lt> + VERSION:3.0<#lt> + N:${lastName};${firstName}<#lt> + FN:${firstName} ${lastName}<#lt> + <#if org != ""> ORG:${org}<#lt> + <#if title != "">TITLE:${title}<#lt> + <#if phoneNumber != "">TEL;TYPE=WORK,VOICE:${phoneNumber}<#lt> + <#if email != "">EMAIL;TYPE=PREF,INTERNET:${email}<#lt> + <#if url != "">URL:${url}<#lt> + <#if photo != "">PHOTO;VALUE=URL;TYPE=JPG:${photo}<#lt> + <#if rev != "">REV:${rev}<#lt> + END:VCARD<#t> + <#t> - <#local qrCodeUrl = "https://chart.googleapis.com/chart?cht=qr&chs=${qrCodeWidth}x${qrCodeWidth}&chl=${vCard}&choe=UTF-8" > - - - <#return qrCodeUrl> + <#local vCard = (removeBlankLines(vCard))?url> + + <#local qrCodeUrl = "https://chart.googleapis.com/chart?cht=qr&chs=${qrCodeWidth}x${qrCodeWidth}&chl=${vCard}&choe=UTF-8" > + + + <#return qrCodeUrl> <#function getQrCodeUrlForLink qrCodeWidth> - <#local qrData = individual.qrData > + <#local qrData = individual.qrData > - <#local url = qrData.externalUrl! > + <#local url = qrData.externalUrl! > - <#local qrCodeUrl = ""> - <#if url != ""> - <#local qrCodeContent = url?url> - <#local qrCodeUrl = "https://chart.googleapis.com/chart?cht=qr&chs=${qrCodeWidth}x${qrCodeWidth}&chl=${qrCodeContent}&choe=UTF-8" > - - - <#return qrCodeUrl> + <#local qrCodeUrl = ""> + <#if url != ""> + <#local qrCodeContent = url?url> + <#local qrCodeUrl = "https://chart.googleapis.com/chart?cht=qr&chs=${qrCodeWidth}x${qrCodeWidth}&chl=${qrCodeContent}&choe=UTF-8" > + + + <#return qrCodeUrl> <#function removeBlankLines input> - <#local test = "\n\n"> - <#local replacement = "\n"> + <#local test = "\n\n"> + <#local replacement = "\n"> - <#local output = input> - - <#local maxLoop = 50> - <#list 1..maxLoop as i> - <#if output?contains(test)> - <#local output = output?replace(test, replacement)> - <#else> - <#break> - - + <#local output = input> - <#return output> + <#local maxLoop = 50> + <#list 1..maxLoop as i> + <#if output?contains(test)> + <#local output = output?replace(test, replacement)> + <#else> + <#break> + + + + <#return output> + + +<#function hasValidVCard> + + <#local qrData = individual.qrData > + + <#local firstName = qrData.firstName! > + <#local lastName = qrData.lastName! > + + <#local validVCard = false> + <#if firstName != "" && lastName != ""> + <#local validVCard = true> + + + <#return validVCard> + +