@ca-plant-list/ca-plant-list 0.2.14 → 0.2.16

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/synonyms.csv CHANGED
@@ -811,7 +811,6 @@ Helianthemum scoparium var. vulgare,Crocanthemum scoparium var. vulgare
811
811
  Helianthus annuus subsp. jaegeri,Helianthus annuus
812
812
  Helianthus annuus subsp. lenticularis,Helianthus annuus
813
813
  Helianthus annuus var. macrocarpus,Helianthus annuus
814
- Helichrysum luteoalbum,Pseudognaphalium luteoalbum,INAT
815
814
  Heliotropium oculatum,Heliotropium curassavicum var. oculatum
816
815
  Heliotropium spathulatum subsp. oculatum,Heliotropium curassavicum var. oculatum
817
816
  Helxine soleirolii,Soleirolia soleirolii
@@ -979,7 +978,6 @@ Lessingia filaginifolia var. filaginifolia,Corethrogyne filaginifolia
979
978
  Lessingia germanorum var. parvula,Lessingia tenuis
980
979
  Lessingia germanorum var. tenuis,Lessingia tenuis
981
980
  Lessingia nemaclada var. albiflora,Lessingia nemaclada
982
- Leuzea repens,Rhaponticum repens,INAT
983
981
  Lewisia alba,Lewisia rediviva var. rediviva
984
982
  Leymus ×multiflorus,Elymus ×gouldii,INAT
985
983
  Leymus mollis subsp. mollis,Elymus mollis subsp. mollis,INAT
@@ -1538,6 +1536,7 @@ Prunella vulgaris var. atropurpurea,Prunella vulgaris var. lanceolata
1538
1536
  Prunella vulgaris var. parviflora,Prunella vulgaris var. vulgaris
1539
1537
  Prunus amygdalus,Prunus dulcis,INAT
1540
1538
  Pseudognaphalium canescens subsp. beneolens,Pseudognaphalium beneolens
1539
+ Pseudognaphalium luteoalbum,Pseudognaphalium luteoalbum,INAT
1541
1540
  Pseudognaphalium microcephalum var. thermale,Pseudognaphalium thermale
1542
1541
  Psilocarphus tenellus var. globiferus,Psilocarphus chilensis
1543
1542
  Psilocarphus tenellus var. tenellus,Psilocarphus tenellus
@@ -1590,6 +1589,7 @@ Rhamnus tomentella subsp. tomentella,Frangula californica subsp. tomentella
1590
1589
  Rhamnus tomentella,Frangula californica subsp. tomentella
1591
1590
  Rhamphospermum arvense,Sinapis arvensis,INAT
1592
1591
  Rhamphospermum nigrum,Brassica nigra,INAT
1592
+ Rhaponticum repens,Rhaponticum repens,INAT
1593
1593
  Rhus aromatica subsp. trilobata,Rhus aromatica
1594
1594
  Rhus aromatica var. simplicifolia,Rhus aromatica
1595
1595
  Rhus aromatica var. trilobata,Rhus aromatica
package/data/taxa.csv CHANGED
@@ -248,7 +248,7 @@ Bromus sitchensis var. maritimus,maritime brome,N,108591,13625,71142
248
248
  Bromus sterilis,poverty brome,X,16288,1216,57163
249
249
  Bromus tectorum,cheat grass,X,16290,1218,58369
250
250
  Buddleja davidii,butterfly bush,X,16349,1222,75916
251
- Cabomba caroliniana,fanwort,X,16450,8513,75921
251
+ Cabomba caroliniana,fanwort,X,16450,8513,75921,white,5,9
252
252
  Cakile edentula,sea rocket,X,16523,1232,52162
253
253
  Cakile maritima,sea rocket,X,16531,1233,60982
254
254
  Calamagrostis koelerioides,,N,16557,1240,75927
@@ -267,7 +267,7 @@ Calochortus albus,white globe lily,N,16710,1264,51315,white
267
267
  Calochortus argillosus,clay mariposa lily,N,76542,1268,64330,"white,pink"
