template updated

This commit is contained in:
Francesco Mangiacrapa 2024-06-21 15:32:28 +02:00
parent e0c9513f36
commit 21dd5fff1c
1 changed files with 21 additions and 10 deletions

View File

@ -6,6 +6,13 @@
<#assign tags=[]>
<#assign extras=[]>
<#function sanitizeString(value)>
<#if value??>
<#return value?trim?replace('\n','')?replace('\"','')>
</#if>
<#return "">
</#function>
<#-- Macro to assign Tags -->
<#macro assignTag in_tags>
<#if in_tags??>
@ -26,7 +33,7 @@
<#assign description = ""/>
</#if>
<#if url??>
<#assign resource = {"name": name, "url": url, "description": description, "format": format}>
<#assign resource = {"name": name, "url": url, "description": sanitizeString(description), "format": format}>
<#assign resources = resources + [resource]/>
</#if>
</#macro>
@ -47,7 +54,11 @@
<#-- Macro to assign Extras field -->
<#macro assignExtraField key value asObject>
<#if key??>
<#assign extra = {"key": key, "value": value, "asObject": asObject}>
<#assign checkedValue = value/>
<#if key != "spatial">
<#assign checkedValue = sanitizeString(value)/>
</#if>
<#assign extra = {"key": sanitizeString(key), "value": checkedValue, "asObject": asObject}>
<#assign extras = extras + [extra]/>
</#if>
</#macro>
@ -120,17 +131,17 @@
</#macro>
<#--
Starting document mapping to Catalogue
-->
<#compress>
{
"name": "${jsonProj._id}",
"title": "${theDocument.nome}",
"license_id": "CC-BY-SA-4.0",
"private": false,
<#assign description = theDocument.introduzione?trim />
<#assign sanitizedNotes = description?replace("\\n", "")>
<#assign sanitizedNotes = sanitizeString(theDocument.introduzione) />
"notes": "${sanitizedNotes}",
<#--
@ -263,10 +274,10 @@ Starting document mapping to Catalogue
<#if theDocument.contestoIndagine??>
<#if theDocument.contestoIndagine?is_sequence>
<#list theDocument.contestoIndagine as my_extra>
<@assignExtraField key="Definizione del contesto d'indagine" value=my_extra asObject=false></@assignExtraField>
<@assignExtraField key="Contesto Indagine" value=my_extra asObject=false></@assignExtraField>
</#list>
<#else>
<@assignExtraField key="Definizione del contesto d'indagine" value=theDocument.contestoIndagine asObject=false></@assignExtraField>
<@assignExtraField key="Contesto Indagine" value=theDocument.contestoIndagine asObject=false></@assignExtraField>
</#if>
</#if>
@ -281,10 +292,10 @@ Starting document mapping to Catalogue
<#if theDocument.cronologiaMacrofase??>
<#if theDocument.cronologiaMacrofase?is_sequence>
<#list theDocument.cronologiaMacrofase as my_extra>
<@assignExtraField key="Cronologia (Macrofase)" value=my_extra asObject=false></@assignExtraField>
<@assignExtraField key="Cronologia Macrofase" value=my_extra asObject=false></@assignExtraField>
</#list>
<#else>
<@assignExtraField key="Cronologia (Macrofase)" value=theDocument.cronologiaMacrofase asObject=false></@assignExtraField>
<@assignExtraField key="Cronologia Macrofase" value=theDocument.cronologiaMacrofase asObject=false></@assignExtraField>
</#if>
</#if>
@ -304,4 +315,4 @@ Starting document mapping to Catalogue
<@buildExtrasFields the_extras=extras></@buildExtrasFields>
}
</#compress>