individual-qrCodeFoafPerson.ftl: add hasValidVCard function, remove tabs

individual--foaf-person.ftl: use hasValidVCard function in commented-out QR code section
This commit is contained in:
mbarbier 2011-04-07 17:40:48 +00:00
parent 1c3df021cf
commit 41aa28ed03
2 changed files with 92 additions and 73 deletions

View file

@ -71,12 +71,14 @@
<@p.vitroLinks propertyGroups namespaces editable "individual-urls-people" /> <@p.vitroLinks propertyGroups namespaces editable "individual-urls-people" />
<#-- <#--
<div style="border:1px solid #cccccc"> <#if hasValidVCard()>
<span style="padding-left:5px">vCard QR <a style="font-size:smaller" href="${individual.qrData.aboutQrCodesUrl}">What is this?</a></span> <div style="border:1px solid #cccccc">
<a title="Export QR codes" href="${individual.qrData.exportQrCodeUrl}"> <span style="padding-left:5px">vCard QR <a style="font-size:smaller" href="${individual.qrData.aboutQrCodesUrl}">What is this?</a></span>
<@qrCodeVCard qrCodeWidth="150" /> <a title="Export QR codes" href="${individual.qrData.exportQrCodeUrl}">
</a> <@qrCodeVCard qrCodeWidth="150" />
</div> </a>
</div>
</#if>
--> -->
</section> </section>

View file