268
268
  Calochortus clavatus var. pallidus,,N,55455,1275,58360
269
269
  Calochortus invenustus,,N,16733,1284,64432
270
- Calochortus leichtlinii
270
+ Calochortus leichtlinii,,N,16735,1288,52542
271
271
  Calochortus luteus,yellow mariposa lily,N,16737,1290,51077,yellow
272
272
  Calochortus pulchellus,Mt. Diablo fairy lantern,N,16755,1303,47326,,,,50,1B.2,,,S2,G2
273
273
  Calochortus splendens,,N,16759,1306,58361
@@ -362,7 +362,7 @@ Centromadia pungens subsp. pungens,common spikeweed,N,80173,9544,64196
362
362
  Cephalanthus occidentalis,button bush,N,18612,9794,52763
363
363
  Cerastium fontanum subsp. vulgare,,X,49818,1872,1005385
364
364
  Cerastium glomeratum,mouse-ear chickweed,X,18675,1873,52973
365
- Ceratophyllum demersum,hornwort,N,18711,1874,60997
365
+ Ceratophyllum demersum,hornwort,N,18711,1874,60997,,6,8
366
366
  Cercis occidentalis,western redbud,N,18736,1877,59556
367
367
  Cercocarpus betuloides var. betuloides,mountain-mahogany,N,71734,1879,59001
368
368
  Cestrum parqui,Chilean jessamine,X,18790,8746,76226
@@ -907,7 +907,7 @@ Impatiens balfourii,touch-me-not,X,28954,4320,77490
907
907
  Iris douglasiana,Douglas' iris,N,29188,4346,50854
908
908
  Iris foetidissima,stinking iris,X,29193,8604,64331
909
909
  Iris longipetala,central coast iris,N,29293,4354,67703,,,,3169,4.2,,,S3,G3
910
- Iris macrosiphon,,N,29289
910
+ Iris macrosiphon,,N,29289,4355,54057
911
911
  Iris pseudacorus,yellow flag,X,29301,4358,47779
912
912
  Isocoma arguta,Carquinez goldenbush,N,3633,4369,77510,,,,1264,1B.1,,,S1,G1
913
913
  Isoetes howellii,Howell's quillwort,N,29392,4379,63823
@@ -1216,7 +1216,7 @@ Navarretia squarrosa,skunkweed,N,34475,5807,53157
1216
1216
  Navarretia tagetina,,N,34477,5809,60226
1217
1217
  Navarretia viscidula,sticky navarretia,N,34478,5810,78195
1218
1218
  Nemophila heterophylla,,N,34539,5834,53158
1219
- Nemophila menziesii var. atomaria,,N,62279,,,white,2,6
1219
+ Nemophila menziesii var. atomaria,,N,62279,5837,50647,white,2,6
1220
1220
  Nemophila menziesii var. menziesii,baby blue-eyes,N,62285,5839,50650
1221
1221
  Nemophila parviflora var. parviflora,,N,62288,5842,58921
1222
1222
  Nemophila pedunculata,,N,34544,5844,55461
@@ -1425,7 +1425,7 @@ Prunus virginiana var. demissa,western choke-cherry,N,64546,6898,63900
1425
1425
  Pseudognaphalium beneolens,,N,81674,11047,64303
1426
1426
  Pseudognaphalium biolettii,,N,81666,11955,58829
1427
1427
  Pseudognaphalium californicum,,N,80569,11956,53077
1428
- Pseudognaphalium luteoalbum,cudweed,X,101867,11957,209711
1428
+ Pseudognaphalium luteoalbum,cudweed,X,101867,11957,53083
1429
1429
  Pseudognaphalium microcephalum,,N,81265,11048,78763
1430
1430
  Pseudognaphalium ramosissimum,,N,80579,11959,53088
1431
1431
  Pseudognaphalium stramineum,,N,40045,11960,53089
@@ -1480,7 +1480,7 @@ Raphanus sativus,wild radish,X,40992,7064,55410
1480
1480
  Rhamnus alaternus,Italian buckthorn,X,81104,9447,82856
1481
1481
  Rhamnus crocea,spiny redberry,N,41069,7075,57243
1482
1482
  Rhamnus ilicifolia,holly-leaf redberry,N,41070,7076,58308
1483
- Rhaponticum repens,Russian knapweed,X,103802,13621,1061170
1483
+ Rhaponticum repens,Russian knapweed,X,103802,13621,339502
1484
1484
  Rhinotropis californica,California milkwort,N,107535,14636,876453
1485
1485
  Rhus aromatica,skunkbrush,N,41175,11056,58738
1486
1486
  Ribes amarum,bitter gooseberry,N,41372,7099,53433
@@ -0,0 +1,9 @@
1
+ defaults:
2
+ -
3
+ scope:
4
+ path: ""
5
+ values:
6
+ layout: "html"
7
+
8
+ navbar-name: SITE NAME
9
+ bootstrap-prefix: https://cdn.jsdelivr.net/npm/bootstrap/dist
@@ -1,60 +1,57 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
 
4
- <head>
5
- <meta charset="utf-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1">
7
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet"
8
- integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
9
- <title>{{page.title}}</title>
10
- <link href="{{site.baseurl}}/assets/css/main.css" rel="stylesheet">
11
- </head>
12
-
13
- <body>
14
-
15
- <nav class="navbar navbar-expand-md">
16
- <div class="container-xxl px-5">
17
- <button id="hamburger" class="navbar-toggler" type="button" data-bs-toggle="collapse"
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <link href="{{site.bootstrap-prefix}}/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
8
+ <title>{{page.title}}</title>
9
+ <link href="{{site.baseurl}}/assets/css/main.css" rel="stylesheet">
10
+ </head>
11
+
12
+ <body>
13
+
14
+ <nav class="navbar navbar-expand-md">
15
+ <div class="container-xxl px-5">
16
+ <button id="hamburger" class="navbar-toggler" type="button" data-bs-toggle="collapse"
18
17
  data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
19
18
  aria-label="Toggle navigation">
20
- <span class="navbar-toggler-icon"></span>
21
- </button>
22
- <a class="navbar-brand" href="{{'/' | relative_url}}">{{site.navbar-name}}</a>
23
- <div class="collapse navbar-collapse" id="navbarSupportedContent">
24
- <ul class="navbar-nav me-auto mb-lg-0">
25
- <li class="nav-item">
26
- <a class="nav-link" href="{{site.baseurl}}/index_lists.html">Plant Lists</a>
27
- </li>
28
- <li class="nav-item">
29
- <a class="nav-link" href="{{site.baseurl}}/rare_plants.html">Rare Plants</a>
30
- </li>
31
- <li class="nav-item">
32
- <a class="nav-link" href="{{site.baseurl}}/name_search.html">Name Search</a>
33
- </li>
34
- <li class="nav-item">
35
- <a class="nav-link" href="{{site.baseurl}}/glossary.html">Glossary</a>
36
- </li>
37
- {%include menu_extra.html %}
38
- </ul>
19
+ <span class="navbar-toggler-icon"></span>
20
+ </button>
21
+ <a class="navbar-brand" href="{{'/' | relative_url}}">{{site.navbar-name}}</a>
22
+ <div class="collapse navbar-collapse" id="navbarSupportedContent">
23
+ <ul class="navbar-nav me-auto mb-lg-0">
24
+ <li class="nav-item">
25
+ <a class="nav-link" href="{{site.baseurl}}/index_lists.html">Plant Lists</a>
26
+ </li>
27
+ <li class="nav-item">
28
+ <a class="nav-link" href="{{site.baseurl}}/rare_plants.html">Rare Plants</a>
29
+ </li>
30
+ <li class="nav-item">
31
+ <a class="nav-link" href="{{site.baseurl}}/name_search.html">Name Search</a>
32
+ </li>
33
+ <li class="nav-item">
34
+ <a class="nav-link" href="{{site.baseurl}}/glossary.html">Glossary</a>
35
+ </li>
36
+ {%include menu_extra.html %}
37
+ </ul>
38
+ </div>
39
39
  </div>
