@rr0/cms 0.3.48 → 0.3.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -66,14 +66,14 @@ export class DataContentVisitor {
|
|
|
66
66
|
const contents = doc.querySelector(".contents");
|
|
67
67
|
if (contents) {
|
|
68
68
|
const imgEl = contents.querySelector("img");
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
69
|
+
const eventCaption = event.name;
|
|
70
|
+
const eventSsrc = event.url;
|
|
71
|
+
if (imgEl && ![imgEl.src, path.join("/", path.dirname(context.file.name), imgEl.src)].includes(eventSsrc)) {
|
|
72
72
|
const imgEl = doc.createElement("img");
|
|
73
|
-
imgEl.src =
|
|
73
|
+
imgEl.src = eventSsrc;
|
|
74
74
|
imgEl.alt = event.title;
|
|
75
75
|
const figcaptionEl = doc.createElement("figcaption");
|
|
76
|
-
figcaptionEl.innerHTML =
|
|
76
|
+
figcaptionEl.innerHTML = eventCaption;
|
|
77
77
|
await this.eventRenderer.renderEnd(context, event, figcaptionEl);
|
|
78
78
|
const figureEl = doc.createElement("figure");
|
|
79
79
|
figureEl.append(imgEl);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { HtmlRR0Context } from "../RR0Context.js";
|
|
2
2
|
import { CountryCode, Occupation, People } from "@rr0/data";
|
|
3
3
|
export declare class PeopleHtmlRenderer {
|
|
4
|
-
protected defaultPreviewFileNames: string[];
|
|
5
|
-
constructor(defaultPreviewFileNames?: string[]);
|
|
6
4
|
renderLink(context: HtmlRR0Context, people: People, pseudoPeopleList: People[], allCountries: Set<CountryCode>, occupations: Set<Occupation>, filterOccupations?: Occupation[], content?: string): HTMLElement;
|
|
7
5
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { Gender } from "@rr0/common";
|
|
3
|
+
import { AbstractDataFactory } from "@rr0/data";
|
|
3
4
|
export class PeopleHtmlRenderer {
|
|
4
|
-
constructor(defaultPreviewFileNames = ["portrait.jpg", "portrait.gif", "portrait.png", "portrait.webp"]) {
|
|
5
|
-
this.defaultPreviewFileNames = defaultPreviewFileNames;
|
|
6
|
-
}
|
|
7
5
|
renderLink(context, people, pseudoPeopleList, allCountries, occupations, filterOccupations = [], content) {
|
|
8
6
|
var _a, _b, _c;
|
|
9
7
|
const dirName = people.dirName;
|
|
@@ -73,7 +71,7 @@ export class PeopleHtmlRenderer {
|
|
|
73
71
|
let portraitUrl = people.image;
|
|
74
72
|
const imageEvents = events.filter(event => event.eventType === "image");
|
|
75
73
|
if (!portraitUrl) {
|
|
76
|
-
const portraitEvent = imageEvents.find(event =>
|
|
74
|
+
const portraitEvent = imageEvents.find(event => AbstractDataFactory.defaultPreviewFileNames.includes(event.url));
|
|
77
75
|
if (portraitEvent) {
|
|
78
76
|
portraitUrl = path.join("/", people.dirName, portraitEvent.url);
|
|
79
77
|
}
|
|
@@ -7,7 +7,9 @@ import { PeopleHtmlRenderer } from "./PeopleHtmlRenderer.js";
|
|
|
7
7
|
describe("PeopleReplacer", () => {
|
|
8
8
|
const rootDir = rr0TestUtil.filePath("people");
|
|
9
9
|
const files = [
|
|
10
|
+
path.join(rootDir, "j/Jésus"),
|
|
10
11
|
path.join(rootDir, "b/BeauJerome"),
|
|
12
|
+
path.join(rootDir, "j/Jesus"),
|
|
11
13
|
path.join(rootDir, "h/HynekJosefAllen"),
|
|
12
14
|
path.join(rootDir, "r/ReaganRonald"),
|
|
13
15
|
path.join(rootDir, "v/VertongenJeanLuc")
|
|
@@ -38,31 +40,36 @@ describe("PeopleReplacer", () => {
|
|
|
38
40
|
expect(replacement.outerHTML).toBe(`<span title="1910-1986, 76 ans, USA, ufologue, astronome" class="deceased country-us occupation-ufologist occupation-astronomer" translate="no"><a href="/src/people/h/HynekJosefAllen/">Josef Allen Hynek (Northwestern University, Evanston, Illinois)</a></span>`);
|
|
39
41
|
}
|
|
40
42
|
});
|
|
41
|
-
test("replace people tags",
|
|
43
|
+
test("replace people tags", async () => {
|
|
42
44
|
const dataService = new AllDataService([peopleFactory]);
|
|
43
45
|
const peopleService = new PeopleService(dataService, peopleFactory, { rootDir, files });
|
|
44
46
|
const peopleRenderer = new PeopleHtmlRenderer();
|
|
45
47
|
const replacer = new PeopleReplacer(peopleService, peopleRenderer);
|
|
46
48
|
const context = rr0TestUtil.time.newHtmlContext("1/9/9/0/08/index.html", "");
|
|
47
49
|
{
|
|
48
|
-
const peopleWithTitle = createPeopleElement(context, "
|
|
50
|
+
const peopleWithTitle = createPeopleElement(context, "Jésus");
|
|
49
51
|
const replacement = await replacer.replacement(context, peopleWithTitle);
|
|
50
|
-
expect(replacement.outerHTML).toBe(`<span class="
|
|
52
|
+
expect(replacement.outerHTML).toBe(`<span class="data-resolved people-resolved" translate="no"><a href="/test/people/j/Jesus/">Jésus</a></span>`);
|
|
51
53
|
}
|
|
52
54
|
{
|
|
53
|
-
const
|
|
55
|
+
const peopleWithComposedFirstName = createPeopleElement(context, "Jean-Luc Vertongen");
|
|
56
|
+
const replacement = await replacer.replacement(context, peopleWithComposedFirstName);
|
|
57
|
+
expect(replacement.outerHTML).toBe(`<span title="1939-2015, 76 ans, Belgique, ufologue" class="data-resolved people-resolved deceased country-be occupation-ufologist" translate="no"><a href="/test/people/v/VertongenJeanLuc/">Jean-Luc Vertongen<img src="/test/people/v/VertongenJeanLuc/portrait.jpg" alt="Jean-Luc Vertongen" class="portrait" width="75"></a></span>`);
|
|
58
|
+
}
|
|
59
|
+
{
|
|
60
|
+
const peopleWithTitle = createPeopleElement(context, "Reagan", "Ronald Reagan");
|
|
54
61
|
const replacement = await replacer.replacement(context, peopleWithTitle);
|
|
55
|
-
expect(replacement.outerHTML).toBe(`<span class="
|
|
62
|
+
expect(replacement.outerHTML).toBe(`<span title="1911-2004, 93 ans, USA, acteur, politicien, dirigeant" class="data-resolved people-resolved deceased country-us occupation-actor occupation-politician occupation-leader" translate="no"><a href="/test/people/r/ReaganRonald/">Reagan<img src="/test/people/r/ReaganRonald/portrait.gif" alt="Reagan" class="portrait" width="75"></a></span>`);
|
|
56
63
|
}
|
|
57
64
|
{
|
|
58
65
|
const peopleWithFullName = createPeopleElement(context, "Jérôme Beau");
|
|
59
66
|
let replacement = await replacer.replacement(context, peopleWithFullName);
|
|
60
|
-
expect(replacement.outerHTML).toBe(`<span
|
|
67
|
+
expect(replacement.outerHTML).toBe(`<span class="data-resolved people-resolved" translate="no"><a href="/test/people/b/BeauJerome/">Jérôme Beau</a></span>`);
|
|
61
68
|
}
|
|
62
69
|
{
|
|
63
70
|
const peopleWithLastName = createPeopleElement(context, "Beau");
|
|
64
71
|
let replacement = await replacer.replacement(context, peopleWithLastName);
|
|
65
|
-
expect(replacement.outerHTML).toBe(`<span
|
|
72
|
+
expect(replacement.outerHTML).toBe(`<span class="data-resolved people-resolved" translate="no"><a href="/test/people/b/BeauJerome/">Beau</a></span>`);
|
|
66
73
|
}
|
|
67
74
|
});
|
|
68
75
|
});
|
package/package.json
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"name": "@rr0/cms",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"author": "Jérôme Beau <rr0@rr0.org> (https://rr0.org)",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.50",
|
|
6
6
|
"description": "RR0 Content Management System (CMS)",
|
|
7
7
|
"exports": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
10
|
+
"node": ">=22"
|
|
11
11
|
},
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"homepage": "https://github.com/RR0/cms#readme",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"circular-deps": "dpdm src",
|
|
26
26
|
"prepublishOnly": "npm run build && npm run test-ci",
|
|
27
27
|
"test": "testscript",
|
|
28
|
-
"test-one": "rm -Rf out && tsx src/
|
|
28
|
+
"test-one": "rm -Rf out && tsx src/people/PeopleReplacer.test.ts",
|
|
29
29
|
"test-ci": "rm -Rf out && testscript"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
"@rr0/lang": "^0.1.12",
|
|
36
36
|
"@rr0/place": "^0.5.3",
|
|
37
37
|
"@rr0/time": "^0.11.1",
|
|
38
|
-
"canvas": "^3.1.
|
|
38
|
+
"canvas": "^3.1.2",
|
|
39
39
|
"csv-parser": "^3.2.0",
|
|
40
|
-
"glob": "^11.0.
|
|
40
|
+
"glob": "^11.0.3",
|
|
41
41
|
"image-size": "^2.0.2",
|
|
42
42
|
"jsdom": "^26.1.0",
|
|
43
|
-
"selenium-webdriver": "^4.
|
|
44
|
-
"ssg-api": "^1.17.
|
|
43
|
+
"selenium-webdriver": "^4.34.0",
|
|
44
|
+
"ssg-api": "^1.17.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@javarome/testscript": "^0.13.1",
|
|
48
48
|
"@types/jsdom": "^21.1.7",
|
|
49
|
-
"@types/node": "^22.
|
|
50
|
-
"tsx": "4.19.
|
|
51
|
-
"typescript": "^5.8.
|
|
52
|
-
"vite": "^6.
|
|
49
|
+
"@types/node": "^22.15.30",
|
|
50
|
+
"tsx": "4.19.4",
|
|
51
|
+
"typescript": "^5.8.3",
|
|
52
|
+
"vite": "^6.3.5"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
55
55
|
"cms",
|