Skip to content

Commit d17d9c5

Browse files
committed
JSON+LD metadata added
Script for creating json+ld metadata for each extracted image from .qmd file License and Description fields added to templates
1 parent 5430d6a commit d17d9c5

File tree

7 files changed

+127
-4
lines changed

7 files changed

+127
-4
lines changed

_quarto.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ project:
55
render:
66
- src/index.qmd
77
- src/guidelines/*.qmd
8-
- src/templates/*.qmd
98

109
resources:
1110
- assets/ # Ensure images are copied to _site/
@@ -28,3 +27,6 @@ format:
2827
output-dir: ../_site # Moves rendered files outside src/
2928
include-before-body: src/styles/main-logos.html
3029
css: src/styles/main.css
30+
31+
filters:
32+
- scripts/filters/extract-images.lua

metadata/default.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ toc-depth: 3 # Include headings up to level 3 (###)
55
number-sections: true
66
sitemap: true # Enables sitemap generation for web crawlers
77
tbl-colwidths: auto
8+
license: "EUPL (>= 1.2)"
89
format:
910
html:
11+
include-in-header:
12+
- ../../metadata/json-ld.html
1013
code-fold: true # Allow code blocks to be foldable
1114
self-contained: true # Embed resources like CSS and images
1215
docx:

metadata/json-ld.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script type="application/ld+json">
2+
{
3+
"@context": "https://schema.org",
4+
"@type": "ScholarlyArticle",
5+
"headline": "{{< meta title >}}",
6+
"description": "{{< meta description | default: '' >}}",
7+
"datePublished": "{{< meta date | default: '' >}}",
8+
"author": {
9+
"@type": "Person",
10+
"name": "{{< meta author | default: '' >}}",
11+
},
12+
"publisher": {
13+
"@type": "Organization",
14+
"name": "Copernicus Land Monitoring Service",
15+
"logo": {
16+
"@type": "ImageObject",
17+
"url": "https://land.copernicus.eu/static/media/ccl-icon-land-text-2.e04af716.svg"
18+
}
19+
},
20+
"keywords": "{{< meta keywords | default: '' >}}",
21+
"articleSection": "General",
22+
"isAccessibleForFree": "true",
23+
"license": "{{< meta license | default: '' >}}",
24+
"speakable": {
25+
"@type": "SpeakableSpecification",
26+
"cssSelector": "article p"
27+
}
28+
}
29+
</script>

scripts/filters/extract-images.lua

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
local images = {}
2+
3+
-- Extract images from the document
4+
function Image(el)
5+
local caption_text = ""
6+
7+
-- Extract caption correctly (works with ![Caption](image.png) syntax)
8+
if el.caption and type(el.caption) == "table" then
9+
for _, inline in ipairs(el.caption) do
10+
if inline.t == "Str" then
11+
caption_text = caption_text .. inline.text .. " "
12+
elseif inline.t == "Space" then
13+
caption_text = caption_text .. " "
14+
end
15+
end
16+
caption_text = caption_text:gsub("%s+$", "")
17+
end
18+
19+
table.insert(images, {
20+
url = el.src,
21+
caption = caption_text,
22+
width = el.attributes.width or nil,
23+
height = el.attributes.height or nil
24+
})
25+
26+
return el
27+
end
28+
29+
-- Function to inject JSON-LD before the first heading or at the end
30+
function Pandoc(doc)
31+
if #images == 0 then
32+
return doc
33+
end
34+
35+
-- Ensure `site_url` exists; otherwise, use empty string
36+
local site_url = doc.meta.site_url or ""
37+
if site_url ~= "" and not site_url:match("/$") then
38+
site_url = site_url .. "/"
39+
end
40+
41+
local jsonld_images = {
42+
["@context"] = "https://schema.org",
43+
["@type"] = "ItemList",
44+
itemListElement = {}
45+
}
46+
47+
for _, img in ipairs(images) do
48+
local absolute_url = img.url
49+
if not absolute_url:match("^https?://") then
50+
absolute_url = site_url .. img.url:gsub("^%./", "")
51+
end
52+
53+
table.insert(jsonld_images.itemListElement, {
54+
["@type"] = "ImageObject",
55+
url = absolute_url,
56+
caption = img.caption,
57+
width = img.width,
58+
height = img.height
59+
})
60+
end
61+
62+
-- Convert JSON-LD to a script tag
63+
local jsonld_script = pandoc.RawBlock("html", "<script type=\"application/ld+json\">\n"
64+
.. quarto.json.encode(jsonld_images, { pretty = true }) .. "\n</script>")
65+
66+
-- Inject JSON-LD **before the first <h1> or at the end**
67+
local inserted = false
68+
for i, block in ipairs(doc.blocks) do
69+
if block.t == "Header" and block.level == 1 then
70+
table.insert(doc.blocks, i, jsonld_script)
71+
inserted = true
72+
break
73+
end
74+
end
75+
76+
-- If no <h1> was found, append JSON-LD at the end
77+
if not inserted then
78+
table.insert(doc.blocks, jsonld_script)
79+
end
80+
81+
return doc
82+
end

src/guidelines/IT_Architecture_Principles_and_Implementation_Guidelines.qmd

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ author: "European Environment Agency (EEA)"
55
version: "1.4a"
66
date: "2025-03-06"
77
product-name: IT Architecture Principles and Implementation Guidelines
8+
description: "IT Architecture Principles and Implementation Guidelines"
89
keywords: ["Copernicus Land Monitoring Service, CLMS IT Architecture, European Environment Agency, IT Principles and Guidelines, IT Ecosystem, IT Security, EUPL Licensing, Reproducibility, Reusability, Transparency, Scalability, Maintainability, Resilient IT Solutions, Modular IT Architecture, Continuous Integration"]
910

1011

1112
metadata-files:
1213
- ../../metadata/default.yml
1314

1415
format:
16+
pdf: default
1517
html:
1618
css: ../styles/styles.css
1719
docx:
18-
reference-doc: ../styles/template-guideline.docx
19-
pdf: default
20+
reference-doc: ../styles/template-guideline.docx
21+
2022
---
2123

2224
```{=html}
@@ -200,11 +202,14 @@ The CLMS is funded by the EU and supports its community with data and services.
200202

201203
| **Transparency 1:** | **Source code of client specific software to be supplied with IT solution** |
202204
|----------------:|:------------------------------------------------------|
203-
| **What:** | Source code of client specific IT solution is supplied as part of the deliverable and made publicly available under the EUPL-1.2 license ^[https://commission.europa.eu/content/european-union-public-licence_en] |
205+
| **What:** | Source code of client specific IT solution is supplied as part of the deliverable and made publicly available under the EUPL-1.2 license [^1] |
204206
| **Why:** | To ensure transparency, it is essential to have clear insights into the client-specific software. This enables efficient future developments and modifications |
205207
| **Consequence:** | Source code of client specific software must be delivered with IT solution. The source code shall include Docker recipes and scripts for building the source code and be published under the EUPL-1.2 license |
206208
| **Example:** | *Source code of all the components of the specific IT solution must be delivered. Any updates or developments of the source code shall be reflected in the EEA GitHub repository, which is the main repository of the system. Moreover, the specific client IT solutions shall be published under the EUPL-1.2 license, so the openness and transparency are ensured* |
207209

210+
[^1]:https://commission.europa.eu/content/european-union-public-licence_en
211+
212+
208213
| **Transparency 2:** | **Inline documentation of the source code** |
209214
|----------------:|:------------------------------------------------------|
210215
| **What:** | Source code of client specific IT solution must be documented in-line |

src/templates/CLMS_ATBD_Template.qmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ subtitle: "ATBD Copernicus Land Monitoring Service -- Product full name"
44
date: "2022-10-06"
55
version: Issue x.y (“(x) version of the document” + “.”+ “(y) version of the document update”)
66
product-name: Product Name
7+
description: "Product DESCRIPTION"
78

89
metadata-files:
910
- ../../metadata/default.yml

src/templates/CLMS_PUM_Template.qmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ subtitle: "PUM Copernicus Land Monitoring Service - Product full name"
44
date: "2022-10-06"
55
version: Issue x.y (“(x) version of the document” + “.”+ “(y) version of the document update”) (first published version must start with 1.0)
66
product-name: Product Name
7+
description: "Product DESCRIPTION"
78

89
metadata-files:
910
- ../../metadata/default.yml

0 commit comments

Comments
 (0)