feature: don't create federation when there is only one target

This commit is contained in:
Jean-Baptiste Pasquier 2021-07-05 19:15:43 +02:00
parent 8c860e07aa
commit 6d52e869d1

View File

@ -113,15 +113,20 @@ for component of components
for(const [attribute, path] of Object.entries(component.parameters)) { for(const [attribute, path] of Object.entries(component.parameters)) {
if(typeof path === 'string') { if(typeof path === 'string') {
if(path.startsWith('federation://')) { if(path.startsWith('federation://')) {
federations[`store://local.${component.uniq}/${attribute}/`] = { let contains = generateUrl(federation, path);
"@cache": "false", if(contains.length > 1) {
"@context": "https://cdn.happy-dev.fr/owl/hdcontext.jsonld", federations[`store://local.${component.uniq}/${attribute}/`] = {
"@type": "ldp:Container", "@cache": "false",
"@id": `store://local.${component.uniq}/${attribute}/`, "@context": "https://cdn.happy-dev.fr/owl/hdcontext.jsonld",
"ldp:contains": generateUrl(federation, path), "@type": "ldp:Container",
"permissions": [{"mode": {"@type": "view"}}] "@id": `store://local.${component.uniq}/${attribute}/`,
}; "ldp:contains": contains,
component.parameters[attribute] = `store://local.${component.uniq}/${attribute}/`; "permissions": [{"mode": {"@type": "view"}}]
};
component.parameters[attribute] = `store://local.${component.uniq}/${attribute}/`;
} else {
component.parameters[attribute] = federation.values().next().value + path.replace(/federation:\//, '');
}
} }
if(path.startsWith('server://')) { if(path.startsWith('server://')) {
component.parameters[attribute] = client.server + path.replace(/server:\//, ''); component.parameters[attribute] = client.server + path.replace(/server:\//, '');
@ -163,15 +168,20 @@ for component of components
for(const [attribute, path] of Object.entries(extension.parameters)) { for(const [attribute, path] of Object.entries(extension.parameters)) {
if(typeof path === 'string') { if(typeof path === 'string') {
if(path.startsWith('federation://')) { if(path.startsWith('federation://')) {
federations[`store://local.${extension.uniq}/${attribute}/`] = { let contains = generateUrl(federation, path);
"@cache": "false", if(contains.length > 1) {
"@context": "https://cdn.happy-dev.fr/owl/hdcontext.jsonld", federations[`store://local.${extension.uniq}/${attribute}/`] = {
"@type": "ldp:Container", "@cache": "false",
"@id": `store://local.${extension.uniq}/${attribute}/`, "@context": "https://cdn.happy-dev.fr/owl/hdcontext.jsonld",
"ldp:contains": generateUrl(federation, path), "@type": "ldp:Container",
"permissions": [{"mode": {"@type": "view"}}] "@id": `store://local.${extension.uniq}/${attribute}/`,
}; "ldp:contains": contains,
extension.parameters[attribute] = `store://local.${extension.uniq}/${attribute}/`; "permissions": [{"mode": {"@type": "view"}}]
};
extension.parameters[attribute] = `store://local.${extension.uniq}/${attribute}/`;
} else {
component.parameters[attribute] = federation.values().next().value + path.replace(/federation:\//, '');
}
} }
if(path.startsWith('server://')) { if(path.startsWith('server://')) {
extension.parameters[attribute] = client.server + path.replace(/server:\//, ''); extension.parameters[attribute] = client.server + path.replace(/server:\//, '');