Skip to content

Commit

Permalink
Update packages, add css classes, add renderItem option
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Sep 19, 2024
1 parent c2b5a2b commit 851af88
Show file tree
Hide file tree
Showing 55 changed files with 6,854 additions and 4,798 deletions.
97 changes: 69 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,61 @@
# distinguish

An interactive key engine that feeds off of [TaxonWorks](https://taxonworks.org)' [API](https://api.taxonworks.org). Distinguish is a product of the [Species File Group](https://speciesfilegroup.org) and its collaborators.
An interactive key engine that feeds off of [TaxonWorks](https://taxonworks.org)' [API](https://api.taxonworks.org). Distinguish is a product of the [Species File Group](https://speciesfilegroup.org) and its collaborators.

## Quick start

See [Example page](#example-page).

## Details

Interactive keys are tools used by taxonomists and others to diagnosis or seperate one taxon (e.g. a species) from others. Distinguish provides an embedable, web-based, interactive key interface. The key uses logic (the "engine") and data managed in an instance of TaxonWorks. Keys can served locally (e.g. by opening a file in your browser) or on websites. They require an internet connection.
Interactive keys are tools used by taxonomists and others to diagnosis or seperate one taxon (e.g. a species) from others. Distinguish provides an embedable, web-based, interactive key interface. The key uses logic (the "engine") and data managed in an instance of TaxonWorks. Keys can served locally (e.g. by opening a file in your browser) or on websites. They require an internet connection.

## Features

* Figure descriptors and observations.
* Multi-language support.
* Filter by tagged set.
* Filter by rank (e.g. "Family" or "Genus").
* Qualitative, quantitative descriptors.
* Local (file in your browser) or server-based (both require internet access).
- Figure descriptors and observations.
- Multi-language support.
- Filter by tagged set.
- Filter by rank (e.g. "Family" or "Genus").
- Qualitative, quantitative descriptors.
- Local (file in your browser) or server-based (both require internet access).

## Technical

Distinguish is a node module. All functionality is driven from a single, parameterized API call.
Distinguish is a javascript package. All functionality is driven from a single, parameterized API call.

## Install

### Package manager

You can install the latest version with the npm CLI command:

```bash
npm install @sfgrp/distinguish
npm install @sfgrp/distinguish vue pinia
```

As an alternative you can use the Yarn CLI command:

```bash
yarn add @sfgrp/distinguish
yarn add @sfgrp/distinguish vue pinia
```

### CDN

You can copy and paste the following tags into your HTML file.

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@sfgrp/distinguish@latest/dist/style.min.css">
<script src="https://unpkg.com/vue/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/vue-demi"></script>
<script src="https://unpkg.com/pinia"></script>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@sfgrp/distinguish@latest/dist/style.min.css"
/>
<script src="https://cdn.jsdelivr.net/npm/@sfgrp/distinguish@latest/dist/distinguish.umd.min.js"></script>
```

## Usage

There are two ways to setup Interactive Keys. The easiest way is to let InteractiveKey auto discover your inputs automatically. For that, you simply need to provide a data attribute on your element.

### Declarative
Expand All @@ -53,7 +64,7 @@ Add `data-interactive-key="true"` attribute to input elements to initialize it.
To pass the options you need to add the prefix `data-` and write the option in kebab-case, like the following example:

```html
<div
<div
data-interactive-key="true"
data-observation-matrix-id="1"
data-project-token="xQ9bKrhfQtHYfro9t6YY0A"
Expand All @@ -62,11 +73,13 @@ To pass the options you need to add the prefix `data-` and write the option in k
```

### Imperative

You can initialize it by `createInteractiveKey` function

```html
<div id="interactive-key"></div>
```

```javascript
import { createInteractiveKey } from '@sfgrp/distinguish'
import '@sfgrp/distinguish/dist/style.css'
Expand All @@ -75,6 +88,7 @@ const app = createInteractiveKey('#interactive-key', options)
```

### Options object

```javascript
{
observationMatrixId: '', // Observation matrix ID
Expand All @@ -87,54 +101,81 @@ const app = createInteractiveKey('#interactive-key', options)
}
}
```

### Example page

This uses the [CDN](#cdn) and [Declarative](#declarative) approach.
* Copy the text below into a file called `index.html`.
* Configure the `data-` options to point to your key.
* Open that file in your browser.

- Copy the text below into a file called `index.html`.
- Configure the `data-` options to point to your key.
- Open that file in your browser.

```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@sfgrp/distinguish@latest/dist/style.min.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@sfgrp/distinguish@latest/dist/style.min.css"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<style>
body {
margin: 0;
}
.standalone-app {
height: 100vh;
}
</style>
<title>Distinguish</title>
</head>
<body>
<div
<div
class="standalone-app"
data-interactive-key="true"
data-observation-matrix-id="1"
data-project-token="yourprojecttoken"
data-base-url="https://<your.taxonworks.server>/api/v1"
></div>
<script src="https://unpkg.com/vue/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/vue-demi"></script>
<script src="https://unpkg.com/pinia"></script>
<script src="https://cdn.jsdelivr.net/npm/@sfgrp/distinguish@latest/dist/distinguish.umd.min.js"></script>
</body>
</html>
```

### Deploying a key on-line

[GitHub Pages](https://pages.github.com/) is perhaps the quickest way to deploy your key if you don't have access to your own server.
* Follow instructions above to setup your repository.
* Add a page to that repository that looks like the [example page](#example-page).

- Follow instructions above to setup your repository.
- Add a page to that repository that looks like the [example page](#example-page).

### Troubleshooting

If nothing loads (blank page):
* Open your Browser's development tools console panel. Reload the page. Errors will appear in red.

If when loaded or during use you see:
* `Request failed with status code 401` - The API configuration parameters are incorrect
* `Request failed with status code 404` - The API URL path or Token is incorrect (the base of the API URL is correct)
* `Network error` - The key can not connect to the internet
- Open your Browser's development tools console panel. Reload the page. Errors will appear in red.

If when loaded or during use you see:

- `Request failed with status code 401` - The API configuration parameters are incorrect
- `Request failed with status code 404` - The API URL path or Token is incorrect (the base of the API URL is correct)
- `Network error` - The key can not connect to the internet

## Building a key (in TaxonWorks)
Distinguish is based of interfaces available inside TaxonWorks. Those interfaces have many additional features facilitating the addition and management of images, curation, annotations, expansion, and editing of the underlying data. To start editing a key find a [TaxonWorks provider](https://docs.taxonworks.org/guide/start-a-project.html#finding-a-collaborating-provider), or [install your own instance](https://github.com/SpeciesFileGroup/install_taxonworks). Need help? [Chat on Gitter](https://gitter.im/SpeciesFileGroup/taxonworks) or [join a TaxonWorks event](https://speciesfilegroup.org/events.html).

Distinguish is based of interfaces available inside TaxonWorks. Those interfaces have many additional features facilitating the addition and management of images, curation, annotations, expansion, and editing of the underlying data. To start editing a key find a [TaxonWorks provider](https://docs.taxonworks.org/guide/start-a-project.html#finding-a-collaborating-provider), or [install your own instance](https://github.com/SpeciesFileGroup/install_taxonworks). Need help? [Chat on Gitter](https://gitter.im/SpeciesFileGroup/taxonworks) or [join a TaxonWorks event](https://speciesfilegroup.org/events.html).

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).

## License

Distinguish is open source and is presently available under the [University of Illinois/NCSA Open Source License](https://en.wikipedia.org/wiki/University_of_Illinois/NCSA_Open_Source_License).
17 changes: 13 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TaxonKeys</title>
<link
rel="icon"
href="/favicon.ico"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<title>Distinguish</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<script
type="module"
src="/src/main.ts"
></script>
</body>
</html>
Loading

0 comments on commit 851af88

Please sign in to comment.