@ -4,103 +4,120 @@
<#macro qrCodeVCard qrCodeWidth> <#macro qrCodeVCard qrCodeWidth>
<#local qrCodeUrl = getQrCodeUrlForVCard(qrCodeWidth)> <#local qrCodeUrl = getQrCodeUrlForVCard(qrCodeWidth)>
<#if qrCodeUrl != ""> <#if qrCodeUrl != "">
<img src="${qrCodeUrl}" /> <img src="${qrCodeUrl}" />
</#if> </#if>
</#macro> </#macro>
<#macro qrCodeLink qrCodeWidth> <#macro qrCodeLink qrCodeWidth>
<#local qrCodeUrl = getQrCodeUrlForLink(qrCodeWidth)> <#local qrCodeUrl = getQrCodeUrlForLink(qrCodeWidth)>
<#if qrCodeUrl != ""> <#if qrCodeUrl != "">
<img src="${qrCodeUrl}" /> <img src="${qrCodeUrl}" />
</#if> </#if>
</#macro> </#macro>
<#function getQrCodeUrlForVCard qrCodeWidth> <#function getQrCodeUrlForVCard qrCodeWidth>
<#local qrData = individual.qrData > <#local qrData = individual.qrData >
<#local core = "http://vivoweb.org/ontology/core#"> <#local core = "http://vivoweb.org/ontology/core#">
<#local foaf = "http://xmlns.com/foaf/0.1/"> <#local foaf = "http://xmlns.com/foaf/0.1/">
<#local rdfs = "http://www.w3.org/2000/01/rdf-schema#"> <#local rdfs = "http://www.w3.org/2000/01/rdf-schema#">
<#local firstName = qrData.firstName! > <#local firstName = qrData.firstName! >
<#local lastName = qrData.lastName! > <#local lastName = qrData.lastName! >
<#local org = "" > <#local org = "" >
<#local title = qrData.preferredTitle! > <#local title = qrData.preferredTitle! >
<#local phoneNumber = qrData.phoneNumber! > <#local phoneNumber = qrData.phoneNumber! >
<#local email = qrData.email! > <#local email = qrData.email! >
<#local url = qrData.externalUrl! > <#local url = qrData.externalUrl! >
<#local photo = individual.thumbUrl! > <#local photo = individual.thumbUrl! >
<#local rev = "" > <#local rev = "" >
<#local qrCodeUrl = ""> <#local qrCodeUrl = "">
<#if firstName != "" && lastName != ""> <#if firstName != "" && lastName != "">
<#local vCard><#t> <#local vCard><#t>
BEGIN:VCARD<#lt> BEGIN:VCARD<#lt>
VERSION:3.0<#lt> VERSION:3.0<#lt>
N:${lastName};${firstName}<#lt> N:${lastName};${firstName}<#lt>
FN:${firstName} ${lastName}<#lt> FN:${firstName} ${lastName}<#lt>
<#if org != ""> ORG:${org}</#if><#lt> <#if org != ""> ORG:${org}</#if><#lt>
<#if title != "">TITLE:${title}</#if><#lt> <#if title != "">TITLE:${title}</#if><#lt>
<#if phoneNumber != "">TEL;TYPE=WORK,VOICE:${phoneNumber}</#if><#lt> <#if phoneNumber != "">TEL;TYPE=WORK,VOICE:${phoneNumber}</#if><#lt>
<#if email != "">EMAIL;TYPE=PREF,INTERNET:${email}</#if><#lt> <#if email != "">EMAIL;TYPE=PREF,INTERNET:${email}</#if><#lt>
<#if url != "">URL:${url}</#if><#lt> <#if url != "">URL:${url}</#if><#lt>
<#if photo != "">PHOTO;VALUE=URL;TYPE=JPG:${photo}</#if><#lt> <#if photo != "">PHOTO;VALUE=URL;TYPE=JPG:${photo}</#if><#lt>
<#if rev != "">REV:${rev}</#if><#lt> <#if rev != "">REV:${rev}</#if><#lt>
END:VCARD<#t> END:VCARD<#t>
</#local><#t> </#local><#t>
<#local vCard = (removeBlankLines(vCard))?url> <#local vCard = (removeBlankLines(vCard))?url>
<#local qrCodeUrl = "https://chart.googleapis.com/chart?cht=qr&amp;chs=${qrCodeWidth}x${qrCodeWidth}&amp;chl=${vCard}&amp;choe=UTF-8" > <#local qrCodeUrl = "https://chart.googleapis.com/chart?cht=qr&amp;chs=${qrCodeWidth}x${qrCodeWidth}&amp;chl=${vCard}&amp;choe=UTF-8" >
</#if> </#if>
<#return qrCodeUrl> <#return qrCodeUrl>
</#function> </#function>
<#function getQrCodeUrlForLink qrCodeWidth> <#function getQrCodeUrlForLink qrCodeWidth>
<#local qrData = individual.qrData > <#local qrData = individual.qrData >
<#local url = qrData.externalUrl! > <#local url = qrData.externalUrl! >
<#local qrCodeUrl = ""> <#local qrCodeUrl = "">
<#if url != ""> <#if url != "">
<#local qrCodeContent = url?url> <#local qrCodeContent = url?url>
<#local qrCodeUrl = "https://chart.googleapis.com/chart?cht=qr&amp;chs=${qrCodeWidth}x${qrCodeWidth}&amp;chl=${qrCodeContent}&amp;choe=UTF-8" > <#local qrCodeUrl = "https://chart.googleapis.com/chart?cht=qr&amp;chs=${qrCodeWidth}x${qrCodeWidth}&amp;chl=${qrCodeContent}&amp;choe=UTF-8" >
</#if> </#if>
<#return qrCodeUrl> <#return qrCodeUrl>
</#function> </#function>
<#function removeBlankLines input> <#function removeBlankLines input>
<#local test = "\n\n"> <#local test = "\n\n">
<#local replacement = "\n"> <#local replacement = "\n">
<#local output = input> <#local output = input>
<#local maxLoop = 50> <#local maxLoop = 50>
<#list 1..maxLoop as i> <#list 1..maxLoop as i>
<#if output?contains(test)> <#if output?contains(test)>
<#local output = output?replace(test, replacement)> <#local output = output?replace(test, replacement)>
<#else> <#else>
<#break> <#break>
</#if> </#if>
</#list> </#list>
<#return output> <#return output>
</#function>
<#function hasValidVCard>
<#local qrData = individual.qrData >
<#local firstName = qrData.firstName! >
<#local lastName = qrData.lastName! >
<#local validVCard = false>
<#if firstName != "" && lastName != "">
<#local validVCard = true>
</#if>
<#return validVCard>
</#function> </#function>