@ca-plant-list/ca-plant-list 0.1.18 → 0.1.19

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/genera.json CHANGED
@@ -11,10 +11,6 @@
11
11
  "family": "Lycopodiaceae",
12
12
  "id": "9179"
13
13
  },
14
- "Rhinotropis": {
15
- "family": "Polygalaceae",
16
- "id": 99965
17
- },
18
14
  "Selaginella": {
19
15
  "family": "Selaginellaceae",
20
16
  "id": "8877"
@@ -2091,6 +2087,10 @@
2091
2087
  "family": "Caryophyllaceae",
2092
2088
  "id": "10424"
2093
2089
  },
2090
+ "Atocion": {
2091
+ "family": "Caryophyllaceae",
2092
+ "id": "85146"
2093
+ },
2094
2094
  "Agrostemma": {
2095
2095
  "family": "Caryophyllaceae",
2096
2096
  "id": "10425"
@@ -2107,6 +2107,10 @@
2107
2107
  "family": "Caryophyllaceae",
2108
2108
  "id": "10429"
2109
2109
  },
2110
+ "Cherleria": {
2111
+ "family": "Caryophyllaceae",
2112
+ "id": "103805"
2113
+ },
2110
2114
  "Dianthus": {
2111
2115
  "family": "Caryophyllaceae",
2112
2116
  "id": "10431"
@@ -2119,6 +2123,10 @@
2119
2123
  "family": "Caryophyllaceae",
2120
2124
  "id": "10434"
2121
2125
  },
2126
+ "Hartmaniella": {
2127
+ "family": "Caryophyllaceae",
2128
+ "id": "82772"
2129
+ },
2122
2130
  "Herniaria": {
2123
2131
  "family": "Caryophyllaceae",
2124
2132
  "id": "10435"
@@ -2135,10 +2143,6 @@
2135
2143
  "family": "Caryophyllaceae",
2136
2144
  "id": "10844"
2137
2145
  },
2138
- "Minuartia": {
2139
- "family": "Caryophyllaceae",
2140
- "id": "10845"
2141
- },
2142
2146
  "Moehringia": {
2143
2147
  "family": "Caryophyllaceae",
2144
2148
  "id": "10846"
@@ -2159,10 +2163,6 @@
2159
2163
  "family": "Caryophyllaceae",
2160
2164
  "id": "10841"
2161
2165
  },
2162
- "Pseudostellaria": {
2163
- "family": "Caryophyllaceae",
2164
- "id": "10842"
2165
- },
2166
2166
  "Sabulina": {
2167
2167
  "family": "Caryophyllaceae",
2168
2168
  "id": "69193"
@@ -2175,6 +2175,10 @@
2175
2175
  "family": "Caryophyllaceae",
2176
2176
  "id": "10855"
2177
2177
  },
2178
+ "Schizotechium": {
2179
+ "family": "Caryophyllaceae",
2180
+ "id": "85148"
2181
+ },
2178
2182
  "Scleranthus": {
2179
2183
  "family": "Caryophyllaceae",
2180
2184
  "id": "10857"
@@ -2199,14 +2203,6 @@
2199
2203
  "family": "Caryophyllaceae",
2200
2204
  "id": "10852"
2201
2205
  },
2202
- "Vaccaria": {
2203
- "family": "Caryophyllaceae",
2204
- "id": "10862"
2205
- },
2206
- "Velezia": {
2207
- "family": "Caryophyllaceae",
2208
- "id": "10863"
2209
- },
2210
2206
  "Euonymus": {
2211
2207
  "family": "Celastraceae",
2212
2208
  "id": "9802"
@@ -2275,10 +2271,6 @@
2275
2271
  "family": "Chenopodiaceae",
2276
2272
  "id": "11499"
2277
2273
  },
2278
- "Kochia": {
2279
- "family": "Chenopodiaceae",
2280
- "id": "11500"
2281
- },
2282
2274
  "Krascheninnikovia": {
2283
2275
  "family": "Chenopodiaceae",
2284
2276
  "id": "11501"
@@ -2291,6 +2283,10 @@
2291
2283
  "family": "Chenopodiaceae",
2292
2284
  "id": "11502"
2293
2285
  },
2286
+ "Neokochia": {
2287
+ "family": "Chenopodiaceae",
2288
+ "id": "91852"
2289
+ },
2294
2290
  "Salicornia": {
2295
2291
  "family": "Chenopodiaceae",
2296
2292
  "id": "11506"
@@ -3847,9 +3843,9 @@
3847
3843
  "family": "Polemoniaceae",
3848
3844
  "id": "80251"
3849
3845
  },
