@rr0/cms 0.3.53 → 0.3.55
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.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpSource, RR0CaseMapping, TimeElementFactory, TimeRenderer, TimeReplacer, TimeService, TimeTextBuilder, TimeUrlBuilder } from "./time/index.js";
|
|
2
|
-
import { CaseFactory } from "./science/crypto/ufo/enquete/dossier/index.js";
|
|
2
|
+
import { CaseDirectoryStep, CaseFactory, CaseService } from "./science/crypto/ufo/enquete/dossier/index.js";
|
|
3
3
|
import { CityService, DepartmentService, OrganizationService } from "./org/index.js";
|
|
4
4
|
import { HtmlRR0Context, RR0ContextImpl } from "./RR0Context.js";
|
|
5
5
|
import { FileWriteConfig, ReplaceCommand } from "ssg-api";
|
|
@@ -96,5 +96,8 @@ export declare class CMSGenerator implements CMSContext {
|
|
|
96
96
|
copies: string[];
|
|
97
97
|
}>;
|
|
98
98
|
private setupNotes;
|
|
99
|
-
|
|
99
|
+
protected setupCases(timeElementFactory: TimeElementFactory): Promise<{
|
|
100
|
+
caseService: CaseService;
|
|
101
|
+
ufoCasesStep: CaseDirectoryStep;
|
|
102
|
+
}>;
|
|
100
103
|
}
|
package/dist/CMSGenerator.js
CHANGED
|
@@ -25,6 +25,7 @@ import { GooglePlaceService } from "@rr0/place";
|
|
|
25
25
|
import { PeopleHtmlRenderer } from "./people/PeopleHtmlRenderer.js";
|
|
26
26
|
import { CountryService } from "./org/country/CountryService.js";
|
|
27
27
|
import { TimeContext } from "./time/TimeContext.mjs";
|
|
28
|
+
import { IndexDirectoryStep } from "./IndexDirectoryStep.js";
|
|
28
29
|
const outputFunc = async (context, outFile) => {
|
|
29
30
|
try {
|
|
30
31
|
if (context.file instanceof HtmlFileContents) {
|
|
@@ -146,9 +147,8 @@ export class CMSGenerator {
|
|
|
146
147
|
outputFunc, fileVisitors: [], contentVisitors: [], force, name: "content includes", toProcess
|
|
147
148
|
};
|
|
148
149
|
const includeStep = new RR0ContentStep(contentStepOptions, timeService);
|
|
149
|
-
|
|
150
|
-
ssg.add(ufoCasesStep);
|
|
151
|
-
ssg.add(...peopleSteps);
|
|
150
|
+
const defaultDirectoryStep = new IndexDirectoryStep(contentRoots, [], `<ul></ul>`, outputFunc, config);
|
|
151
|
+
ssg.add(includeStep, ufoCasesStep, ...peopleSteps, defaultDirectoryStep);
|
|
152
152
|
if (contentRoots) {
|
|
153
153
|
const dataContentVisitor = new DataContentVisitor(dataService, caseRenderer, timeElementFactory);
|
|
154
154
|
const contentVisitors = [dataContentVisitor, searchVisitor];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DirectoryStep, FileWriteConfig, OutputFunc } from "ssg-api";
|
|
2
|
+
import { HtmlRR0Context, RR0Context } from "./RR0Context.js";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a directory index.
|
|
5
|
+
*/
|
|
6
|
+
export declare class IndexDirectoryStep extends DirectoryStep {
|
|
7
|
+
protected outputFunc: OutputFunc;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param rootDirs The directories where UFO cases info can be found.
|
|
11
|
+
* @param excludedDirs The directories to exclude from the UFO case directory search.
|
|
12
|
+
* @param templateFileName The template of the directory page to build.
|
|
13
|
+
* @param outputFunc
|
|
14
|
+
* @param config
|
|
15
|
+
*/
|
|
16
|
+
constructor(rootDirs: string[], excludedDirs: string[], templateFileName: string, outputFunc: OutputFunc, config: FileWriteConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Convert an array of Case[] to an <ul> HTML unordered list.
|
|
19
|
+
*
|
|
20
|
+
* @param context
|
|
21
|
+
* @param cases
|
|
22
|
+
*/
|
|
23
|
+
protected toList(context: HtmlRR0Context, cases: any[]): HTMLUListElement;
|
|
24
|
+
/**
|
|
25
|
+
* Convert a Case object to an HTML list item.
|
|
26
|
+
*
|
|
27
|
+
* @param context
|
|
28
|
+
* @param dirCase
|
|
29
|
+
*/
|
|
30
|
+
protected toListItem(context: HtmlRR0Context, dirCase: any): HTMLLIElement;
|
|
31
|
+
protected processDirs(context: HtmlRR0Context, dirNames: string[]): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Read case JSON files contents and instantiate them as Case objects.
|
|
34
|
+
*
|
|
35
|
+
* @param context
|
|
36
|
+
* @param dirNames The directories to look for case.json files.
|
|
37
|
+
*/
|
|
38
|
+
protected scan(context: RR0Context, dirNames: string[]): Promise<any[]>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { DirectoryStep } from "ssg-api";
|
|
2
|
+
import { StringUtil } from "./util/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a directory index.
|
|
5
|
+
*/
|
|
6
|
+
export class IndexDirectoryStep extends DirectoryStep {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param rootDirs The directories where UFO cases info can be found.
|
|
10
|
+
* @param excludedDirs The directories to exclude from the UFO case directory search.
|
|
11
|
+
* @param templateFileName The template of the directory page to build.
|
|
12
|
+
* @param outputFunc
|
|
13
|
+
* @param config
|
|
14
|
+
*/
|
|
15
|
+
constructor(rootDirs, excludedDirs, templateFileName, outputFunc, config) {
|
|
16
|
+
super({ rootDirs, excludedDirs, templateFileName, getOutputPath: config.getOutputPath }, "directory index");
|
|
17
|
+
this.outputFunc = outputFunc;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Convert an array of Case[] to an <ul> HTML unordered list.
|
|
21
|
+
*
|
|
22
|
+
* @param context
|
|
23
|
+
* @param cases
|
|
24
|
+
*/
|
|
25
|
+
toList(context, cases) {
|
|
26
|
+
const listItems = cases.map(dirCase => {
|
|
27
|
+
if (!dirCase.title) {
|
|
28
|
+
const lastSlash = dirCase.dirName.lastIndexOf("/");
|
|
29
|
+
const lastDir = dirCase.dirName.substring(lastSlash + 1);
|
|
30
|
+
dirCase.title = StringUtil.camelToText(lastDir);
|
|
31
|
+
}
|
|
32
|
+
return this.toListItem(context, dirCase);
|
|
33
|
+
});
|
|
34
|
+
const ul = context.file.document.createElement("ul");
|
|
35
|
+
ul.append(...listItems);
|
|
36
|
+
ul.className = "links";
|
|
37
|
+
return ul;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Convert a Case object to an HTML list item.
|
|
41
|
+
*
|
|
42
|
+
* @param context
|
|
43
|
+
* @param dirCase
|
|
44
|
+
*/
|
|
45
|
+
toListItem(context, dirCase) {
|
|
46
|
+
const item = context.file.document.createElement("li");
|
|
47
|
+
const ref = document.createElement("a");
|
|
48
|
+
ref.href = dirCase.dirName + "/";
|
|
49
|
+
item.appendChild(ref);
|
|
50
|
+
return item;
|
|
51
|
+
}
|
|
52
|
+
async processDirs(context, dirNames) {
|
|
53
|
+
const cases = await this.scan(context, dirNames);
|
|
54
|
+
const ul = this.toList(context, cases);
|
|
55
|
+
const config = this.config;
|
|
56
|
+
const outputPath = config.getOutputPath(context);
|
|
57
|
+
const output = context.newOutput(outputPath);
|
|
58
|
+
output.contents = context.file.contents.replace(`<!--#echo var="directories" -->`, ul.outerHTML);
|
|
59
|
+
await this.outputFunc(context, output);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Read case JSON files contents and instantiate them as Case objects.
|
|
63
|
+
*
|
|
64
|
+
* @param context
|
|
65
|
+
* @param dirNames The directories to look for case.json files.
|
|
66
|
+
*/
|
|
67
|
+
async scan(context, dirNames) {
|
|
68
|
+
const cases = [];
|
|
69
|
+
for (const dirName of dirNames) {
|
|
70
|
+
try {
|
|
71
|
+
const dirCases = dirName;
|
|
72
|
+
cases.push(...dirCases);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
context.warn(`${dirName} has no case.json description`);
|
|
76
|
+
// No json, just guess title.
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return cases;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -20,7 +20,7 @@ export class SourceRenderer {
|
|
|
20
20
|
let sep = "";
|
|
21
21
|
for (const author of authors) {
|
|
22
22
|
const peopleTag = doc.createElement("span");
|
|
23
|
-
peopleTag.className = "
|
|
23
|
+
peopleTag.className = "peopl";
|
|
24
24
|
peopleTag.textContent = author;
|
|
25
25
|
container.append(sep, peopleTag);
|
|
26
26
|
sep = " & "; // Will be escaped as &
|
|
@@ -45,6 +45,6 @@ describe("TimeEventRenderer", () => {
|
|
|
45
45
|
const outDoc = context.file.document;
|
|
46
46
|
const elem = outDoc.createElement("li");
|
|
47
47
|
await renderer.render(context, c, elem);
|
|
48
|
-
expect(elem.innerHTML).toBe(`<span class="time-resolved">en <time datetime="1970-03">mars 1970</time></span> À <span class="place">Nanterre (Hauts-de-Seine (Île-de-France (France)))</span>, some sighting <span class="source"><span class="
|
|
48
|
+
expect(elem.innerHTML).toBe(`<span class="time-resolved">en <time datetime="1970-03">mars 1970</time></span> À <span class="place">Nanterre (Hauts-de-Seine (Île-de-France (France)))</span>, some sighting <span class="source"><span class="peopl">Some Author</span> : <a href="https://somesite.com/case1">Case 1</a>, <i>Some site</i>, jeudi 13 décembre 2001</span>.`);
|
|
49
49
|
});
|
|
50
50
|
});
|
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.55",
|
|
6
6
|
"description": "RR0 Content Management System (CMS)",
|
|
7
7
|
"exports": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"circular-deps": "dpdm src",
|
|
26
26
|
"prepublishOnly": "npm run build && npm run test-ci",
|
|
27
27
|
"test": "testscript",
|
|
28
|
-
"test-one": "rm -Rf out && tsx src/
|
|
28
|
+
"test-one": "rm -Rf out && tsx src/CMSGenerator.test.ts",
|
|
29
29
|
"test-ci": "rm -Rf out && testscript"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"@rr0/data": "^0.3.39",
|
|
35
35
|
"@rr0/lang": "^0.1.12",
|
|
36
36
|
"@rr0/place": "^0.5.3",
|
|
37
|
-
"@rr0/time": "^0.11.
|
|
38
|
-
"canvas": "^3.2.
|
|
37
|
+
"@rr0/time": "^0.11.2",
|
|
38
|
+
"canvas": "^3.2.1",
|
|
39
39
|
"csv-parser": "^3.2.0",
|
|
40
40
|
"glob": "^11.0.3",
|
|
41
41
|
"image-size": "^2.0.2",
|
|
42
|
-
"jsdom": "^27.
|
|
43
|
-
"selenium-webdriver": "^4.
|
|
42
|
+
"jsdom": "^27.4.0",
|
|
43
|
+
"selenium-webdriver": "^4.39.0",
|
|
44
44
|
"ssg-api": "^1.17.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|