@rr0/cms 0.1.13 → 0.1.15
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/README.md +2 -0
- 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/lang/form.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/Australia_en.d.ts +1 -1
- package/dist/org/au/Australia_fr.d.ts +1 -1
- package/dist/org/au/region/index.d.ts +4 -4
- package/dist/org/au/region/index.js +4 -4
- package/dist/org/au/region/nsw/NewSouthWalesMessages_en.d.ts +2 -2
- package/dist/org/au/region/nsw/NewSouthWalesMessages_en.js +2 -2
- package/dist/org/au/region/nsw/NewSouthWalesMessages_fr.d.ts +2 -2
- package/dist/org/au/region/nsw/NewSouthWalesMessages_fr.js +2 -2
- package/dist/org/au/region/nsw/index.d.ts +1 -1
- package/dist/org/au/region/nsw/index.js +1 -1
- 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/eu/fr/region/idf/77/SeineEtMarneCities.js +1 -1
- package/dist/org/eu/fr/region/idf/77/SeineEtMarneMessages.js +1 -1
- package/dist/org/eu/fr/region/idf/77/SivryCourtry/index.d.ts +2 -0
- package/dist/org/eu/fr/region/idf/77/SivryCourtry/index.js +2 -0
- package/dist/org/eu/fr/region/idf/77/index.d.ts +5 -0
- package/dist/org/eu/fr/region/idf/77/index.js +5 -0
- 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/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 +15 -12
- 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/org/eu/fr/region/idf/77/{paris → SivryCourtry}/SivryCourtry.d.ts +0 -0
- /package/dist/org/eu/fr/region/idf/77/{paris → SivryCourtry}/SivryCourtry.js +0 -0
- /package/dist/org/eu/fr/region/idf/77/{paris → SivryCourtry}/SivryCourtryMessages.d.ts +0 -0
- /package/dist/org/eu/fr/region/idf/77/{paris → SivryCourtry}/SivryCourtryMessages.js +0 -0
- /package/dist/{place/PlaceMessages.js → time/datasource/rr0/NamedPlace.js} +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
export class RelativeTimeTextBuilder {
|
|
2
|
+
constructor(timeTextBuilder) {
|
|
3
|
+
this.timeTextBuilder = timeTextBuilder;
|
|
4
|
+
}
|
|
5
|
+
build(oldContext, newContext) {
|
|
6
|
+
let text;
|
|
7
|
+
let print = true;
|
|
8
|
+
const previousTime = oldContext === null || oldContext === void 0 ? void 0 : oldContext.time;
|
|
9
|
+
if (previousTime === null || previousTime === void 0 ? void 0 : previousTime.isDefined()) {
|
|
10
|
+
const deltaContext = oldContext.clone();
|
|
11
|
+
const deltaTime = deltaContext.time;
|
|
12
|
+
let dayOfMonthDelta;
|
|
13
|
+
let yearDelta;
|
|
14
|
+
let monthDelta;
|
|
15
|
+
let hourDelta;
|
|
16
|
+
let minutesDelta;
|
|
17
|
+
function shouldSetDay() {
|
|
18
|
+
return !previousTime.getMonth() || monthDelta === 0;
|
|
19
|
+
}
|
|
20
|
+
function shouldSetHour() {
|
|
21
|
+
return !previousTime.getDayOfMonth() || dayOfMonthDelta === 0;
|
|
22
|
+
}
|
|
23
|
+
function shouldSetMinutes() {
|
|
24
|
+
return !previousTime.getMinutes() || hourDelta === 0;
|
|
25
|
+
}
|
|
26
|
+
function setYear(year) {
|
|
27
|
+
const previousYear = previousTime.getYear();
|
|
28
|
+
if (previousYear) {
|
|
29
|
+
yearDelta = year - previousYear;
|
|
30
|
+
if (yearDelta != 0) {
|
|
31
|
+
deltaTime.setYear(year);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function setMonth(month) {
|
|
36
|
+
const previousMonth = previousTime.getMonth();
|
|
37
|
+
if (yearDelta === 0) {
|
|
38
|
+
monthDelta = month - (previousMonth || 0);
|
|
39
|
+
if (monthDelta != 0) {
|
|
40
|
+
deltaTime.setMonth(month);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if (yearDelta != 0) {
|
|
44
|
+
deltaTime.setMonth(month);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function setDayOfMonth(dayOfMonth) {
|
|
48
|
+
const sameMonth = yearDelta === 0 && shouldSetDay();
|
|
49
|
+
if (sameMonth) {
|
|
50
|
+
dayOfMonthDelta = dayOfMonth - (previousTime.getDayOfMonth() || 0);
|
|
51
|
+
if (dayOfMonthDelta != 0) {
|
|
52
|
+
deltaTime.setDayOfMonth(dayOfMonth);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (monthDelta != 0) {
|
|
56
|
+
deltaTime.setDayOfMonth(dayOfMonth);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function setHour(hour) {
|
|
60
|
+
const sameDay = yearDelta === 0 && shouldSetDay() && shouldSetHour();
|
|
61
|
+
if (sameDay) {
|
|
62
|
+
hourDelta = hour - (previousTime.getHour() || 0);
|
|
63
|
+
if (hourDelta != 0) {
|
|
64
|
+
deltaTime.setHour(hour);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (dayOfMonthDelta != 0) {
|
|
68
|
+
deltaTime.setHour(hour);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function setMinutes(minutes) {
|
|
72
|
+
const sameHour = yearDelta === 0 && shouldSetDay() && shouldSetHour() && shouldSetMinutes();
|
|
73
|
+
if (sameHour) {
|
|
74
|
+
minutesDelta = minutes - (previousTime.getMinutes() || 0);
|
|
75
|
+
if (minutesDelta != 0) {
|
|
76
|
+
deltaTime.setMinutes(minutes);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
deltaTime.setMinutes(minutes);
|
|
80
|
+
}
|
|
81
|
+
const time = newContext.time;
|
|
82
|
+
const year = time.getYear();
|
|
83
|
+
if (year) {
|
|
84
|
+
setYear(year);
|
|
85
|
+
}
|
|
86
|
+
const month = time.getMonth();
|
|
87
|
+
if (month) {
|
|
88
|
+
setMonth(month);
|
|
89
|
+
}
|
|
90
|
+
const dayOfMonth = time.getDayOfMonth();
|
|
91
|
+
if (dayOfMonth) {
|
|
92
|
+
setDayOfMonth(dayOfMonth);
|
|
93
|
+
}
|
|
94
|
+
const hour = time.getHour();
|
|
95
|
+
if (hour) {
|
|
96
|
+
setHour(hour);
|
|
97
|
+
}
|
|
98
|
+
const minutes = time.getMinutes();
|
|
99
|
+
if (minutes) {
|
|
100
|
+
setMinutes(minutes);
|
|
101
|
+
}
|
|
102
|
+
let messages = newContext.messages.context.time.relative;
|
|
103
|
+
if (dayOfMonthDelta) {
|
|
104
|
+
switch (dayOfMonthDelta) {
|
|
105
|
+
case -1:
|
|
106
|
+
text = messages.day.before;
|
|
107
|
+
break;
|
|
108
|
+
case +1:
|
|
109
|
+
text = messages.day.after;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
if (!dayOfMonth) {
|
|
115
|
+
switch (monthDelta) {
|
|
116
|
+
case -1:
|
|
117
|
+
text = messages.month.before;
|
|
118
|
+
break;
|
|
119
|
+
case +1:
|
|
120
|
+
text = messages.month.after;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (!month) {
|
|
125
|
+
switch (yearDelta) {
|
|
126
|
+
case -1:
|
|
127
|
+
text = messages.year.before;
|
|
128
|
+
break;
|
|
129
|
+
case +1:
|
|
130
|
+
text = messages.year.after;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (!minutes) {
|
|
135
|
+
switch (hourDelta) {
|
|
136
|
+
case -1:
|
|
137
|
+
text = messages.hour.before;
|
|
138
|
+
break;
|
|
139
|
+
case +1:
|
|
140
|
+
text = messages.hour.after;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (!text) {
|
|
146
|
+
let defaultContext;
|
|
147
|
+
if (deltaContext.time.isDefined()) {
|
|
148
|
+
defaultContext = deltaContext;
|
|
149
|
+
const dayOfMonth = defaultContext.time.getDayOfMonth();
|
|
150
|
+
if (dayOfMonth && shouldSetDay()) {
|
|
151
|
+
defaultContext.time.setMonth(newContext.time.getMonth() || previousTime.getMonth(), false); // give month
|
|
152
|
+
defaultContext.time.setYear(newContext.time.getYear() || previousTime.getYear(), false); // give year
|
|
153
|
+
// context for the day but won't
|
|
154
|
+
print = false;
|
|
155
|
+
}
|
|
156
|
+
newContext = defaultContext;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (!text) {
|
|
161
|
+
text = this.timeTextBuilder.build(newContext, print);
|
|
162
|
+
}
|
|
163
|
+
return text;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RR0Context } from "../../RR0Context.js";
|
|
2
2
|
export declare class TimeTextBuilder {
|
|
3
3
|
readonly options: Intl.DateTimeFormatOptions;
|
|
4
4
|
constructor(options: Intl.DateTimeFormatOptions);
|
|
@@ -9,5 +9,5 @@ export declare class TimeTextBuilder {
|
|
|
9
9
|
* @param print
|
|
10
10
|
* @param options
|
|
11
11
|
*/
|
|
12
|
-
build(context:
|
|
12
|
+
build(context: RR0Context, print: boolean, options?: Intl.DateTimeFormatOptions): string;
|
|
13
13
|
}
|
|
@@ -9,7 +9,7 @@ export class TimeTextBuilder {
|
|
|
9
9
|
* @param print
|
|
10
10
|
* @param options
|
|
11
11
|
*/
|
|
12
|
-
build(context, print
|
|
12
|
+
build(context, print, options = this.options) {
|
|
13
13
|
const time = context.time;
|
|
14
14
|
const printOptions = {};
|
|
15
15
|
const date = new Date(undefined, undefined, undefined);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DomReplaceCommand, DomReplacer } from "ssg-api";
|
|
2
|
-
import {
|
|
2
|
+
import { HtmlRR0Context } from "../RR0Context.js";
|
|
3
3
|
/**
|
|
4
4
|
* Register images (`<img>` tags) required in an HTML file.
|
|
5
5
|
*/
|
|
6
6
|
export declare class UnitReplaceCommand extends DomReplaceCommand {
|
|
7
7
|
constructor();
|
|
8
|
-
protected createReplacer(context:
|
|
8
|
+
protected createReplacer(context: HtmlRR0Context): Promise<DomReplacer>;
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rr0/cms",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"author": "rr0@rr0.org",
|
|
5
|
-
"version": "0.1.
|
|
6
|
-
"description": "Content Management System",
|
|
4
|
+
"author": "Jérôme Beau <rr0@rr0.org> (https://rr0.org)",
|
|
5
|
+
"version": "0.1.15",
|
|
6
|
+
"description": "RR0 Content Management System (CMS)",
|
|
7
7
|
"exports": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"engines": {
|
|
10
10
|
"node": ">=20"
|
|
11
11
|
},
|
|
12
12
|
"license": "MIT",
|
|
13
|
-
"homepage": "https://github.com/RR0/cms",
|
|
13
|
+
"homepage": "https://github.com/RR0/cms#readme",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git+https://github.com/RR0/cms.git"
|
|
@@ -20,34 +20,37 @@
|
|
|
20
20
|
"build": "rm -Rf dist && tsc --project tsconfig.prod.json",
|
|
21
21
|
"prepublishOnly": "npm run build",
|
|
22
22
|
"test": "testscript",
|
|
23
|
-
"test-one": "rm -Rf out && tsx src/time/
|
|
23
|
+
"test-one": "rm -Rf out && tsx src/time/RelativeTimeTextBuilder.test.ts",
|
|
24
24
|
"test-ci": "rm -Rf out && testscript"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@googlemaps/google-maps-services-js": "^3.4.0",
|
|
28
|
-
"@rr0/common": "^1.
|
|
29
|
-
"@rr0/lang": "^0.1.
|
|
30
|
-
"@rr0/time": "^0.
|
|
28
|
+
"@rr0/common": "^1.1.3",
|
|
29
|
+
"@rr0/lang": "^0.1.12",
|
|
30
|
+
"@rr0/time": "^0.7.7",
|
|
31
|
+
"@rr0/place": "^0.3.1",
|
|
31
32
|
"canvas": "^2.11.2",
|
|
32
33
|
"csv-parser": "^3.0.0",
|
|
33
34
|
"glob": "^11.0.0",
|
|
34
35
|
"image-size": "^1.1.1",
|
|
35
36
|
"jsdom": "^24.1.0",
|
|
36
37
|
"selenium-webdriver": "^4.22.0",
|
|
37
|
-
"ssg-api": "^1.16.
|
|
38
|
+
"ssg-api": "^1.16.3"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@types/jsdom": "^21.1.7",
|
|
41
|
-
"typescript": "^5.
|
|
42
|
+
"typescript": "^5.6.3",
|
|
42
43
|
"@types/node": "^22.7.4",
|
|
43
44
|
"tsx": "4.17.0",
|
|
44
|
-
"@javarome/testscript": "^0.
|
|
45
|
+
"@javarome/testscript": "^0.13.0"
|
|
45
46
|
},
|
|
46
47
|
"keywords": [
|
|
47
48
|
"cms",
|
|
48
49
|
"time",
|
|
49
50
|
"place",
|
|
50
|
-
"
|
|
51
|
+
"people",
|
|
52
|
+
"organization",
|
|
53
|
+
"event"
|
|
51
54
|
],
|
|
52
55
|
"publishConfig": {
|
|
53
56
|
"access": "public"
|
package/tsconfig.json
CHANGED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { RR0SsgContext } from "../RR0SsgContext.js";
|
|
2
|
-
export type DMS = {
|
|
3
|
-
deg: number;
|
|
4
|
-
min: number;
|
|
5
|
-
sec: number;
|
|
6
|
-
positive: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare class PlaceLocation {
|
|
9
|
-
readonly lat: number;
|
|
10
|
-
readonly lng: number;
|
|
11
|
-
static readonly DMS_PATTERN: RegExp;
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {float} lat Latitude in decimal degrees. North is positive.
|
|
15
|
-
* @param {float} lng Longitude in decimal degrees. East is positive.
|
|
16
|
-
*/
|
|
17
|
-
constructor(lat: number, lng: number);
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param dms A string with deg°minutes"seconds'N|S|E|O format
|
|
21
|
-
*/
|
|
22
|
-
static fromDMS(dms: string): PlaceLocation;
|
|
23
|
-
static fromDouble(double: number): DMS;
|
|
24
|
-
protected static toDouble(m: RegExpExecArray, offset: number): number;
|
|
25
|
-
toDMS(context: RR0SsgContext): string;
|
|
26
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
export class PlaceLocation {
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {float} lat Latitude in decimal degrees. North is positive.
|
|
6
|
-
* @param {float} lng Longitude in decimal degrees. East is positive.
|
|
7
|
-
*/
|
|
8
|
-
constructor(lat, lng) {
|
|
9
|
-
this.lat = lat;
|
|
10
|
-
this.lng = lng;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param dms A string with deg°minutes"seconds'N|S|E|O format
|
|
15
|
-
*/
|
|
16
|
-
static fromDMS(dms) {
|
|
17
|
-
const m = PlaceLocation.DMS_PATTERN.exec(dms.trim());
|
|
18
|
-
assert.ok(m, `Malformed degrees/minutes/seconds/direction coordinates in "${dms}"`);
|
|
19
|
-
const latitude = PlaceLocation.toDouble(m, 0);
|
|
20
|
-
const longitude = PlaceLocation.toDouble(m, 5);
|
|
21
|
-
assert.ok(Math.abs(latitude) <= 90, `Invalid latitude ${latitude}`);
|
|
22
|
-
assert.ok(Math.abs(longitude) <= 180, `Invalid longitude ${longitude}`);
|
|
23
|
-
return new PlaceLocation(latitude, longitude);
|
|
24
|
-
}
|
|
25
|
-
static fromDouble(double) {
|
|
26
|
-
const positive = double >= 0;
|
|
27
|
-
const value = Math.abs(double);
|
|
28
|
-
const deg = Math.trunc(value);
|
|
29
|
-
const minFloat = (value - deg) * 60;
|
|
30
|
-
const min = Math.trunc(minFloat);
|
|
31
|
-
const sec = Math.round((minFloat - min) * 60);
|
|
32
|
-
return { deg, min, sec, positive };
|
|
33
|
-
}
|
|
34
|
-
static toDouble(m, offset) {
|
|
35
|
-
const sign = "" === m[1 + offset] ? 1 : -1;
|
|
36
|
-
const degrees = parseFloat(m[2 + offset]);
|
|
37
|
-
const minutes = parseFloat(m[3 + offset]) || 0;
|
|
38
|
-
const seconds = parseFloat(m[4 + offset]) || 0;
|
|
39
|
-
const direction = "NE".includes(m[5 + offset]) ? 1 : -1;
|
|
40
|
-
return sign * direction * (degrees + minutes / 60 + seconds / 3600);
|
|
41
|
-
}
|
|
42
|
-
toDMS(context) {
|
|
43
|
-
const placeMsg = context.messages.place;
|
|
44
|
-
return placeMsg.dmsLat(PlaceLocation.fromDouble(this.lat)) + ","
|
|
45
|
-
+ placeMsg.dmsLng(PlaceLocation.fromDouble(this.lng));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
PlaceLocation.DMS_PATTERN = /(-?)([0-9]{1,2})°\s*([0-5]?[0-9])[′'](?:\s*([0-5]?[0-9])[″"])?\s*([NS])\s*[, ]\s*(-?)([0-1]?[0-9]{1,2})°\s*([0-9]?[0-9])[′'](?:\s*([0-5]?[0-9])["″])?\s*([EWO])/;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
export class RelativeTimeTextBuilder {
|
|
2
|
-
constructor(timeTextBuilder) {
|
|
3
|
-
this.timeTextBuilder = timeTextBuilder;
|
|
4
|
-
}
|
|
5
|
-
build(oldContext, newContext) {
|
|
6
|
-
const previousTime = oldContext === null || oldContext === void 0 ? void 0 : oldContext.time;
|
|
7
|
-
if (!(previousTime === null || previousTime === void 0 ? void 0 : previousTime.isDefined())) {
|
|
8
|
-
return this.timeTextBuilder.build(newContext);
|
|
9
|
-
}
|
|
10
|
-
const deltaContext = oldContext.clone();
|
|
11
|
-
const deltaTime = deltaContext.time;
|
|
12
|
-
let dayOfMonthDelta;
|
|
13
|
-
let yearDelta;
|
|
14
|
-
let monthDelta;
|
|
15
|
-
let hourDelta;
|
|
16
|
-
let minutesDelta;
|
|
17
|
-
function shouldSetDay() {
|
|
18
|
-
return !previousTime.getMonth() || monthDelta === 0;
|
|
19
|
-
}
|
|
20
|
-
function shouldSetHour() {
|
|
21
|
-
return !previousTime.getDayOfMonth() || dayOfMonthDelta === 0;
|
|
22
|
-
}
|
|
23
|
-
function shouldSetMinutes() {
|
|
24
|
-
return !previousTime.getMinutes() || hourDelta === 0;
|
|
25
|
-
}
|
|
26
|
-
function setYear(year) {
|
|
27
|
-
const previousYear = previousTime.getYear();
|
|
28
|
-
if (previousYear) {
|
|
29
|
-
yearDelta = year - previousYear;
|
|
30
|
-
if (yearDelta != 0) {
|
|
31
|
-
deltaTime.setYear(year);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function setMonth(month) {
|
|
36
|
-
const previousMonth = previousTime.getMonth();
|
|
37
|
-
if (yearDelta === 0) {
|
|
38
|
-
monthDelta = month - (previousMonth || 0);
|
|
39
|
-
if (monthDelta != 0) {
|
|
40
|
-
deltaTime.setMonth(month);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else if (yearDelta != 0) {
|
|
44
|
-
deltaTime.setMonth(month);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function setDayOfMonth(dayOfMonth) {
|
|
48
|
-
const sameMonth = yearDelta === 0 && shouldSetDay();
|
|
49
|
-
if (sameMonth) {
|
|
50
|
-
dayOfMonthDelta = dayOfMonth - (previousTime.getDayOfMonth() || 0);
|
|
51
|
-
if (dayOfMonthDelta != 0) {
|
|
52
|
-
deltaTime.setDayOfMonth(dayOfMonth);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else if (monthDelta != 0) {
|
|
56
|
-
deltaTime.setDayOfMonth(dayOfMonth);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function setHour(hour) {
|
|
60
|
-
const sameDay = yearDelta === 0 && shouldSetDay() && shouldSetHour();
|
|
61
|
-
if (sameDay) {
|
|
62
|
-
hourDelta = hour - (previousTime.getHour() || 0);
|
|
63
|
-
if (hourDelta != 0) {
|
|
64
|
-
deltaTime.setHour(hour);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
else if (dayOfMonthDelta != 0) {
|
|
68
|
-
deltaTime.setHour(hour);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function setMinutes(minutes) {
|
|
72
|
-
const sameHour = yearDelta === 0 && shouldSetDay() && shouldSetHour() && shouldSetMinutes();
|
|
73
|
-
if (sameHour) {
|
|
74
|
-
minutesDelta = minutes - (previousTime.getMinutes() || 0);
|
|
75
|
-
if (minutesDelta != 0) {
|
|
76
|
-
deltaTime.setMinutes(minutes);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
deltaTime.setMinutes(minutes);
|
|
80
|
-
}
|
|
81
|
-
const time = newContext.time;
|
|
82
|
-
const year = time.getYear();
|
|
83
|
-
if (year) {
|
|
84
|
-
setYear(year);
|
|
85
|
-
}
|
|
86
|
-
const month = time.getMonth();
|
|
87
|
-
if (month) {
|
|
88
|
-
setMonth(month);
|
|
89
|
-
}
|
|
90
|
-
const dayOfMonth = time.getDayOfMonth();
|
|
91
|
-
if (dayOfMonth) {
|
|
92
|
-
setDayOfMonth(dayOfMonth);
|
|
93
|
-
}
|
|
94
|
-
const hour = time.getHour();
|
|
95
|
-
if (hour) {
|
|
96
|
-
setHour(hour);
|
|
97
|
-
}
|
|
98
|
-
const minutes = time.getMinutes();
|
|
99
|
-
if (minutes) {
|
|
100
|
-
setMinutes(minutes);
|
|
101
|
-
}
|
|
102
|
-
let text;
|
|
103
|
-
let messages = newContext.messages.context.time.relative;
|
|
104
|
-
if (dayOfMonthDelta) {
|
|
105
|
-
switch (dayOfMonthDelta) {
|
|
106
|
-
case -1:
|
|
107
|
-
text = messages.day.before;
|
|
108
|
-
break;
|
|
109
|
-
case +1:
|
|
110
|
-
text = messages.day.after;
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
if (!dayOfMonth) {
|
|
116
|
-
switch (monthDelta) {
|
|
117
|
-
case -1:
|
|
118
|
-
text = messages.month.before;
|
|
119
|
-
break;
|
|
120
|
-
case +1:
|
|
121
|
-
text = messages.month.after;
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (!month) {
|
|
126
|
-
switch (yearDelta) {
|
|
127
|
-
case -1:
|
|
128
|
-
text = messages.year.before;
|
|
129
|
-
break;
|
|
130
|
-
case +1:
|
|
131
|
-
text = messages.year.after;
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (!minutes) {
|
|
136
|
-
switch (hourDelta) {
|
|
137
|
-
case -1:
|
|
138
|
-
text = messages.hour.before;
|
|
139
|
-
break;
|
|
140
|
-
case +1:
|
|
141
|
-
text = messages.hour.after;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (!text) {
|
|
147
|
-
let print = true;
|
|
148
|
-
let defaultContext;
|
|
149
|
-
if (deltaContext.time.isDefined()) {
|
|
150
|
-
defaultContext = deltaContext;
|
|
151
|
-
const dayOfMonth = defaultContext.time.getDayOfMonth();
|
|
152
|
-
if (dayOfMonth && shouldSetDay()) {
|
|
153
|
-
defaultContext.time.setMonth(newContext.time.getMonth() || previousTime.getMonth(), false); // give month
|
|
154
|
-
defaultContext.time.setYear(newContext.time.getYear() || previousTime.getYear(), false); // give year
|
|
155
|
-
// context for the day but won't
|
|
156
|
-
print = false;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
defaultContext = newContext;
|
|
161
|
-
}
|
|
162
|
-
text = this.timeTextBuilder.build(defaultContext, print);
|
|
163
|
-
}
|
|
164
|
-
return text;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { HtmlRR0SsgContext } from "../RR0SsgContext.js";
|
|
2
|
-
import { TimeParseResult } from "./TimeReplacer.js";
|
|
3
|
-
import { Level2Date as EdtfDate, Level2Duration as EdtfDuration, Level2Interval as EdtfInterval } from "@rr0/time";
|
|
4
|
-
/**
|
|
5
|
-
* Time context for a RR0 page.
|
|
6
|
-
*/
|
|
7
|
-
export declare class TimeContext {
|
|
8
|
-
static readonly dateTimeRegexp: RegExp;
|
|
9
|
-
static readonly MINUTE = 60;
|
|
10
|
-
static readonly HOUR: number;
|
|
11
|
-
static readonly DAY: number;
|
|
12
|
-
date: EdtfDate | undefined;
|
|
13
|
-
interval: EdtfInterval | undefined;
|
|
14
|
-
duration: EdtfDuration | undefined;
|
|
15
|
-
constructor(_year?: number, _month?: number, _dayOfMonth?: number, _hour?: number, _minutes?: number, _timeZone?: string, approximate?: boolean, approximateTime?: boolean,
|
|
16
|
-
/** @deprecated */
|
|
17
|
-
from?: TimeContext | undefined,
|
|
18
|
-
/** @deprecated */
|
|
19
|
-
to?: TimeContext | undefined, duration?: number | undefined);
|
|
20
|
-
get from(): EdtfDate | undefined;
|
|
21
|
-
get to(): EdtfDate | undefined;
|
|
22
|
-
get approximate(): boolean;
|
|
23
|
-
set approximate(approx: boolean);
|
|
24
|
-
get approximateTime(): boolean;
|
|
25
|
-
static parseDateTime(timeStr: string): TimeParseResult;
|
|
26
|
-
static fromString(timeStr: string): TimeContext;
|
|
27
|
-
static fromDate(date: Date): TimeContext;
|
|
28
|
-
static fromFileName(context: HtmlRR0SsgContext, fileName?: string): TimeContext | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* @param {string} timeStr
|
|
31
|
-
* @return If the string could be parsed
|
|
32
|
-
*/
|
|
33
|
-
updateFromStr(timeStr: string): boolean;
|
|
34
|
-
getYear(): number | undefined;
|
|
35
|
-
setYear(year: number | undefined, print?: boolean): this;
|
|
36
|
-
getMonth(): number | undefined;
|
|
37
|
-
setMonth(month: number | undefined, print?: boolean): this;
|
|
38
|
-
getDayOfMonth(): number | undefined;
|
|
39
|
-
setDayOfMonth(dayOfMonth: number | undefined, print?: boolean): this;
|
|
40
|
-
getHour(): number | undefined;
|
|
41
|
-
setHour(hour: number | undefined, print?: boolean): this;
|
|
42
|
-
getMinutes(): number | undefined;
|
|
43
|
-
setMinutes(minutes: number | undefined): this;
|
|
44
|
-
/**
|
|
45
|
-
* @deprecated
|
|
46
|
-
*/
|
|
47
|
-
getTimeZone(): string | undefined;
|
|
48
|
-
getTimeshift(): string | undefined;
|
|
49
|
-
setTimeZone(timeZone: string | undefined): this;
|
|
50
|
-
isDefined(): boolean;
|
|
51
|
-
clone(): TimeContext;
|
|
52
|
-
reset(): this;
|
|
53
|
-
isBefore(other: TimeContext): boolean;
|
|
54
|
-
isAfter(other: TimeContext): boolean;
|
|
55
|
-
equals(other: TimeContext): boolean;
|
|
56
|
-
toString(): string;
|
|
57
|
-
toJSON(): string;
|
|
58
|
-
protected isSet(value: any): boolean;
|
|
59
|
-
}
|