@rr0/cms 0.3.4 → 0.3.5
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.
- package/dist/time/datasource/DatasourceTestCase.js +2 -2
- package/dist/time/datasource/rr0/RR0Datasource.d.ts +3 -0
- package/dist/time/datasource/rr0/RR0Datasource.js +4 -0
- package/dist/time/datasource/rr0/RR0Datasource.test.js +8 -2
- package/dist/time/datasource/rr0/RR0HttpDatasource.d.ts +0 -2
- package/dist/time/datasource/rr0/RR0HttpDatasource.js +0 -3
- package/package.json +2 -2
|
@@ -29,12 +29,12 @@ export class DatasourceTestCase {
|
|
|
29
29
|
const expected = this.mapping.mapper.map(context, nativeCase, dataDate);
|
|
30
30
|
const time = this.getTime(nativeCase);
|
|
31
31
|
const caseContext = context.clone();
|
|
32
|
-
|
|
32
|
+
caseContext.time.date = time;
|
|
33
33
|
const timeStr = this.timeTextBuilder.build(caseContext);
|
|
34
34
|
const placeStr = expected.place ? this.placeRenderer.render(context, expected.place) : "";
|
|
35
35
|
const expectedSources = expected.sources;
|
|
36
36
|
const sourceStr = (expectedSources === null || expectedSources === void 0 ? void 0 : expectedSources.length) > 0 ? this.expectedSourceStr(context, expectedSources, nativeCase) : "";
|
|
37
|
-
expect(item.innerHTML).toBe(`<time datetime="${time.toString()}">${timeStr}</time>${placeStr}, ${expected.description}${sourceStr}.`);
|
|
37
|
+
expect(item.innerHTML).toBe(`<span class="time-resolved">${time.day ? "le" : "en"} <time datetime="${time.toString()}">${timeStr}</time></span>${placeStr}, ${expected.description}${sourceStr}.`);
|
|
38
38
|
}
|
|
39
39
|
async testRender(context) {
|
|
40
40
|
const sourceCases = await this.mapping.datasource.fetch(context);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { RR0CaseSummary } from "./RR0CaseSummary.js";
|
|
2
2
|
import { AbstractDatasource } from "../AbstractDatasource.js";
|
|
3
3
|
import { TimeContextFilter } from "../TimeContextFilter.js";
|
|
4
|
+
import { Level2Date as EdtfDate } from "@rr0/time";
|
|
5
|
+
import { Place } from "@rr0/place";
|
|
4
6
|
export declare class RR0ContextFilter extends TimeContextFilter<RR0CaseSummary> {
|
|
5
7
|
}
|
|
6
8
|
export declare abstract class RR0Datasource extends AbstractDatasource<RR0CaseSummary> {
|
|
7
9
|
static readonly placeRegex: RegExp;
|
|
8
10
|
protected constructor();
|
|
11
|
+
static id(dateTime: EdtfDate, place: Place | undefined): string;
|
|
9
12
|
}
|
|
@@ -6,5 +6,9 @@ export class RR0Datasource extends AbstractDatasource {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super(["Beau, Jérôme"], "RR0");
|
|
8
8
|
}
|
|
9
|
+
static id(dateTime, place) {
|
|
10
|
+
const placeStr = place ? "$" + `${place.id || place.name}` : "";
|
|
11
|
+
return `${dateTime.toString()}${placeStr}`;
|
|
12
|
+
}
|
|
9
13
|
}
|
|
10
14
|
RR0Datasource.placeRegex = /^(.+?)(?:\s*\((.+?)(?:\s*,\s*(.+?)(?:\s*,\s*(.+?)))?\))?$/g;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { beforeEach, describe, test } from "@javarome/testscript";
|
|
1
|
+
import { beforeEach, describe, expect, test } from "@javarome/testscript";
|
|
2
2
|
import { rr0TestUtil } from "../../../test/index.js";
|
|
3
3
|
import { rr0TestCases } from "./RR0TestCases.js";
|
|
4
4
|
import { DatasourceTestCase } from "../DatasourceTestCase.js";
|
|
5
|
+
import { Level2Date as EdtfDate } from "@rr0/time";
|
|
5
6
|
import { HtmlTag } from "../../../util/html/HtmlTag.js";
|
|
6
7
|
import { RR0Datasource } from "./RR0Datasource.js";
|
|
7
8
|
import { TimeTextBuilder } from "../../text/TimeTextBuilder.js";
|
|
8
9
|
import { RR0CaseSummaryMapper } from "./RR0CaseSummaryMapper";
|
|
9
10
|
import { RR0FileDatasource } from "./RR0FileDatasource";
|
|
11
|
+
import { NamedPlace } from "@rr0/place";
|
|
10
12
|
export class RR0TestDatasource extends RR0Datasource {
|
|
11
13
|
constructor() {
|
|
12
14
|
super();
|
|
@@ -70,7 +72,7 @@ describe("RR0CaseSource", () => {
|
|
|
70
72
|
return " " + HtmlTag.toString("span", authorStr + sourceItems.join(", "), { class: "source" });
|
|
71
73
|
}).join("");
|
|
72
74
|
}
|
|
73
|
-
}(new RR0TestMapping({ read: ["fetch"], write: [] }), rr0TestCases);
|
|
75
|
+
}(new RR0TestMapping({ read: ["fetch"], write: [] }).init(rr0TestUtil), rr0TestCases);
|
|
74
76
|
let context;
|
|
75
77
|
beforeEach(() => {
|
|
76
78
|
context = rr0TestUtil.time.newHtmlContext("1/9/7/0/03/index.html");
|
|
@@ -83,4 +85,8 @@ describe("RR0CaseSource", () => {
|
|
|
83
85
|
test("render", async () => {
|
|
84
86
|
await testCase.testRender(context);
|
|
85
87
|
});
|
|
88
|
+
test("id", async () => {
|
|
89
|
+
const id = RR0Datasource.id(EdtfDate.fromString("1972-08-12"), new NamedPlace("Chatillon"));
|
|
90
|
+
expect(id).toBe("1972-08-12$Chatillon");
|
|
91
|
+
});
|
|
86
92
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { HtmlRR0Context } from "../../../RR0Context.js";
|
|
2
2
|
import { HttpSource } from "../HttpSource.js";
|
|
3
3
|
import { RR0Datasource } from "./RR0Datasource.js";
|
|
4
|
-
import { Level2Date as EdtfDate } from "@rr0/time";
|
|
5
4
|
import { RR0CaseSummary } from "./RR0CaseSummary.js";
|
|
6
5
|
import { CityService } from "../../../org/index.js";
|
|
7
6
|
import { Source } from "@rr0/data/dist/source";
|
|
@@ -12,7 +11,6 @@ export declare class RR0HttpDatasource extends RR0Datasource {
|
|
|
12
11
|
protected cityService: CityService;
|
|
13
12
|
http: HttpSource;
|
|
14
13
|
constructor(baseUrl: URL, searchPath: string, cityService: CityService);
|
|
15
|
-
static id(dateTime: EdtfDate, place: Place | undefined): string;
|
|
16
14
|
getFromRows(context: HtmlRR0Context, rows: Element[]): RR0CaseSummary[];
|
|
17
15
|
findRows(doc: HTMLElement): Element[];
|
|
18
16
|
getFromRow(context: HtmlRR0Context, r: Element): RR0CaseSummary;
|
|
@@ -12,9 +12,6 @@ export class RR0HttpDatasource extends RR0Datasource {
|
|
|
12
12
|
this.cityService = cityService;
|
|
13
13
|
this.http = new HttpSource();
|
|
14
14
|
}
|
|
15
|
-
static id(dateTime, place) {
|
|
16
|
-
return `${dateTime.toString()}-${place.id || place.name}`;
|
|
17
|
-
}
|
|
18
15
|
getFromRows(context, rows) {
|
|
19
16
|
const cases = [];
|
|
20
17
|
for (const row of rows) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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.5",
|
|
6
6
|
"description": "RR0 Content Management System (CMS)",
|
|
7
7
|
"exports": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"build": "rm -Rf dist && tsc --project tsconfig.prod.json",
|
|
25
25
|
"prepublishOnly": "npm run build",
|
|
26
26
|
"test": "testscript",
|
|
27
|
-
"test-one": "rm -Rf out && tsx src/
|
|
27
|
+
"test-one": "rm -Rf out && tsx src/time/datasource/rr0/RR0Datasource.test.ts",
|
|
28
28
|
"test-ci": "rm -Rf out && testscript"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|