@ca-plant-list/ca-plant-list 0.4.3 → 0.4.4

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.
@@ -4,205 +4,208 @@ import { GenericPage } from "../genericpage.js";
4
4
  import { ExternalSites } from "../externalsites.js";
5
5
  import { HTML } from "../html.js";
6
6
  import { HTMLTaxon } from "../htmltaxon.js";
7
+ import { Markdown } from "../markdown.js";
8
+ import { Config } from "../config.js";
7
9
 
8
10
  class PageTaxon extends GenericPage {
9
- #config;
10
- #taxon;
11
-
12
- /**
13
- * @param {string} outputDir
14
- * @param {Config} config
15
- * @param {Taxon} taxon
16
- */
17
- constructor(outputDir, config, taxon) {
18
- super(outputDir, taxon.getName(), taxon.getBaseFileName());
19
- this.#config = config;
20
- this.#taxon = taxon;
11
+ #config;
12
+ #taxon;
13
+
14
+ /**
15
+ * @param {string} outputDir
16
+ * @param {Config} config
17
+ * @param {Taxon} taxon
18
+ */
19
+ constructor(outputDir, config, taxon) {
20
+ super(outputDir, taxon.getName(), taxon.getBaseFileName());
21
+ this.#config = config;
22
+ this.#taxon = taxon;
23
+ }
24
+
25
+ #getInfoLinks() {
26
+ const links = [];
27
+ const jepsonID = this.#taxon.getJepsonID();
28
+ if (jepsonID) {
29
+ links.push(Jepson.getEFloraLink(jepsonID));
21
30
  }
22
-
23
- #getInfoLinks() {
24
- const links = [];
25
- const jepsonID = this.#taxon.getJepsonID();
26
- if (jepsonID) {
27
- links.push(Jepson.getEFloraLink(jepsonID));
28
- }
29
- const cfLink = this.#taxon.getCalfloraTaxonLink();
30
- if (cfLink) {
31
- links.push(cfLink);
32
- }
33
- const iNatLink = this.#taxon.getINatTaxonLink();
34
- if (iNatLink) {
35
- links.push(iNatLink);
36
- }
37
- const rpiLink = this.#taxon.getRPITaxonLink();
38
- if (rpiLink) {
39
- links.push(rpiLink);
40
- }
41
- return links;
31
+ const cfLink = this.#taxon.getCalfloraTaxonLink();
32
+ if (cfLink) {
33
+ links.push(cfLink);
42
34
  }
43
-
44
- #getObsLinks() {
45
- const links = [];
46
- links.push(
47
- HTML.getLink(
48
- "https://www.calflora.org/entry/observ.html?track=m#srch=t&grezc=5&cols=b&lpcli=t&cc=" +
49
- this.#config.getCountyCodes().join("!") +
50
- "&incobs=f&taxon=" +
51
- this.#taxon.getCalfloraName().replaceAll(" ", "+"),
52
- "Calflora",
53
- {},
54
- true
55
- )
56
- );
57
- const iNatID = this.#taxon.getINatID();
58
- if (iNatID) {
59
- links.push(
60
- HTML.getLink(
61
- ExternalSites.getInatObsLink({
62
- project_id: this.#config.getConfigValue(
63
- "inat",
64
- "project_id"
65
- ),
66
- subview: "map",
67
- taxon_id: iNatID,
68
- }),
69
- "iNaturalist",
70
- {},
71
- true
72
- )
73
- );
74
- }
75
-
76
- return links;
35
+ const iNatLink = this.#taxon.getINatTaxonLink();
36
+ if (iNatLink) {
37
+ links.push(iNatLink);
77
38
  }
78
-
79
- /**
80
- * @param {string[]} list
81
- * @param {string} header
82
- * @param {string} className
83
- */
84
- #getListSectionHTML(list, header, className) {
85
- let html = "";
86
- if (list.length > 0) {
87
- html += '<div class="section ' + className + '">';
88
- html += HTML.textElement("h2", header);
89
- html += "<ul>";
90
- html += HTML.arrayToLI(list);
91
- html += "</ul>";
92
- html += "</div>";
93
- }
94
- return html;
39
+ const rpiLink = this.#taxon.getRPITaxonLink();
40
+ if (rpiLink) {
41
+ links.push(rpiLink);
42
+ }
43
+ return links;
44
+ }
45
+
46
+ #getObsLinks() {
47
+ const links = [];
48
+ links.push(
49
+ HTML.getLink(
50
+ "https://www.calflora.org/entry/observ.html?track=m#srch=t&grezc=5&cols=b&lpcli=t&cc=" +
51
+ this.#config.getCountyCodes().join("!") +
52
+ "&incobs=f&taxon=" +
53
+ this.#taxon.getCalfloraName().replaceAll(" ", "+"),
54
+ "Calflora",
55
+ {},
56
+ true
57
+ )
58
+ );
59
+ const iNatID = this.#taxon.getINatID();
60
+ if (iNatID) {
61
+ const projectId = links.push(
62
+ HTML.getLink(
63
+ ExternalSites.getInatObsLink({
64
+ project_id: this.#config.getConfigValue("inat", "project_id"),
65
+ subview: "map",
66
+ taxon_id: iNatID,
67
+ }),
68
+ "iNaturalist",
69
+ {},
70
+ true
71
+ )
72
+ );
95
73
  }
