@ca-plant-list/ca-plant-list 0.2.12 → 0.2.13
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/lib/config.js +7 -10
- package/lib/index.d.ts +6 -5
- package/lib/pagerenderer.js +6 -7
- package/lib/taxon.js +2 -3
- package/lib/web/pagetaxon.js +6 -5
- package/package.json +1 -1
- package/scripts/build-site.js +2 -1
package/lib/config.js
CHANGED
@@ -4,18 +4,15 @@ import { Files } from "./files.js";
|
|
4
4
|
|
5
5
|
class Config {
|
6
6
|
|
7
|
-
static #config = {};
|
8
7
|
static #packageDir = path.dirname( path.dirname( url.fileURLToPath( import.meta.url ) ) );
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
console.log( e );
|
15
|
-
}
|
9
|
+
#config = {};
|
10
|
+
|
11
|
+
constructor( dataDir ) {
|
12
|
+
this.#config = JSON.parse( Files.read( dataDir + "/config.json" ) );
|
16
13
|
}
|
17
14
|
|
18
|
-
|
15
|
+
getConfigValue( prefix, name, subcat, dflt ) {
|
19
16
|
const obj = this.#config[ prefix ];
|
20
17
|
if ( obj ) {
|
21
18
|
if ( Object.hasOwn( obj, name ) ) {
|
@@ -34,11 +31,11 @@ class Config {
|
|
34
31
|
return dflt;
|
35
32
|
}
|
36
33
|
|
37
|
-
|
34
|
+
getCountyCodes() {
|
38
35
|
return this.#config[ "counties" ];
|
39
36
|
}
|
40
37
|
|
41
|
-
|
38
|
+
getLabel( name, dflt ) {
|
42
39
|
return this.getConfigValue( "labels", name, undefined, dflt );
|
43
40
|
}
|
44
41
|
|
package/lib/index.d.ts
CHANGED
@@ -3,12 +3,13 @@ export class BasePageRenderer {
|
|
3
3
|
static renderTools(outputDir: any, taxa: any): void;
|
4
4
|
}
|
5
5
|
export class Config {
|
6
|
-
static "__#1@#config": {};
|
7
6
|
static "__#1@#packageDir": string;
|
8
|
-
static getConfigValue(prefix: any, name: any, subcat: any, dflt: any): any;
|
9
|
-
static getCountyCodes(): any;
|
10
|
-
static getLabel(name: any, dflt: any): any;
|
11
7
|
static getPackageDir(): string;
|
8
|
+
constructor(dataDir: any);
|
9
|
+
getConfigValue(prefix: any, name: any, subcat: any, dflt: any): any;
|
10
|
+
getCountyCodes(): any;
|
11
|
+
getLabel(name: any, dflt: any): any;
|
12
|
+
#private;
|
12
13
|
}
|
13
14
|
export class CSV {
|
14
15
|
static getMap(dir: any, fileName: any): {};
|
@@ -256,7 +257,7 @@ export class Taxon {
|
|
256
257
|
getRPIRankAndThreatTooltip(): string;
|
257
258
|
getRPITaxonLink(): string;
|
258
259
|
getStatus(): any;
|
259
|
-
getStatusDescription(): any;
|
260
|
+
getStatusDescription(config: any): any;
|
260
261
|
getSynonyms(): any[];
|
261
262
|
isCANative(): boolean;
|
262
263
|
/**
|
package/lib/pagerenderer.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import { Files, HTML } from "@ca-plant-list/ca-plant-list";
|
2
2
|
import { Taxa, TAXA_LIST_COLS } from "./taxa.js";
|
3
3
|
import { PageTaxon } from "./web/pagetaxon.js";
|
4
|
-
import { Config } from "./config.js";
|
5
4
|
import { RarePlants } from "./rareplants.js";
|
6
5
|
import { BasePageRenderer } from "./basepagerenderer.js";
|
7
6
|
import { GenericPage } from "./genericpage.js";
|
@@ -11,20 +10,20 @@ const RPI_COLUMNS = [ TAXA_LIST_COLS.SPECIES_BARE, TAXA_LIST_COLS.COMMON_NAME, T
|
|
11
10
|
|
12
11
|
class PageRenderer extends BasePageRenderer {
|
13
12
|
|
14
|
-
static render( outputDir, taxa ) {
|
13
|
+
static render( outputDir, config, taxa ) {
|
15
14
|
|
16
15
|
super.render( outputDir, taxa );
|
17
16
|
|
18
|
-
this.renderLists( outputDir, taxa );
|
17
|
+
this.renderLists( outputDir, config, taxa );
|
19
18
|
|
20
19
|
const taxonList = taxa.getTaxa();
|
21
20
|
for ( const taxon of taxonList ) {
|
22
|
-
new PageTaxon( outputDir, taxon ).render();
|
21
|
+
new PageTaxon( outputDir, config, taxon ).render();
|
23
22
|
}
|
24
23
|
|
25
24
|
}
|
26
25
|
|
27
|
-
static renderLists( outputDir, taxa ) {
|
26
|
+
static renderLists( outputDir, config, taxa ) {
|
28
27
|
|
29
28
|
function getListArray( listInfo, attributes = {}, columns ) {
|
30
29
|
|
@@ -76,8 +75,8 @@ class PageRenderer extends BasePageRenderer {
|
|
76
75
|
{
|
77
76
|
title: "All Species",
|
78
77
|
listInfo: [
|
79
|
-
{ name:
|
80
|
-
{ name:
|
78
|
+
{ name: config.getLabel( "native", "Native" ), filename: "list_native", include: ( t ) => t.isNative() },
|
79
|
+
{ name: config.getLabel( "introduced", "Introduced" ), filename: "list_introduced", include: ( t ) => !t.isNative() },
|
81
80
|
{ name: "All Plants", filename: "list_all", include: () => true },
|
82
81
|
]
|
83
82
|
},
|
package/lib/taxon.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { Config } from "./config.js";
|
2
1
|
import { Genera } from "./genera.js";
|
3
2
|
import { HTML } from "./html.js";
|
4
3
|
import { RarePlants } from "./rareplants.js";
|
@@ -224,12 +223,12 @@ class Taxon {
|
|
224
223
|
return this.#status;
|
225
224
|
}
|
226
225
|
|
227
|
-
getStatusDescription() {
|
226
|
+
getStatusDescription( config ) {
|
228
227
|
switch ( this.#status ) {
|
229
228
|
case "N":
|
230
229
|
return "Native";
|
231
230
|
case "NC":
|
232
|
-
return
|
231
|
+
return config.getLabel( "status-NC", "Introduced" );
|
233
232
|
case "X":
|
234
233
|
return "Introduced";
|
235
234
|
}
|
package/lib/web/pagetaxon.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { HTML } from "@ca-plant-list/ca-plant-list";
|
2
2
|
import { Jepson } from "../jepson.js";
|
3
|
-
import { Config } from "../config.js";
|
4
3
|
import { RarePlants } from "../rareplants.js";
|
5
4
|
import { GenericPage } from "../genericpage.js";
|
6
5
|
import { ExternalSites } from "../externalsites.js";
|
@@ -8,10 +7,12 @@ import { DateUtils } from "../dateutils.js";
|
|
8
7
|
|
9
8
|
class PageTaxon extends GenericPage {
|
10
9
|
|
10
|
+
#config;
|
11
11
|
#taxon;
|
12
12
|
|
13
|
-
constructor( outputDir, taxon ) {
|
13
|
+
constructor( outputDir, config, taxon ) {
|
14
14
|
super( outputDir, taxon.getName(), taxon.getBaseFileName() );
|
15
|
+
this.#config = config;
|
15
16
|
this.#taxon = taxon;
|
16
17
|
}
|
17
18
|
|
@@ -73,7 +74,7 @@ class PageTaxon extends GenericPage {
|
|
73
74
|
links.push(
|
74
75
|
HTML.getLink(
|
75
76
|
"https://www.calflora.org/entry/observ.html?track=m#srch=t&grezc=5&cols=b&lpcli=t&cc="
|
76
|
-
+
|
77
|
+
+ this.#config.getCountyCodes().join( "!" ) + "&incobs=f&taxon="
|
77
78
|
+ this.#taxon.getCalfloraName().replaceAll( " ", "+" ),
|
78
79
|
"Calflora",
|
79
80
|
{},
|
@@ -86,7 +87,7 @@ class PageTaxon extends GenericPage {
|
|
86
87
|
HTML.getLink(
|
87
88
|
ExternalSites.getInatObsLink(
|
88
89
|
{
|
89
|
-
project_id:
|
90
|
+
project_id: this.#config.getConfigValue( "inat", "project_id" ),
|
90
91
|
subview: "map",
|
91
92
|
taxon_id: iNatID
|
92
93
|
}
|
@@ -163,7 +164,7 @@ class PageTaxon extends GenericPage {
|
|
163
164
|
html += HTML.textElement( "div", cn.join( ", " ), { class: "section common-names" } );
|
164
165
|
}
|
165
166
|
|
166
|
-
html += HTML.textElement( "div", this.#taxon.getStatusDescription(), { class: "section native-status" } );
|
167
|
+
html += HTML.textElement( "div", this.#taxon.getStatusDescription( this.#config ), { class: "section native-status" } );
|
167
168
|
|
168
169
|
const family = this.#taxon.getFamily();
|
169
170
|
html += HTML.wrap(
|
package/package.json
CHANGED
package/scripts/build-site.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
|
3
|
+
import { Config } from "../lib/config.js";
|
3
4
|
import { DataLoader } from "../lib/dataloader.js";
|
4
5
|
import { ErrorLog } from "../lib/errorlog.js";
|
5
6
|
import { PageRenderer } from "../lib/pagerenderer.js";
|
@@ -9,6 +10,6 @@ const options = commandLineArgs( DataLoader.getOptionDefs() );
|
|
9
10
|
|
10
11
|
const OUTPUT_DIR = "./output";
|
11
12
|
|
12
|
-
PageRenderer.render( OUTPUT_DIR, DataLoader.load( options ) );
|
13
|
+
PageRenderer.render( OUTPUT_DIR, new Config( options.datadir ), DataLoader.load( options ) );
|
13
14
|
|
14
15
|
ErrorLog.write( OUTPUT_DIR + "/errors.tsv" );
|