@ca-plant-list/ca-plant-list 0.3.3 → 0.3.5

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 (51) hide show
  1. package/data/glossary/calyx.md +1 -0
  2. package/data/glossary/pedicel.md +1 -0
  3. package/data/glossary/sepal.md +1 -0
  4. package/data/synonyms.csv +6 -4
  5. package/data/taxa.csv +293 -291
  6. package/data/text/Agoseris-grandiflora-var-grandiflora.md +1 -0
  7. package/data/text/Agoseris-heterophylla-var-cryptopleura.md +1 -0
  8. package/data/text/Calochortus-argillosus.md +1 -0
  9. package/data/text/Calochortus-luteus.md +1 -0
  10. package/data/text/Calochortus-venustus.md +1 -0
  11. package/data/text/Claytonia-parviflora-subsp-parviflora.md +1 -0
  12. package/data/text/Claytonia-perfoliata-subsp-perfoliata.md +1 -0
  13. package/data/text/Collinsia-heterophylla-var-heterophylla.md +1 -0
  14. package/data/text/Galium-aparine.md +1 -0
  15. package/data/text/Galium-triflorum.md +1 -0
  16. package/data/text/Hypochaeris-glabra.md +1 -1
  17. package/data/text/Hypochaeris-radicata.md +1 -1
  18. package/data/text/Leptosiphon-ambiguus.md +1 -0
  19. package/data/text/Leptosiphon-androsaceus.md +1 -0
  20. package/data/text/Leptosiphon-bicolor.md +1 -1
  21. package/data/text/Leptosiphon-parviflorus.md +1 -0
  22. package/data/text/Lithophragma-affine.md +1 -1
  23. package/data/text/Lupinus-formosus-var-formosus.md +1 -1
  24. package/data/text/Lupinus-latifolius-var-latifolius.md +1 -1
  25. package/data/text/Lupinus-microcarpus-var-densiflorus.md +1 -1
  26. package/data/text/Lupinus-microcarpus-var-microcarpus.md +1 -1
  27. package/data/text/Lupinus-succulentus.md +1 -1
  28. package/data/text/Pinus-ponderosa-var-pacifica.md +1 -0
  29. package/data/text/Pinus-sabiniana.md +1 -0
  30. package/data/text/Quercus-douglasii.md +1 -0
  31. package/data/text/Quercus-kelloggii.md +1 -0
  32. package/data/text/Quercus-lobata.md +1 -0
  33. package/data/text/Sidalcea-diploscypha.md +1 -1
  34. package/ebook/css/main.css +6 -1
  35. package/jekyll/assets/css/main.css +6 -1
  36. package/lib/basepagerenderer.js +1 -2
  37. package/lib/ebook/image.js +6 -4
  38. package/lib/ebook/pages/page_list_families.js +15 -9
  39. package/lib/ebook/pages/taxonpage.js +9 -36
  40. package/lib/ebook/plantbook.js +82 -48
  41. package/lib/families.js +5 -8
  42. package/lib/genera.js +40 -26
  43. package/lib/html.js +70 -41
  44. package/lib/htmltaxon.js +51 -0
  45. package/lib/index.js +2 -1
  46. package/lib/taxa.js +14 -5
  47. package/lib/taxon.js +16 -5
  48. package/lib/textutils.js +10 -0
  49. package/lib/web/pagetaxon.js +107 -82
  50. package/package.json +3 -3
  51. package/scripts/build-ebook.js +3 -0
@@ -2,64 +2,50 @@ import { Jepson } from "../jepson.js";
2
2
  import { RarePlants } from "../rareplants.js";
3
3
  import { GenericPage } from "../genericpage.js";
4
4
  import { ExternalSites } from "../externalsites.js";
5
- import { DateUtils } from "../dateutils.js";
6
5
  import { HTML } from "../html.js";
6
+ // eslint-disable-next-line no-unused-vars
7
+ import { Config } from "../config.js";
8
+ // eslint-disable-next-line no-unused-vars
9
+ import { Taxon } from "../taxon.js";
10
+ import { HTMLTaxon } from "../htmltaxon.js";
7
11
 