96
74
 
97
- #getRarityInfo() {
98
- const cnpsRank = this.#taxon.getRPIRankAndThreat();
99
- if (!cnpsRank) {
100
- return "";
101
- }
102
- const ranks = [];
103
-
104
- ranks.push(
105
- HTML.textElement("span", "CNPS Rare Plant Rank:", {
106
- class: "label",
107
- }) +
108
- HTML.getToolTip(
109
- cnpsRank,
110
- this.#taxon.getRPIRankAndThreatTooltip()
111
- )
112
- );
113
- if (this.#taxon.getCESA()) {
114
- ranks.push(
115
- HTML.textElement("span", "CESA:", { class: "label" }) +
116
- RarePlants.getCESADescription(this.#taxon.getCESA())
117
- );
118
- }
75
+ return links;
76
+ }
77
+
78
+ /**
79
+ * @param {string[]} list
80
+ * @param {string} header
81
+ * @param {string} className
82
+ */
83
+ #getListSectionHTML(list, header, className) {
84
+ let html = "";
85
+ if (list.length > 0) {
86
+ html += '<div class="section nobullet ' + className + '">';
87
+ html += HTML.textElement("h2", header);
88
+ html += "<ul>";
89
+ html += HTML.arrayToLI(list);
90
+ html += "</ul>";
91
+ html += "</div>";
92
+ }
93
+ return html;
94
+ }
119
95
 
120
- return HTML.wrap("div", "<ul>" + HTML.arrayToLI(ranks) + "</ul>", {
121
- class: "section",
122
- });
96
+ #getRarityInfo() {
97
+ const cnpsRank = this.#taxon.getRPIRankAndThreat();
98
+ if (!cnpsRank) {
99
+ return "";
100
+ }
101
+ const ranks = [];
102
+
103
+ ranks.push(
104
+ HTML.textElement("span", "CNPS Rare Plant Rank:", {
105
+ class: "label",
106
+ }) + HTML.getToolTip(cnpsRank, this.#taxon.getRPIRankAndThreatTooltip())
107
+ );
108
+ if (this.#taxon.getCESA()) {
109
+ ranks.push(
110
+ HTML.textElement("span", "CESA:", { class: "label" }) +
111
+ RarePlants.getCESADescription(this.#taxon.getCESA())
112
+ );
123
113
  }
124
114
 
125
- #getRelatedTaxaLinks() {
126
- const links = [];
127
- const genus = this.#taxon.getGenus();
128
- if (genus) {
129
- const taxa = genus.getTaxa();
130
- if (taxa.length > 1) {
131
- for (const taxon of taxa) {
132
- links.push(
133
- taxon.getHTMLLink(
134
- taxon.getName() !== this.#taxon.getName()
135
- )
136
- );
137
- }
138
- }
115
+ return HTML.wrap("div", "<ul>" + HTML.arrayToLI(ranks) + "</ul>", {
116
+ class: "section",
117
+ });
118
+ }
119
+
120
+ #getRelatedTaxaLinks() {
121
+ const links = [];
122
+ const genus = this.#taxon.getGenus();
123
+ if (genus) {
124
+ const taxa = genus.getTaxa();
125
+ if (taxa.length > 1) {
126
+ for (const taxon of taxa) {
127
+ links.push(
128
+ taxon.getHTMLLink(taxon.getName() !== this.#taxon.getName())
129
+ );
139
130
  }
140
- return links;
131
+ }
141
132
  }
133
+ return links;
134
+ }
142
135
 
143
- #getSynonyms() {
144
- return this.#taxon.getSynonyms();
145
- }
136
+ #getSynonyms() {
137
+ return this.#taxon.getSynonyms();
138
+ }
146
139
 
