Skip to content

Commit f435245

Browse files
LTSMPS-606 Working plugin after putting in valid API endpoint.
1 parent 403006c commit f435245

File tree

22 files changed

+14353
-2
lines changed

22 files changed

+14353
-2
lines changed

.github/pull_request_template.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
**The title of this pull-request should be a brief description of what the pull-request fixes/improves/changes. Ideally 50 characters or less.**
2+
3+
---
4+
5+
**JIRA Ticket**: (link)
6+
7+
- Other Relevant Links (Mailing list discussion, related pull requests, etc.)
8+
9+
# What does this Pull Request do?
10+
11+
A brief description of what the intended result of the PR will be and/or what problem it solves.
12+
13+
# How should this be tested?
14+
15+
A description of what steps someone could take to:
16+
17+
- Reproduce the problem you are fixing (if applicable)
18+
- Test that the Pull Request does what is intended.
19+
- Please be as detailed as possible.
20+
- Good testing instructions help get your PR completed faster.
21+
22+
# Test coverage
23+
24+
Yes/No: Are changes in this pull-request covered by:
25+
26+
- unit tests?
27+
- integration tests?
28+
29+
# Interested parties
30+
31+
Tag (@ mention) interested parties
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish to npmjs on release
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v3
13+
with:
14+
ref: ${{ github.ref_name }}
15+
token: ${{ secrets.ACCESS_TOKEN }}
16+
17+
- run: |
18+
git config user.name "Github Action"
19+
git config user.email [email protected]
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 18
25+
registry-url: "https://registry.npmjs.org"
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Create new version
31+
run: |
32+
TAG_NAME="${GITHUB_REF##*/}"
33+
npm version "$TAG_NAME"
34+
git push origin HEAD:${{ github.event.release.target_commitish }}
35+
36+
- name: Publish to npm
37+
run: npm publish
38+
env:
39+
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dist
2+
es
3+
node_modules
4+
npm-debug.log*
5+
6+
.idea/
7+
.DS_Store

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/hydrogen

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sudo: false
2+
3+
language: node_js
4+
node_js:
5+
- 18
6+
7+
before_install:
8+
- npm install codecov.io coveralls
9+
10+
after_success:
11+
- cat ./coverage/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js
12+
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
13+
14+
branches:
15+
only:

