@rr0/cms 0.1.14 → 0.1.16
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/BaseReplaceCommand.d.ts +2 -2
- package/dist/DefaultContentVisitor.d.ts +11 -11
- package/dist/DescriptionReplaceCommand.d.ts +3 -3
- package/dist/ImageCommand.d.ts +3 -3
- package/dist/MetaLinkReplaceCommand.d.ts +3 -3
- package/dist/OpenGraphCommand.d.ts +6 -6
- package/dist/OpenGraphCommand.js +1 -1
- package/dist/RR0ContentStep.d.ts +11 -11
- package/dist/RR0ContentStep.js +2 -2
- package/dist/{RR0SsgContext.d.ts → RR0Context.d.ts} +8 -8
- package/dist/{RR0SsgContext.js → RR0Context.js} +4 -4
- package/dist/anchor/AnchorHandler.d.ts +2 -2
- package/dist/anchor/AnchorReplaceCommand.d.ts +2 -2
- package/dist/anchor/AnchorReplacer.d.ts +3 -3
- package/dist/anchor/CaseAnchorHandler.d.ts +2 -2
- package/dist/anchor/CaseAnchorHandler.js +2 -2
- package/dist/anchor/DataAnchorHandler.d.ts +6 -6
- package/dist/book/BookContentVisitor.d.ts +2 -2
- package/dist/book/BookDirectoryStep.d.ts +5 -5
- package/dist/book/BookService.d.ts +3 -1
- package/dist/book/BookService.js +4 -4
- package/dist/book/Chapters.d.ts +3 -3
- package/dist/book/Chapters.js +2 -2
- package/dist/build.js +27 -8
- package/dist/data/AbstractDataFactory.d.ts +3 -2
- package/dist/data/AbstractDataFactory.js +1 -1
- package/dist/data/AbstractDataService.d.ts +2 -3
- package/dist/data/AbstractDataService.js +2 -8
- package/dist/data/RR0Data.d.ts +4 -3
- package/dist/data/TypedDataFactory.d.ts +3 -2
- package/dist/data/TypedDataFactory.js +4 -0
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.js +1 -1
- package/dist/index/IndexedReplacer.d.ts +4 -4
- package/dist/index/IndexedReplacerFactory.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lang/LanguageReplaceCommand.d.ts +3 -3
- package/dist/lang/RR0Messages.d.ts +1 -1
- package/dist/lang/RR0Messages_en.d.ts +1 -1
- package/dist/lang/RR0Messages_en.js +1 -1
- package/dist/lang/RR0Messages_fr.d.ts +1 -1
- package/dist/lang/RR0Messages_fr.js +1 -1
- package/dist/note/NoteFileCounter.d.ts +2 -2
- package/dist/note/NoteRenderer.d.ts +2 -2
- package/dist/note/NoteReplacer.d.ts +2 -2
- package/dist/note/NoteReplacerFactory.d.ts +2 -2
- package/dist/org/OrgMessages.d.ts +2 -2
- package/dist/org/Organization.d.ts +3 -3
- package/dist/org/Organization.js +3 -3
- package/dist/org/OrganizationMessages.d.ts +3 -3
- package/dist/org/OrganizationService.d.ts +4 -3
- package/dist/org/OrganizationService.js +10 -9
- package/dist/org/au/region/vic/index.d.ts +1 -1
- package/dist/org/au/region/vic/index.js +1 -1
- package/dist/org/br/region/cw/CentralWest.js +1 -1
- package/dist/org/br/region/se/SouthEast.js +1 -1
- package/dist/org/country/region/department/city/CityService.d.ts +2 -2
- package/dist/org/country/region/department/city/CityService.js +2 -1
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseSummary.d.ts +1 -1
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseSummaryRR0Mapper.d.ts +4 -4
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseSummaryRR0Mapper.js +1 -1
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseToSummaryMapper.d.ts +3 -3
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanCaseToSummaryMapper.js +1 -1
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanDatasource.d.ts +3 -3
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanFileDatasource.d.ts +3 -3
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanHttpDatasource.d.ts +6 -5
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanSummaryToCaseMapper.d.ts +3 -3
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanTestCases.js +1 -1
- package/dist/org/eu/fr/cnes/geipan/geipan/GeipanTestimonial.d.ts +1 -1
- package/dist/org/us/region/fl/Florida.js +1 -1
- package/dist/org/us/region/hi/Hawaii.js +1 -1
- package/dist/org/us/region/in/Indiana.js +1 -1
- package/dist/org/us/region/va/Virginia.js +1 -1
- package/dist/org/us/region/wa/Washington.js +1 -1
- package/dist/org/us/region/wv/WestVirginia.js +1 -1
- package/dist/people/PeopleDirectoryStep.d.ts +4 -4
- package/dist/people/PeopleReplacer.d.ts +3 -3
- package/dist/people/PeopleReplacerFactory.d.ts +2 -2
- package/dist/people/PeopleService.d.ts +3 -4
- package/dist/people/PeopleService.js +3 -14
- package/dist/people/author/AuthorReplaceCommand.d.ts +2 -2
- package/dist/people/witness/WitnessReplacer.d.ts +2 -2
- package/dist/people/witness/WitnessReplacerFactory.d.ts +2 -2
- package/dist/place/GooglePlaceService.d.ts +1 -1
- package/dist/place/GooglePlaceService.js +1 -1
- package/dist/place/Place.d.ts +1 -1
- package/dist/place/Place.js +1 -1
- package/dist/place/PlaceService.d.ts +1 -1
- package/dist/place/PlaceService.js +1 -1
- package/dist/place/index.d.ts +0 -4
- package/dist/place/index.js +0 -4
- package/dist/science/crypto/ufo/enquete/dossier/CaseDirectoryStep.d.ts +5 -5
- package/dist/science/crypto/ufo/enquete/dossier/CaseDirectoryStep.js +1 -1
- package/dist/science/crypto/ufo/enquete/dossier/CaseService.d.ts +3 -3
- package/dist/science/crypto/ufo/enquete/dossier/CaseService.js +2 -2
- package/dist/search/SearchVisitor.d.ts +5 -5
- package/dist/source/Source.d.ts +1 -1
- package/dist/source/SourceFactory.d.ts +4 -4
- package/dist/source/SourceFactory.js +3 -2
- package/dist/source/SourceFileCounter.d.ts +2 -2
- package/dist/source/SourceRegistry.d.ts +2 -2
- package/dist/source/SourceRenderer.d.ts +3 -3
- package/dist/source/SourceRenderer.js +2 -2
- package/dist/source/SourceReplacer.d.ts +3 -3
- package/dist/source/SourceReplacerFactory.d.ts +2 -2
- package/dist/tech/info/soft/proj/impl/lang/CodeReplacer.d.ts +3 -3
- package/dist/tech/info/soft/proj/impl/lang/CodeReplacerFactory.d.ts +2 -2
- package/dist/time/CaseSummaryRenderer.d.ts +1 -1
- package/dist/time/EventRenderer.d.ts +7 -7
- package/dist/time/EventReplacerFactory.d.ts +4 -4
- package/dist/time/SsiTitleReplaceCommand.d.ts +2 -2
- package/dist/time/Time.d.ts +5 -3
- package/dist/time/Time.js +31 -5
- package/dist/time/TimeLinkDefaultHandler.d.ts +10 -9
- package/dist/time/TimeLinkDefaultHandler.js +8 -12
- package/dist/time/TimeService.d.ts +16 -7
- package/dist/time/TimeService.js +16 -22
- package/dist/time/TimeTestUtil.d.ts +16 -0
- package/dist/time/TimeTestUtil.js +29 -0
- package/dist/time/TimeUrlBuilder.d.ts +7 -3
- package/dist/time/TimeUrlBuilder.js +7 -4
- package/dist/time/datasource/AbstractDatasource.d.ts +6 -6
- package/dist/time/datasource/ChronologyReplacer.d.ts +6 -6
- package/dist/time/datasource/ChronologyReplacerFactory.d.ts +2 -2
- package/dist/time/datasource/ChronologyReplacerFactory.js +1 -1
- package/dist/time/datasource/ContextFilter.d.ts +3 -3
- package/dist/time/datasource/CsvFileSource.d.ts +2 -2
- package/dist/time/datasource/CsvMapper.d.ts +5 -5
- package/dist/time/datasource/CsvMapper.js +1 -1
- package/dist/time/datasource/Datasource.d.ts +2 -2
- package/dist/time/datasource/DatasourceTestCase.d.ts +8 -8
- package/dist/time/datasource/DatasourceTestCase.js +18 -16
- package/dist/time/datasource/FileDatasource.d.ts +2 -2
- package/dist/time/datasource/JsonMapper.d.ts +4 -4
- package/dist/time/datasource/TimeContextFilter.d.ts +3 -3
- package/dist/time/datasource/acufo/AcufoCase.d.ts +1 -1
- package/dist/time/datasource/acufo/AcufoDatasource.d.ts +3 -3
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummary.d.ts +1 -1
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryMapper.d.ts +3 -3
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryMapper.js +1 -1
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.d.ts +3 -3
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.js +1 -1
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceDatasource.d.ts +2 -2
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceHttpDatasource.d.ts +6 -6
- package/dist/time/datasource/baseovnifrance/BaseOvniFranceTestCases.js +1 -1
- package/dist/time/datasource/fufora/FuforaCaseSummary.d.ts +1 -1
- package/dist/time/datasource/fufora/FuforaCaseSummaryRR0Mapper.d.ts +3 -3
- package/dist/time/datasource/fufora/FuforaCaseSummaryRR0Mapper.js +1 -1
- package/dist/time/datasource/fufora/FuforaDatasource.d.ts +2 -2
- package/dist/time/datasource/fufora/FuforaHttpDatasource.d.ts +5 -5
- package/dist/time/datasource/fufora/FuforaTestCases.js +1 -1
- package/dist/time/datasource/nuforc/NuforcCaseSummary.d.ts +1 -1
- package/dist/time/datasource/nuforc/NuforcDatasource.d.ts +2 -2
- package/dist/time/datasource/nuforc/NuforcHttpDatasource.d.ts +6 -6
- package/dist/time/datasource/nuforc/NuforcRR0Mapper.d.ts +3 -3
- package/dist/time/datasource/nuforc/NuforcRR0Mapper.js +1 -1
- package/dist/time/datasource/nuforc/NuforcTestCases.js +1 -1
- package/dist/time/datasource/rr0/NamedPlace.d.ts +7 -0
- package/dist/time/datasource/rr0/RR0CaseMapping.d.ts +2 -2
- package/dist/time/datasource/rr0/RR0CaseSummary.d.ts +0 -7
- package/dist/time/datasource/rr0/RR0CaseSummaryMapper.d.ts +3 -3
- package/dist/time/datasource/rr0/RR0FileDatasource.d.ts +5 -5
- package/dist/time/datasource/rr0/RR0HttpDatasource.d.ts +10 -9
- package/dist/time/datasource/rr0/RR0HttpDatasource.js +3 -32
- package/dist/time/datasource/rr0/RR0TestCases.js +1 -1
- package/dist/time/datasource/rr0/index.d.ts +1 -0
- package/dist/time/datasource/rr0/index.js +1 -0
- package/dist/time/datasource/sceau/SceauCaseSummaryRR0Mapper.d.ts +3 -3
- package/dist/time/datasource/sceau/SceauCaseSummaryRR0Mapper.js +1 -1
- package/dist/time/datasource/sceau/SceauDatasource.d.ts +4 -4
- package/dist/time/datasource/sceau/SceauDatasource.js +1 -1
- package/dist/time/datasource/sceau/SceauHttpDatasource.d.ts +5 -5
- package/dist/time/datasource/ufo-search/UfoSearchCase.d.ts +1 -1
- package/dist/time/datasource/ufo-search/UfoSearchCaseRR0Mapper.d.ts +4 -4
- package/dist/time/datasource/ufo-search/UfoSearchCaseRR0Mapper.js +10 -10
- package/dist/time/datasource/ufo-search/UfoSearchDatasource.d.ts +2 -2
- package/dist/time/datasource/ufo-search/UfoSearchFileDatasource.d.ts +3 -3
- package/dist/time/datasource/ufo-search/UfoSearchFileDatasource.js +1 -1
- package/dist/time/datasource/ufo-search/UfoSearchHttpDatasource.d.ts +4 -4
- package/dist/time/datasource/ufo-search/UfoSearchTestCases.js +1 -1
- package/dist/time/datasource/urecat/UrecatCase.d.ts +1 -1
- package/dist/time/datasource/urecat/UrecatHttpDatasource.d.ts +5 -5
- package/dist/time/datasource/urecat/UrecatHttpDatasource.js +1 -1
- package/dist/time/datasource/urecat/UrecatRR0Mapper.d.ts +3 -3
- package/dist/time/datasource/urecat/UrecatRR0Mapper.js +1 -1
- package/dist/time/datasource/urecat/UrecatTestCases.js +1 -1
- package/dist/time/html/TimeElementFactory.d.ts +15 -0
- package/dist/time/{TimeElementFactory.js → html/TimeElementFactory.js} +16 -22
- package/dist/time/html/TimeRenderer.d.ts +18 -0
- package/dist/time/html/TimeRenderer.js +46 -0
- package/dist/time/html/TimeReplacer.d.ts +12 -0
- package/dist/time/{TimeReplacer.js → html/TimeReplacer.js} +0 -3
- package/dist/time/{TimeReplacerFactory.d.ts → html/TimeReplacerFactory.d.ts} +2 -2
- package/dist/time/{TimeReplacerFactory.js → html/TimeReplacerFactory.js} +1 -1
- package/dist/time/html/index.d.ts +4 -0
- package/dist/time/html/index.js +4 -0
- package/dist/time/index.d.ts +3 -8
- package/dist/time/index.js +3 -8
- package/dist/time/{RelativeTimeTextBuilder.d.ts → text/RelativeTimeTextBuilder.d.ts} +2 -2
- package/dist/time/text/RelativeTimeTextBuilder.js +165 -0
- package/dist/time/{TimeTextBuilder.d.ts → text/TimeTextBuilder.d.ts} +2 -2
- package/dist/time/{TimeTextBuilder.js → text/TimeTextBuilder.js} +1 -1
- package/dist/time/text/index.d.ts +2 -0
- package/dist/time/text/index.js +2 -0
- package/dist/value/UnitReplaceCommand.d.ts +2 -2
- package/package.json +12 -11
- package/tsconfig.json +2 -1
- package/dist/place/PlaceLocation.d.ts +0 -26
- package/dist/place/PlaceLocation.js +0 -48
- package/dist/place/PlaceMessages.d.ts +0 -5
- package/dist/place/PlaceMessages_en.d.ts +0 -2
- package/dist/place/PlaceMessages_en.js +0 -4
- package/dist/place/PlaceMessages_fr.d.ts +0 -2
- package/dist/place/PlaceMessages_fr.js +0 -4
- package/dist/time/RelativeTimeTextBuilder.js +0 -166
- package/dist/time/TimeContext.d.ts +0 -59
- package/dist/time/TimeContext.js +0 -267
- package/dist/time/TimeElementFactory.d.ts +0 -15
- package/dist/time/TimeRenderer.d.ts +0 -19
- package/dist/time/TimeRenderer.js +0 -63
- package/dist/time/TimeReplacer.d.ts +0 -24
- /package/dist/{place/PlaceMessages.js → time/datasource/rr0/NamedPlace.js} +0 -0
package/dist/time/Time.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RR0SsgContextImpl } from "../RR0SsgContext.js";
|
|
1
|
+
import { RR0ContextImpl } from "../RR0Context.js";
|
|
3
2
|
import { StringUtil } from "../util/string/StringUtil.js";
|
|
4
3
|
export class Time {
|
|
5
4
|
/**
|
|
@@ -21,13 +20,40 @@ export class Time {
|
|
|
21
20
|
}
|
|
22
21
|
static titleFromFile(context, fileName, timeTextBuilder) {
|
|
23
22
|
let title;
|
|
24
|
-
const timeContext =
|
|
23
|
+
const timeContext = Time.contextFromFileName(context, fileName);
|
|
25
24
|
if (timeContext) {
|
|
26
|
-
const pageContext = new
|
|
27
|
-
title = timeTextBuilder.build(pageContext);
|
|
25
|
+
const pageContext = new RR0ContextImpl(context.locale, timeContext, context.config, context.people, context.file);
|
|
26
|
+
title = timeTextBuilder.build(pageContext, true);
|
|
28
27
|
title = StringUtil.capitalizeFirstLetter(title);
|
|
29
28
|
}
|
|
30
29
|
return title;
|
|
31
30
|
}
|
|
31
|
+
static contextFromFileName(context, fileName = context.file.name) {
|
|
32
|
+
let timeContext;
|
|
33
|
+
let elems;
|
|
34
|
+
if (fileName.endsWith("index.html")) {
|
|
35
|
+
while ((elems = fileName.split("/")).length < 6) {
|
|
36
|
+
fileName = elems.slice(0, elems.length - 1).join("/") + "/0/index.html";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const timeExec = Time.parseFileName(fileName);
|
|
40
|
+
if (timeExec && timeExec.length > 5) {
|
|
41
|
+
const pageContext = context.clone();
|
|
42
|
+
timeContext = pageContext.time;
|
|
43
|
+
const m = parseInt(timeExec[2], 10);
|
|
44
|
+
const c = parseInt(timeExec[3], 10);
|
|
45
|
+
const d = parseInt(timeExec[4], 10);
|
|
46
|
+
const u = parseInt(timeExec[5], 10);
|
|
47
|
+
const year = (timeExec[1] ? -1 : 1) * (m * 1000 + c * 100 + d * 10 + u);
|
|
48
|
+
timeContext.setYear(year);
|
|
49
|
+
const monthStr = timeExec[6];
|
|
50
|
+
timeContext.setMonth(monthStr ? parseInt(monthStr, 10) : undefined);
|
|
51
|
+
const dayStr = timeExec[7];
|
|
52
|
+
timeContext.setDayOfMonth(dayStr ? parseInt(dayStr, 10) : undefined);
|
|
53
|
+
timeContext.setHour(undefined);
|
|
54
|
+
timeContext.setMinutes(undefined);
|
|
55
|
+
}
|
|
56
|
+
return timeContext;
|
|
57
|
+
}
|
|
32
58
|
}
|
|
33
59
|
Time.timePathRegex = /time\/(-)?(\d)\/(\d)\/(\d)\/(\d)\/?(\d{2})?\/?(\d{2})?\/?(index(_[a-z]{2})?.html)?/;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { LinkHandler } from "../MetaLinkReplaceCommand.js";
|
|
2
|
-
import {
|
|
2
|
+
import { HtmlRR0Context } from "../RR0Context.js";
|
|
3
3
|
import { Link } from "ssg-api";
|
|
4
|
-
import { TimeTextBuilder } from "./TimeTextBuilder.js";
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { TimeTextBuilder } from "./text/TimeTextBuilder.js";
|
|
5
|
+
import { TimeService } from "./TimeService";
|
|
6
|
+
export declare class TimeLinkDefaultHandler implements LinkHandler<HtmlRR0Context> {
|
|
7
|
+
protected service: TimeService;
|
|
7
8
|
protected timeTextBuilder: TimeTextBuilder;
|
|
8
|
-
constructor(
|
|
9
|
-
contents(context:
|
|
10
|
-
next(context:
|
|
11
|
-
prev(context:
|
|
12
|
-
start(context:
|
|
9
|
+
constructor(service: TimeService, timeTextBuilder: TimeTextBuilder);
|
|
10
|
+
contents(context: HtmlRR0Context): Link | undefined;
|
|
11
|
+
next(context: HtmlRR0Context): Link | undefined;
|
|
12
|
+
prev(context: HtmlRR0Context): Link | undefined;
|
|
13
|
+
start(context: HtmlRR0Context): Link | undefined;
|
|
13
14
|
protected isTimeFile(fileName: string): boolean;
|
|
14
15
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { Time } from "./Time.js";
|
|
2
2
|
import { LinkType } from "ssg-api";
|
|
3
3
|
export class TimeLinkDefaultHandler {
|
|
4
|
-
constructor(
|
|
5
|
-
this.
|
|
4
|
+
constructor(service, timeTextBuilder) {
|
|
5
|
+
this.service = service;
|
|
6
6
|
this.timeTextBuilder = timeTextBuilder;
|
|
7
7
|
}
|
|
8
8
|
contents(context) {
|
|
9
9
|
const prevLink = this.prev(context);
|
|
10
10
|
if (prevLink) {
|
|
11
|
-
let contentUrl = prevLink.url.substring(1);
|
|
12
|
-
|
|
13
|
-
const slash = contentUrl.lastIndexOf("/");
|
|
14
|
-
contentUrl = contentUrl.substring(0, slash);
|
|
15
|
-
} while (this.timeFiles.indexOf(contentUrl) < 0 && contentUrl !== "time");
|
|
16
|
-
if (contentUrl != "time") {
|
|
11
|
+
let contentUrl = this.service.matchExistingTimeFile(prevLink.url.substring(1));
|
|
12
|
+
if (contentUrl != this.service.root) {
|
|
17
13
|
const text = Time.titleFromFile(context, contentUrl, this.timeTextBuilder);
|
|
18
14
|
if (text) {
|
|
19
15
|
return { type: LinkType.prev, text, url: "/" + contentUrl };
|
|
@@ -24,9 +20,9 @@ export class TimeLinkDefaultHandler {
|
|
|
24
20
|
next(context) {
|
|
25
21
|
let fileName = context.file.name;
|
|
26
22
|
if (this.isTimeFile(fileName)) {
|
|
27
|
-
const pos = this.
|
|
23
|
+
const pos = this.service.files.indexOf(fileName);
|
|
28
24
|
if (pos >= 0) {
|
|
29
|
-
const nextFile = this.
|
|
25
|
+
const nextFile = this.service.files[pos + 1];
|
|
30
26
|
if (nextFile) {
|
|
31
27
|
const text = Time.titleFromFile(context, nextFile, this.timeTextBuilder);
|
|
32
28
|
return { type: LinkType.next, text, url: "/" + nextFile };
|
|
@@ -37,9 +33,9 @@ export class TimeLinkDefaultHandler {
|
|
|
37
33
|
prev(context) {
|
|
38
34
|
let fileName = context.file.name;
|
|
39
35
|
if (this.isTimeFile(fileName)) {
|
|
40
|
-
const pos = this.
|
|
36
|
+
const pos = this.service.files.indexOf(fileName);
|
|
41
37
|
if (pos >= 0) {
|
|
42
|
-
const prevFile = this.
|
|
38
|
+
const prevFile = this.service.files[pos - 1];
|
|
43
39
|
if (prevFile) {
|
|
44
40
|
const text = Time.titleFromFile(context, prevFile, this.timeTextBuilder);
|
|
45
41
|
if (text) {
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import { TimeRenderer } from "./TimeRenderer.js";
|
|
2
|
-
import { TimeTextBuilder } from "./TimeTextBuilder.js";
|
|
1
|
+
import { TimeRenderer } from "./html/TimeRenderer.js";
|
|
2
|
+
import { TimeTextBuilder } from "./text/TimeTextBuilder.js";
|
|
3
3
|
import { AbstractDataService, AllDataService } from "../data/index.js";
|
|
4
4
|
import { RR0Event } from "../event/index.js";
|
|
5
|
+
import { TimeUrlBuilder } from "./TimeUrlBuilder";
|
|
6
|
+
export type TimeServiceOptions = {
|
|
7
|
+
readonly root: string;
|
|
8
|
+
readonly files: string[];
|
|
9
|
+
};
|
|
5
10
|
export declare class TimeService extends AbstractDataService<RR0Event> {
|
|
6
11
|
readonly textBuilder: TimeTextBuilder;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
isTimeFile(filePath: string):
|
|
12
|
+
readonly urlBuilder: TimeUrlBuilder;
|
|
13
|
+
readonly renderer: TimeRenderer;
|
|
14
|
+
readonly root: string;
|
|
15
|
+
constructor(dataService: AllDataService, textBuilder: TimeTextBuilder, urlBuilder: TimeUrlBuilder, options: TimeServiceOptions);
|
|
16
|
+
isTimeFile(filePath: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* @return the found time URL or undefined if not found.
|
|
19
|
+
*/
|
|
20
|
+
matchExistingTimeFile(url: string): string | undefined;
|
|
12
21
|
}
|
package/dist/time/TimeService.js
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
import { TimeRenderer } from "./TimeRenderer.js";
|
|
1
|
+
import { TimeRenderer } from "./html/TimeRenderer.js";
|
|
2
2
|
import { AbstractDataService } from "../data/index.js";
|
|
3
|
-
import { glob } from "glob";
|
|
4
3
|
export class TimeService extends AbstractDataService {
|
|
5
|
-
constructor(dataService, textBuilder) {
|
|
6
|
-
super(dataService, null);
|
|
4
|
+
constructor(dataService, textBuilder, urlBuilder, options) {
|
|
5
|
+
super(dataService, null, options.files);
|
|
7
6
|
this.textBuilder = textBuilder;
|
|
7
|
+
this.urlBuilder = urlBuilder;
|
|
8
|
+
this.root = options.root;
|
|
9
|
+
this.renderer = new TimeRenderer(this, this.textBuilder);
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
return this.
|
|
11
|
+
isTimeFile(filePath) {
|
|
12
|
+
return this.files.includes(filePath);
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const monthFiles = await glob("time/?/?/?/?/??/index.html");
|
|
20
|
-
const dayFiles = await glob("time/?/?/?/?/??/??/index.html");
|
|
21
|
-
const files = this.files = year1Files.concat(year2Files).concat(year3Files).concat(year4Files).concat(minusYearFiles).concat(monthFiles).concat(dayFiles).sort();
|
|
22
|
-
this._renderer = new TimeRenderer(files, this.textBuilder);
|
|
14
|
+
/**
|
|
15
|
+
* @return the found time URL or undefined if not found.
|
|
16
|
+
*/
|
|
17
|
+
matchExistingTimeFile(url) {
|
|
18
|
+
while (url && url !== this.root && this.files.indexOf(`${url}/index.html`) < 0) {
|
|
19
|
+
const slash = url.lastIndexOf("/");
|
|
20
|
+
url = url.substring(0, slash);
|
|
23
21
|
}
|
|
24
|
-
return this.
|
|
25
|
-
}
|
|
26
|
-
async isTimeFile(filePath) {
|
|
27
|
-
const files = await this.getFiles();
|
|
28
|
-
return files.includes(filePath);
|
|
22
|
+
return url === this.root ? undefined : url;
|
|
29
23
|
}
|
|
30
24
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TimeElementFactory, TimeService, TimeServiceOptions, TimeTextBuilder, TimeUrlBuilder } from "../time/index.js";
|
|
2
|
+
import { RR0TestUtil } from "../test";
|
|
3
|
+
import { HtmlRR0Context } from "../RR0Context";
|
|
4
|
+
export declare class TimeTestUtil {
|
|
5
|
+
readonly timeTextBuilder: TimeTextBuilder;
|
|
6
|
+
timeElementFactory: TimeElementFactory;
|
|
7
|
+
timeOptions: TimeServiceOptions;
|
|
8
|
+
urlBuilder: TimeUrlBuilder;
|
|
9
|
+
protected timeService: TimeService;
|
|
10
|
+
fullRoot: string;
|
|
11
|
+
constructor(rr0TestUtil: RR0TestUtil);
|
|
12
|
+
newHtmlContext(inputFileName: string, contents?: string): HtmlRR0Context;
|
|
13
|
+
filePath(inputFileName: string): string;
|
|
14
|
+
url(inputFileName: string): string;
|
|
15
|
+
getService(options?: TimeServiceOptions): TimeService;
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { TimeElementFactory, TimeService, TimeTextBuilder, TimeUrlBuilder } from "../time/index.js";
|
|
3
|
+
import { rr0TestUtil } from "../test";
|
|
4
|
+
export class TimeTestUtil {
|
|
5
|
+
constructor(rr0TestUtil) {
|
|
6
|
+
this.timeOptions = { root: "time", files: [] };
|
|
7
|
+
this.urlBuilder = new TimeUrlBuilder({ rootDir: this.timeOptions.root });
|
|
8
|
+
this.timeTextBuilder = new TimeTextBuilder(rr0TestUtil.intlOptions);
|
|
9
|
+
this.fullRoot = path.join(rr0TestUtil.rootDir, this.timeOptions.root);
|
|
10
|
+
}
|
|
11
|
+
newHtmlContext(inputFileName, contents) {
|
|
12
|
+
return rr0TestUtil.newHtmlContext(this.filePath(inputFileName), contents);
|
|
13
|
+
}
|
|
14
|
+
filePath(inputFileName) {
|
|
15
|
+
return path.join(this.timeOptions.root, inputFileName);
|
|
16
|
+
}
|
|
17
|
+
url(inputFileName) {
|
|
18
|
+
return path.join("/", this.filePath(inputFileName));
|
|
19
|
+
}
|
|
20
|
+
getService(options = this.timeOptions) {
|
|
21
|
+
if (!this.timeService
|
|
22
|
+
|| this.timeService.root !== options.root
|
|
23
|
+
|| JSON.stringify(this.timeService.files) !== JSON.stringify(options.files)) {
|
|
24
|
+
this.timeService = new TimeService(rr0TestUtil.dataService, this.timeTextBuilder, this.urlBuilder, options);
|
|
25
|
+
this.timeElementFactory = new TimeElementFactory(this.timeService.renderer);
|
|
26
|
+
}
|
|
27
|
+
return this.timeService;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { TimeContext } from "
|
|
1
|
+
import { TimeContext } from "@rr0/time";
|
|
2
|
+
export type TimeUrlBuilderOptions = {
|
|
3
|
+
rootDir: string;
|
|
4
|
+
};
|
|
2
5
|
export declare class TimeUrlBuilder {
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
readonly options: TimeUrlBuilderOptions;
|
|
7
|
+
constructor(options: TimeUrlBuilderOptions);
|
|
8
|
+
fromContext(time: TimeContext): string;
|
|
5
9
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import path from "path";
|
|
1
2
|
export class TimeUrlBuilder {
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.options = options;
|
|
5
|
+
}
|
|
6
|
+
fromContext(time) {
|
|
7
|
+
let url = this.options.rootDir;
|
|
4
8
|
const year = time.getYear();
|
|
5
9
|
if (year) {
|
|
6
|
-
url
|
|
10
|
+
url = path.join(url, year.toString().split("").join("/"));
|
|
7
11
|
}
|
|
8
12
|
let month = time.getMonth();
|
|
9
13
|
if (month) {
|
|
@@ -16,4 +20,3 @@ export class TimeUrlBuilder {
|
|
|
16
20
|
return url;
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
|
-
TimeUrlBuilder.root = "time/";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Datasource } from "./Datasource";
|
|
2
|
-
import {
|
|
2
|
+
import { HtmlRR0Context } from "../../RR0Context.js";
|
|
3
3
|
import { ContextFilter } from "./ContextFilter.js";
|
|
4
4
|
/**
|
|
5
5
|
* Cache cases which were already fetched, and filter out cases in memory according to (time) context.
|
|
@@ -9,9 +9,9 @@ export declare abstract class AbstractDatasource<S> implements Datasource<S> {
|
|
|
9
9
|
readonly copyright: string;
|
|
10
10
|
protected readonly cases: Map<string, S[]>;
|
|
11
11
|
protected constructor(authors: string[], copyright: string);
|
|
12
|
-
getCases(context:
|
|
13
|
-
fetch(context:
|
|
14
|
-
protected createFilter(context:
|
|
15
|
-
protected contextKey(context:
|
|
16
|
-
protected abstract readCases(context:
|
|
12
|
+
getCases(context: HtmlRR0Context): Promise<S[]>;
|
|
13
|
+
fetch(context: HtmlRR0Context): Promise<S[]>;
|
|
14
|
+
protected createFilter(context: HtmlRR0Context): ContextFilter<S>;
|
|
15
|
+
protected contextKey(context: HtmlRR0Context): string;
|
|
16
|
+
protected abstract readCases(context: HtmlRR0Context): Promise<S[]>;
|
|
17
17
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DomReplacement } from "../DomReplacement.js";
|
|
2
|
-
import {
|
|
2
|
+
import { HtmlRR0Context } from "../../RR0Context.js";
|
|
3
3
|
import { CaseSummaryRenderer } from "../CaseSummaryRenderer.js";
|
|
4
4
|
import { RR0CaseSummary } from "./rr0/RR0CaseSummary.js";
|
|
5
5
|
import { RR0CaseMapping } from "./rr0/RR0CaseMapping.js";
|
|
6
6
|
/**
|
|
7
7
|
* Replaces a (ul) tag from (chronology) files with case summaries from external datasources.
|
|
8
8
|
*/
|
|
9
|
-
export declare class ChronologyReplacer implements DomReplacement<
|
|
9
|
+
export declare class ChronologyReplacer implements DomReplacement<HtmlRR0Context, HTMLUListElement> {
|
|
10
10
|
protected mappings: RR0CaseMapping<any>[];
|
|
11
11
|
protected renderer: CaseSummaryRenderer;
|
|
12
12
|
/**
|
|
@@ -16,8 +16,8 @@ export declare class ChronologyReplacer implements DomReplacement<HtmlRR0SsgCont
|
|
|
16
16
|
*/
|
|
17
17
|
protected readonly done: Set<string>;
|
|
18
18
|
constructor(mappings: RR0CaseMapping<any>[], renderer: CaseSummaryRenderer);
|
|
19
|
-
replacement(context:
|
|
20
|
-
protected aggregate(context:
|
|
21
|
-
protected aggregateDatasource(mapping: RR0CaseMapping<any>, context:
|
|
22
|
-
protected merge(context:
|
|
19
|
+
replacement(context: HtmlRR0Context, element: HTMLUListElement): Promise<HTMLUListElement>;
|
|
20
|
+
protected aggregate(context: HtmlRR0Context, element: HTMLUListElement): Promise<void>;
|
|
21
|
+
protected aggregateDatasource(mapping: RR0CaseMapping<any>, context: HtmlRR0Context, existingCases: RR0CaseSummary[], casesToAdd: RR0CaseSummary[]): Promise<void>;
|
|
22
|
+
protected merge(context: HtmlRR0Context, sourceCases: any[], fetchTime: Date, mapping: RR0CaseMapping<any>, existingCases: RR0CaseSummary[]): RR0CaseSummary[];
|
|
23
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DomReplacer, ReplacerFactory } from "ssg-api";
|
|
2
2
|
import { ChronologyReplacer } from "./ChronologyReplacer.js";
|
|
3
|
-
import {
|
|
3
|
+
import { HtmlRR0Context } from "../../RR0Context.js";
|
|
4
4
|
import { CaseSummaryRenderer } from "../CaseSummaryRenderer.js";
|
|
5
5
|
import { TimeService } from "../TimeService.js";
|
|
6
6
|
import { RR0CaseMapping } from "./rr0/RR0CaseMapping.js";
|
|
@@ -13,5 +13,5 @@ export declare class ChronologyReplacerFactory implements ReplacerFactory<DomRep
|
|
|
13
13
|
*
|
|
14
14
|
* @param context
|
|
15
15
|
*/
|
|
16
|
-
create(context:
|
|
16
|
+
create(context: HtmlRR0Context): Promise<DomReplacer>;
|
|
17
17
|
}
|
|
@@ -12,7 +12,7 @@ export class ChronologyReplacerFactory {
|
|
|
12
12
|
async create(context) {
|
|
13
13
|
return {
|
|
14
14
|
replace: async (ul) => {
|
|
15
|
-
const isTimeFile =
|
|
15
|
+
const isTimeFile = this.timeService.isTimeFile(context.file.name);
|
|
16
16
|
if (isTimeFile) {
|
|
17
17
|
ul = await this.replacer.replacement(context, ul);
|
|
18
18
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { UfoCaseFilter } from "./UfoCaseFilter.js";
|
|
2
|
-
import {
|
|
2
|
+
import { RR0Context } from "../../RR0Context.js";
|
|
3
3
|
export declare abstract class ContextFilter<T> implements UfoCaseFilter<T> {
|
|
4
|
-
protected context:
|
|
4
|
+
protected context: RR0Context;
|
|
5
5
|
/**
|
|
6
6
|
* @param context The context to match
|
|
7
7
|
* @protected
|
|
8
8
|
*/
|
|
9
|
-
protected constructor(context:
|
|
9
|
+
protected constructor(context: RR0Context);
|
|
10
10
|
/**
|
|
11
11
|
* @param ufoCase
|
|
12
12
|
* @return if that UFO case matches the filter.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HtmlRR0Context } from "../../RR0Context.js";
|
|
2
2
|
import { Datasource } from "./Datasource.js";
|
|
3
3
|
import { CsvMapper } from "./CsvMapper.js";
|
|
4
4
|
import { FileSource } from "./FileSource.js";
|
|
@@ -15,5 +15,5 @@ export declare class CsvFileSource<S> extends FileSource {
|
|
|
15
15
|
* @protected
|
|
16
16
|
*/
|
|
17
17
|
fileName(context: HtmlSsgContext, datasource: Datasource<S>): string;
|
|
18
|
-
write(context:
|
|
18
|
+
write(context: HtmlRR0Context, datasourceCases: S[], fetchTime: Date, datasource: Datasource<any>): void;
|
|
19
19
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CaseMapper } from "./CaseMapper.js";
|
|
2
|
-
import {
|
|
3
|
-
export declare class CsvMapper<S> implements CaseMapper<
|
|
2
|
+
import { RR0Context } from "../../RR0Context.js";
|
|
3
|
+
export declare class CsvMapper<S> implements CaseMapper<RR0Context, S, string> {
|
|
4
4
|
readonly sep: string;
|
|
5
5
|
readonly escapeStr: string;
|
|
6
6
|
readonly prefix: string;
|
|
7
7
|
readonly fields: Set<string>;
|
|
8
8
|
constructor(sep?: string, escapeStr?: string, prefix?: string);
|
|
9
|
-
readonly fieldMapper: (context:
|
|
9
|
+
readonly fieldMapper: (context: RR0Context, key: string, value: any, sourceTime: Date) => string;
|
|
10
10
|
/**
|
|
11
11
|
* Map a case to a CSV row.
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@ export declare class CsvMapper<S> implements CaseMapper<RR0SsgContext, S, string
|
|
|
14
14
|
* @param sourceCase
|
|
15
15
|
* @param sourceTime
|
|
16
16
|
*/
|
|
17
|
-
map(context:
|
|
17
|
+
map(context: RR0Context, sourceCase: S, sourceTime: Date): string;
|
|
18
18
|
/**
|
|
19
19
|
* Reduce a set of cases to a CSV string.
|
|
20
20
|
*
|
|
@@ -22,7 +22,7 @@ export declare class CsvMapper<S> implements CaseMapper<RR0SsgContext, S, string
|
|
|
22
22
|
* @param sourceCases
|
|
23
23
|
* @param sourceTime
|
|
24
24
|
*/
|
|
25
|
-
mapAll(context:
|
|
25
|
+
mapAll(context: RR0Context, sourceCases: S[], sourceTime: Date): string;
|
|
26
26
|
escape(value: string, force?: boolean): string;
|
|
27
27
|
/**
|
|
28
28
|
* Converts CSV contents to a list of cases.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HtmlRR0Context } from "../../RR0Context.js";
|
|
2
2
|
/**
|
|
3
3
|
* A source for cases.
|
|
4
4
|
*
|
|
@@ -19,5 +19,5 @@ export interface Datasource<S> {
|
|
|
19
19
|
* @param context
|
|
20
20
|
* @return Promise<S[]>
|
|
21
21
|
*/
|
|
22
|
-
fetch(context:
|
|
22
|
+
fetch(context: HtmlRR0Context): Promise<S[]>;
|
|
23
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TimeContext } from "
|
|
3
|
-
import { TimeTextBuilder } from "../TimeTextBuilder.js";
|
|
1
|
+
import { HtmlRR0Context } from "../../RR0Context.js";
|
|
2
|
+
import { TimeContext } from "@rr0/time";
|
|
3
|
+
import { TimeTextBuilder } from "../text/TimeTextBuilder.js";
|
|
4
4
|
import { Source } from "../../source/index.js";
|
|
5
5
|
import { RR0CaseMapping } from "./rr0/index.js";
|
|
6
6
|
export declare abstract class DatasourceTestCase<S> {
|
|
@@ -8,11 +8,11 @@ export declare abstract class DatasourceTestCase<S> {
|
|
|
8
8
|
readonly sourceCases: S[];
|
|
9
9
|
protected readonly intlOptions: Intl.DateTimeFormatOptions;
|
|
10
10
|
timeTextBuilder: TimeTextBuilder;
|
|
11
|
-
protected constructor(mapping: RR0CaseMapping<S>, sourceCases: S[]);
|
|
12
|
-
checkCaseHTML(context:
|
|
13
|
-
testRender(context:
|
|
14
|
-
testFetch(context:
|
|
11
|
+
protected constructor(mapping: RR0CaseMapping<S>, sourceCases: S[], intlOptions?: Intl.DateTimeFormatOptions);
|
|
12
|
+
checkCaseHTML(context: HtmlRR0Context, nativeCase: S, item: HTMLLIElement, dataDate: Date): void;
|
|
13
|
+
testRender(context: HtmlRR0Context): Promise<void>;
|
|
14
|
+
testFetch(context: HtmlRR0Context): Promise<void>;
|
|
15
15
|
protected abstract sortComparator(c1: S, c2: S): number;
|
|
16
16
|
protected abstract getTime(c: S): TimeContext;
|
|
17
|
-
protected expectedSourceStr(context:
|
|
17
|
+
protected expectedSourceStr(context: HtmlRR0Context, expectedSources: Source[], nativeCase: S): string;
|
|
18
18
|
}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { expect } from "@javarome/testscript";
|
|
2
2
|
import { CaseSummaryRenderer } from "../CaseSummaryRenderer.js";
|
|
3
|
-
import { TimeTextBuilder } from "../TimeTextBuilder.js";
|
|
3
|
+
import { TimeTextBuilder } from "../text/TimeTextBuilder.js";
|
|
4
4
|
import { SourceFactory, SourceRenderer } from "../../source/index.js";
|
|
5
5
|
import { NoteFileCounter, NoteRenderer } from "../../note/index.js";
|
|
6
6
|
import { AllDataService } from "../../data/index.js";
|
|
7
7
|
import { HttpSource } from "./HttpSource.js";
|
|
8
|
-
import { TimeElementFactory } from "../TimeElementFactory.js";
|
|
9
|
-
import { TimeRenderer } from "../TimeRenderer.js";
|
|
8
|
+
import { TimeElementFactory } from "../html/TimeElementFactory.js";
|
|
9
|
+
import { TimeRenderer } from "../html/TimeRenderer.js";
|
|
10
|
+
import { rr0TestUtil } from "../../test";
|
|
10
11
|
export class DatasourceTestCase {
|
|
11
|
-
constructor(mapping, sourceCases
|
|
12
|
+
constructor(mapping, sourceCases, intlOptions = {
|
|
13
|
+
year: "numeric",
|
|
14
|
+
month: "long",
|
|
15
|
+
day: "numeric",
|
|
16
|
+
weekday: "long",
|
|
17
|
+
hour: "2-digit",
|
|
18
|
+
minute: "2-digit",
|
|
19
|
+
timeZoneName: "short"
|
|
20
|
+
}) {
|
|
12
21
|
this.mapping = mapping;
|
|
13
22
|
this.sourceCases = sourceCases;
|
|
14
|
-
this.intlOptions =
|
|
15
|
-
year: "numeric",
|
|
16
|
-
month: "long",
|
|
17
|
-
day: "numeric",
|
|
18
|
-
weekday: "long",
|
|
19
|
-
hour: "2-digit",
|
|
20
|
-
minute: "2-digit",
|
|
21
|
-
timeZoneName: "short"
|
|
22
|
-
};
|
|
23
|
+
this.intlOptions = intlOptions;
|
|
23
24
|
this.timeTextBuilder = new TimeTextBuilder(this.intlOptions);
|
|
24
25
|
}
|
|
25
26
|
checkCaseHTML(context, nativeCase, item, dataDate) {
|
|
@@ -27,7 +28,7 @@ export class DatasourceTestCase {
|
|
|
27
28
|
const time = this.getTime(nativeCase);
|
|
28
29
|
const caseContext = context.clone();
|
|
29
30
|
Object.assign(caseContext, { time });
|
|
30
|
-
const timeStr = this.timeTextBuilder.build(caseContext);
|
|
31
|
+
const timeStr = this.timeTextBuilder.build(caseContext, true);
|
|
31
32
|
const placeStr = expected.place ? ` À <span class="place">${expected.place.name}</span>` : "";
|
|
32
33
|
const expectedSources = expected.sources;
|
|
33
34
|
const sourceStr = (expectedSources === null || expectedSources === void 0 ? void 0 : expectedSources.length) > 0 ? this.expectedSourceStr(context, expectedSources, nativeCase) : "";
|
|
@@ -41,7 +42,8 @@ export class DatasourceTestCase {
|
|
|
41
42
|
const baseUrl = "https://rr0.org";
|
|
42
43
|
const http = new HttpSource();
|
|
43
44
|
const sourceFactory = new SourceFactory(dataService, http, baseUrl, this.intlOptions);
|
|
44
|
-
const
|
|
45
|
+
const timeService = await rr0TestUtil.time.getService();
|
|
46
|
+
const timeElementFactory = new TimeElementFactory(new TimeRenderer(timeService, this.timeTextBuilder));
|
|
45
47
|
const eventRenderer = new CaseSummaryRenderer(new NoteRenderer(new NoteFileCounter()), sourceFactory, new SourceRenderer(this.timeTextBuilder), timeElementFactory);
|
|
46
48
|
const items = [];
|
|
47
49
|
for (const c of cases) {
|
|
@@ -67,7 +69,7 @@ export class DatasourceTestCase {
|
|
|
67
69
|
const source = expectedSources[0];
|
|
68
70
|
const sourceContext = context.clone();
|
|
69
71
|
sourceContext.time = source.publication.time;
|
|
70
|
-
const publicationStr = source.publication ? `, ${this.timeTextBuilder.build(sourceContext)}` : "";
|
|
72
|
+
const publicationStr = source.publication ? `, ${this.timeTextBuilder.build(sourceContext, true)}` : "";
|
|
71
73
|
const indexStr = source.index ? `, ${source.index}` : "";
|
|
72
74
|
const authorStr = datasource.authors.map(authorStr => `<span class="people">${authorStr}</span>`).join(" & ");
|
|
73
75
|
const title = `cas n° ${nativeCase["id"]}`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HtmlRR0Context } from "../../RR0Context.js";
|
|
2
2
|
import { Datasource } from "./Datasource.js";
|
|
3
3
|
export interface FileDatasource<S> extends Datasource<S> {
|
|
4
|
-
save(context:
|
|
4
|
+
save(context: HtmlRR0Context, fetched: any[], fetchTime: Date): void;
|
|
5
5
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CaseMapper } from "./CaseMapper.js";
|
|
2
|
-
import {
|
|
3
|
-
export declare class JsonMapper<S> implements CaseMapper<
|
|
4
|
-
map(context:
|
|
2
|
+
import { RR0Context } from "../../RR0Context.js";
|
|
3
|
+
export declare class JsonMapper<S> implements CaseMapper<RR0Context, S, Object> {
|
|
4
|
+
map(context: RR0Context, sourceCase: S, sourceTime: Date): Object;
|
|
5
5
|
/**
|
|
6
6
|
* Converts CSV contents to a list of cases.
|
|
7
7
|
*
|
|
8
8
|
* @param context
|
|
9
9
|
* @param data
|
|
10
10
|
*/
|
|
11
|
-
parse(context:
|
|
11
|
+
parse(context: RR0Context, data: string): S[];
|
|
12
12
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ContextFilter } from "./ContextFilter.js";
|
|
2
|
-
import {
|
|
3
|
-
import { TimeContext } from "
|
|
2
|
+
import { RR0Context } from "../../RR0Context.js";
|
|
3
|
+
import { TimeContext } from "@rr0/time";
|
|
4
4
|
export interface TimeContextCase {
|
|
5
5
|
time?: TimeContext;
|
|
6
6
|
}
|
|
7
7
|
export declare class TimeContextFilter<S extends TimeContextCase> extends ContextFilter<S> {
|
|
8
|
-
constructor(context:
|
|
8
|
+
constructor(context: RR0Context);
|
|
9
9
|
filter(c: S): boolean;
|
|
10
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RR0Context } from "../../../RR0Context.js";
|
|
2
2
|
import { HttpSource } from "../HttpSource.js";
|
|
3
3
|
import { AcufoCase } from "./AcufoCase.js";
|
|
4
4
|
import { AbstractDatasource } from "../AbstractDatasource.js";
|
|
@@ -7,6 +7,6 @@ export declare class AcufoDatasource extends AbstractDatasource<AcufoCase> {
|
|
|
7
7
|
readonly searchPath: string;
|
|
8
8
|
protected http: HttpSource;
|
|
9
9
|
constructor(baseUrl?: string, searchPath?: string);
|
|
10
|
-
protected readCases(context:
|
|
11
|
-
protected getNativeCase(context:
|
|
10
|
+
protected readCases(context: RR0Context): Promise<AcufoCase[]>;
|
|
11
|
+
protected getNativeCase(context: RR0Context, row: Element): AcufoCase;
|
|
12
12
|
}
|