Skip to content

Commit

Permalink
Merge branch 'PS-748_subdefinition-to-rendition-migration' of github.…
Browse files Browse the repository at this point in the history
…com:alchemy-fr/phrasea into w2452
  • Loading branch information
nmaillat committed Dec 24, 2024
2 parents 5f5c365 + 9599ffd commit 953f79f
Show file tree
Hide file tree
Showing 21 changed files with 1,253 additions and 266 deletions.
37 changes: 37 additions & 0 deletions databox/indexer/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,43 @@
"attributeDefinition": "idmp_attributeDefinition",
"renditionDefinition": "idmp_renditionDefinition"
},
"renditions": {
"original": {
"from": "document",
"useAsOriginal": true,
"class": "document"
},
"preview": {
"useAsPreview": true,
"class": "public",
"builders": {
"image": {
"from": "image:preview"
},
"video": {
"from": "video:preview"
},
"document": {
"from": "document:preview"
}
}
},
"thumbnail": {
"useAsThumbnail": true,
"parent": "preview",
"builders": {
"image": {
"from": "image:thumbnail"
},
"video": {
"from": "video:thumbnail"
},
"document": {
"from": "document:thumbnail"
}
}
}
},
"databoxMapping": [
{
"databox": "%env(PHRASEANET_DATABOX)%",
Expand Down
92 changes: 92 additions & 0 deletions databox/indexer/doc/conf_phraseanet.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,95 @@ To prevent twig to crash if a field doest not exists in a record (when trying to
`getMetadata(...)` will return a "fake" empty metadata object.

Same method applies for subdefs: `record.getSubdef('missingSubdef').permalink.url` will return null.


## `renditions`

Allows to map Phraseanet subdef / (structures) to Phrasea renditions / (definitions).

A Phraseanet subdef is identified by it **type** (image, video, audio, document, unknown) and its **name**. e.g. `image:thumbnail`.

A Phrasea rendition-definition is declared by its **name** and **build settings** (sections image, video, ...).

### `from`
The `from` setting maps the phrasea rendition-definition to the phraseanet subdef. The build settings will be generated from the phraseanet to match the subdef.

It is possible to declare a rendition with no `from`: not imported from Phraseanet, but created in Phrasea.

### `parent`
One can declare a `parent` relation between renditions, the parent rendition **must** be declared before the child.


The special `original` rendition has no build settings, so the `from` setting is top-level. Mostly it will be mapped to the Phraseanet special `document` subdef.

### `useAsOriginal`, `useAsPreview`, `useAsThumbnail`, `class`, ...

Common settings for all renditions. If not set, the value will be "guessed" from the subdef name / class.

e.g.

```json lines
...
"renditions": {
"original": {
"from": "document",
"useAsOriginal": true,
"class": "document"
},
"preview": {
"useAsPreview": true,
"parent": "original",
"class": "public_preview",
"builders": {
"image": {
"from": "image:preview"
},
"video": {
"from": "video:preview"
}
}
},
"thumbnail": {
"useAsThumbnail": true,
"parent": "preview",
"builders": {
"image": {
"from": "image:thumbnail"
},
"video": {
"from": "video:thumbnail"
}
}
}
/* ------------------- WIP ------------
,
"pivot": {
"parent": "original",
"builders": {
"video": {
"build": {
"transformations": {
"module": "ffmpeg",
"enabled": true,
"options": {
"format": "video-mp4",
"audio_kilobitrate": 100,
"timeout": 7200,
"threads": 2,
"filters": {
"name": "resize",
"width": 1200,
"height": 1200,
"mode": "inset",
"enabled": true
}
}
}
}
}
}
}
*/
}
...
```
5 changes: 3 additions & 2 deletions databox/indexer/src/databox/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ export class DataboxClient {
return res.data['hydra:member'];
}

async createRenditionDefinition(data: object): Promise<void> {
await this.client.post(`/rendition-definitions`, data);
async createRenditionDefinition(data: object): Promise<string> {
const res = await this.client.post(`/rendition-definitions`, data);
return res.data.id;
}

async flushWorkspace(workspaceId: string): Promise<string> {
Expand Down
3 changes: 3 additions & 0 deletions databox/indexer/src/handlers/phraseanet/CPhraseanetRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ class CPhraseanetRecordBase {

export class CPhraseanetRecord extends CPhraseanetRecordBase {
record_id: string = '';
phrasea_type: string = '';
constructor(r: PhraseanetRecord, client: PhraseanetClient) {
super(r, client);
this.record_id = r.record_id;
this.phrasea_type = r.phrasea_type;
}
}

Expand All @@ -112,5 +114,6 @@ export class CPhraseanetStory extends CPhraseanetRecordBase {
constructor(s: PhraseanetStory, client: PhraseanetClient) {
super(s, client);
this.story_id = s.story_id;
this.children = s.children.map(r => new CPhraseanetRecord(r, client));
}
}
Loading

0 comments on commit 953f79f

Please sign in to comment.