Skip to content

Conversation

amen12bb
Copy link

@amen12bb amen12bb commented Aug 2, 2025

Allow to integrate into your Zotero Library items from the Collections of the Château de Versailles' website.
Hello,
This adds a new translator for the Château de Versailles collections website (collections.chateauversailles.fr).
It correctly imports artwork metadata, including title, artist, date, and combines the "Commentaire" and "Historique" sections into the abstract field.

Example URL: https://collections.chateauversailles.fr/#/query/efca7ba3-35b6-4624-af48-b6ca0838b5e5

Allow to integrate into your Zotero Library items from the Collections of the Château de Versailles' website.
@@ -0,0 +1,121 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Scaffold to create a translator. You can have ChatGPT generate sections, but as is, this isn't a valid translator:

  • License text is wrong
  • License text is above the metadata block (metadata block needs to be the very first thing in the file)

Create a new translator in Scaffold and add the Web Translator template (toolbar Plus button in the Code tab).

{
"translatorID": "7ae64474-9f23-4d2c-9995-dfe8c5010c4b",
"label": "ChateauVersailles",
"creator": "OpenAI / Alexandre MENISSEZ",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenAI doesn't get credit (or blame) for code we merge. creator should just be the human who worked on the code.

"translatorID": "7ae64474-9f23-4d2c-9995-dfe8c5010c4b",
"label": "ChateauVersailles",
"creator": "OpenAI / Alexandre MENISSEZ",
"target": "^https://collections\\.chateauversailles\\.fr/\\#/query/.*",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"target": "^https://collections\\.chateauversailles\\.fr/\\#/query/.*",
"target": "^https://collections\\.chateauversailles\\.fr/",

"creator": "OpenAI / Alexandre MENISSEZ",
"target": "^https://collections\\.chateauversailles\\.fr/\\#/query/.*",
"minVersion": "3.0",
"maxVersion": "6.999",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this doesn't work. Use Scaffold to create a new translator and copy your code (everything below the metadata block) into the Code tab.

item.attachments.push({
title: "Image de l'œuvre",
mimeType: "image/jpeg",
url: new URL(img.getAttribute("src"), url).href,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url: new URL(img.getAttribute("src"), url).href,
url: img.src,

let abstractParts = [];
let commentaireNode = doc.querySelector("div.commentaire-chef-doeuvre") || [...doc.querySelectorAll("div")].find(el => el.textContent.includes("Commentaire"));
if (commentaireNode) {
let texte = commentaireNode.textContent.trim().replace(/\s+/g, " ");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let texte = commentaireNode.textContent.trim().replace(/\s+/g, " ");
let texte = ZU.trimInternal(commentaireNode.textContent);


let historiqueNode = [...doc.querySelectorAll("div")].find(el => el.textContent.includes("Historique"));
if (historiqueNode) {
let texte = historiqueNode.textContent.trim().replace(/\s+/g, " ");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let texte = historiqueNode.textContent.trim().replace(/\s+/g, " ");
let texte = ZU.trimInternal(historiqueNode.textContent);


item.libraryCatalog = "Château de Versailles Collections";
item.language = "fr";
item.publisher = "Château de Versailles";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

artwork doesn't have a publisher field, and this would probably create an incorrect citation. archive would be better.


{
"translatorID": "7ae64474-9f23-4d2c-9995-dfe8c5010c4b",
"label": "ChateauVersailles",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"label": "ChateauVersailles",
"label": "Château de Versailles",

And rename the file to Château de Versailles.js (Scaffold will do this for you).

item.url = url;

item.complete();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests (Scaffold can help with that - load a page in the browser and click Create Web Test).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants