@ca-plant-list/ca-plant-list 0.2.0 → 0.2.2
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/data/exceptions.json +43 -1
- package/data/photos.csv +7 -0
- package/data/taxa.csv +184 -184
- package/data/text/Bromus-catharticus-var-catharticus.md +1 -0
- package/data/text/Bromus-catharticus-var-elatus.md +1 -0
- package/data/text/Bromus-sitchensis-var-carinatus.md +1 -0
- package/data/text/Bromus-sitchensis-var-marginatus.md +1 -0
- package/data/text/Castilleja-foliolosa.md +1 -0
- package/data/text/Grindelia-camporum.md +1 -0
- package/data/text/Grindelia-hirsutula.md +1 -0
- package/data/text/Layia-chrysanthemoides.md +1 -0
- package/data/text/Layia-gaillardioides.md +1 -0
- package/data/text/Layia-hieracioides.md +1 -0
- package/data/text/Layia-platyglossa.md +1 -0
- package/data/text/Leptosiphon-bicolor.md +1 -0
- package/data/text/Leptosiphon-ciliatus.md +1 -0
- package/data/text/Leptosiphon-grandiflorus.md +1 -0
- package/data/text/Lithophragma-affine.md +1 -0
- package/data/text/Lithophragma-heterophyllum.md +1 -0
- package/data/text/Lithophragma-parviflorum-var-parviflorum.md +1 -0
- package/data/text/Lupinus-bicolor.md +1 -0
- package/data/text/Lupinus-formosus-var-formosus.md +1 -0
- package/data/text/Lupinus-latifolius-var-latifolius.md +1 -0
- package/data/text/Lupinus-microcarpus-var-densiflorus.md +1 -0
- package/data/text/Lupinus-microcarpus-var-microcarpus.md +1 -0
- package/data/text/Lupinus-nanus.md +1 -0
- package/data/text/Lupinus-succulentus.md +1 -0
- package/data/text/Wyethia-angustifolia.md +1 -0
- package/data/text/Wyethia-glabra.md +1 -0
- package/data/text/Wyethia-helenioides.md +1 -0
- package/ebook/css/main.css +16 -0
- package/ebook/i/f-blue.svg +5 -0
- package/ebook/i/f-orange.svg +5 -0
- package/ebook/i/f-pink.svg +5 -0
- package/ebook/i/f-red.svg +5 -0
- package/ebook/i/f-white.svg +5 -0
- package/ebook/i/f-yellow.svg +5 -0
- package/jekyll/assets/css/main.css +6 -0
- package/lib/ebook/ebook.js +146 -0
- package/lib/ebook/ebookpage.js +47 -0
- package/lib/ebook/image.js +21 -0
- package/lib/ebook/pages/page_list_families.js +27 -0
- package/lib/ebook/pages/page_list_flower_color.js +26 -0
- package/lib/ebook/pages/page_list_species.js +26 -0
- package/lib/ebook/pages/taxonpage.js +79 -0
- package/lib/ebook/pages/tocpage.js +37 -0
- package/lib/ebook/plantbook.js +179 -0
- package/lib/ebook/xhtml.js +7 -0
- package/lib/exceptions.js +14 -4
- package/lib/families.js +4 -0
- package/lib/index.d.ts +14 -7
- package/lib/index.js +2 -1
- package/lib/pagetaxon.js +2 -2
- package/lib/taxa.js +53 -2
- package/lib/taxon.js +9 -1
- package/package.json +7 -2
- package/scripts/build-ebook.js +12 -0
@@ -0,0 +1,179 @@
|
|
1
|
+
import * as fs from "node:fs";
|
2
|
+
import path from "node:path";
|
3
|
+
import sharp from "sharp";
|
4
|
+
import { CSV, Families, Files, Taxa } from "@ca-plant-list/ca-plant-list";
|
5
|
+
import { EBook } from "./ebook.js";
|
6
|
+
import { Image } from "./image.js";
|
7
|
+
import { PageListFamilies } from "./pages/page_list_families.js";
|
8
|
+
import { PageListFlowerColor } from "./pages/page_list_flower_color.js";
|
9
|
+
import { PageListSpecies } from "./pages/page_list_species.js";
|
10
|
+
import { TaxonPage } from "./pages/taxonpage.js";
|
11
|
+
import { TOCPage } from "./pages/tocpage.js";
|
12
|
+
import { Config } from "../config.js";
|
13
|
+
import { FLOWER_COLOR_NAMES } from "../taxa.js";
|
14
|
+
|
15
|
+
class PlantBook extends EBook {
|
16
|
+
|
17
|
+
#images = {};
|
18
|
+
|
19
|
+
constructor() {
|
20
|
+
|
21
|
+
super(
|
22
|
+
"output",
|
23
|
+
Config.getConfigValue( "ebook", "filename" ),
|
24
|
+
Config.getConfigValue( "ebook", "pub_id" ),
|
25
|
+
Config.getConfigValue( "ebook", "title" )
|
26
|
+
);
|
27
|
+
|
28
|
+
}
|
29
|
+
|
30
|
+
async createPages() {
|
31
|
+
|
32
|
+
console.log( "checking images" );
|
33
|
+
await this.#importImages();
|
34
|
+
|
35
|
+
const contentDir = this.getContentDir();
|
36
|
+
|
37
|
+
console.log( "creating taxon pages" );
|
38
|
+
const taxa = Taxa.getTaxa();
|
39
|
+
for ( const taxon of taxa ) {
|
40
|
+
const name = taxon.getName();
|
41
|
+
new TaxonPage( contentDir, taxon, this.#images[ name ] ).create();
|
42
|
+
}
|
43
|
+
|
44
|
+
// Create lists.
|
45
|
+
for ( const colorName of FLOWER_COLOR_NAMES ) {
|
46
|
+
new PageListFlowerColor( contentDir, Taxa.getFlowerColor( colorName ) ).create();
|
47
|
+
}
|
48
|
+
new PageListFamilies( contentDir ).create();
|
49
|
+
for ( const family of Families.getFamilies() ) {
|
50
|
+
const taxa = family.getTaxa();
|
51
|
+
if ( !taxa ) {
|
52
|
+
continue;
|
53
|
+
}
|
54
|
+
const name = family.getName();
|
55
|
+
new PageListSpecies( contentDir, taxa, name + ".html", name ).create();
|
56
|
+
}
|
57
|
+
new PageListSpecies( contentDir, taxa, "list_species.html", "All Species" ).create();
|
58
|
+
|
59
|
+
new TOCPage( contentDir ).create();
|
60
|
+
}
|
61
|
+
|
62
|
+
async #importImages() {
|
63
|
+
|
64
|
+
const photoDirSrc = "external_data/photos";
|
65
|
+
const imagePrefix = "i";
|
66
|
+
const photoDirTarget = this.getContentDir() + "/" + imagePrefix;
|
67
|
+
fs.mkdirSync( photoDirSrc, { recursive: true } );
|
68
|
+
fs.mkdirSync( photoDirTarget, { recursive: true } );
|
69
|
+
|
70
|
+
const rows = CSV.parseFile( Config.getPackageDir() + "/data", "photos.csv" );
|
71
|
+
for ( const row of rows ) {
|
72
|
+
|
73
|
+
const name = row[ "taxon_name" ];
|
74
|
+
const taxon = Taxa.getTaxon( name );
|
75
|
+
if ( !taxon ) {
|
76
|
+
continue;
|
77
|
+
}
|
78
|
+
|
79
|
+
let imageList = this.#images[ name ];
|
80
|
+
if ( !imageList ) {
|
81
|
+
imageList = [];
|
82
|
+
this.#images[ name ] = imageList;
|
83
|
+
}
|
84
|
+
|
85
|
+
const src = new URL( row[ "source" ] );
|
86
|
+
const parts = path.parse( src.pathname ).dir.split( "/" );
|
87
|
+
const prefix = src.host.includes( "calflora" ) ? "cf-" : "inat-";
|
88
|
+
const filename = prefix + parts.slice( -1 )[ 0 ] + ".jpg";
|
89
|
+
const srcFileName = photoDirSrc + "/" + filename;
|
90
|
+
const targetFileName = photoDirTarget + "/" + filename;
|
91
|
+
|
92
|
+
if ( !fs.existsSync( srcFileName ) ) {
|
93
|
+
// File is not there; retrieve it.
|
94
|
+
console.log( "retrieving " + srcFileName );
|
95
|
+
await Files.fetch( src, srcFileName );
|
96
|
+
}
|
97
|
+
|
98
|
+
await new sharp( srcFileName ).resize( { width: 400 } ).jpeg( { quality: 40 } ).toFile( targetFileName );
|
99
|
+
|
100
|
+
imageList.push( new Image( imagePrefix + "/" + filename, row[ "credit" ] ) );
|
101
|
+
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
renderManifestEntries() {
|
106
|
+
|
107
|
+
let xml = "";
|
108
|
+
|
109
|
+
xml += "<item id=\"f0\" href=\"i/f-blue.svg\" media-type=\"image/svg+xml\" />";
|
110
|
+
xml += "<item id=\"f1\" href=\"i/f-orange.svg\" media-type=\"image/svg+xml\" />";
|
111
|
+
xml += "<item id=\"f2\" href=\"i/f-pink.svg\" media-type=\"image/svg+xml\" />";
|
112
|
+
xml += "<item id=\"f3\" href=\"i/f-red.svg\" media-type=\"image/svg+xml\" />";
|
113
|
+
xml += "<item id=\"f4\" href=\"i/f-white.svg\" media-type=\"image/svg+xml\" />";
|
114
|
+
xml += "<item id=\"f5\" href=\"i/f-yellow.svg\" media-type=\"image/svg+xml\" />";
|
115
|
+
|
116
|
+
// Add lists.
|
117
|
+
xml += "<item id=\"lspecies\" href=\"list_species.html\" media-type=\"application/xhtml+xml\" />";
|
118
|
+
xml += "<item id=\"lfamilies\" href=\"list_families.html\" media-type=\"application/xhtml+xml\" />";
|
119
|
+
for ( const colorName of FLOWER_COLOR_NAMES ) {
|
120
|
+
const color = Taxa.getFlowerColor( colorName );
|
121
|
+
xml += "<item id=\"l" + color.getColorName() + "\" href=\"" + color.getFileName() + "\" media-type=\"application/xhtml+xml\" />";
|
122
|
+
}
|
123
|
+
|
124
|
+
// Add family pages.
|
125
|
+
for ( const family of Families.getFamilies() ) {
|
126
|
+
const taxa = family.getTaxa();
|
127
|
+
if ( !taxa ) {
|
128
|
+
continue;
|
129
|
+
}
|
130
|
+
xml += "<item id=\"fam" + family.getName() + "\" href=\"" + family.getFileName() + "\" media-type=\"application/xhtml+xml\" />";
|
131
|
+
}
|
132
|
+
|
133
|
+
// Add taxon pages.
|
134
|
+
const taxa = Taxa.getTaxa();
|
135
|
+
for ( let index = 0; index < taxa.length; index++ ) {
|
136
|
+
const taxon = taxa[ index ];
|
137
|
+
xml += "<item id=\"t" + index + "\" href=\"" + taxon.getFileName() + "\" media-type=\"application/xhtml+xml\" />";
|
138
|
+
}
|
139
|
+
|
140
|
+
// Add images.
|
141
|
+
let index = 0;
|
142
|
+
for ( const imageList of Object.values( this.#images ) ) {
|
143
|
+
for ( const image of imageList ) {
|
144
|
+
xml += "<item id=\"i" + index + "\" href=\"" + image.getSrc() + "\" media-type=\"image/jpeg\" />";
|
145
|
+
index++;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
return xml;
|
149
|
+
}
|
150
|
+
|
151
|
+
renderSpineElements() {
|
152
|
+
let xml = "";
|
153
|
+
|
154
|
+
// Add lists.
|
155
|
+
for ( const colorName of FLOWER_COLOR_NAMES ) {
|
156
|
+
const color = Taxa.getFlowerColor( colorName );
|
157
|
+
xml += "<itemref idref=\"l" + color.getColorName() + "\"/>";
|
158
|
+
}
|
159
|
+
xml += "<itemref idref=\"lfamilies\"/>";
|
160
|
+
xml += "<itemref idref=\"lspecies\"/>";
|
161
|
+
|
162
|
+
// Add families.
|
163
|
+
for ( const family of Families.getFamilies() ) {
|
164
|
+
const taxa = family.getTaxa();
|
165
|
+
if ( !taxa ) {
|
166
|
+
continue;
|
167
|
+
}
|
168
|
+
xml += "<itemref idref=\"fam" + family.getName() + "\"/>";
|
169
|
+
}
|
170
|
+
|
171
|
+
// Add taxa.
|
172
|
+
for ( let index = 0; index < Taxa.getTaxa().length; index++ ) {
|
173
|
+
xml += "<itemref idref=\"t" + index + "\"/>";
|
174
|
+
}
|
175
|
+
return xml;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
export { PlantBook };
|
package/lib/exceptions.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Config } from "./config.js";
|
1
2
|
import { Files } from "./files.js";
|
2
3
|
|
3
4
|
class Exceptions {
|
@@ -32,11 +33,20 @@ class Exceptions {
|
|
32
33
|
}
|
33
34
|
|
34
35
|
static init( dir ) {
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
console.log( e );
|
36
|
+
|
37
|
+
function readConfig( fileName ) {
|
38
|
+
return JSON.parse( Files.read( fileName ) );
|
39
39
|
}
|
40
|
+
|
41
|
+
// Read default configuration.
|
42
|
+
this.#exceptions = readConfig( Config.getPackageDir() + "/data/exceptions.json" );
|
43
|
+
|
44
|
+
// Add/overwrite with local configuration.
|
45
|
+
const localExceptions = readConfig( dir + "/exceptions.json" );
|
46
|
+
for ( const [ k, v ] of Object.entries( localExceptions ) ) {
|
47
|
+
this.#exceptions[ k ] = v;
|
48
|
+
}
|
49
|
+
|
40
50
|
}
|
41
51
|
|
42
52
|
}
|
package/lib/families.js
CHANGED
@@ -10,6 +10,10 @@ class Families {
|
|
10
10
|
|
11
11
|
static #families;
|
12
12
|
|
13
|
+
static getFamilies() {
|
14
|
+
return Object.values( this.#families ).sort( ( a, b ) => a.getName().localeCompare( b.getName() ) );
|
15
|
+
}
|
16
|
+
|
13
17
|
static getFamily( familyName ) {
|
14
18
|
return this.#families[ familyName ];
|
15
19
|
}
|
package/lib/index.d.ts
CHANGED
@@ -33,14 +33,15 @@ export class ErrorLog {
|
|
33
33
|
static write(fileName: any): void;
|
34
34
|
}
|
35
35
|
export class Exceptions {
|
36
|
-
static "__#
|
36
|
+
static "__#17@#exceptions": {};
|
37
37
|
static getExceptions(): [string, any][];
|
38
38
|
static getValue(name: any, cat: any, subcat: any, defaultValue: any): any;
|
39
39
|
static hasException(name: any, cat: any, subcat: any): boolean;
|
40
40
|
static init(dir: any): void;
|
41
41
|
}
|
42
42
|
export class Families {
|
43
|
-
static "__#
|
43
|
+
static "__#11@#families": any;
|
44
|
+
static getFamilies(): any[];
|
44
45
|
static getFamily(familyName: any): any;
|
45
46
|
static init(): void;
|
46
47
|
static renderPages(outputDir: any, taxaColumns: any): void;
|
@@ -135,10 +136,11 @@ import { Families } from "./families.js";
|
|
135
136
|
import { Files } from "./files.js";
|
136
137
|
import { HTML } from "./html.js";
|
137
138
|
import { Jekyll } from "./jekyll.js";
|
139
|
+
import { PlantBook } from "./ebook/plantbook.js";
|
138
140
|
import { Taxa } from "./taxa.js";
|
139
141
|
import { TAXA_COLNAMES } from "./taxon.js";
|
140
142
|
import { Taxon } from "./taxon.js";
|
141
|
-
export { BasePageRenderer, Config, CSV, DataLoader, ErrorLog, Exceptions, Families, Files, HTML, Jekyll, Taxa, TAXA_COLNAMES, Taxon };
|
143
|
+
export { BasePageRenderer, Config, CSV, DataLoader, ErrorLog, Exceptions, Families, Files, HTML, Jekyll, PlantBook, Taxa, TAXA_COLNAMES, Taxon };
|
142
144
|
export class Jekyll {
|
143
145
|
static hasInclude(baseDir: any, path: any): boolean;
|
144
146
|
static include(path: any): string;
|
@@ -153,18 +155,21 @@ export class RarePlants {
|
|
153
155
|
static getRPIRankDescription(rank: any): any;
|
154
156
|
static getRPIRankAndThreatDescriptions(rank: any): any[];
|
155
157
|
}
|
158
|
+
export const FLOWER_COLOR_NAMES: string[];
|
156
159
|
export class Taxa {
|
157
|
-
static "__#
|
158
|
-
static "__#
|
160
|
+
static "__#10@#taxa": {};
|
161
|
+
static "__#10@#flower_colors": {};
|
162
|
+
static "__#10@#sortedTaxa": any;
|
159
163
|
static getHTMLTable(taxa: any, columns?: {
|
160
164
|
title: string;
|
161
165
|
data: (t: any) => any;
|
162
166
|
}[]): string;
|
167
|
+
static getFlowerColor(name: any): any;
|
163
168
|
static getTaxa(): any;
|
164
169
|
static getTaxon(name: any): any;
|
165
170
|
static init(inclusionList: any, taxaMeta?: {}, taxonClass?: typeof Taxon, extraTaxa?: any[], extraSynonyms?: any[]): void;
|
166
|
-
static "__#
|
167
|
-
static "__#
|
171
|
+
static "__#10@#loadSyns"(synCSV: any, inclusionList: any): void;
|
172
|
+
static "__#10@#loadTaxa"(taxaCSV: any, inclusionList: any, taxaMeta: any, taxonClass: any): void;
|
168
173
|
}
|
169
174
|
export namespace TAXA_LIST_COLS {
|
170
175
|
namespace CESA {
|
@@ -205,6 +210,7 @@ export namespace TAXA_LIST_COLS {
|
|
205
210
|
import { Taxon } from "./taxon.js";
|
206
211
|
export namespace TAXA_COLNAMES {
|
207
212
|
const COMMON_NAME: string;
|
213
|
+
const FLOWER_COLOR: string;
|
208
214
|
}
|
209
215
|
export class Taxon {
|
210
216
|
constructor(data: any);
|
@@ -219,6 +225,7 @@ export class Taxon {
|
|
219
225
|
getFamily(): any;
|
220
226
|
getFESA(): any;
|
221
227
|
getFileName(ext?: string): string;
|
228
|
+
getFlowerColors(): any;
|
222
229
|
getGenus(): {
|
223
230
|
"__#5@#data": any;
|
224
231
|
getTaxa(): any;
|
package/lib/index.js
CHANGED
@@ -8,7 +8,8 @@ import { Families } from "./families.js";
|
|
8
8
|
import { Files } from "./files.js";
|
9
9
|
import { HTML } from "./html.js";
|
10
10
|
import { Jekyll } from "./jekyll.js";
|
11
|
+
import { PlantBook } from "./ebook/plantbook.js";
|
11
12
|
import { Taxa } from "./taxa.js";
|
12
13
|
import { Taxon, TAXA_COLNAMES } from "./taxon.js";
|
13
14
|
|
14
|
-
export { BasePageRenderer, Config, CSV, DataLoader, ErrorLog, Exceptions, Families, Files, HTML, Jekyll, Taxa, TAXA_COLNAMES, Taxon };
|
15
|
+
export { BasePageRenderer, Config, CSV, DataLoader, ErrorLog, Exceptions, Families, Files, HTML, Jekyll, PlantBook, Taxa, TAXA_COLNAMES, Taxon };
|
package/lib/pagetaxon.js
CHANGED
@@ -153,8 +153,8 @@ class PageTaxon extends GenericPage {
|
|
153
153
|
|
154
154
|
html += "</div>";
|
155
155
|
|
156
|
-
html += "<div class=\"grid\">";
|
157
|
-
html += this.#getListSectionHTML( this.#getInfoLinks(), "
|
156
|
+
html += "<div class=\"grid borders\">";
|
157
|
+
html += this.#getListSectionHTML( this.#getInfoLinks(), "References", "info" );
|
158
158
|
html += this.#getListSectionHTML( this.#getObsLinks(), "Observations", "obs" );
|
159
159
|
html += this.#getListSectionHTML( this.#getRelatedTaxaLinks(), "Related Species", "rel-taxa" );
|
160
160
|
html += this.#getListSectionHTML( this.#getSynonyms(), "Synonyms", "synonyms" );
|
package/lib/taxa.js
CHANGED
@@ -5,6 +5,8 @@ import { HTML } from "./html.js";
|
|
5
5
|
import { CSV } from "./csv.js";
|
6
6
|
import { RarePlants } from "./rareplants.js";
|
7
7
|
|
8
|
+
const FLOWER_COLOR_NAMES = [ "white", "red", "pink", "orange", "yellow", "blue" ];
|
9
|
+
|
8
10
|
const TAXA_LIST_COLS = {
|
9
11
|
CESA: {
|
10
12
|
title: "California",
|
@@ -34,11 +36,45 @@ const TAXA_LIST_COLS = {
|
|
34
36
|
|
35
37
|
const DEFAULT_COLUMNS = [ TAXA_LIST_COLS.SPECIES, TAXA_LIST_COLS.COMMON_NAME ];
|
36
38
|
|
39
|
+
class FlowerColor {
|
40
|
+
|
41
|
+
#color;
|
42
|
+
#taxa = [];
|
43
|
+
|
44
|
+
constructor( color ) {
|
45
|
+
this.#color = color;
|
46
|
+
}
|
47
|
+
|
48
|
+
addTaxon( taxon ) {
|
49
|
+
this.#taxa.push( taxon );
|
50
|
+
}
|
51
|
+
|
52
|
+
getColorName( uc = false ) {
|
53
|
+
return uc ? ( this.#color[ 0 ].toUpperCase() + this.#color.substring( 1 ) ) : this.#color;
|
54
|
+
}
|
55
|
+
|
56
|
+
getFileName() {
|
57
|
+
return "list_fc_" + this.#color + ".html";
|
58
|
+
}
|
59
|
+
|
60
|
+
getTaxa() {
|
61
|
+
return this.#taxa;
|
62
|
+
}
|
63
|
+
|
64
|
+
}
|
65
|
+
|
37
66
|
class Taxa {
|
38
67
|
|
39
68
|
static #taxa = {};
|
69
|
+
static #flower_colors = {};
|
40
70
|
static #sortedTaxa;
|
41
71
|
|
72
|
+
static {
|
73
|
+
for ( const color of FLOWER_COLOR_NAMES ) {
|
74
|
+
this.#flower_colors[ color ] = new FlowerColor( color );
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
42
78
|
static getHTMLTable( taxa, columns = DEFAULT_COLUMNS ) {
|
43
79
|
|
44
80
|
let html = "<table><thead>";
|
@@ -67,6 +103,10 @@ class Taxa {
|
|
67
103
|
return html;
|
68
104
|
}
|
69
105
|
|
106
|
+
static getFlowerColor( name ) {
|
107
|
+
return this.#flower_colors[ name ];
|
108
|
+
}
|
109
|
+
|
70
110
|
static getTaxa() {
|
71
111
|
return this.#sortedTaxa;
|
72
112
|
}
|
@@ -134,7 +174,18 @@ class Taxa {
|
|
134
174
|
if ( status !== undefined ) {
|
135
175
|
row[ "status" ] = status;
|
136
176
|
}
|
137
|
-
|
177
|
+
const taxon = new taxonClass( row, taxaMeta[ name ] );
|
178
|
+
this.#taxa[ name ] = taxon;
|
179
|
+
const colors = taxon.getFlowerColors();
|
180
|
+
if ( colors ) {
|
181
|
+
for ( const colorName of colors ) {
|
182
|
+
const color = this.#flower_colors[ colorName ];
|
183
|
+
if ( !color ) {
|
184
|
+
throw new Error( "flower color \"" + colorName + "\" not found" );
|
185
|
+
}
|
186
|
+
color.addTaxon( taxon );
|
187
|
+
}
|
188
|
+
}
|
138
189
|
|
139
190
|
}
|
140
191
|
|
@@ -143,4 +194,4 @@ class Taxa {
|
|
143
194
|
|
144
195
|
}
|
145
196
|
|
146
|
-
export { Taxa, TAXA_LIST_COLS };
|
197
|
+
export { FLOWER_COLOR_NAMES, Taxa, TAXA_LIST_COLS };
|
package/lib/taxon.js
CHANGED
@@ -4,7 +4,8 @@ import { HTML } from "./html.js";
|
|
4
4
|
import { RarePlants } from "./rareplants.js";
|
5
5
|
|
6
6
|
const TAXA_COLNAMES = {
|
7
|
-
COMMON_NAME: "common name"
|
7
|
+
COMMON_NAME: "common name",
|
8
|
+
FLOWER_COLOR: "flower_color",
|
8
9
|
};
|
9
10
|
|
10
11
|
class Taxon {
|
@@ -18,6 +19,7 @@ class Taxon {
|
|
18
19
|
#cfSyn;
|
19
20
|
#iNatID;
|
20
21
|
#iNatSyn;
|
22
|
+
#flowerColors;
|
21
23
|
#rpiID;
|
22
24
|
#rankRPI;
|
23
25
|
#cesa;
|
@@ -40,6 +42,8 @@ class Taxon {
|
|
40
42
|
this.#jepsonID = data[ "jepson id" ];
|
41
43
|
this.#calRecNum = data[ "calrecnum" ];
|
42
44
|
this.#iNatID = data[ "inat id" ];
|
45
|
+
const colors = data[ TAXA_COLNAMES.FLOWER_COLOR ];
|
46
|
+
this.#flowerColors = colors ? colors.split( "," ) : undefined;
|
43
47
|
this.#rpiID = data[ "RPI ID" ];
|
44
48
|
this.#rankRPI = data[ "CRPR" ];
|
45
49
|
this.#cesa = cesa ? cesa : undefined;
|
@@ -112,6 +116,10 @@ class Taxon {
|
|
112
116
|
return this.getBaseFileName() + "." + ext;
|
113
117
|
}
|
114
118
|
|
119
|
+
getFlowerColors() {
|
120
|
+
return this.#flowerColors;
|
121
|
+
}
|
122
|
+
|
115
123
|
getGenus() {
|
116
124
|
return Genera.getGenus( this.#genus );
|
117
125
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ca-plant-list/ca-plant-list",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.2",
|
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": {
|
@@ -18,13 +18,18 @@
|
|
18
18
|
},
|
19
19
|
"types": "./lib/index.d.ts",
|
20
20
|
"bin": {
|
21
|
-
"ca-plant-list": "scripts/build-site.js"
|
21
|
+
"ca-plant-list": "scripts/build-site.js",
|
22
|
+
"ca-plant-book": "scripts/build-ebook.js"
|
22
23
|
},
|
23
24
|
"dependencies": {
|
24
25
|
"@ca-plant-list/tools": "file:../ca-tools",
|
26
|
+
"archiver": "^5.3.1",
|
25
27
|
"command-line-args": "^5.2.1",
|
26
28
|
"command-line-usage": "^6.1.3",
|
27
29
|
"csv-parse": "^5.3.1",
|
30
|
+
"image-size": "^1.0.2",
|
31
|
+
"markdown-it": "^13.0.1",
|
32
|
+
"sharp": "^0.32.1",
|
28
33
|
"unzipper": "^0.10.11"
|
29
34
|
},
|
30
35
|
"devDependencies": {
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
import commandLineArgs from "command-line-args";
|
4
|
+
import { PlantBook } from "@ca-plant-list/ca-plant-list";
|
5
|
+
import { DataLoader } from "../lib/dataloader.js";
|
6
|
+
|
7
|
+
const options = commandLineArgs( DataLoader.getOptionDefs() );
|
8
|
+
|
9
|
+
DataLoader.load( options );
|
10
|
+
|
11
|
+
const ebook = new PlantBook();
|
12
|
+
await ebook.create();
|