147
- render() {
148
- let html = this.getFrontMatter();
140
+ render() {
141
+ let html = this.getFrontMatter();
149
142
 
150
- html += '<div class="wrapper">';
143
+ html += '<div class="wrapper">';
151
144
 
152
- const cn = this.#taxon.getCommonNames();
153
- if (cn.length > 0) {
154
- html += HTML.textElement("div", cn.join(", "), {
155
- class: "section common-names",
156
- });
157
- }
145
+ const cn = this.#taxon.getCommonNames();
146
+ if (cn.length > 0) {
147
+ html += HTML.textElement("div", cn.join(", "), {
148
+ class: "section common-names",
149
+ });
150
+ }
158
151
 
159
- html += HTML.textElement(
160
- "div",
161
- this.#taxon.getStatusDescription(this.#config),
162
- { class: "section native-status" }
163
- );
164
-
165
- const family = this.#taxon.getFamily();
166
- html += HTML.wrap(
167
- "div",
168
- HTML.textElement("span", "Family:", { class: "label" }) +
169
- HTML.getLink("./" + family.getFileName(), family.getName()),
170
- { class: "section" }
171
- );
172
-
173
- html += this.#getRarityInfo();
174
-
175
- html += "</div>";
176
-
177
- html += HTMLTaxon.getFlowerInfo(this.#taxon, undefined, false);
178
-
179
- html += this.getMarkdown();
180
-
181
- html += '<div class="grid borders">';
182
- html += this.#getListSectionHTML(
183
- this.#getInfoLinks(),
184
- "References",
185
- "info"
186
- );
187
- html += this.#getListSectionHTML(
188
- this.#getObsLinks(),
189
- "Observations",
190
- "obs"
191
- );
192
- html += this.#getListSectionHTML(
193
- this.#getRelatedTaxaLinks(),
194
- "Related Species",
195
- "rel-taxa"
196
- );
197
- html += this.#getListSectionHTML(
198
- this.#getSynonyms(),
199
- "Synonyms",
200
- "synonyms"
201
- );
202
- html += "</div>";
203
-
204
- this.writeFile(html);
152
+ html += HTML.textElement(
153
+ "div",
154
+ this.#taxon.getStatusDescription(this.#config),
155
+ { class: "section native-status" }
156
+ );
157
+
158
+ const family = this.#taxon.getFamily();
159
+ html += HTML.wrap(
160
+ "div",
161
+ HTML.textElement("span", "Family:", { class: "label" }) +
162
+ HTML.getLink("./" + family.getFileName(), family.getName()),
163
+ { class: "section" }
164
+ );
165
+
166
+ html += this.#getRarityInfo();
167
+
168
+ html += "</div>";
169
+
170
+ html += HTMLTaxon.getFlowerInfo(this.#taxon, undefined, false);
171
+
172
+ html += this.getMarkdown();
173
+
174
+ html += '<div class="grid borders">';
175
+ html += this.#getListSectionHTML(
176
+ this.#getInfoLinks(),
177
+ "References",
178
+ "info"
179
+ );
180
+ html += this.#getListSectionHTML(
181
+ this.#getObsLinks(),
182
+ "Observations",
183
+ "obs"
184
+ );
185
+ html += this.#getListSectionHTML(
186
+ this.#getRelatedTaxaLinks(),
187
+ "Related Species",
188
+ "rel-taxa"
189
+ );
190
+ html += this.#getListSectionHTML(
191
+ this.#getSynonyms(),
192
+ "Synonyms",
193
+ "synonyms"
194
+ );
195
+ html += "</div>";
196
+
197
+ const footerTextPath =
198
+ Config.getPackageDir() +
199
+ "/data/text/" +
200
+ this.getBaseFileName() +
201
+ ".footer.md";
202
+ const footerMarkdown = Markdown.fileToHTML(footerTextPath);
203
+ if (footerMarkdown) {
204
+ html += HTML.wrap("div", footerMarkdown, "section");
205
205
  }
