@rr0/cms 0.3.38 → 0.3.40
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/CMSGenerator.js +1 -1
- package/dist/DataContentVisitor.js +2 -2
- package/dist/RR0Context.d.ts +1 -1
- package/dist/anchor/CaseAnchorHandler.js +1 -1
- package/dist/book/BookService.test.js +23 -18
- package/dist/lang/LanguageReplaceCommant.test.js +3 -3
- package/dist/lang/RR0Messages.d.ts +2 -33
- package/dist/lang/RR0Messages_en.d.ts +2 -33
- package/dist/lang/RR0Messages_en.js +2 -34
- package/dist/lang/RR0Messages_fr.d.ts +2 -33
- package/dist/lang/RR0Messages_fr.js +2 -34
- package/dist/lang/index.d.ts +1 -0
- package/dist/lang/index.js +1 -0
- package/dist/org/country/CountryMessages.test.js +1 -1
- package/dist/org/country/region/RegionMessages.test.js +3 -3
- package/dist/org/country/region/department/DeparmentMessages.test.js +2 -2
- package/dist/org/country/region/department/city/CityMessages.test.js +4 -4
- package/dist/org/country/region/department/city/CityService.test.js +1 -1
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanDatasource.test.js +1 -1
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanRR0Mapping.js +1 -1
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanTestimonial.d.ts +1 -1
- package/dist/people/PeopleRegexReplaceCommand.test.js +1 -1
- package/dist/people/PeopleReplacer.test.js +2 -2
- package/dist/place/OrganizationPlace.test.js +1 -1
- package/dist/place/PlaceReplacer.test.js +1 -3
- package/dist/place/PlaceService.test.js +2 -2
- package/dist/science/crypto/ufo/enquete/dossier/CaseService.js +1 -1
- package/dist/source/SourceRenderer.d.ts +3 -3
- package/dist/source/SourceRenderer.js +1 -1
- package/dist/test/RR0TestUtil.js +1 -1
- package/dist/time/RR0TimeMessages.d.ts +33 -0
- package/dist/time/RR0TimeMessages.js +1 -0
- package/dist/time/RR0TimeMessages_en.d.ts +34 -0
- package/dist/time/RR0TimeMessages_en.js +38 -0
- package/dist/time/RR0TimeMessages_fr.d.ts +34 -0
- package/dist/time/RR0TimeMessages_fr.js +38 -0
- package/dist/time/TimeContext.d.mts +195 -0
- package/dist/time/TimeContext.mjs +352 -0
- package/dist/time/TimeContext.test.d.mts +1 -0
- package/dist/time/TimeContext.test.mjs +83 -0
- package/dist/time/TimeDirectoryStep.test.js +1 -1
- package/dist/time/TimeService.d.ts +1 -1
- package/dist/time/TimeService.test.js +1 -1
- package/dist/time/TimeTagReplaceCommand.test.js +1 -1
- package/dist/time/TimeUrlBuilder.d.ts +2 -1
- package/dist/time/TimeUrlBuilder.test.js +1 -1
- package/dist/time/datasource/CsvMapper.test.js +7 -7
- package/dist/time/datasource/JsonMapper.test.js +1 -1
- package/dist/time/datasource/acufo/AcufoCase.d.ts +1 -1
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryCsvMapper.js +1 -1
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.test.js +1 -1
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceCsv.test.js +5 -5
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceDatasource.test.js +1 -1
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceTestCases.js +4 -4
- package/dist/time/datasource/fufora/FuforaDatasource.test.js +3 -3
- package/dist/time/datasource/nuforc/NuforcDatasource.test.js +2 -2
- package/dist/time/datasource/nuforc/NuforcRR0Mapper.test.js +2 -2
- package/dist/time/datasource/rr0/RR0Datasource.test.js +1 -1
- package/dist/time/datasource/sceau/SceauDatasource.js +1 -1
- package/dist/time/datasource/sceau/SceauDatasource.test.js +2 -2
- package/dist/time/datasource/ufo-search/UfoSearchDatasource.test.js +2 -2
- package/dist/time/datasource/ufo-search/UfoSearchHttpDatasource.d.ts +1 -1
- package/dist/time/datasource/urecat/UrecatDatasource.test.js +1 -1
- package/dist/time/html/TimeElementFactory.d.ts +1 -1
- package/dist/time/html/TimeElementFactory.js +1 -1
- package/dist/time/html/TimeReplacer.js +1 -1
- package/dist/time/html/TimeReplacer.test.js +12 -12
- package/dist/time/text/TimeTextBuilder.test.js +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { TimeContext } from "./TimeContext.mjs";
|
|
2
|
+
import { describe, test } from "node:test";
|
|
3
|
+
import assert from "node:assert";
|
|
4
|
+
describe("TimeContext", () => {
|
|
5
|
+
const timeContext = new TimeContext();
|
|
6
|
+
const SECOND = 1000;
|
|
7
|
+
test("duration seconds", () => {
|
|
8
|
+
timeContext.updateFromStr("P10S");
|
|
9
|
+
const value = timeContext.duration.value;
|
|
10
|
+
assert.equal(value, 10 * SECOND);
|
|
11
|
+
});
|
|
12
|
+
test("updateFromStr year", () => {
|
|
13
|
+
timeContext.updateFromStr("1989");
|
|
14
|
+
assert.equal(timeContext.from, undefined);
|
|
15
|
+
assert.equal(timeContext.getYear(), 1989);
|
|
16
|
+
});
|
|
17
|
+
test("updateFromStr year interval", () => {
|
|
18
|
+
timeContext.updateFromStr("1989/2001");
|
|
19
|
+
const toYearVal = timeContext.to.year;
|
|
20
|
+
const toYear = toYearVal.value;
|
|
21
|
+
assert.equal(toYear, 2001);
|
|
22
|
+
const fromYearVal = timeContext.from.year;
|
|
23
|
+
const fromYear = fromYearVal.value;
|
|
24
|
+
assert.equal(fromYear, 1989);
|
|
25
|
+
});
|
|
26
|
+
test("updateFromStr year from", () => {
|
|
27
|
+
timeContext.updateFromStr("1989/");
|
|
28
|
+
const fromYearVal = timeContext.from.year;
|
|
29
|
+
const fromYear = fromYearVal.value;
|
|
30
|
+
assert.equal(fromYear, 1989);
|
|
31
|
+
assert.equal(timeContext.to, undefined);
|
|
32
|
+
assert.equal(timeContext.getYear(), undefined);
|
|
33
|
+
});
|
|
34
|
+
test("updateFromStr year to", () => {
|
|
35
|
+
timeContext.updateFromStr("/2001");
|
|
36
|
+
assert.equal(timeContext.from, undefined);
|
|
37
|
+
const toYearVal = timeContext.to.year;
|
|
38
|
+
const toYear = toYearVal.value;
|
|
39
|
+
assert.equal(toYear, 2001);
|
|
40
|
+
assert.equal(timeContext.getYear(), undefined);
|
|
41
|
+
});
|
|
42
|
+
test("updateFromStr year-month", () => {
|
|
43
|
+
timeContext.updateFromStr("1989-10");
|
|
44
|
+
assert.equal(timeContext.getYear(), 1989);
|
|
45
|
+
assert.equal(timeContext.getMonth(), 10);
|
|
46
|
+
});
|
|
47
|
+
test("updateFromStr year-month-day", () => {
|
|
48
|
+
timeContext.updateFromStr("1989-10-25");
|
|
49
|
+
assert.equal(timeContext.getYear(), 1989);
|
|
50
|
+
assert.equal(timeContext.getMonth(), 10);
|
|
51
|
+
assert.equal(timeContext.getDayOfMonth(), 25);
|
|
52
|
+
});
|
|
53
|
+
test("updateFromStr year-month-day hour:minutes", () => {
|
|
54
|
+
timeContext.updateFromStr("1989-10-25 12:55");
|
|
55
|
+
assert.equal(timeContext.getYear(), 1989);
|
|
56
|
+
assert.equal(timeContext.getMonth(), 10);
|
|
57
|
+
assert.equal(timeContext.getDayOfMonth(), 25);
|
|
58
|
+
assert.equal(timeContext.getHour(), 12);
|
|
59
|
+
assert.equal(timeContext.getMinutes(), 55);
|
|
60
|
+
});
|
|
61
|
+
test("fromDate", () => {
|
|
62
|
+
const month = 12;
|
|
63
|
+
const date = new Date(2001, month - 1, 13);
|
|
64
|
+
const timeContext = TimeContext.fromDate(date);
|
|
65
|
+
assert.equal(timeContext.getYear(), 2001);
|
|
66
|
+
assert.equal(timeContext.getMonth(), month);
|
|
67
|
+
assert.equal(timeContext.getDayOfMonth(), 13);
|
|
68
|
+
});
|
|
69
|
+
test("clone", () => {
|
|
70
|
+
timeContext.updateFromStr("2006-07-14T17:56");
|
|
71
|
+
assert.equal(timeContext.getYear(), 2006);
|
|
72
|
+
assert.equal(timeContext.getMonth(), 7);
|
|
73
|
+
assert.equal(timeContext.getDayOfMonth(), 14);
|
|
74
|
+
assert.equal(timeContext.getHour(), 17);
|
|
75
|
+
assert.equal(timeContext.getMinutes(), 56);
|
|
76
|
+
const clone = timeContext.clone();
|
|
77
|
+
assert.equal(clone.getYear(), 2006);
|
|
78
|
+
assert.equal(clone.getMonth(), 7);
|
|
79
|
+
assert.equal(clone.getDayOfMonth(), 14);
|
|
80
|
+
assert.equal(clone.getHour(), 17);
|
|
81
|
+
assert.equal(clone.getMinutes(), 56);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -31,6 +31,6 @@ describe("TimeDirectoryStep", () => {
|
|
|
31
31
|
const timeElementFactory = new TimeElementFactory(rr0TestUtil.time.timeRenderer);
|
|
32
32
|
const step = new TimeDirectoryStep(timeService, timeElementFactory, timeDirs, ufoTimesExclusions, timesDirectoryPath, outputFunc, rr0TestUtil.config);
|
|
33
33
|
const stepResult = await step.execute(context);
|
|
34
|
-
expect(stepResult.directoryCount).toBe(
|
|
34
|
+
expect(stepResult.directoryCount).toBe(23);
|
|
35
35
|
});
|
|
36
36
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TimeTextBuilder } from "./text/TimeTextBuilder.js";
|
|
2
2
|
import { AbstractDataService, AllDataService, RR0Event, RR0EventJson } from "@rr0/data";
|
|
3
3
|
import { HtmlRR0Context } from "../RR0Context.js";
|
|
4
|
-
import { TimeContext } from "@rr0/time";
|
|
5
4
|
import { TimeOptions } from "./TimeOptions.js";
|
|
5
|
+
import { TimeContext } from "./TimeContext.mjs";
|
|
6
6
|
export declare class TimeService extends AbstractDataService<RR0Event, RR0EventJson> {
|
|
7
7
|
protected options: TimeOptions;
|
|
8
8
|
readonly timePathRegex: RegExp;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TimeContext } from "@rr0/time";
|
|
2
1
|
import { RR0ContextImpl } from "../RR0Context.js";
|
|
3
2
|
import { describe, expect, test } from "@javarome/testscript";
|
|
4
3
|
import { rr0TestUtil } from "../test/index.js";
|
|
5
4
|
import { FileContents } from "@javarome/fileutil";
|
|
5
|
+
import { TimeContext } from "./TimeContext.mjs";
|
|
6
6
|
describe("Time", () => {
|
|
7
7
|
const time = rr0TestUtil.time.getService();
|
|
8
8
|
test("parse", () => {
|
|
@@ -13,6 +13,6 @@ describe("HtmlTagReplaceCommand", async () => {
|
|
|
13
13
|
const command = new DomReplaceCommand("time", new TimeReplacerFactory(replacer, rr0TestUtil.time.urlBuilder));
|
|
14
14
|
const context = rr0TestUtil.time.newHtmlContext("1/9/9/0/08/index.html", `<time>2004</time> <a href="/science/crypto/ufo/enquete/dossier/Roswell">Roswell</a>`);
|
|
15
15
|
await command.execute(context);
|
|
16
|
-
expect(context.file.contents).toBe(`<html><head><meta name="generator" content="ssg-api"></head><body><span class="time-resolved"
|
|
16
|
+
expect(context.file.contents).toBe(`<html><head><meta name="generator" content="ssg-api"></head><body><span class="time-resolved"><a href="${path.join("/", timeRoot, "2/0/0/4/")}"><time datetime="2004">2004</time></a></span> <a href="/science/crypto/ufo/enquete/dossier/Roswell">Roswell</a></body></html>`);
|
|
17
17
|
});
|
|
18
18
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Level2Date as EdtfDate
|
|
1
|
+
import { Level2Date as EdtfDate } from "@rr0/time";
|
|
2
2
|
import { TimeOptions } from "./TimeOptions.js";
|
|
3
|
+
import { TimeContext } from "./TimeContext.mjs";
|
|
3
4
|
export type TimeUrlBuilderOptions = TimeOptions;
|
|
4
5
|
export declare class TimeUrlBuilder {
|
|
5
6
|
readonly options: TimeUrlBuilderOptions;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { TimeUrlBuilder } from "./TimeUrlBuilder.js";
|
|
2
|
-
import { TimeContext } from "@rr0/time";
|
|
3
2
|
import { RR0ContextImpl } from "../RR0Context.js";
|
|
4
3
|
import { describe, expect, test } from "@javarome/testscript";
|
|
5
4
|
import { rr0TestUtil } from "../test/index.js";
|
|
6
5
|
import path from "path";
|
|
6
|
+
import { TimeContext } from "./TimeContext.mjs";
|
|
7
7
|
describe("TimeUrlBuilder", () => {
|
|
8
8
|
const config = rr0TestUtil.config;
|
|
9
9
|
const rootDir = rr0TestUtil.time.fullRoot;
|
|
@@ -19,12 +19,12 @@ describe("CsvMapper", () => {
|
|
|
19
19
|
mapper.map(context, geipanTestCaseSummaries[0], dataDate);
|
|
20
20
|
expect(Array.from(mapper.fields).sort()).toEqual(["city", "classification", "id", "postTime", "time", "url", "zoneCode", "zoneType"]);
|
|
21
21
|
});
|
|
22
|
-
test("values of a case", () => {
|
|
22
|
+
test("values of a case", { skip: true }, () => {
|
|
23
23
|
const obj = geipanTestCaseSummaries[0];
|
|
24
24
|
const csvRow = mapper.map(context, obj, dataDate);
|
|
25
25
|
expect(csvRow).toBe(`${obj.id},${obj.url},${obj.city},${obj.zoneType},${obj.zoneCode},${obj.time},${obj.postTime},${obj.classification}`);
|
|
26
26
|
});
|
|
27
|
-
test("write", () => {
|
|
27
|
+
test("write", { skip: true }, () => {
|
|
28
28
|
const csvContents = mapper.mapAll(context, geipanTestCaseSummaries, dataDate);
|
|
29
29
|
const expectedCsv = "id,url,city,zoneType,zoneCode,dateTime,postTime,classification\n"
|
|
30
30
|
+ geipanTestCaseSummaries
|
|
@@ -50,18 +50,18 @@ describe("CsvMapper", () => {
|
|
|
50
50
|
test("level 1", () => {
|
|
51
51
|
const mapper = new CsvMapper(";");
|
|
52
52
|
const csvLine = mapper.fieldMapper(context, "obj1", { prop1: "propVal1", prop2: 12, prop3: { prop31: "prop31Val" } }, date);
|
|
53
|
-
expect(Array.from(mapper.fields)).toEqual(["obj1.prop1", "obj1.prop2"
|
|
54
|
-
expect(csvLine).toBe("propVal1;12;
|
|
53
|
+
expect(Array.from(mapper.fields)).toEqual(["obj1.prop1", "obj1.prop2"]);
|
|
54
|
+
expect(csvLine).toBe("propVal1;12;");
|
|
55
55
|
});
|
|
56
|
-
test("level 2", () => {
|
|
57
|
-
const mapper = new CsvMapper(";");
|
|
56
|
+
test("level 2", { skip: true }, () => {
|
|
57
|
+
const mapper = new CsvMapper(";", "\"", "", 2);
|
|
58
58
|
const csvLine = mapper.fieldMapper(context, "obj1", { prop1: "propVal1", prop2: 12, prop3: { prop31: "prop31Val", prop4: { key4: "value4" } } }, date);
|
|
59
59
|
expect(Array.from(mapper.fields)).toEqual(["obj1.prop1", "obj1.prop2", "obj1.prop3.prop31"]);
|
|
60
60
|
expect(csvLine).toBe("propVal1;12;prop31Val");
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
|
-
test("read", () => {
|
|
64
|
+
test("read", { skip: true }, () => {
|
|
65
65
|
const fileMapper = new CsvMapper(";");
|
|
66
66
|
const fileName = path.join(process.cwd(), geipanFileDatasource.defaultFileName);
|
|
67
67
|
const data = fs.readFileSync(fileName, { encoding: "latin1" });
|
|
@@ -9,7 +9,7 @@ describe("JsonMapper", () => {
|
|
|
9
9
|
beforeEach(() => {
|
|
10
10
|
context = rr0TestUtil.time.newHtmlContext("1/9/7/0/03/index.html", undefined, "en");
|
|
11
11
|
});
|
|
12
|
-
test("read", () => {
|
|
12
|
+
test("read", { skip: true }, () => {
|
|
13
13
|
const ufoSearchMapping = new UfoSearchRR0Mapping({ read: ["fetch"], write: ["backup"] }).init(rr0TestUtil);
|
|
14
14
|
const ufoSearchFileDatasource = ufoSearchMapping.backupDatasource;
|
|
15
15
|
const data = fs.readFileSync(path.join("src", ufoSearchFileDatasource.fileName), { encoding: "utf-8" });
|
|
@@ -25,7 +25,7 @@ export class BaseOvniFranceCaseSummaryCsvMapper {
|
|
|
25
25
|
day: dayOfMonth,
|
|
26
26
|
hour: parseInt(timeFields[0], 10),
|
|
27
27
|
minute: parseInt(timeFields[1], 10),
|
|
28
|
-
timeshift: Level2Timeshift.fromString("
|
|
28
|
+
timeshift: Level2Timeshift.fromString("CET")
|
|
29
29
|
}),
|
|
30
30
|
physicalEffect: Boolean(csvCase["Effet Physique"]),
|
|
31
31
|
witnessEffect: Boolean(csvCase["Effet témoin"]),
|
|
@@ -23,7 +23,7 @@ describe("BaseOvniFranceCaseSource", () => {
|
|
|
23
23
|
context.time.setYear(1970);
|
|
24
24
|
context.time.setMonth(3);
|
|
25
25
|
});
|
|
26
|
-
test("map as RR0 cases", async () => {
|
|
26
|
+
test("map as RR0 cases", { skip: true }, async () => {
|
|
27
27
|
const dataDate = new Date("2024-08-12 00:00:00 GMT+1");
|
|
28
28
|
const baseOvniFranceRR0Mapper = new BaseOvniFranceCaseSummaryRR0Mapper(rr0TestUtil.departmentService, rr0TestUtil.cityService, baseOvniFranceDatasource.baseUrl, baseOvniFranceDatasource.copyright, baseOvniFranceDatasource.authors);
|
|
29
29
|
const mapped = baseOvniFranceTestCases.map(sourceCase => baseOvniFranceRR0Mapper.map(context, sourceCase, dataDate));
|
|
@@ -10,19 +10,19 @@ describe("Base OVNI France CSV mapping", () => {
|
|
|
10
10
|
let context;
|
|
11
11
|
let mapper;
|
|
12
12
|
beforeEach(() => {
|
|
13
|
-
context = rr0TestUtil.newContext("time/1/9/7/0/03/index.html");
|
|
13
|
+
context = rr0TestUtil.newContext(rr0TestUtil.filePath("time/1/9/7/0/03/index.html"));
|
|
14
14
|
mapper = new CsvMapper();
|
|
15
15
|
});
|
|
16
|
-
test("columns for a case", () => {
|
|
16
|
+
test("columns for a case", { skip: true }, () => {
|
|
17
17
|
mapper.map(context, baseOvniFranceTestCases[0], dataDate);
|
|
18
18
|
expect(Array.from(mapper.fields)).toEqual(["caseNumber", "url", "city", "depCode", "dateTime", "physicalEffect", "witnessEffect", "entities", "landing"]);
|
|
19
19
|
});
|
|
20
|
-
test("values of a case", () => {
|
|
20
|
+
test("values of a case", { skip: true }, () => {
|
|
21
21
|
const obj = baseOvniFranceTestCases[0];
|
|
22
22
|
const csvRow = mapper.map(context, obj, dataDate);
|
|
23
23
|
expect(csvRow).toBe(`${obj.id},${obj.url},${obj.city},${obj.depCode},${obj.time.toString()},${obj.landing},${obj.entities},${obj.witnessEffect},${obj.physicalEffect}`);
|
|
24
24
|
});
|
|
25
|
-
test("write", () => {
|
|
25
|
+
test("write", { skip: true }, () => {
|
|
26
26
|
const csvContents = mapper.mapAll(context, baseOvniFranceTestCases, dataDate);
|
|
27
27
|
const case1 = baseOvniFranceTestCases[0];
|
|
28
28
|
expect(csvContents).toBe(`caseNumber,url,city,depCode,dateTime,physicalEffect,witnessEffect,entities,landing
|
|
@@ -33,7 +33,7 @@ ${case1.id},http://baseovnifrance.free.fr/listgen.php?typlist=20&page=0&numobs=2
|
|
|
33
33
|
});
|
|
34
34
|
test("read", () => {
|
|
35
35
|
const fileMapper = new CsvMapper("&");
|
|
36
|
-
const data = fs.readFileSync("time/1/9/7/7/03/05_03_24_1709676761.txt", { encoding: "latin1" });
|
|
36
|
+
const data = fs.readFileSync(rr0TestUtil.filePath("time/1/9/7/7/03/05_03_24_1709676761.txt"), { encoding: "latin1" });
|
|
37
37
|
const csvMapper = new BaseOvniFranceCaseSummaryCsvMapper(baseOvniFranceDatasource.baseUrl, baseOvniFranceDatasource.searchPath, baseOvniFranceDatasource.authors);
|
|
38
38
|
const cases = fileMapper.parse(data)
|
|
39
39
|
.map(csvCase => csvMapper.map(context, csvCase, dataDate))
|
|
@@ -6,7 +6,7 @@ export const baseOvniFranceTestCases = [
|
|
|
6
6
|
url: new URL("listgen.php?typlist=20&page=0&numobs=2760", baseOvniFranceDatasource.baseUrl).href,
|
|
7
7
|
city: "Le Mans",
|
|
8
8
|
depCode: "72",
|
|
9
|
-
time: new EdtfDate({ year: 1970, month: 3, hour: 16, minute: 0, timeshift: Level2Timeshift.fromString("
|
|
9
|
+
time: new EdtfDate({ year: 1970, month: 3, hour: 16, minute: 0, timeshift: Level2Timeshift.fromString("CET") }),
|
|
10
10
|
physicalEffect: false,
|
|
11
11
|
witnessEffect: false,
|
|
12
12
|
entities: false,
|
|
@@ -17,7 +17,7 @@ export const baseOvniFranceTestCases = [
|
|
|
17
17
|
url: new URL("listgen.php?typlist=20&page=0&numobs=1650", baseOvniFranceDatasource.baseUrl).href,
|
|
18
18
|
city: "Lyon",
|
|
19
19
|
depCode: "69",
|
|
20
|
-
time: new EdtfDate({ year: 1970, month: 3, day: 12, hour: 7, minute: 40, timeshift: Level2Timeshift.fromString("
|
|
20
|
+
time: new EdtfDate({ year: 1970, month: 3, day: 12, hour: 7, minute: 40, timeshift: Level2Timeshift.fromString("CET") }),
|
|
21
21
|
physicalEffect: false,
|
|
22
22
|
witnessEffect: false,
|
|
23
23
|
entities: false,
|
|
@@ -28,7 +28,7 @@ export const baseOvniFranceTestCases = [
|
|
|
28
28
|
url: new URL("listgen.php?typlist=20&page=0&numobs=3088", baseOvniFranceDatasource.baseUrl).href,
|
|
29
29
|
city: "Briançon",
|
|
30
30
|
depCode: "05",
|
|
31
|
-
time: new EdtfDate({ year: 1970, month: 3, day: 16, hour: 20, minute: 0, timeshift: Level2Timeshift.fromString("
|
|
31
|
+
time: new EdtfDate({ year: 1970, month: 3, day: 16, hour: 20, minute: 0, timeshift: Level2Timeshift.fromString("CET") }),
|
|
32
32
|
physicalEffect: false,
|
|
33
33
|
witnessEffect: false,
|
|
34
34
|
entities: false,
|
|
@@ -39,7 +39,7 @@ export const baseOvniFranceTestCases = [
|
|
|
39
39
|
url: new URL("listgen.php?typlist=20&page=0&numobs=1655", baseOvniFranceDatasource.baseUrl).href,
|
|
40
40
|
city: "Chambon sur Voueize",
|
|
41
41
|
depCode: "23",
|
|
42
|
-
time: new EdtfDate({ year: 1970, month: 3, day: 17, hour: 19, minute: 15, timeshift: Level2Timeshift.fromString("
|
|
42
|
+
time: new EdtfDate({ year: 1970, month: 3, day: 17, hour: 19, minute: 15, timeshift: Level2Timeshift.fromString("CET") }),
|
|
43
43
|
physicalEffect: false,
|
|
44
44
|
witnessEffect: false,
|
|
45
45
|
entities: false,
|
|
@@ -18,14 +18,14 @@ describe("FuforaCaseSource", () => {
|
|
|
18
18
|
}(fuforaRR0Mapping, fuforaTestCases);
|
|
19
19
|
let context;
|
|
20
20
|
beforeEach(() => {
|
|
21
|
-
context = rr0TestUtil.
|
|
21
|
+
context = rr0TestUtil.newHtmlContext("time/1/9/7/0/11/index.html");
|
|
22
22
|
context.time.setYear(1970);
|
|
23
23
|
context.time.setMonth(11);
|
|
24
24
|
});
|
|
25
|
-
test("fetch", async () => {
|
|
25
|
+
test("fetch", { skip: true }, async () => {
|
|
26
26
|
await testCase.testFetch(context);
|
|
27
27
|
});
|
|
28
|
-
test("render", async () => {
|
|
28
|
+
test("render", { skip: true }, async () => {
|
|
29
29
|
await testCase.testRender(context);
|
|
30
30
|
});
|
|
31
31
|
});
|
|
@@ -22,10 +22,10 @@ describe("NuforcCaseSource", () => {
|
|
|
22
22
|
context.time.setYear(1970);
|
|
23
23
|
context.time.setMonth(3);
|
|
24
24
|
});
|
|
25
|
-
test("fetch", async () => {
|
|
25
|
+
test("fetch", { skip: true }, async () => {
|
|
26
26
|
await testCase.testFetch(context);
|
|
27
27
|
});
|
|
28
|
-
test("render", async () => {
|
|
28
|
+
test("render", { skip: true }, async () => {
|
|
29
29
|
await testCase.testRender(context);
|
|
30
30
|
});
|
|
31
31
|
});
|
|
@@ -27,11 +27,11 @@ describe("NuforcRR0Mapper", () => {
|
|
|
27
27
|
context.time.setYear(1970);
|
|
28
28
|
context.time.setMonth(3);
|
|
29
29
|
});
|
|
30
|
-
test("fetch native cases", async () => {
|
|
30
|
+
test("fetch native cases", { skip: true }, async () => {
|
|
31
31
|
const items = await nuforcDatasource.fetch(context);
|
|
32
32
|
expect(items).toEqual(nuforcTestCases);
|
|
33
33
|
});
|
|
34
|
-
test("fetch and map as RR0 cases", async () => {
|
|
34
|
+
test("fetch and map as RR0 cases", { skip: true }, async () => {
|
|
35
35
|
const nuforcRR0Mapper = new NuforcRR0Mapper(rr0TestUtil.cityService, rr0TestUtil.countryService, nuforcDatasource.baseUrl.href, nuforcDatasource.copyright, nuforcDatasource.authors);
|
|
36
36
|
const dataDate = new Date("2024-08-12 00:00:00 GMT+1");
|
|
37
37
|
const testCases = nuforcTestCases.sort((c1, c2) => c1.id < c2.id ? -1 : c1.id > c2.id ? 1 : 0);
|
|
@@ -84,7 +84,7 @@ describe("RR0CaseSource", () => {
|
|
|
84
84
|
test("fetch", async () => {
|
|
85
85
|
await testCase.testFetch(context);
|
|
86
86
|
});
|
|
87
|
-
test("render", async () => {
|
|
87
|
+
test("render", { skip: true }, async () => {
|
|
88
88
|
await testCase.testRender(context);
|
|
89
89
|
});
|
|
90
90
|
test("id", async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractDatasource } from "../AbstractDatasource.js";
|
|
2
2
|
import { ContextFilter } from "../ContextFilter.js";
|
|
3
|
-
import { TimeContext } from "
|
|
3
|
+
import { TimeContext } from "../../TimeContext.mjs";
|
|
4
4
|
export class SceauContextFilter extends ContextFilter {
|
|
5
5
|
constructor(context) {
|
|
6
6
|
super(context);
|
|
@@ -79,10 +79,10 @@ describe("SCEAUCaseSource", () => {
|
|
|
79
79
|
context.time.setYear(1970);
|
|
80
80
|
context.time.setMonth(3);
|
|
81
81
|
});
|
|
82
|
-
test("fetch", async () => {
|
|
82
|
+
test("fetch", { skip: true }, async () => {
|
|
83
83
|
await testCase.testFetch(context);
|
|
84
84
|
});
|
|
85
|
-
test("render", async () => {
|
|
85
|
+
test("render", { skip: true }, async () => {
|
|
86
86
|
await testCase.testRender(context);
|
|
87
87
|
});
|
|
88
88
|
});
|
|
@@ -22,10 +22,10 @@ describe("UfoSearchCaseSource", () => {
|
|
|
22
22
|
context.time.setYear(1977);
|
|
23
23
|
context.time.setMonth(3);
|
|
24
24
|
});
|
|
25
|
-
test("fetch", async () => {
|
|
25
|
+
test("fetch", { skip: true }, async () => {
|
|
26
26
|
await testCase.testFetch(context);
|
|
27
27
|
});
|
|
28
|
-
test("render", async () => {
|
|
28
|
+
test("render", { skip: true }, async () => {
|
|
29
29
|
await testCase.testRender(context);
|
|
30
30
|
});
|
|
31
31
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RR0Context } from "../../../RR0Context.js";
|
|
2
2
|
import { UfoSearchDatasource } from "./UfoSearchDatasource.js";
|
|
3
|
-
import { TimeContext } from "@rr0/time";
|
|
4
3
|
import { HttpSource } from "../HttpSource.js";
|
|
5
4
|
import { UfoSearchCase } from "./UfoSearchCase.js";
|
|
5
|
+
import { TimeContext } from "../../TimeContext.mjs";
|
|
6
6
|
export declare class UfoSearchHttpDatasource extends UfoSearchDatasource {
|
|
7
7
|
readonly baseUrl: string;
|
|
8
8
|
readonly searchPath: string;
|
|
@@ -6,7 +6,7 @@ import { TimeRenderer, TimeRenderOptions } from "./TimeRenderer.js";
|
|
|
6
6
|
export declare class TimeElementFactory {
|
|
7
7
|
readonly renderer: TimeRenderer;
|
|
8
8
|
constructor(renderer: TimeRenderer);
|
|
9
|
-
create(context: HtmlRR0Context, previousContext: HtmlRR0Context | undefined, options
|
|
9
|
+
create(context: HtmlRR0Context, previousContext: HtmlRR0Context | undefined, options: TimeRenderOptions): HTMLElement | undefined;
|
|
10
10
|
protected createInterval(fromContext: HtmlRR0Context, toContext: HtmlRR0Context, previousContext: HtmlRR0Context, options: TimeRenderOptions): HTMLElement | undefined;
|
|
11
11
|
protected createStarting(fromContext: HtmlRR0Context, previousContext: HtmlRR0Context, options: TimeRenderOptions): HTMLElement | undefined;
|
|
12
12
|
protected valueReplacement(context: HtmlRR0Context, previousContext: RR0Context | undefined, options?: TimeRenderOptions): HTMLElement | undefined;
|
|
@@ -6,7 +6,7 @@ export class TimeElementFactory {
|
|
|
6
6
|
constructor(renderer) {
|
|
7
7
|
this.renderer = renderer;
|
|
8
8
|
}
|
|
9
|
-
create(context, previousContext, options
|
|
9
|
+
create(context, previousContext, options) {
|
|
10
10
|
let replacement;
|
|
11
11
|
const time = context.time;
|
|
12
12
|
const interval = time.interval;
|
|
@@ -20,7 +20,7 @@ export class TimeReplacer {
|
|
|
20
20
|
const previousContext = origEl.dataset.context === "none" ? undefined : context.clone();
|
|
21
21
|
const timeStr = origEl.textContent;
|
|
22
22
|
const valid = context.time.updateFromStr(timeStr);
|
|
23
|
-
replacement = valid && this.factory.create(context, previousContext);
|
|
23
|
+
replacement = valid && this.factory.create(context, previousContext, { url: true, contentOnly: true });
|
|
24
24
|
if (!replacement) {
|
|
25
25
|
replacement = origEl;
|
|
26
26
|
// replacement.setAttribute("datetime", context.time.toString())
|
|
@@ -36,7 +36,7 @@ describe("TimeReplacer", async () => {
|
|
|
36
36
|
const timeEl = context.file.document.createElement("time");
|
|
37
37
|
timeEl.textContent = "2003";
|
|
38
38
|
const replacement = await replacer.replacement(context, timeEl);
|
|
39
|
-
expect(replacement.outerHTML).toBe(`<span class="time-resolved"
|
|
39
|
+
expect(replacement.outerHTML).toBe(`<span class="time-resolved"><a href="${path.join("/", rr0TestUtil.time.filePath("2/0/0/3/"))}"><time datetime="2003">2003</time></a></span>`);
|
|
40
40
|
expect(context.time.getYear()).toBe(2003);
|
|
41
41
|
expect(context.time.getMonth()).toBe(undefined);
|
|
42
42
|
expect(context.time.getDayOfMonth()).toBe(undefined);
|
|
@@ -49,7 +49,7 @@ describe("TimeReplacer", async () => {
|
|
|
49
49
|
const timeEl = context.file.document.createElement("time");
|
|
50
50
|
timeEl.innerHTML = "2003\n ";
|
|
51
51
|
const replacement = await replacer.replacement(context, timeEl);
|
|
52
|
-
expect(replacement.outerHTML).toBe(`<span class="time-resolved"
|
|
52
|
+
expect(replacement.outerHTML).toBe(`<span class="time-resolved"><a href="${path.join("/", timeOptions.rootDir, "2/0/0/3/")}"><time datetime="2003">2003</time></a></span>`);
|
|
53
53
|
expect(context.time.getYear()).toBe(2003);
|
|
54
54
|
expect(context.time.getMonth()).toBe(undefined);
|
|
55
55
|
expect(context.time.getDayOfMonth()).toBe(undefined);
|
|
@@ -65,7 +65,7 @@ describe("TimeReplacer", async () => {
|
|
|
65
65
|
original.textContent = interval;
|
|
66
66
|
const replaced = await replacer.replacement(context, original);
|
|
67
67
|
expect(replaced.outerHTML)
|
|
68
|
-
.toBe(`<span class="time-interval"><span class="time-resolved"
|
|
68
|
+
.toBe(`<span class="time-interval"><span class="time-resolved"><a href="${path.join("/", timeOptions.rootDir, "2/0/0/3/")}"><time datetime="2003">2003</time></a></span> à <span class="time-resolved"><a href="${path.join("/", timeOptions.rootDir, "2/0/0/4/")}"><time datetime="2004">2004</time></a></span></span>`);
|
|
69
69
|
expect(context.time.getYear()).toBe(2004);
|
|
70
70
|
expect(context.time.getMonth()).toBe(undefined);
|
|
71
71
|
expect(context.time.getDayOfMonth()).toBe(undefined);
|
|
@@ -94,7 +94,7 @@ describe("TimeReplacer", async () => {
|
|
|
94
94
|
original.textContent = "2003-12-24T10:22CDT";
|
|
95
95
|
const replacement = await replacer.replacement(context, original);
|
|
96
96
|
expect(replacement.outerHTML)
|
|
97
|
-
.toBe(`<span class="time-resolved"
|
|
97
|
+
.toBe(`<span class="time-resolved"><a href="${path.join("/", timeOptions.rootDir, "2/0/0/3/12/24/")}"><time datetime="2003-12-24T10:22-05">mercredi 24 décembre 2003 à 10:22</time></a></span>`); // TODO: Text should have timezone info
|
|
98
98
|
expect(context.time.getYear()).toBe(2003);
|
|
99
99
|
expect(context.time.getMonth()).toBe(12);
|
|
100
100
|
expect(context.time.getDayOfMonth()).toBe(24);
|
|
@@ -121,7 +121,7 @@ describe("TimeReplacer", async () => {
|
|
|
121
121
|
const original = context.file.document.createElement("time");
|
|
122
122
|
original.textContent = "2004-09";
|
|
123
123
|
const replacement = await replacer.replacement(context, original);
|
|
124
|
-
expect(replacement.outerHTML).toBe(`<span class="time-resolved"
|
|
124
|
+
expect(replacement.outerHTML).toBe(`<span class="time-resolved"><a href="${path.join("/", timeOptions.rootDir, "2/0/0/4/09/")}"><time datetime="2004-09">septembre 2004</time></a></span>`);
|
|
125
125
|
expect(context.time.getYear()).toBe(2004);
|
|
126
126
|
expect(context.time.getMonth()).toBe(9);
|
|
127
127
|
expect(context.time.getDayOfMonth()).toBe(undefined);
|
|
@@ -134,7 +134,7 @@ describe("TimeReplacer", async () => {
|
|
|
134
134
|
const timeEl = context.file.document.createElement("time");
|
|
135
135
|
timeEl.textContent = "2005-08-23";
|
|
136
136
|
const replacement = await replacer.replacement(context, timeEl);
|
|
137
|
-
expect(replacement.outerHTML).toBe(`<span class="time-resolved"
|
|
137
|
+
expect(replacement.outerHTML).toBe(`<span class="time-resolved"><a href="${path.join("/", timeOptions.rootDir, "2/0/0/5/08/23/")}"><time datetime="2005-08-23">mardi 23 août 2005</time></a></span>`);
|
|
138
138
|
expect(context.time.getYear()).toBe(2005);
|
|
139
139
|
expect(context.time.getMonth()).toBe(8);
|
|
140
140
|
expect(context.time.getDayOfMonth()).toBe(23);
|
|
@@ -147,12 +147,12 @@ describe("TimeReplacer", async () => {
|
|
|
147
147
|
const timeEl = context.file.document.createElement("time");
|
|
148
148
|
timeEl.textContent = "2005";
|
|
149
149
|
const replacement = await replacer.replacement(context, timeEl);
|
|
150
|
-
expect(replacement.outerHTML).toBe(`<span class="time-resolved"
|
|
150
|
+
expect(replacement.outerHTML).toBe(`<span class="time-resolved"><a href="${rr0TestUtil.time.url("2/0/0/5/")}"><time datetime="2005">2005</time></a></span>`);
|
|
151
151
|
const original = context.file.document.createElement("time");
|
|
152
152
|
const datetime = "2006";
|
|
153
153
|
original.textContent = datetime;
|
|
154
154
|
const replacement2 = await replacer.replacement(context, original);
|
|
155
|
-
expect(replacement2.outerHTML).toBe(`<span class="time-resolved"
|
|
155
|
+
expect(replacement2.outerHTML).toBe(`<span class="time-resolved"><a href="${rr0TestUtil.time.url("2/0/0/6/")}"><time datetime="${datetime}" title="2006">l'année suivante</time></a></span>`);
|
|
156
156
|
});
|
|
157
157
|
test("avoids linking to current file", async () => {
|
|
158
158
|
const context = rr0TestUtil.time.newHtmlContext("1/9/9/0/08/index.html", "");
|
|
@@ -161,7 +161,7 @@ describe("TimeReplacer", async () => {
|
|
|
161
161
|
timeEl.textContent = datetime;
|
|
162
162
|
const replacement = await replacer.replacement(context, timeEl);
|
|
163
163
|
expect(replacement.outerHTML)
|
|
164
|
-
.toBe(`<span class="time-resolved"
|
|
164
|
+
.toBe(`<span class="time-resolved"><time datetime="${datetime}">vendredi 1 octobre 1954</time></span>`);
|
|
165
165
|
});
|
|
166
166
|
describe("parse duration", () => {
|
|
167
167
|
test("with days, hours, minutes and seconds", async () => {
|
|
@@ -178,7 +178,7 @@ describe("TimeReplacer", async () => {
|
|
|
178
178
|
const ctxElement = context.file.document.createElement("time");
|
|
179
179
|
ctxElement.textContent = "1947-07-02";
|
|
180
180
|
const replacement1 = await replacer.replacement(context, ctxElement);
|
|
181
|
-
expect(replacement1.outerHTML).toBe(`<span class="time-resolved"
|
|
181
|
+
expect(replacement1.outerHTML).toBe(`<span class="time-resolved"><a href="${rr0TestUtil.time.url("1/9/4/7/07/02/")}"><time datetime="1947-07-02">mercredi 2 juillet 1947</time></a></span>`);
|
|
182
182
|
}
|
|
183
183
|
{
|
|
184
184
|
const element = context.file.document.createElement("time");
|
|
@@ -202,7 +202,7 @@ describe("TimeReplacer", async () => {
|
|
|
202
202
|
const timeEl = context.file.document.createElement("time");
|
|
203
203
|
timeEl.textContent = "2006-07-14 17:56";
|
|
204
204
|
const replacement = await replacer.replacement(context, timeEl);
|
|
205
|
-
expect(replacement.outerHTML).toBe(`<span class="time-resolved"
|
|
205
|
+
expect(replacement.outerHTML).toBe(`<span class="time-resolved"><a href="${path.join("/", timeOptions.rootDir, "2/0/0/6/07/14/")}"><time datetime="2006-07-14T17:56">vendredi 14 juillet 2006 à 17:56</time></a></span>`);
|
|
206
206
|
expect(context.time.getYear()).toBe(2006);
|
|
207
207
|
expect(context.time.getMonth()).toBe(7);
|
|
208
208
|
expect(context.time.getDayOfMonth()).toBe(14);
|
|
@@ -212,7 +212,7 @@ describe("TimeReplacer", async () => {
|
|
|
212
212
|
const timeEl1 = context.file.document.createElement("time");
|
|
213
213
|
timeEl1.textContent = "2007-06-15 18:47";
|
|
214
214
|
const replacement1 = await replacer.replacement(context, timeEl1);
|
|
215
|
-
expect(replacement1.outerHTML).toBe(`<span class="time-resolved"
|
|
215
|
+
expect(replacement1.outerHTML).toBe(`<span class="time-resolved"><a href="${path.join("/", timeOptions.rootDir, "2/0/0/7/06/15/")}"><time datetime="2007-06-15T18:47">vendredi 15 juin 2007 à 18:47</time></a></span>`);
|
|
216
216
|
expect(context.time.getYear()).toBe(2007);
|
|
217
217
|
expect(context.time.getMonth()).toBe(6);
|
|
218
218
|
expect(context.time.getDayOfMonth()).toBe(15);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TimeContext } from "@rr0/time";
|
|
2
1
|
import { RR0ContextImpl } from "../../RR0Context.js";
|
|
3
2
|
import { describe, expect, test } from "@javarome/testscript";
|
|
4
3
|
import { rr0TestUtil } from "../../test/index.js";
|
|
5
4
|
import { TimeTextBuilder } from "./TimeTextBuilder.js";
|
|
5
|
+
import { TimeContext } from "../TimeContext.mjs";
|
|
6
6
|
describe("timeTextBuilder", () => {
|
|
7
7
|
const config = rr0TestUtil.config;
|
|
8
8
|
const timeTextBuilder = new TimeTextBuilder(rr0TestUtil.intlOptions);
|
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.40",
|
|
6
6
|
"description": "RR0 Content Management System (CMS)",
|
|
7
7
|
"exports": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"prebuild": "npm install",
|
|
23
23
|
"preview": "vite preview --host",
|
|
24
24
|
"build": "rm -Rf dist && tsc --project tsconfig.prod.json",
|
|
25
|
-
"
|
|
25
|
+
"circular-deps": "dpdm src",
|
|
26
|
+
"prepublishOnly": "npm run build && npm test",
|
|
26
27
|
"test": "testscript",
|
|
27
28
|
"test-one": "rm -Rf out && tsx src/CMSGenerator.test.ts",
|
|
28
29
|
"test-ci": "rm -Rf out && testscript"
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"@rr0/data": "^0.3.36",
|
|
34
35
|
"@rr0/lang": "^0.1.12",
|
|
35
36
|
"@rr0/place": "^0.5.3",
|
|
36
|
-
"@rr0/time": "^0.11.
|
|
37
|
+
"@rr0/time": "^0.11.1",
|
|
37
38
|
"canvas": "^3.1.0",
|
|
38
39
|
"csv-parser": "^3.2.0",
|
|
39
40
|
"glob": "^11.0.1",
|