@rr0/cms 0.3.5 → 0.3.8

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.
@@ -8,4 +8,5 @@ export declare class CmsOrganization<M extends TitleMessage = OrganizationMessag
8
8
  get parent(): CmsOrganization | undefined;
9
9
  getMessages(context: RR0Context): M;
10
10
  getTitle(context: RR0Context, options?: OrganizationMessageOptions): string;
11
+ toString(): string;
11
12
  }
@@ -27,4 +27,7 @@ export class CmsOrganization extends Organization {
27
27
  }
28
28
  return str;
29
29
  }
30
+ toString() {
31
+ return this.kind + "$" + this.id;
32
+ }
30
33
  }
@@ -29,6 +29,7 @@ import { uk } from "../uk/Uk";
29
29
  import { usa } from "../us/Usa";
30
30
  import { CmsCountry } from "./CmsCountry";
31
31
  import { georgia } from "../ge/Georgia";
32
+ import { japan } from "../jp/Japan";
32
33
  export const countries = [
33
34
  algeria,
34
35
  new CmsCountry(CountryCode.ar),
@@ -56,7 +57,7 @@ export const countries = [
56
57
  india,
57
58
  new CmsCountry(CountryCode.ir),
58
59
  new CmsCountry(CountryCode.it),
59
- new CmsCountry(CountryCode.jp),
60
+ japan,
60
61
  new CmsCountry(CountryCode.ma),
61
62
  mexico,
62
63
  mozambique,
@@ -0,0 +1,2 @@
1
+ import { CmsCountry } from "../country/CmsCountry";
2
+ export declare const japan: CmsCountry;
@@ -0,0 +1,3 @@
1
+ import { CountryCode } from "@rr0/data";
2
+ import { CmsCountry } from "../country/CmsCountry";
3
+ export const japan = new CmsCountry(CountryCode.jp);
@@ -17,7 +17,7 @@ export class PeopleReplacer {
17
17
  peopleStr = peopleStr.trim().replaceAll("\n", "").replace(/ /g, " ");
18
18
  let people = this.service.cache.get(peopleStr);
19
19
  if (!people) {
20
- people = this.service.createFromFullName(peopleStr);
20
+ people = this.service.createFromTitle(peopleStr);
21
21
  }
22
22
  let url = people.dirName;
23
23
  let replacement;
@@ -3,4 +3,5 @@ import { Place } from "@rr0/place";
3
3
  export declare class OrganizationPlace extends Place {
4
4
  readonly org: CmsOrganization;
5
5
  constructor(org: CmsOrganization);
6
+ toString(): string;
6
7
  }
@@ -1,8 +1,13 @@
1
1
  import { Place } from "@rr0/place";
2
2
  export class OrganizationPlace extends Place {
3
3
  constructor(org) {
4
- super(org.places[0].locations, org.places[0].elevation, org.places[0].dirName);
4
+ var _a, _b, _c;
5
+ super(((_a = org.places[0]) === null || _a === void 0 ? void 0 : _a.locations) || [], (_b = org.places[0]) === null || _b === void 0 ? void 0 : _b.elevation, (_c = org.places[0]) === null || _c === void 0 ? void 0 : _c.dirName);
5
6
  this.org = org;
6
7
  Object.assign(this, org.places[0]);
7
8
  }
9
+ toString() {
10
+ var _a, _b;
11
+ return (_b = (_a = this.org) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : super.toString();
12
+ }
8
13
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { describe, expect, test } from "@javarome/testscript";
2
+ import { OrganizationPlace } from "./OrganizationPlace";
3
+ import { parisCity } from "../org/eu/fr/region/idf/75/paris/Paris";
4
+ import { RR0Datasource } from "../time";
5
+ import { Level2Date as EdtfDate } from "@rr0/time";
6
+ import { CountryCode } from "@rr0/data";
7
+ import { CmsCountry } from "../org/country/CmsCountry";
8
+ describe("OrganizationPlace", () => {
9
+ test("existing organization", async () => {
10
+ const org = parisCity;
11
+ const place = new OrganizationPlace(org);
12
+ expect(place.org).toBe(org);
13
+ expect(place.locations).toBe(org.places[0].locations);
14
+ });
15
+ test("organization with no places", async () => {
16
+ const org = new CmsCountry(CountryCode.jp);
17
+ const place = new OrganizationPlace(org);
18
+ expect(place.org).toBe(org);
19
+ expect(place.locations).toEqual([]);
20
+ });
21
+ test("toString", () => {
22
+ expect(RR0Datasource.id(EdtfDate.fromString("1972-08-12"), new OrganizationPlace(parisCity))).toBe("1972-08-12$city$75000");
23
+ });
24
+ });
@@ -52,8 +52,7 @@ describe("PlaceReplacer", () => {
52
52
  placeTag.innerHTML = text;
53
53
  return placeTag;
54
54
  }
55
- test("link to existing organization", async () => {
56
- return; // Disable test
55
+ test("link to existing organization", { skip: true }, async () => {
57
56
  const location = new PlaceLocation(35.8440582, -106.287162);
58
57
  const elevation = 2161.025390625;
59
58
  const dirName = "org/us/state/nm/lanl/";
@@ -7,8 +7,8 @@ export class RR0Datasource extends AbstractDatasource {
7
7
  super(["Beau, Jérôme"], "RR0");
8
8
  }
9
9
  static id(dateTime, place) {
10
- const placeStr = place ? "$" + `${place.id || place.name}` : "";
11
- return `${dateTime.toString()}${placeStr}`;
10
+ var _a;
11
+ return `${dateTime.toString()}$${((_a = place === null || place === void 0 ? void 0 : place.toString()) !== null && _a !== void 0 ? _a : "")}`;
12
12
  }
13
13
  }
14
14
  RR0Datasource.placeRegex = /^(.+?)(?:\s*\((.+?)(?:\s*,\s*(.+?)(?:\s*,\s*(.+?)))?\))?$/g;
@@ -86,7 +86,7 @@ describe("RR0CaseSource", () => {
86
86
  await testCase.testRender(context);
87
87
  });
88
88
  test("id", async () => {
89
- const id = RR0Datasource.id(EdtfDate.fromString("1972-08-12"), new NamedPlace("Chatillon"));
90
- expect(id).toBe("1972-08-12$Chatillon");
89
+ expect(RR0Datasource.id(EdtfDate.fromString("1972-08-12"), new NamedPlace("Chatillon"))).toBe("1972-08-12$Chatillon");
90
+ expect(RR0Datasource.id(EdtfDate.fromString("1972-08-12"), undefined)).toBe("1972-08-12$");
91
91
  });
92
92
  });
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",
5
+ "version": "0.3.8",
6
6
  "description": "RR0 Content Management System (CMS)",
7
7
  "exports": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
@@ -24,15 +24,15 @@
24
24
  "build": "rm -Rf dist && tsc --project tsconfig.prod.json",
25
25
  "prepublishOnly": "npm run build",
26
26
  "test": "testscript",
27
- "test-one": "rm -Rf out && tsx src/time/datasource/rr0/RR0Datasource.test.ts",
27
+ "test-one": "rm -Rf out && tsx src/RR0Build.test.ts",
28
28
  "test-ci": "rm -Rf out && testscript"
29
29
  },
30
30
  "dependencies": {
31
31
  "@javarome/fileutil": "^0.3.6",
32
32
  "@rr0/common": "^1.1.3",
33
- "@rr0/data": "^0.3.5",
33
+ "@rr0/data": "^0.3.8",
34
34
  "@rr0/lang": "^0.1.12",
35
- "@rr0/place": "^0.5.1",
35
+ "@rr0/place": "^0.5.2",
36
36
  "@rr0/time": "^0.10.0",
37
37
  "canvas": "^2.11.2",
38
38
  "csv-parser": "^3.0.0",