206
+
207
+ this.writeFile(html);
208
+ }
206
209
  }
207
210
 
208
211
  export { PageTaxon };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ca-plant-list/ca-plant-list",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Tools to create Jekyll files for a website listing plants in an area of California.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -22,18 +22,18 @@
22
22
  "commander": "^12.1.0",
23
23
  "csv-parse": "^5.3.1",
24
24
  "image-size": "^1.1.1",
25
- "markdown-it": "^13.0.1",
25
+ "markdown-it": "^14.1.0",
26
26
  "sharp": "^0.32.1",
27
- "svgo-ll": "^5.4.0",
27
+ "svgo-ll": "^5.5.0",
28
28
  "unzipper": "^0.10.11"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/archiver": "^6.0.2",
32
32
  "@types/markdown-it": "^14.1.2",
33
- "@types/node": "^22.5.5",
33
+ "@types/node": "^22.7.8",
34
34
  "@types/unzipper": "^0.10.9",
35
35
  "ajv-cli": "^5.0.0",
36
- "eslint": "^8.26.0",
37
- "typescript": "^5.3.3"
36
+ "eslint": "^9.13.0",
37
+ "typescript": "^5.6.3"
38
38
  }
39
39
  }
@@ -10,20 +10,20 @@ declare class Config {
10
10
  name: string,
11
11
  subcategory?: string,
12
12
  defaultValue?: string
13
- ): string;
13
+ ): string | undefined;
14
14
  getCountyCodes(): string[];
15
15
  getLabel(name: string, dflt: string): string;
16
16
  }
17
17
 
18
18
  declare class ErrorLog {
19
19
  log(...args: string[]): void;
20
- write();
20
+ write(): void;
21
21
  }
22
22
 
23
23
  declare class Families {
24
24
  getFamilies(): Family[];
25
25
  getFamily(name: string): Family;
26
- renderPages(outputDir: string, cols?: TaxaCol[]);
26
+ renderPages(outputDir: string, cols?: TaxaCol[]): void;
27
27
  }
28
28
 
29
29
  declare class Family {
@@ -41,7 +41,7 @@ declare class FlowerColor {
41
41
  }
42
42
 
43
43
  declare class Genera {
44
- addTaxon(Taxon);
44
+ addTaxon(taxon: Taxon): void;
45
45
  getGenus(name: string): Genus;
46
46
  }
47
47
 
@@ -67,13 +67,13 @@ declare class InatObsOptions {
67
67
  }
68
68
 
69
69
  declare class SiteGenerator {
70
- copyIllustrations(flowerColors: FlowerColor[]);
71
- mkdir(path: string);
70
+ copyIllustrations(flowerColors: FlowerColor[]): void;
71
+ mkdir(path: string): void;
72
72
  writeTemplate(
73
73
  content: string,
74
- attributes: Object<string, string>,
74
+ attributes: Record<string, string>,
75
75
  filename: string
76
- );
76
+ ): void;
77
77
  }
78
78
 
79
79
  declare class SynonymData {
@@ -91,7 +91,7 @@ declare class Taxa {
91
91
 
92
92
  declare class TaxaCol {
93
93
  class?: string;
94
- data: Object<string, Taxon>;
94
+ data: function (Taxon):string;
95
95
  title: string;
96
96
  }
97
97