@rr0/cms 0.1.22 → 0.1.24
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/RR0Build.d.ts +0 -1
- package/dist/RR0Build.js +5 -3
- package/dist/RR0Build.test.js +8 -12
- package/dist/RR0Context.js +9 -0
- package/dist/RR0Context.test.d.ts +1 -0
- package/dist/RR0Context.test.js +23 -0
- package/package.json +3 -3
package/dist/RR0Build.d.ts
CHANGED
package/dist/RR0Build.js
CHANGED
|
@@ -6,7 +6,7 @@ import { GooglePlaceService, PlaceReplacerFactory } from "./place/index.js";
|
|
|
6
6
|
import { OrganizationFactory, OrganizationService } from "./org/index.js";
|
|
7
7
|
import { RR0ContextImpl } from "./RR0Context.js";
|
|
8
8
|
import { HtmlTable } from "./util/index.js";
|
|
9
|
-
import { AngularExpressionReplaceCommand, ClassDomReplaceCommand, CopyStep, DomReplaceCommand, HtAccessToNetlifyConfigReplaceCommand, Ssg, SsiEchoVarReplaceCommand, SsiIfReplaceCommand, SsiIncludeReplaceCommand, SsiLastModifiedReplaceCommand, SsiSetVarReplaceCommand, StringEchoVarReplaceCommand } from "ssg-api";
|
|
9
|
+
import { AngularExpressionReplaceCommand, ClassDomReplaceCommand, CopyStep, DomReplaceCommand, HtAccessToNetlifyConfigReplaceCommand, HtmlFileContents, Ssg, SsiEchoVarReplaceCommand, SsiIfReplaceCommand, SsiIncludeReplaceCommand, SsiLastModifiedReplaceCommand, SsiSetVarReplaceCommand, StringEchoVarReplaceCommand } from "ssg-api";
|
|
10
10
|
import { LanguageReplaceCommand } from "./lang/index.js";
|
|
11
11
|
import { AuthorReplaceCommand, PeopleDirectoryStepFactory, PeopleFactory, PeopleReplacerFactory, PeopleService, WitnessReplacerFactory } from "./people";
|
|
12
12
|
import { PersistentSourceRegistry, SourceFileCounter, SourceIndexStep, SourceRenderer, SourceReplacer, SourceReplacerFactory } from "./source";
|
|
@@ -31,7 +31,9 @@ import { writeFile } from "@javarome/fileutil";
|
|
|
31
31
|
import { AllDataService, RR0EventFactory, TypedDataFactory } from "@rr0/data";
|
|
32
32
|
const outputFunc = async (context, outFile) => {
|
|
33
33
|
try {
|
|
34
|
-
context.file
|
|
34
|
+
if (context.file instanceof HtmlFileContents) {
|
|
35
|
+
context.file.contents = context.file.serialize();
|
|
36
|
+
}
|
|
35
37
|
context.log("Writing", outFile.name);
|
|
36
38
|
await outFile.write();
|
|
37
39
|
context.file.contents = outFile.contents;
|
|
@@ -74,7 +76,7 @@ export class RR0Build {
|
|
|
74
76
|
}
|
|
75
77
|
async run(args) {
|
|
76
78
|
const context = this.context;
|
|
77
|
-
const timeFiles = this.options.
|
|
79
|
+
const timeFiles = this.options.timeOptions.files;
|
|
78
80
|
context.setVar("timeFilesCount", timeFiles.length);
|
|
79
81
|
const timeService = this.timeService;
|
|
80
82
|
const timeElementFactory = new TimeElementFactory(timeService.renderer);
|
package/dist/RR0Build.test.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { glob } from "glob";
|
|
2
2
|
import { describe } from "@javarome/testscript";
|
|
3
|
-
import { FileContents } from "@javarome/fileutil";
|
|
4
|
-
import { CLI } from "./util/index.js";
|
|
5
3
|
import { RR0Build } from "./RR0Build.js";
|
|
6
4
|
import { testFilePath } from "./test";
|
|
7
5
|
import * as process from "node:process";
|
|
8
6
|
describe("Build", () => {
|
|
9
7
|
console.time("ssg");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
args = JSON.parse(FileContents.read(configFile).contents);
|
|
14
|
-
}
|
|
8
|
+
const args = {
|
|
9
|
+
force: "true"
|
|
10
|
+
};
|
|
15
11
|
const cliContents = args.contents;
|
|
16
12
|
console.debug("contents", cliContents);
|
|
17
13
|
const mandatoryRoots = ["people/*.html", "science/crypto/ufo/enquete/dossier/*.html"];
|
|
@@ -53,10 +49,6 @@ describe("Build", () => {
|
|
|
53
49
|
if (!googleMapsApiKey) {
|
|
54
50
|
throw Error("GOOGLE_MAPS_API_KEY is required");
|
|
55
51
|
}
|
|
56
|
-
const timeOptions = {
|
|
57
|
-
root: testFilePath("time"),
|
|
58
|
-
files: []
|
|
59
|
-
};
|
|
60
52
|
const timeFormat = {
|
|
61
53
|
year: "numeric",
|
|
62
54
|
month: "long",
|
|
@@ -97,9 +89,13 @@ describe("Build", () => {
|
|
|
97
89
|
const sourceRegistryFileName = testFilePath("source/index.json");
|
|
98
90
|
const siteBaseUrl = "https://rr0.org/";
|
|
99
91
|
const mail = "rr0@rr0.org";
|
|
92
|
+
const timeOptions = {
|
|
93
|
+
root: testFilePath("time"),
|
|
94
|
+
files: timeFiles
|
|
95
|
+
};
|
|
100
96
|
const build = new RR0Build({
|
|
101
97
|
contentRoots, copies, outDir, locale: "fr", googleMapsApiKey, mail, timeOptions,
|
|
102
|
-
siteBaseUrl, timeFormat,
|
|
98
|
+
siteBaseUrl, timeFormat, directoryPages,
|
|
103
99
|
ufoCaseDirectoryFile: testFilePath("science/crypto/ufo/enquete/dossier/index.html"),
|
|
104
100
|
ufoCasesExclusions: ["science/crypto/ufo/enquete/dossier/canular"].map(testFilePath),
|
|
105
101
|
sourceRegistryFileName,
|
package/dist/RR0Context.js
CHANGED
|
@@ -9,6 +9,15 @@ export class RR0ContextImpl extends SsgContextImpl {
|
|
|
9
9
|
this.messages = messages;
|
|
10
10
|
this.images = new Set();
|
|
11
11
|
this.fileMap = new Map();
|
|
12
|
+
while (!this.messages) {
|
|
13
|
+
if (locale.length > 2) {
|
|
14
|
+
locale = locale.substring(0, 2); // Fallback to language without country specifics
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
locale = "fr"; // Default language
|
|
18
|
+
}
|
|
19
|
+
this.messages = ssgMessages[locale];
|
|
20
|
+
}
|
|
12
21
|
}
|
|
13
22
|
read(filePath) {
|
|
14
23
|
let file = this.fileMap.get(filePath);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, test } from "@javarome/testscript";
|
|
2
|
+
import { rr0TestUtil } from "./test";
|
|
3
|
+
import { ssgMessages } from "./lang";
|
|
4
|
+
describe("RROContextImpl", () => {
|
|
5
|
+
describe("constructor with locale", () => {
|
|
6
|
+
test("default locale", () => {
|
|
7
|
+
const context = rr0TestUtil.time.newHtmlContext("test.html", "");
|
|
8
|
+
expect(context.locale).toBe("fr");
|
|
9
|
+
});
|
|
10
|
+
test("supported locale", () => {
|
|
11
|
+
const context = rr0TestUtil.time.newHtmlContext("test.html", "", "en");
|
|
12
|
+
expect(context.locale).toBe("en");
|
|
13
|
+
});
|
|
14
|
+
test("locale fallback to lang only", () => {
|
|
15
|
+
const context = rr0TestUtil.time.newHtmlContext("test.html", "", "en-US");
|
|
16
|
+
expect(context.messages).toEqual(ssgMessages["en"]);
|
|
17
|
+
});
|
|
18
|
+
test("locale fallback to default", () => {
|
|
19
|
+
const context = rr0TestUtil.time.newHtmlContext("test.html", "", "xx");
|
|
20
|
+
expect(context.messages).toEqual(ssgMessages["fr"]);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
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.1.
|
|
5
|
+
"version": "0.1.24",
|
|
6
6
|
"description": "RR0 Content Management System (CMS)",
|
|
7
7
|
"exports": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"build": "rm -Rf dist && tsc --project tsconfig.prod.json",
|
|
24
24
|
"prepublishOnly": "npm run build",
|
|
25
25
|
"test": "testscript",
|
|
26
|
-
"test-one": "rm -Rf out && tsx src/
|
|
26
|
+
"test-one": "rm -Rf out && tsx src/RR0Context.test.ts",
|
|
27
27
|
"test-ci": "rm -Rf out && testscript"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@googlemaps/google-maps-services-js": "^3.4.0",
|
|
31
31
|
"@rr0/common": "^1.1.3",
|
|
32
32
|
"@rr0/lang": "^0.1.12",
|
|
33
|
-
"@rr0/time": "^0.8.
|
|
33
|
+
"@rr0/time": "^0.8.5",
|
|
34
34
|
"@rr0/place": "^0.3.2",
|
|
35
35
|
"@rr0/data": "^0.1.2",
|
|
36
36
|
"@javarome/fileutil": "^0.3.6",
|