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
1 changed files with 28 additions and 18 deletions

View File

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