40
- </div>
41
- </nav>
40
+ </nav>
42
41
 
43
- <div class="container-xxl px-5">
44
- <h1>{{page.title}}</h1>
45
- {{content}}
46
- </div>
42
+ <div class="container-xxl px-5">
43
+ <h1>{{page.title}}</h1>
44
+ {{content}}
45
+ </div>
47
46
 
48
- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js"
49
- integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa"
50
- crossorigin="anonymous"></script>
47
+ <script src="{{site.bootstrap-prefix}}/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
51
48
 
52
- {%if page.js%}
53
- <script src="{{site.baseurl}}/assets/js/{{page.js}}" type="module"></script>{%endif%}
49
+ {%if page.js%}
50
+ <script src="{{site.baseurl}}/assets/js/{{page.js}}" type="module"></script>{%endif%}
54
51
 
55
- <script src="{{site.baseurl}}/assets/js/ui.js" type="module"></script>
52
+ <script src="{{site.baseurl}}/assets/js/ui.js" type="module"></script>
56
53
 
57
- {%include analytics.html%}
58
- </body>
54
+ {%include analytics.html%}
55
+ </body>
59
56
 
60
- </html>
57
+ </html>
@@ -27,7 +27,7 @@ class BasePageRenderer {
27
27
  static renderTools( outputDir, taxa ) {
28
28
 
29
29
  const names = [];
30
- for ( const taxon of taxa.getTaxa() ) {
30
+ for ( const taxon of taxa.getTaxonList() ) {
31
31
  const row = [];
32
32
  row.push( taxon.getName() );
33
33
  const cn = taxon.getCommonNames().join( ", " );
@@ -3,6 +3,20 @@ import commandLineUsage from "command-line-usage";
3
3
 
4
4
  const OPTION_DEFS = [
5
5
  { name: "help", type: Boolean },
6
+ { name: "show-flower-errors", type: Boolean },
7
+ ];
8
+
9
+ const OPTION_HELP = [
10
+ {
11
+ name: "help",
12
+ type: Boolean,
13
+ description: "Print this usage guide."
14
+ },
15
+ {
16
+ name: "show-flower-errors",
17
+ type: Boolean,
18
+ description: "Include flower color and flowering time errors in errors.tsv."
19
+ },
6
20
  ];
7
21
 
8
22
  class CommandRunner {
@@ -45,13 +59,7 @@ class CommandRunner {
45
59
  },
46
60
  {
47
61
  header: "Options",
48
- optionList: [
49
- {
50
- name: "help",
51
- type: Boolean,
52
- description: "Print this usage guide."
53
- },
54
- ]
62
+ optionList: OPTION_HELP
55
63
  }
56
64
  ];
57
65
  help[ 1 ].optionList = help[ 1 ].optionList.concat( this.#optionHelp );
package/lib/dataloader.js CHANGED
@@ -4,7 +4,7 @@ import { Files } from "./files.js";
4
4
 
5
5
  class DataLoader {
6
6
 
7
- static load( dataDir ) {
7
+ static load( options ) {
8
8
 
9
9
  function getIncludeList( dataDir ) {
10
10
  // Read inclusion list.
@@ -22,9 +22,11 @@ class DataLoader {
22
22
  return include;
23
23
  }
24
24
 
25
+ const showFlowerErrors = options[ "show-flower-errors" ];
26
+
25
27
  console.log( "loading data" );
26
28
 
27
- return new Taxa( getIncludeList( dataDir ) );
29
+ return new Taxa( getIncludeList( options.datadir ), showFlowerErrors );
28
30
 
29
31
  }
30
32
 
@@ -93,7 +93,7 @@ class PageListFlowerTime extends EBookPage {
93
93
 
94
94
  const range = [ this.#m1, this.#m2 ];
95
95
  const links = [];
96
- for ( const taxon of this.#taxa.getTaxa() ) {
96
+ for ( const taxon of this.#taxa.getTaxonList() ) {
97
97
  const m1 = taxon.getBloomStart();
98
98
  const m2 = taxon.getBloomEnd();
99
99
  if ( m1 && DateUtils.monthRangesOverlap( range, [ m1, m2 ] ) ) {
@@ -28,8 +28,10 @@ class TaxonPage extends EBookPage {
28
28
  return "";
29
29
  }
30
30
  let html = "";
31
- for ( const color of colors ) {
32
- html += XHTML.textElement( "img", "", { src: "./i/f-" + color + ".svg", class: "flr" } );
31
+ if ( colors ) {
32
+ for ( const color of colors ) {
33
+ html += XHTML.textElement( "img", "", { src: "./i/f-" + color + ".svg", class: "flr" } );
34
+ }
33
35
  }
34
36
  if ( monthStart ) {
35
37
  html += XHTML.textElement( "div", DateUtils.getMonthName( monthStart ) + "-" + DateUtils.getMonthName( monthEnd ) );
@@ -36,7 +36,7 @@ class PlantBook extends EBook {
36
36
  const contentDir = this.getContentDir();
37
37
 
38
38
  console.log( "creating taxon pages" );
39
- const taxonList = this.#taxa.getTaxa();
39
+ const taxonList = this.#taxa.getTaxonList();
40
40
  for ( const taxon of taxonList ) {
41
41
  const name = taxon.getName();
42
42
  new TaxonPage( contentDir, taxon, this.#images[ name ] ).create();
@@ -124,7 +124,7 @@ class PlantBook extends EBook {
124
124
  }
125
125
 
126
126
  // Add taxa.
127
- for ( let index = 0; index < this.#taxa.getTaxa().length; index++ ) {
127
+ for ( let index = 0; index < this.#taxa.getTaxonList().length; index++ ) {
128
128
  xml += "<itemref idref=\"t" + index + "\"/>";
129
129
  }
130
130
 
package/lib/index.d.ts CHANGED
@@ -26,7 +26,7 @@ export class CSV {
26
26
  static parseStream(dir: any, fileName: any, columns: boolean, delimiter: any, callback: any): Promise<void>;
27
27
  }
28
28
  export class DataLoader {
29
- static load(dataDir: any): Taxa;
29
+ static load(options: any): Taxa;
30
30
  }
31
31
  import { Taxa } from "./taxa.js";
32
32
  export class DateUtils {
@@ -175,13 +175,8 @@ export class Taxa {
175
175
  title: string;
176
176
  data: (t: any) => any;
177
177
  }[]): string;
178
- constructor(inclusionList: any, taxaMeta?: {}, taxonClass?: typeof Taxon, extraTaxa?: any[], extraSynonyms?: any[]);
178
+ constructor(inclusionList: any, showFlowerErrors: any, taxaMeta?: {}, taxonClass?: typeof Taxon, extraTaxa?: any[], extraSynonyms?: any[]);
179
179
  getFlowerColor(name: any): any;
180
- /**
181
- *
182
- * @deprecated
183
- */
184
- getTaxa(): any[];
185
180
  getTaxon(name: any): any;
186
181
  getTaxonList(): any[];
187
182
  #private;
@@ -273,5 +268,6 @@ export class Taxon {
273
268
  */
274
269
  isNative(): boolean;
275
270
  isRare(): boolean;
271
+ shouldHaveFlowers(): boolean;
276
272
  #private;
277
273
  }
@@ -32,7 +32,7 @@ class PageRenderer extends BasePageRenderer {
32
32
  const listTaxa = [];
33
33
  const calfloraTaxa = [];
34
34
  const iNatTaxa = [];
35
- for ( const taxon of taxa.getTaxa() ) {
35
+ for ( const taxon of taxa.getTaxonList() ) {
36
36
  if ( list.include( taxon ) ) {
37
37
  listTaxa.push( taxon );
38
38
  calfloraTaxa.push( taxon.getCalfloraName() );
package/lib/taxa.js CHANGED
@@ -69,7 +69,7 @@ class Taxa {
69
69
  #flower_colors = {};
70
70
  #sortedTaxa;
71
71
 
72
- constructor( inclusionList, taxaMeta = {}, taxonClass = Taxon, extraTaxa = [], extraSynonyms = [] ) {
72
+ constructor( inclusionList, showFlowerErrors, taxaMeta = {}, taxonClass = Taxon, extraTaxa = [], extraSynonyms = [] ) {
73
73
  for ( const color of FLOWER_COLOR_NAMES ) {
74
74
  this.#flower_colors[ color ] = new FlowerColor( color );
75
75
  }
@@ -77,8 +77,8 @@ class Taxa {
77
77
  const dataDir = Config.getPackageDir() + "/data";
78
78
 
79
79
  const taxaCSV = CSV.parseFile( dataDir, "taxa.csv" );
80
- this.#loadTaxa( taxaCSV, inclusionList, taxaMeta, taxonClass );
81
- this.#loadTaxa( extraTaxa, inclusionList, taxaMeta, taxonClass );
80
+ this.#loadTaxa( taxaCSV, inclusionList, taxaMeta, taxonClass, showFlowerErrors );
81
+ this.#loadTaxa( extraTaxa, inclusionList, taxaMeta, taxonClass, showFlowerErrors );
82
82
 
83
83
  // Make sure everything in the inclusionList has been loaded.
84
84
  for ( const name of Object.keys( inclusionList ) ) {
@@ -127,14 +127,6 @@ class Taxa {
127
127
  return this.#flower_colors[ name ];
128
128
  }
129
129
 
130
- /**
131
- *
132
- * @deprecated
133
- */
134
- getTaxa() {
135
- return this.#sortedTaxa;
136
- }
137
-
138
130
  getTaxon( name ) {
139
131
  return this.#taxa[ name ];
140
132
  }
@@ -158,7 +150,7 @@ class Taxa {
158
150
  }
159
151
  }
160
152
 
161
- #loadTaxa( taxaCSV, inclusionList, taxaMeta, taxonClass ) {
153
+ #loadTaxa( taxaCSV, inclusionList, taxaMeta, taxonClass, showFlowerErrors ) {
162
154
  for ( const row of taxaCSV ) {
163
155
 
164
156
  const name = row[ "taxon_name" ];
@@ -192,6 +184,18 @@ class Taxa {
192
184
  }
193
185
  }
194
186
 
187
+ if ( showFlowerErrors ) {
188
+ // Make sure flower colors/bloom times are present or not depending on taxon.
189
+ if ( taxon.shouldHaveFlowers() ) {
190
+ if ( !colors || !taxon.getBloomStart() || !taxon.getBloomEnd() ) {
191
+ ErrorLog.log( name, "does not have all flower info" );
192
+ }
193
+ } else {
194
+ if ( colors || taxon.getBloomStart() || taxon.getBloomEnd() ) {
195
+ ErrorLog.log( name, "should not have flower info" );
196
+ }
197
+ }
198
+ }
195
199
  }
196
200
 
197
201
  }
package/lib/taxon.js CHANGED
@@ -255,6 +255,23 @@ class Taxon {
255
255
  return this.getRPIRank() !== undefined;
256
256
  }
257
257
 
258
+ shouldHaveFlowers() {
259
+ const sectionName = this.getFamily().getSectionName();
260
+ switch ( sectionName ) {
261
+ case "Ceratophyllales":
262
+ case "Eudicots":
263
+ case "Magnoliids":
264
+ case "Monocots":
265
+ case "Nymphaeales":
266
+ return true;
267
+ case "Ferns":
268
+ case "Gymnosperms":
269
+ case "Lycophytes":
270
+ return false;
271
+ default:
272
+ throw new Error( sectionName );
273
+ }
274
+ }
258
275
  }
259
276
 
260
277
  export { TAXA_COLNAMES, Taxon };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ca-plant-list/ca-plant-list",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
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": {
@@ -41,7 +41,7 @@ async function generateEBooks( options ) {
41
41
 
42
42
  // If a data directory was specified, use it.
43
43
  if ( dataDir ) {
44
- await generateEBook( dataDir );
44
+ await generateEBook( options );
45
45
  return;
46
46
  }
47
47
 
@@ -54,21 +54,23 @@ async function generateEBooks( options ) {
54
54
  const suffix = "/" + subdir;
55
55
  const path = LOC_DIR + suffix;
56
56
  if ( Files.isDir( path ) ) {
57
- await generateEBook( path, suffix );
57
+ options.datadir = path;
58
+ await generateEBook( options, suffix );
58
59
  }
59
60
  }
60
61
  return;
61
62
  }
62
63
 
63
64
  // Otherwise use the default directory.
64
- await generateEBook( "./data" );
65
+ options.datadir = "./data";
66
+ await generateEBook( options );
65
67
 
66
68
  ErrorLog.write( OUTPUT_DIR + "/errors.tsv" );
67
69
 
68
70
  }
69
71
 
70
- async function generateEBook( dataDir, outputSuffix = "" ) {
71
- const ebook = new PlantBook( OUTPUT_DIR + outputSuffix, new Config( dataDir ), DataLoader.load( dataDir ) );
72
+ async function generateEBook( options, outputSuffix = "" ) {
73
+ const ebook = new PlantBook( OUTPUT_DIR + outputSuffix, new Config( options.datadir ), DataLoader.load( options ) );
72
74
  await ebook.create();
73
75
  }
74
76
 
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import * as child_process from "node:child_process";
4
+ import * as path from "node:path";
5
+ import { Files } from "@ca-plant-list/ca-plant-list";
3
6
  import { Config } from "../lib/config.js";
4
7
  import { DataLoader } from "../lib/dataloader.js";
5
8
  import { PageRenderer } from "../lib/pagerenderer.js";
@@ -22,6 +25,38 @@ const OPTION_HELP = [
22
25
  },
23
26
  ];
24
27
 
28
+ class JekyllRenderer {
29
+
30
+ #srcDir = "./output";
31
+ #destDir = "./public";
32
+
33
+ async renderPages() {
34
+
35
+ function addConfigFile( configFiles, dir, name ) {
36
+ const fullPath = path.join( dir, name );
37
+ if ( Files.exists( fullPath ) ) {
38
+ configFiles.push( fullPath );
39
+ }
40
+ }
41
+
42
+ // Remove existing files.
43
+ Files.rmDir( this.#destDir );
44
+
45
+ const options = [ "--source", this.#srcDir, "--destination", this.#destDir ];
46
+
47
+ // Find out what config files are available.
48
+ const configFiles = [];
49
+ addConfigFile( configFiles, this.#srcDir, "_config.yml" );
50
+ addConfigFile( configFiles, this.#srcDir, "_config-local.yml" );
51
+ addConfigFile( configFiles, ".", "_config-dev.yml" );
52
+ options.push( "--config", "\"" + configFiles.join() + "\"" );
53
+
54
+ const result = child_process.execSync( "bundle exec jekyll build " + options.join( " " ) );
55
+ console.log( result.toString() );
56
+ }
57
+
58
+ }
59
+
25
60
  const cr = new CommandRunner(
26
61
  "ca-plant-list",
27
62
  "A tool to generate a website with local plant data.",
@@ -32,9 +67,13 @@ const cr = new CommandRunner(
32
67
  );
33
68
  await cr.processCommandLine();
34
69
 
35
- function generateSite( options ) {
70
+ async function generateSite( options ) {
36
71
  const dataDir = options.datadir;
37
- PageRenderer.render( OUTPUT_DIR, new Config( dataDir ), DataLoader.load( dataDir ) );
72
+ PageRenderer.render( OUTPUT_DIR, new Config( dataDir ), DataLoader.load( options ) );
38
73
  ErrorLog.write( OUTPUT_DIR + "/errors.tsv" );
74
+
75
+ console.log( "generating site" );
76
+ const r = new JekyllRenderer();
77
+ await r.renderPages();
39
78
  }
40
79