@ca-plant-list/ca-plant-list 0.4.22 → 0.4.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.
Files changed (41) hide show
  1. package/lib/basepagerenderer.js +10 -4
  2. package/lib/ebook/images.js +3 -3
  3. package/lib/ebook/pages/{page_list_families.js → pageListFamilies.js} +1 -1
  4. package/lib/ebook/pages/{page_list_flowers.js → pageListFlowers.js} +2 -2
  5. package/lib/ebook/pages/page_list_species.js +1 -1
  6. package/lib/ebook/pages/taxonpage.js +1 -1
  7. package/lib/ebook/pages/tocpage.js +2 -2
  8. package/lib/ebook/plantbook.js +3 -3
  9. package/lib/externalsites.js +86 -37
  10. package/lib/flowercolor.js +2 -2
  11. package/lib/genera.js +4 -4
  12. package/lib/html.js +7 -8
  13. package/lib/htmltaxon.js +106 -27
  14. package/lib/index.d.ts +51 -16
  15. package/lib/index.js +3 -3
  16. package/lib/pagerenderer.js +7 -9
  17. package/lib/taxonomy/families.js +104 -0
  18. package/lib/{taxa.js → taxonomy/taxa.js} +18 -18
  19. package/lib/{taxon.js → taxonomy/taxon.js} +9 -108
  20. package/lib/taxonomy/taxonomy.js +17 -0
  21. package/lib/tools/calflora.js +2 -2
  22. package/lib/tools/calscape.js +3 -3
  23. package/lib/tools/cch2.js +3 -3
  24. package/lib/tools/fna.js +2 -2
  25. package/lib/tools/inat.js +3 -3
  26. package/lib/tools/jepsoneflora.js +1 -1
  27. package/lib/tools/rpi.js +3 -3
  28. package/lib/tools/supplementaltext.js +1 -1
  29. package/lib/types.js +10 -0
  30. package/lib/utils/inat-tools.js +2 -2
  31. package/lib/web/pageFamily.js +146 -0
  32. package/lib/web/pagetaxon.js +20 -56
  33. package/package.json +1 -1
  34. package/scripts/build-ebook.js +4 -4
  35. package/scripts/build-site.js +3 -3
  36. package/scripts/cpl-photos.js +1 -1
  37. package/scripts/cpl-tools.js +1 -1
  38. package/scripts/inatobsphotos.js +2 -2
  39. package/scripts/inattaxonphotos.js +2 -2
  40. package/lib/families.js +0 -243
  41. package/lib/jepson.js +0 -17
