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

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.
@@ -38,6 +38,7 @@
38
38
  </nav>
39
39
 
40
40
  <div class="container-xxl px-5">
41
+ <h1>{{page.title}}</h1>
41
42
  {{content}}
42
43
  </div>
43
44
 
@@ -54,6 +54,11 @@ ul.listmenu li:last-child:after {
54
54
  content: "";
55
55
  }
56
56
 
57
+ /* Utilities */
58
+ .right {
59
+ text-align: right;
60
+ }
61
+
57
62
  /* Lists */
58
63
 
59
64
  span.native {
@@ -50,7 +50,7 @@ class Search {
50
50
 
51
51
  Search.#debounceTimer = undefined;
52
52
 
53
- const value = document.getElementById( "name" ).value.toLowerCase();
53
+ const value = Search.#normalizeName( document.getElementById( "name" ).value );
54
54
 
55
55
  const matches = [];
56
56
  const shouldSearch = ( value.length >= MIN_LEN );
@@ -124,14 +124,14 @@ class Search {
124
124
  // eslint-disable-next-line no-undef
125
125
  for ( const taxon of NAMES ) {
126
126
  const taxonData = [ taxon ];
127
- taxonData.push( taxon[ 0 ].toLowerCase().replace( / (subsp|var)\./, "" ) );
127
+ taxonData.push( this.#normalizeName( taxon[ 0 ] ) );
128
128
  if ( taxon[ 1 ] ) {
129
129
  taxonData.push( taxon[ 1 ].toLowerCase() );
130
130
  }
131
131
  if ( taxon[ 2 ] ) {
132
132
  const syns = [];
133
133
  for ( const syn of taxon[ 2 ] ) {
134
- syns.push( syn.toLowerCase().replace( / (subsp|var)\./, "" ) );
134
+ syns.push( this.#normalizeName( syn ) );
135
135
  }
136
136
  taxonData[ 3 ] = syns;
137
137
  }
@@ -156,6 +156,10 @@ class Search {
156
156
  document.getElementById( "search_form" ).onsubmit = () => { this.#handleSubmit(); return false; };
157
157
  }
158
158
 
159
+ static #normalizeName( name ) {
160
+ return name.toLowerCase().replace( / (subsp|var)\./, "" );
161
+ }
162
+
159
163
  }
160
164
 
161
165
  Search.init();
@@ -2,7 +2,6 @@
2
2
  title: Name Search
3
3
  js: name_search.js
4
4
  ---
5
- <h1>Search</h1>
6
5
 
7
6
  <script>
8
7
  const NAMES = {% include names.json%};
@@ -0,0 +1,43 @@
1
+ class ExternalSites {
2
+
3
+ static getCalscapeLink( taxonName ) {
4
+ const url = new URL( "https://calscape.org/loc-California/" + taxonName.replace( "subsp.", "ssp." ) + " ()" );
5
+ return url.toString();
6
+ }
7
+
8
+ static getInatObsLink( options ) {
9
+
10
+ const url = new URL( "https://www.inaturalist.org/observations?subview=map" );
11
+
12
+ for ( const [ k, v ] of Object.entries( options ) ) {
13
+ switch ( k ) {
14
+ case "coords": {
15
+ const delta = .1;
16
+ const params = url.searchParams;
17
+ params.set( "nelat", v[ 1 ] + delta );
18
+ params.set( "swlat", v[ 1 ] - delta );
19
+ params.set( "nelng", v[ 0 ] + delta );
20
+ params.set( "swlng", v[ 0 ] - delta );
21
+ break;
22
+ }
23
+ case "created_d1":
24
+ case "list_id":
25
+ case "place_id":
26
+ case "project_id":
27
+ case "subview":
28
+ case "taxon_id":
29
+ case "taxon_name":
30
+ if ( v ) {
31
+ url.searchParams.set( k, v );
32
+ }
33
+ break;
34
+ }
35
+ }
36
+
37
+ return url.toString();
38
+
39
+ }
40
+
41
+ }
42
+
43
+ export { ExternalSites };
@@ -20,7 +20,6 @@ class GenericPage {
20
20
 
21
21
  getDefaultIntro() {
22
22
  let html = this.#getFrontMatter();
23
- html += HTML.textElement( "h1", this.#title );
24
23
  const introPath = "intros/" + this.#baseFileName + ".md";
25
24
  if ( Jekyll.hasInclude( this.#outputDir, introPath ) ) {
26
25
  html += HTML.wrap( "div", Jekyll.include( introPath ), { class: "section" } );
package/lib/pagetaxon.js CHANGED
@@ -3,6 +3,7 @@ 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 { ExternalSites } from "./externalsites.js";
6
7
 
7
8
  class PageTaxon extends GenericPage {
8
9
 
@@ -31,6 +32,16 @@ class PageTaxon extends GenericPage {
31
32
  if ( rpiLink ) {
32
33
  links.push( rpiLink );
33
34
  }
35
+ if ( this.#taxon.isNative() ) {
36
+ links.push(
37
+ HTML.getLink(
38
+ ExternalSites.getCalscapeLink( this.#taxon.getName() ),
39
+ "Calscape",
40
+ undefined,
41
+ true
42
+ )
43
+ );
44
+ }
34
45
  return links;
35
46
  }
36
47
 
@@ -50,8 +61,13 @@ class PageTaxon extends GenericPage {
50
61
  if ( iNatID ) {
51
62
  links.push(
52
63
  HTML.getLink(
53
- "https://www.inaturalist.org/observations?project_id=" + Config.getConfigValue( "inat", "project" )
54
- + "&quality_grade=research&subview=map&taxon_id=" + iNatID,
64
+ ExternalSites.getInatObsLink(
65
+ {
66
+ project_id: Config.getConfigValue( "inat", "project" ),
67
+ subview: "map",
68
+ taxon_id: iNatID
69
+ }
70
+ ),
55
71
  "iNaturalist",
56
72
  {},
57
73
  true
package/lib/taxon.js CHANGED
@@ -137,6 +137,10 @@ class Taxon {
137
137
  return name.replace( / (subsp|var)\./, "" ).replace( "×", "× " );
138
138
  }
139
139
 
140
+ getINatSyn() {
141
+ return this.#iNatSyn;
142
+ }
143
+
140
144
  getINatTaxonLink() {
141
145
  const iNatID = this.getINatID();
142
146
  if ( !iNatID ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ca-plant-list/ca-plant-list",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
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": {