README.md

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,79 @@
1-
# mirador-citation-plugin
2-
A Mirador 3 plugin for displaying Harvard-specific citations
1+
# Mirador citation plugin
2+
3+
A Mirador 3 plugin for displaying Harvard-specific citations.
4+
5+
## Requirements
6+
7+
- [NVM](https://github.com/nvm-sh/nvm)
8+
9+
## Setup
10+
11+
1. Run `nvm use` to ensure your version of matches that in the `.nvmrc` file
12+
2. Run `npm i` to install dependencies
13+
3. Use one of the [NPM scripts](#npm-scripts) to perform the actions described below.
14+
15+
## NPM scripts
16+
17+
The following are some useful scripts can be ran using `npm run <script>`. A full list can be seen in [package.json](./package.json)
18+
19+
| Script | Description |
20+
| ------- | -------------------------------------------------------------------------------------------------------------------------- |
21+
| `clean` | Removes the `dist` directories |
22+
| `build` | Builds the source files into the `./dist` directory |
23+
| `serve` | Runs a local web server where the plugin can be viewed in a vanilla Mirador instance (helpful for testing and development) |
24+
| `test` | Runs the automated test suites
25+
26+
## Installing in Mirador
27+
28+
The `mirador-citation-plugin` requires an instance of Mirador 3. Visit the [Mirador wiki](https://github.com/ProjectMirador/mirador/wiki) to learn how to [install an existing plugin](https://github.com/ProjectMirador/mirador/wiki/Mirador-3-plugins#installing-an-existing-plugin) and for additional information about plugins.
29+
30+
Package you will need to install:
31+
32+
```bash
33+
npm i @harvard-lts/mirador-citation-plugin
34+
```
35+
36+
## Configuration
37+
38+
Configurations for this plugin are injected when Mirador is initialized under the `miradorCitationPlugin` key. See the [demo entry](./demo/demoEntry.js) for an example of importing and configuring `mirador-citation-plugin`. Note: the demo entry does not contain a valid citation API endpoint. You must fill it in for the demo to work.
39+
40+
```js
41+
...
42+
id: 'mirador',
43+
miradorCitationPlugin: {
44+
...
45+
}
46+
...
47+
```
48+
49+
| Config Key | Type | Description |
50+
| --- | --- | --- |
51+
| `citationAPI` | string | The API endpoint of your custom citation service |
52+
53+
Additionally, the `aria-label` and `title` of the buttons are injected when Mirador is initialized under the `translations` key. See the [demo entry](./demo/demoEntry.js) for an example. The common configuration is also listed below.
54+
55+
```js
56+
...
57+
id: 'mirador',
58+
translations: {
59+
en: {
60+
openCompanionWindow_CitationKey: 'Cite',
61+
openCompanionWindow_RelatedLinksKey: 'Related Links'
62+
}
63+
}
64+
...
65+
```
66+
67+
| Config Key | Type | Description |
68+
| --- | --- | --- |
69+
| `openCompanionWindow_CitationKey` | string | The text you wish to appear in the `aria-label` and `title` of the Citation button |
70+
| `openCompanionWindow_RelatedLinksKey` | string | The text you wish to appear in the `aria-label` and `title` of the Related Links button |
71+
72+
## Contribute
73+
Mirador's development, design, and maintenance is driven by community needs and ongoing feedback and discussion. Join us at our regularly scheduled community calls, on [IIIF slack #mirador](http://bit.ly/iiif-slack), or the [mirador-tech](https://groups.google.com/forum/#!forum/mirador-tech) and [iiif-discuss](https://groups.google.com/forum/#!forum/iiif-discuss) mailing lists. To suggest features, report bugs, and clarify usage, please submit a GitHub issue.
74+
75+
[build-badge]: https://img.shields.io/travis/projectmirador/mirador-citation-plugin/master.png?style=flat-square
76+
[build]: https://travis-ci.org/projectmirador/mirador-citation-plugin
77+
78+
[npm-badge]: https://img.shields.io/npm/v/mirador-citation-plugin.png?style=flat-square
79+
[npm]: https://www.npmjs.org/package/mirador-citation-plugin

babel.config.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"modules": "auto"
7+
}
8+
],
9+
["@babel/preset-react", { "runtime": "automatic" }]
10+
]
11+
}
12+

demo/demoEntry.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Mirador from "mirador/dist/es/src/index";
2+
import Plugin from "../src/index";
3+
4+
document.addEventListener("DOMContentLoaded", () => {
5+
const config = {
6+
id: "mirador",
7+
windows: [
8+
{
9+
manifestId: "https://nrs.lib.harvard.edu/URN-3:FHCL:37563741:MANIFEST:3",
10+
},
11+
],
12+
miradorCitationPlugin: {
13+
citationAPI:'YOUR CITATION API ENDPOINT GOES HERE',
14+
},
15+
translations: {
16+
en: {
17+
openCompanionWindow_CitationKey: 'Cite',
18+
openCompanionWindow_RelatedLinksKey: 'Related Links'
19+
}
20+
}
21+
};
22+
23+
const plugins = [...Plugin];
24+
25+
Mirador.viewer(config, plugins);
26+
});

demo/index.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Test</title>
7+
<style>
8+
body {
9+
margin: 0;
10+
padding: 0;
11+
}
12+
#mirador {
13+
height: 100vh;
14+
width: 100vw;
15+
}
16+
</style>
17+
<script src="demo.js"></script>
18+
</head>
19+
<body>
20+
<div id="mirador"></div>
21+
</script>
22+
</body>
23+
</html>

jest.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/** @type {import('jest').Config} */
2+
module.exports = {
3+
testEnvironment: "jsdom",
4+
transformIgnorePatterns: ["node_modules/(?!mirador)/", "node_modules/pdiiif"],
5+
setupFilesAfterEnv: ["@testing-library/jest-dom", "./setupTests"],
6+
// collectCoverage: true,
7+
// coverageDirectory: "coverage",
8+
// verbose: true,
9+
// testRegex: "(/tests/.*|\\.(test|spec))\\.jsx?$",
10+
// moduleFileExtensions: ["js", "json", "jsx", "node"],
11+
// coverageThreshold: {
12+
// global: {
13+
// branches: 30,
14+
// functions: 90,
15+
// lines: 90,
16+
// statements: 90,
17+
// },
18+
// },
19+
// // setupFiles: ["./setupTests"],
20+
};
21+

0 commit comments

Comments
 (0)