package/lib/families.js DELETED
@@ -1,243 +0,0 @@
1
- import { GenericPage } from "./genericpage.js";
2
- import { HTML } from "./html.js";
3
- import { Jepson } from "./jepson.js";
4
- import { Files } from "./files.js";
5
- import { Config } from "./config.js";
6
- import { HTMLTaxon } from "./htmltaxon.js";
7
-
8
- export class Family {
9
- #name;
10
- #data;
11
-
12
- /**
13
- * @param {string} name
14
- * @param {*} data
15
- */
16
- constructor(name, data) {
17
- this.#name = name;
18
- this.#data = data;
19
- }
20
-
21
- /**
22
- * @param {import("./taxon.js").Taxon} taxon
23
- */
24
- addTaxon(taxon) {
25
- if (!this.#data.taxa) {
26
- this.#data.taxa = [];
27
- }
28
- this.#data.taxa.push(taxon);
29
- Sections.addTaxon(this.getSectionName(), taxon);
30
- }
31
-
32
- getBaseFileName() {
33
- return this.getName();
34
- }
35
-
36
- getFileName(ext = "html") {
37
- return this.getBaseFileName() + "." + ext;
38
- }
39
-
40
- getJepsonID() {
41
- return this.#data.id;
42
- }
43
-
44
- getName() {
45
- return this.#name;
46
- }
47
-
48
- getSectionName() {
49
- return this.#data.section;
50
- }
51
-
52
- getTaxa() {
53
- return this.#data.taxa;
54
- }
55
- }
56
-
57
- class Families {
58
- #families;
59
-
60
- constructor() {
61
- const dataDir = Config.getPackageDir() + "/data";
62
-
63
- this.#families = JSON.parse(Files.read(dataDir + "/families.json"));
64
- for (const [k, v] of Object.entries(this.#families)) {
65
- this.#families[k] = new Family(k, v);
66
- }
67
- }
68
-
69
- getFamilies() {
70
- return Object.values(this.#families).sort((a, b) =>
71
- a.getName().localeCompare(b.getName()),
72
- );
73
- }
74
-
75
- /**
76
- * @param {string} familyName
77
- */
78
- getFamily(familyName) {
79
- return this.#families[familyName];
80
- }
81
-
82
- /**
83
- * @param {string} outputDir
84
- * @param {import("./htmltaxon.js").TaxaColDef[]} [taxaColumns]
85
- */
86
- renderPages(outputDir, taxaColumns) {
87
- new PageFamilyList(outputDir, this.#families).render(taxaColumns);
88
-
89
- const names = Object.keys(this.#families);
90
- for (const name of names.sort()) {
91
- const family = this.#families[name];
92
- if (family.getTaxa()) {
93
- new PageFamily(outputDir, family).render(taxaColumns);
94
- }
95
- }
96
- }
97
- }
98
-
99
- class PageFamilyList extends GenericPage {
100
- #families;
101
-
102
- /**
103
- * @param {string} outputDir
104
- * @param {Object<string,Family>} families
105
- */
106
- constructor(outputDir, families) {
107
- super(outputDir, "Families", "list_families");
108
- this.#families = families;
109
- }
110
-
111
- /**
112
- * @param {import("./htmltaxon.js").TaxaColDef[]} [taxaColumns]
113
- */
114
- render(taxaColumns) {
115
- let html = this.getDefaultIntro();
116
-
117
- const sections = Sections.getSections();
118
- const sectionLinks = [];
119
- for (const name of Object.keys(sections).sort()) {
120
- const taxa = sections[name];
121
-
122
- // Render the section page.
123
- new PageSection(this.getOutputDir(), name, taxa).render(
124
- taxaColumns,
125
- );
126
-
127
- // Render the link.
128
- const href = "./" + name + ".html";
129
- sectionLinks.push(
130
- HTML.getLink(href, name) + " (" + taxa.length + ")",
131
- );
132
- }
133
- html += HTML.wrap("ul", HTML.arrayToLI(sectionLinks), {
134
- class: "listmenu",
135
- });
136
-
137
- html += "<table>";
138
- html += "<thead>";
139
- html += HTML.textElement("th", "Family");
140
- html += HTML.textElement("th", "Number of Species", { class: "right" });
141
- html += "</thead>";
142
-
143
- html += "<tbody>";
144
- const names = Object.keys(this.#families).sort();
145
- for (const name of names) {
146
- const family = this.#families[name];
147
- const taxa = family.getTaxa();
148
- if (!taxa) {
149
- continue;
150
- }
151
- let cols = HTML.wrap(
152
- "td",
153
- HTML.getLink("./" + family.getFileName(), family.getName()),
154
- );
155
- cols += HTML.wrap("td", taxa.length, { class: "right" });
156
- html += HTML.wrap("tr", cols);
157
- }
158
- html += "</tbody>";
159
-
160
- html += "</table>";
161
-
162
- this.writeFile(html);
163
- }
164
- }
165
-
166
- class PageFamily extends GenericPage {
167
- #family;
168
-
169
- /**
170
- * @param {string} outputDir
171
- * @param {Family} family
172
- */
173
- constructor(outputDir, family) {
174
- super(outputDir, family.getName(), family.getBaseFileName());
175
- this.#family = family;
176
- }
177
-
178
- /**
179
- * @param {import("./htmltaxon.js").TaxaColDef[]} [columns]
180
- */
181
- render(columns) {
182
- let html = this.getDefaultIntro();
183
-
184
- html += HTML.wrap(
185
- "div",
186
- Jepson.getEFloraLink(this.#family.getJepsonID()),
187
- { class: "section" },
188
- );
189
-
190
- html += HTMLTaxon.getTaxaTable(this.#family.getTaxa(), columns);
191
-
192
- this.writeFile(html);
193
- }
194
- }
195
-
196
- class PageSection extends GenericPage {
197
- #taxa;
198
-
199
- /**
200
- * @param {string} outputDir
201
- * @param {string} name
202
- * @param {import("./taxon.js").Taxon[]} taxa
203
- */
204
- constructor(outputDir, name, taxa) {
205
- super(outputDir, name, name);
206
- this.#taxa = taxa;
207
- }
208
-
209
- /**
210
- * @param {import("./htmltaxon.js").TaxaColDef[]} [columns]
211
- */
212
- render(columns) {
213
- let html = this.getDefaultIntro();
214
-
215
- html += HTMLTaxon.getTaxaTable(this.#taxa, columns);
216
-
217
- this.writeFile(html);
218
- }
219
- }
220
-
221
- class Sections {
222
- /** @type {Object<string,import("./taxon.js").Taxon[]>} */
223
- static #sections = {};
224
-
225
- /**
226
- * @param {string} name
227
- * @param {import("./taxon.js").Taxon} taxon
228
- */
229
- static addTaxon(name, taxon) {
230
- let section = this.#sections[name];
231
- if (!section) {
232
- section = [];
233
- this.#sections[name] = section;
234
- }
235
- section.push(taxon);
236
- }
237
-
238
- static getSections() {
239
- return this.#sections;
240
- }
241
- }
242
-
243
- export { Families };
package/lib/jepson.js DELETED
@@ -1,17 +0,0 @@
1
- import { HTML } from "./html.js";
2
-
3
- class Jepson {
4
- /**
5
- * @param {string} id
6
- */
7
- static getEFloraLink(id) {
8
- return HTML.getLink(
9
- "https://ucjeps.berkeley.edu/eflora/eflora_display.php?tid=" + id,
10
- "Jepson eFlora",
11
- {},
12
- true
13
- );
14
- }
15
- }
16
-
17
- export { Jepson };