@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.
- package/.prettierrc +1 -0
- package/.vscode/settings.json +2 -1
- package/data/text/Rosa-rubiginosa.footer.md +3 -0
- package/jekyll/assets/css/main.css +59 -59
- package/lib/config.js +12 -4
- package/lib/ebook/ebook.js +178 -179
- package/lib/ebook/plantbook.js +147 -139
- package/lib/genericpage.js +3 -4
- package/lib/htmltaxon.js +118 -123
- package/lib/index.d.ts +12 -9
- package/lib/markdown.js +4 -0
- package/lib/pagerenderer.js +220 -221
- package/lib/web/pagetaxon.js +184 -181
- package/package.json +6 -6
- package/types/classes.d.ts +9 -9
package/lib/web/pagetaxon.js
CHANGED
@@ -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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
24
|
-
|
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
|
-
|
45
|
-
|
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
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
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
|
-
|
121
|
-
|
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
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
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
|
-
|
131
|
+
}
|
141
132
|
}
|
133
|
+
return links;
|
134
|
+
}
|
142
135
|
|
143
|
-
|
144
|
-
|
145
|
-
|
136
|
+
#getSynonyms() {
|
137
|
+
return this.#taxon.getSynonyms();
|
138
|
+
}
|
146
139
|
|
147
|
-
|
148
|
-
|
140
|
+
render() {
|
141
|
+
let html = this.getFrontMatter();
|
149
142
|
|
150
|
-
|
143
|
+
html += '<div class="wrapper">';
|
151
144
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
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
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
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
|
+
"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": "^
|
25
|
+
"markdown-it": "^14.1.0",
|
26
26
|
"sharp": "^0.32.1",
|
27
|
-
"svgo-ll": "^5.
|
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.
|
33
|
+
"@types/node": "^22.7.8",
|
34
34
|
"@types/unzipper": "^0.10.9",
|
35
35
|
"ajv-cli": "^5.0.0",
|
36
|
-
"eslint": "^
|
37
|
-
"typescript": "^5.
|
36
|
+
"eslint": "^9.13.0",
|
37
|
+
"typescript": "^5.6.3"
|
38
38
|
}
|
39
39
|
}
|
package/types/classes.d.ts
CHANGED
@@ -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:
|
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:
|
94
|
+
data: function (Taxon):string;
|
95
95
|
title: string;
|
96
96
|
}
|
97
97
|
|