3850
- "Polygala": {
3846
+ "Rhinotropis": {
3851
3847
  "family": "Polygalaceae",
3852
- "id": "9160"
3848
+ "id": "99965"
3853
3849
  },
3854
3850
  "Acanthoscyphus": {
3855
3851
  "family": "Polygonaceae",
@@ -35,6 +35,25 @@ th {
35
35
  vertical-align: bottom;
36
36
  }
37
37
 
38
+ ul.listmenu {
39
+ display: flex;
40
+ padding: 0;
41
+ }
42
+
43
+ ul.listmenu li {
44
+ display: inline-block;
45
+ padding: 0;
46
+ padding-right: .25em;
47
+ }
48
+
49
+ ul.listmenu li::after {
50
+ content: " |";
51
+ }
52
+
53
+ ul.listmenu li:last-child:after {
54
+ content: "";
55
+ }
56
+
38
57
  /* Lists */
39
58
 
40
59
  span.native {
package/lib/families.js CHANGED
@@ -1,4 +1,4 @@
1
- import { HTMLPage } from "./htmlpage.js";
1
+ import { GenericPage } from "./genericpage.js";
2
2
  import { HTML } from "./html.js";
3
3
  import { Jepson } from "./jepson.js";
4
4
  import { Taxa } from "./taxa.js";
@@ -20,41 +20,54 @@ class Families {
20
20
 
21
21
  this.#families = JSON.parse( Files.read( dataDir + "/families.json" ) );
22
22
  for ( const [ k, v ] of Object.entries( this.#families ) ) {
23
- this.#families[ k ] = new Family( k, { id: v } );
23
+ this.#families[ k ] = new Family( k, v );
24
24
  }
25
25
 
26
26
  Genera.init( dataDir );
27
27
 
28
28
  }
29
29
 
30
- static renderPages( outputDir, columns ) {
31
- new PageFamilyList( Object.values( this.#families ) ).render( outputDir );
30
+ static renderPages( outputDir, taxaColumns ) {
31
+ new PageFamilyList( outputDir, this.#families ).render( taxaColumns );
32
32
 
33
- for ( const family of Object.values( this.#families ) ) {
33
+ const names = Object.keys( this.#families );
34
+ for ( const name of names.sort() ) {
35
+ const family = this.#families[ name ];
34
36
  if ( family.getTaxa() ) {
35
- new PageFamily( family ).render( outputDir, columns );
37
+ new PageFamily( outputDir, family ).render( taxaColumns );
36
38
  }
37
39
  }
38
40
  }
39
41
 
40
42
  }
41
43
 
42
- class PageFamilyList extends HTMLPage {
44
+ class PageFamilyList extends GenericPage {
43
45
 
44
46
  #families;
45
47
 
46
- constructor( families ) {
47
- super();
48
+ constructor( outputDir, families ) {
49
+ super( outputDir, "Families", "list_families" );
48
50
  this.#families = families;
49
51
  }
50
52
 
51
- render( outputDir ) {
53
+ render( taxaColumns ) {
52
54
 
53
- const title = "Families";
55
+ let html = this.getDefaultIntro();
54
56
 
55
- let html = this.getFrontMatter( title );
57
+ const sections = Sections.getSections();
58
+ const sectionLinks = [];
59
+ for ( const name of Object.keys( sections ).sort() ) {
56
60
 
57
- html += HTML.textElement( "h1", title );
61
+ const taxa = sections[ name ];
62
+
63
+ // Render the section page.
64
+ new PageSection( this.getOutputDir(), name, taxa ).render( taxaColumns );
65
+
66
+ // Render the link.
67
+ const href = "./" + name + ".html";
68
+ sectionLinks.push( HTML.getLink( href, name ) + " (" + taxa.length + ")" );
69
+ }
70
+ html += HTML.wrap( "ul", HTML.arrayToLI( sectionLinks ), { class: "listmenu" } );
58
71
 
59
72
  html += "<table>";
60
73
  html += "<thead>";
@@ -63,7 +76,9 @@ class PageFamilyList extends HTMLPage {
63
76
  html += "</thead>";
64
77
 
65
78
  html += "<tbody>";
66
- for ( const family of this.#families ) {
79
+ const names = Object.keys( this.#families ).sort();
80
+ for ( const name of names ) {
81
+ const family = this.#families[ name ];
67
82
  const taxa = family.getTaxa();
68
83
  if ( !taxa ) {
69
84
  continue;
@@ -76,24 +91,22 @@ class PageFamilyList extends HTMLPage {
76
91
 
77
92
  html += "</table>";
78
93
 
79
- this.writeFile( outputDir, "list_families.html", html );
94
+ this.writeFile( html );
80
95
  }
81
96
  }
82
97
 
83
- class PageFamily extends HTMLPage {
98
+ class PageFamily extends GenericPage {
84
99
 
85
100
  #family;
86
101
 
87
- constructor( family ) {
88
- super();
102
+ constructor( outputDir, family ) {
103
+ super( outputDir, family.getName(), family.getBaseFileName() );
89
104
  this.#family = family;
90
105
  }
91
106
 
92
- render( outputDir, columns ) {
93
-
94
- let html = this.getFrontMatter( this.#family.getName() );
107
+ render( columns ) {
95
108
 
96
- html += HTML.textElement( "h1", this.#family.getName() );
109
+ let html = this.getDefaultIntro();
97
110
 
98
111
  html += HTML.wrap(
99
112
  "div",
@@ -103,7 +116,27 @@ class PageFamily extends HTMLPage {
103
116
 
104
117
  html += Taxa.getHTMLTable( this.#family.getTaxa(), columns );
105
118
 
106
- this.writeFile( outputDir, this.#family.getFileName(), html );
119
+ this.writeFile( html );
120
+
121
+ }
122
+ }
123
+
124
+ class PageSection extends GenericPage {
125
+
126
+ #taxa;
127
+
128
+ constructor( outputDir, name, taxa ) {
129
+ super( outputDir, name, name );
130
+ this.#taxa = taxa;
131
+ }
132
+
133
+ render( columns ) {
134
+
135
+ let html = this.getDefaultIntro();
136
+
137
+ html += Taxa.getHTMLTable( this.#taxa, columns );
138
+
139
+ this.writeFile( html );
107
140
 
108
141
  }
109
142
  }
@@ -123,10 +156,15 @@ class Family {
123
156
  this.#data.taxa = [];
124
157
  }
125
158
  this.#data.taxa.push( taxon );
159
+ Sections.addTaxon( this.getSectionName(), taxon );
160
+ }
161
+
162
+ getBaseFileName() {
163
+ return this.getName();
126
164
  }
127
165
 
128
166
  getFileName( ext = "html" ) {
129
- return this.getName() + "." + ext;
167
+ return this.getBaseFileName() + "." + ext;
130
168
  }
131
169
 
132
170
  getJepsonID() {
@@ -137,10 +175,33 @@ class Family {
137
175
  return this.#name;
138
176
  }
139
177
 
178
+ getSectionName() {
179
+ return this.#data.section;
180
+ }
181
+
140
182
  getTaxa() {
141
183
  return this.#data.taxa;
142
184
  }
143
185
 
144
186
  }
145
187
 
188
+ class Sections {
189
+
190
+ static #sections = {};
191
+
192
+ static addTaxon( name, taxon ) {
193
+ let section = this.#sections[ name ];
194
+ if ( !section ) {
195
+ section = [];
196
+ this.#sections[ name ] = section;
197
+ }
198
+ section.push( taxon );
199
+ }
200
+
201
+ static getSections() {
202
+ return this.#sections;
203
+ }
204
+
205
+ }
206
+
146
207
  export { Families };
package/lib/files.js CHANGED
@@ -27,7 +27,7 @@ class Files {
27
27
  * @param {string|URL} url
28
28
  * @param {string|undefined} targetFileName If targetFileName is undefined, the data will be retrieved but not written to a file.
29
29
  * @param {Object} [headers={}] Request Headers.
30
- * @returns {Headers} The Response headers.
30
+ * @returns {Promise<Headers>} The Response headers.
31
31
  */
32
32
  static async fetch( url, targetFileName, headers = {} ) {
33
33
  const response = await fetch( url, headers );
package/lib/index.d.ts CHANGED
@@ -7,9 +7,9 @@ export class Files {
7
7
  * @param {string|URL} url
8
8
  * @param {string|undefined} targetFileName If targetFileName is undefined, the data will be retrieved but not written to a file.
9
9
  * @param {Object} [headers={}] Request Headers.
10
- * @returns {Headers} The Response headers.
10
+ * @returns {Promise<Headers>} The Response headers.
11
11
  */
12
- static fetch(url: string | URL, targetFileName: string | undefined, headers?: any): Headers;
12
+ static fetch(url: string | URL, targetFileName: string | undefined, headers?: any): Promise<Headers>;
13
13
  static mkdir(path: any): void;
14
14
  static read(path: any): string;
15
15
  static rmDir(dir: any): void;
@@ -29,7 +29,7 @@ export class HTML {
29
29
  * @deprecated
30
30
  */
31
31
  static getElement(elName: any, text: any, attributes?: {}, options?: number): string;
32
- static "__#2@#getElement"(elName: any, text: any, attributes: any, escape: any): string;
32
+ static "__#3@#getElement"(elName: any, text: any, attributes: any, escape: any): string;
33
33
  /**
34
34
  * Generate HTML for an &lt;a> element.
35
35
  * @param {string|undefined} href
package/lib/pagetaxon.js CHANGED
@@ -3,7 +3,6 @@ import { Jepson } from "./jepson.js";
3
3
  import { Config } from "./config.js";
4
4
  import { RarePlants } from "./rareplants.js";
5
5
  import { GenericPage } from "./genericpage.js";
6
- import { Files } from "./files.js";
7
6
 
8
7
  class PageTaxon extends GenericPage {
9
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ca-plant-list/ca-plant-list",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
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": {
package/lib/htmlpage.js DELETED
@@ -1,21 +0,0 @@
1
- import { Files } from "./files.js";
2
-
3
- /**
4
- * @deprecated
5
- */
6
- class HTMLPage {
7
-
8
- getFrontMatter( title, js ) {
9
- return "---\n"
10
- + "title: \"" + title + "\"\n"
11
- + ( js ? ( "js: " + js + "\n" ) : "" )
12
- + "---\n";
13
- }
14
-
15
- writeFile( outputDir, fileName, html ) {
16
- Files.write( outputDir + "/" + fileName, html );
17
- }
18
-
19
- }
20
-
21
- export { HTMLPage };