8
12
  class PageTaxon extends GenericPage {
9
-
10
13
  #config;
11
14
  #taxon;
12
15
 
13
- constructor( outputDir, config, taxon ) {
14
- super( outputDir, taxon.getName(), taxon.getBaseFileName() );
16
+ /**
17
+ * @param {string} outputDir
18
+ * @param {Config} config
19
+ * @param {Taxon} taxon
20
+ */
21
+ constructor(outputDir, config, taxon) {
22
+ super(outputDir, taxon.getName(), taxon.getBaseFileName());
15
23
  this.#config = config;
16
24
  this.#taxon = taxon;
17
25
  }
18
26
 
19
- getFlowerInfo() {
20
-
21
- const colors = this.#taxon.getFlowerColors();
22
- const monthStart = this.#taxon.getBloomStart();
23
- const monthEnd = this.#taxon.getBloomEnd();
24
-
25
- if ( !colors && !monthStart ) {
26
- return "";
27
- }
28
-
29
- let html = "Flowers: ";
30
- if ( colors ) {
31
- for ( const color of colors ) {
32
- html += HTML.textElement( "img", "", { src: "/i/f-" + color + ".svg", alt: color + " flowers", title: color, class: "flower-color" } );
33
- }
34
- }
35
- if ( monthStart ) {
36
- html += DateUtils.getMonthName( monthStart ) + "-" + DateUtils.getMonthName( monthEnd );
37
- }
38
- return HTML.wrap( "div", html, { class: "section" } );
39
- }
40
-
41
27
  #getInfoLinks() {
42
28
  const links = [];
43
29
  const jepsonID = this.#taxon.getJepsonID();
44
- if ( jepsonID ) {
45
- links.push( Jepson.getEFloraLink( jepsonID ) );
30
+ if (jepsonID) {
31
+ links.push(Jepson.getEFloraLink(jepsonID));
46
32
  }
47
33
  const cfLink = this.#taxon.getCalfloraTaxonLink();
48
- if ( cfLink ) {
49
- links.push( cfLink );
34
+ if (cfLink) {
35
+ links.push(cfLink);
50
36
  }
51
37
  const iNatLink = this.#taxon.getINatTaxonLink();
52
- if ( iNatLink ) {
53
- links.push( iNatLink );
38
+ if (iNatLink) {
39
+ links.push(iNatLink);
54
40
  }
55
41
  const rpiLink = this.#taxon.getRPITaxonLink();
56
- if ( rpiLink ) {
57
- links.push( rpiLink );
42
+ if (rpiLink) {
43
+ links.push(rpiLink);
58
44
  }
59
- if ( this.#taxon.isNative() ) {
45
+ if (this.#taxon.isNative()) {
60
46
  links.push(
61
47
  HTML.getLink(
62
- ExternalSites.getCalscapeLink( this.#taxon.getName() ),
48
+ ExternalSites.getCalscapeLink(this.#taxon.getName()),
63
49
  "Calscape",
64
50
  undefined,
65
51
  true
@@ -73,25 +59,27 @@ class PageTaxon extends GenericPage {
73
59
  const links = [];
74
60
  links.push(
75
61
  HTML.getLink(
76
- "https://www.calflora.org/entry/observ.html?track=m#srch=t&grezc=5&cols=b&lpcli=t&cc="
77
- + this.#config.getCountyCodes().join( "!" ) + "&incobs=f&taxon="
78
- + this.#taxon.getCalfloraName().replaceAll( " ", "+" ),
62
+ "https://www.calflora.org/entry/observ.html?track=m#srch=t&grezc=5&cols=b&lpcli=t&cc=" +
63
+ this.#config.getCountyCodes().join("!") +
64
+ "&incobs=f&taxon=" +
65
+ this.#taxon.getCalfloraName().replaceAll(" ", "+"),
79
66
  "Calflora",
80
67
  {},
81
68
  true
82
69
  )
83
70
  );
84
71
  const iNatID = this.#taxon.getINatID();
85
- if ( iNatID ) {
72
+ if (iNatID) {
86
73
  links.push(
87
74
  HTML.getLink(
88
- ExternalSites.getInatObsLink(
89
- {
90
- project_id: this.#config.getConfigValue( "inat", "project_id" ),
91
- subview: "map",
92
- taxon_id: iNatID
93
- }
94
- ),
75
+ ExternalSites.getInatObsLink({
76
+ project_id: this.#config.getConfigValue(
77
+ "inat",
78
+ "project_id"
79
+ ),
80
+ subview: "map",
81
+ taxon_id: iNatID,
82
+ }),
95
83
  "iNaturalist",
96
84
  {},
97
85
  true
@@ -102,13 +90,18 @@ class PageTaxon extends GenericPage {
102
90
  return links;
103
91
  }
104
92
 
105
- #getListSectionHTML( list, header, className ) {
93
+ /**
94
+ * @param {string[]} list
95
+ * @param {string} header
96
+ * @param {string} className
97
+ */
98
+ #getListSectionHTML(list, header, className) {
106
99
  let html = "";
107
- if ( list.length > 0 ) {
108
- html += "<div class=\"section " + className + "\">";
109
- html += HTML.textElement( "h2", header );
100
+ if (list.length > 0) {
101
+ html += '<div class="section ' + className + '">';
102
+ html += HTML.textElement("h2", header);
110
103
  html += "<ul>";
111
- html += HTML.arrayToLI( list );
104
+ html += HTML.arrayToLI(list);
112
105
  html += "</ul>";
113
106
  html += "</div>";
114
107
  }
@@ -117,32 +110,44 @@ class PageTaxon extends GenericPage {
117
110
 
118
111
  #getRarityInfo() {
119
112
  const cnpsRank = this.#taxon.getRPIRankAndThreat();
120
- if ( !cnpsRank ) {
113
+ if (!cnpsRank) {
121
114
  return "";
122
115
  }
123
116
  const ranks = [];
124
117
 
125
- ranks.push( HTML.textElement( "span", "CNPS Rare Plant Rank:", { class: "label" } )
126
- + HTML.getToolTip( cnpsRank, this.#taxon.getRPIRankAndThreatTooltip() ) );
127
- if ( this.#taxon.getCESA() ) {
128
- ranks.push( HTML.textElement( "span", "CESA:", { class: "label" } ) + RarePlants.getCESADescription( this.#taxon.getCESA() ) );
118
+ ranks.push(
119
+ HTML.textElement("span", "CNPS Rare Plant Rank:", {
120
+ class: "label",
121
+ }) +
122
+ HTML.getToolTip(
123
+ cnpsRank,
124
+ this.#taxon.getRPIRankAndThreatTooltip()
125
+ )
126
+ );
127
+ if (this.#taxon.getCESA()) {
128
+ ranks.push(
129
+ HTML.textElement("span", "CESA:", { class: "label" }) +
130
+ RarePlants.getCESADescription(this.#taxon.getCESA())
131
+ );
129
132
  }
130
133
 
131
- return HTML.wrap(
132
- "div",
133
- "<ul>" + HTML.arrayToLI( ranks ) + "</ul>",
134
- { class: "section" }
135
- );
134
+ return HTML.wrap("div", "<ul>" + HTML.arrayToLI(ranks) + "</ul>", {
135
+ class: "section",
136
+ });
136
137
  }
137
138
 
138
139
  #getRelatedTaxaLinks() {
139
140
  const links = [];
140
141
  const genus = this.#taxon.getGenus();
141
- if ( genus ) {
142
+ if (genus) {
142
143
  const taxa = genus.getTaxa();
143
- if ( taxa.length > 1 ) {
144
- for ( const taxon of taxa ) {
145
- links.push( taxon.getHTMLLink( taxon.getName() !== this.#taxon.getName() ) );
144
+ if (taxa.length > 1) {
145
+ for (const taxon of taxa) {
146
+ links.push(
147
+ taxon.getHTMLLink(
148
+ taxon.getName() !== this.#taxon.getName()
149
+ )
150
+ );
146
151
  }
147
152
  }
148
153
  }
@@ -154,22 +159,28 @@ class PageTaxon extends GenericPage {
154
159
  }
155
160
 
156
161
  render() {
157
-
158
162
  let html = this.getFrontMatter();
159
163
 
160
- html += "<div class=\"wrapper\">";
164
+ html += '<div class="wrapper">';
161
165
 
162
166
  const cn = this.#taxon.getCommonNames();
163
- if ( cn.length > 0 ) {
164
- html += HTML.textElement( "div", cn.join( ", " ), { class: "section common-names" } );
167
+ if (cn.length > 0) {
168
+ html += HTML.textElement("div", cn.join(", "), {
169
+ class: "section common-names",
170
+ });
165
171
  }
166
172
 
167
- html += HTML.textElement( "div", this.#taxon.getStatusDescription( this.#config ), { class: "section native-status" } );
173
+ html += HTML.textElement(
174
+ "div",
175
+ this.#taxon.getStatusDescription(this.#config),
176
+ { class: "section native-status" }
177
+ );
168
178
 
169
179
  const family = this.#taxon.getFamily();
170
180
  html += HTML.wrap(
171
181
  "div",
172
- HTML.textElement( "span", "Family:", { class: "label" } ) + HTML.getLink( "./" + family.getFileName(), family.getName() ),
182
+ HTML.textElement("span", "Family:", { class: "label" }) +
183
+ HTML.getLink("./" + family.getFileName(), family.getName()),
173
184
  { class: "section" }
174
185
  );
175
186
 
@@ -177,21 +188,35 @@ class PageTaxon extends GenericPage {
177
188
 
178
189
  html += "</div>";
179
190
 
180
- html += this.getFlowerInfo();
191
+ html += HTMLTaxon.getFlowerInfo(this.#taxon);
181
192
 
182
193
  html += this.getMarkdown();
183
194
 
184
- html += "<div class=\"grid borders\">";
185
- html += this.#getListSectionHTML( this.#getInfoLinks(), "References", "info" );
186
- html += this.#getListSectionHTML( this.#getObsLinks(), "Observations", "obs" );
187
- html += this.#getListSectionHTML( this.#getRelatedTaxaLinks(), "Related Species", "rel-taxa" );
188
- html += this.#getListSectionHTML( this.#getSynonyms(), "Synonyms", "synonyms" );
195
+ html += '<div class="grid borders">';
196
+ html += this.#getListSectionHTML(
197
+ this.#getInfoLinks(),
198
+ "References",
199
+ "info"
200
+ );
201
+ html += this.#getListSectionHTML(
202
+ this.#getObsLinks(),
203
+ "Observations",
204
+ "obs"
205
+ );
206
+ html += this.#getListSectionHTML(
207
+ this.#getRelatedTaxaLinks(),
208
+ "Related Species",
209
+ "rel-taxa"
210
+ );
211
+ html += this.#getListSectionHTML(
212
+ this.#getSynonyms(),
213
+ "Synonyms",
214
+ "synonyms"
215
+ );
189
216
  html += "</div>";
190
217
 
191
- this.writeFile( html );
192
-
218
+ this.writeFile(html);
193
219
  }
194
-
195
220
  }
196
221
 
197
- export { PageTaxon };
222
+ export { PageTaxon };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ca-plant-list/ca-plant-list",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
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": {
@@ -23,7 +23,7 @@
23
23
  "command-line-args": "^5.2.1",
24
24
  "command-line-usage": "^6.1.3",
25
25
  "csv-parse": "^5.3.1",
26
- "image-size": "^1.0.2",
26
+ "image-size": "^1.1.1",
27
27
  "markdown-it": "^13.0.1",
28
28
  "sharp": "^0.32.1",
29
29
  "svgo": "^3.0.3",
@@ -36,4 +36,4 @@
36
36
  "eslint": "^8.26.0",
37
37
  "typescript": "^5.3.3"
38
38
  }
39
- }
39
+ }
@@ -31,6 +31,9 @@ class BookCommand extends CommandProcessor {
31
31
  }
32
32
  }
33
33
 
34
+ /**
35
+ * @param {TaxaProcessor} tp
36
+ */
34
37
  async function commandRunner(tp) {
35
38
  const options = tp.getOptions();
36
39
  const ebook = new PlantBook(