Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata citation improvements #8607

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0"
xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0"
xmlns:mrd="http://standards.iso.org/iso/19115/-3/mrd/1.0"
xmlns:lan="http://standards.iso.org/iso/19115/-3/lan/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gn-fn-iso19115-3.2018="http://geonetwork-opensource.org/xsl/functions/profiles/iso19115-3.2018"
Expand Down Expand Up @@ -92,6 +93,10 @@
('publication', 'revision')]/
cit:date/gco:*[. != '']"/>


<xsl:variable name="datasetLanguage"
select="$metadata/mdb:identificationInfo/*/mri:defaultLocale/*/lan:language/*/@codeListValue"/>

<xsl:variable name="publicationDates" as="node()*">
<xsl:perform-sort select="$dates">
<xsl:sort select="." order="descending"/>
Expand Down Expand Up @@ -163,6 +168,7 @@
<doiUrl><xsl:value-of select="$doiUrl"/></doiUrl>
<xsl:copy-of select="$translatedKeywords"/>
<additionalCitation><xsl:value-of select="$additionalCitation"/></additionalCitation>
<language><xsl:value-of select="$datasetLanguage" /></language>
</citation>

</xsl:template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

<xsl:template mode="citation" match="citation[lower-case($format) = 'bibtex']">
<!-- https://en.wikipedia.org/wiki/BibTeX -->
<textResponse>@data{<xsl:value-of select="uuid"/>,
<textResponse>@misc{<xsl:value-of select="uuid"/>,
author = {<xsl:value-of select="normalize-space(string-join(authorsNameAndOrgList/*, ', '))"/>},
publisher = {<xsl:value-of select="normalize-space(string-join(publishersNameAndOrgList/*, ', '))"/>},
title = {<xsl:value-of select="normalize-space(translatedTitle)"/>},
Expand All @@ -91,7 +91,10 @@
<xsl:text>AU - </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text>&#13;&#10;</xsl:text>
</xsl:for-each>
<xsl:text>TI - </xsl:text><xsl:value-of select="normalize-space(translatedTitle)"/><xsl:text>&#13;&#10;</xsl:text>
<!-- TODO: LA, ET -->
<!-- TODO: ET -->
<xsl:if test="language != ''">
<xsl:text>LA - </xsl:text><xsl:value-of select="language"/><xsl:text>&#13;&#10;</xsl:text>
</xsl:if>
<xsl:for-each select="publishersNameAndOrgList/*[. != '']">
<xsl:text>PB - </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text>&#13;&#10;</xsl:text>
</xsl:for-each>
Expand All @@ -103,6 +106,10 @@
<xsl:text>DO - </xsl:text><xsl:value-of select="doi"/><xsl:text>&#13;&#10;</xsl:text>
</xsl:if>
<xsl:text>ID - </xsl:text><xsl:value-of select="uuid"/><xsl:text>&#13;&#10;</xsl:text>
<xsl:if test="lastPublicationDate != ''">
<xsl:text>DA - </xsl:text><xsl:value-of select="concat(replace(substring(lastPublicationDate, 1, 12), '-', '/'), '/')" /><xsl:text>&#13;&#10;</xsl:text>
<xsl:text>PY - </xsl:text><xsl:value-of select="substring(lastPublicationDate, 1, 4)" /><xsl:text>&#13;&#10;</xsl:text>
</xsl:if>
<xsl:text>ER -</xsl:text>
</textResponse>
</xsl:template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
<xsl:variable name="langId"
select="gn-fn-iso19139:getLangId($metadata, $language)"/>

<xsl:variable name="datasetLanguage"
select="$metadata/gmd:identificationInfo/*/gmd:language/*/@codeListValue"/>

<xsl:variable name="authors"
select="$metadata/gmd:identificationInfo/*/gmd:pointOfContact/
*[gmd:role/*/@codeListValue = $authorRolesList]"/>
Expand Down Expand Up @@ -167,6 +170,7 @@
<doiUrl><xsl:value-of select="$doiUrl"/></doiUrl>
<xsl:copy-of select="$translatedKeywords"/>
<additionalCitation><xsl:value-of select="$additionalCitation"/></additionalCitation>
<language><xsl:value-of select="$datasetLanguage" /></language>
</citation>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@data{{uuid},
@misc{{uuid},
author = {Production géomatique et traitement de données (SPW - Secrétariat général - SPW Digital - Département Données transversales - Production géomatique et traitement de données)},
publisher = {},
title = {Utilisation du Sol en Wallonie - WALOUS 2018},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
TY - DATA
AU - Production géomatique et traitement de données (SPW - Secrétariat général - SPW Digital - Département Données transversales - Production géomatique et traitement de données)
TI - Utilisation du Sol en Wallonie - WALOUS 2018
LA - fre
KW - Données de base
KW - Nature et environnement
KW - Aménagement du territoire
Expand All @@ -20,4 +21,6 @@ KW - UTS
KW - COSW
UR - http://localhost:8080/srv/api/records/{uuid}
ID - {uuid}
DA - 2020/10/30/
PY - 2020
ER -
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@data{{uuid},
@misc{{uuid},
author = {},
publisher = {},
title = {CORINE Land Cover Change 2012-2018 (vector), Europe, 6-yearly - version 2020_20u1, May 2020},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
TY - DATA
TI - CORINE Land Cover Change 2012-2018 (vector), Europe, 6-yearly - version 2020_20u1, May 2020
LA - eng
KW - Land cover
KW - EEA39
KW - landscape
Expand All @@ -14,4 +15,6 @@ KW - Water
UR - https://doi.org/10.2909/f30f1000-7cf8-43bb-872c-5eb093911b24
DO - 10.2909/f30f1000-7cf8-43bb-872c-5eb093911b24
ID - {uuid}
DA - 2020/05/13/
PY - 2020
ER -
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,23 @@
return "../api/records/" + scope.md.uuid + "/formatters/citation?format=";
}

var getCitationFormatExtension = function (format) {
if (format === "text") {
return "txt";
} else {
return format ? format : "txt";
}
};

scope.getCitationFilename = function () {
return (
"citation-" +
scope.md.uuid +
"." +
getCitationFormatExtension(scope.currentFormat)
);
};

scope.getCitation = function (format) {
return $http
.get(buildUrl() + format, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ <h2>
</h2>
</div>
<div>
<div
class="gn-copy-to-clipboard-button-floatright gn-margin-left-sm"
gn-save-text-button=""
data-file-name="{{ getCitationFilename() }}"
></div>

<div
class="gn-copy-to-clipboard-button-floatright"
gn-copy-to-clipboard-button=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1194,12 +1194,12 @@
*
* The code to be used in a HTML page:
*
* <span gn-copy-to-clipboard=""></span>
* <span gn-copy-to-clipboard-button=""></span>
* eg. for citation
*
* or
*
* <span gn-copy-to-clipboard="" data-text="{{::r.locUrl}}" gn-copy-button-only="true"></span>
* <span gn-copy-to-clipboard-button="" data-text="{{::r.locUrl}}" gn-copy-button-only="true"></span>
* eg. copy UUID or link URL
*
* or
Expand Down Expand Up @@ -1261,6 +1261,67 @@
}
]);

/*
* @description
* Save a file with a string in an input field, the parent element text
* or the results of a promise.
*
* The code to be used in a HTML page:
*
* <span gn-save-text-button="" data-file-name="citation.txt"></span>
* eg. for citation
*
* <span gn-save-text-button="" data-text="{{::r.locUrl}}"></span>
* eg. save UUID or link URL
*
* or
*
* <button gn-save-text-button="" get-text-fn="getListOfUuids()"/>
* eg. UUID of record with indexing errors
*/
module.directive("gnSaveTextButton", [
"$q",
function ($q) {
return {
restrict: "A",
replace: true,
template:
"<a class=\"{{::btnClass || 'btn btn-default btn-xs'}}\" " +
' ng-click="save()" ' +
' href=""' +
' title="{{::title | translate}}">' +
' <i class="fa fa-download"></i>' +
"</a>",
scope: {
btnClass: "@",
getTextFn: "&?",
fileName: "@"
},
link: function linkFn(scope, element, attr) {
scope.title = attr["tooltip"] || "saveToFile";
scope.fileName = scope.fileName || "file.txt";
scope.save = function () {
var promise = undefined;

if (angular.isFunction(scope.getTextFn)) {
promise = scope.getTextFn();
} else {
promise = $q.when(
attr["text"] ? attr["text"] : element.parent().text().trim()
);
}

promise.then(function (text) {
var blob = new Blob([text], { type: "text/plain;charset=utf-8" });
// Bootstrap FileSaver
saveAs(blob, scope.fileName);
});
};
}
};
}
]);

/**
* @ngdoc directive
* @name gn_utility.directive:gnMetadataPicker
Expand Down
3 changes: 2 additions & 1 deletion web-ui/src/main/resources/catalog/locales/en-core.json
Original file line number Diff line number Diff line change
Expand Up @@ -588,5 +588,6 @@
"mapLegend": "Legend",
"quality": "Quality",
"download": "Download",
"links": "Links"
"links": "Links",
"saveToFile": "Save to file."
}
Loading