Skip to content

Commit 418e3f7

Browse files
authored
Merge pull request #7 from cwrc/development
Marge Development into Production
2 parents 6b54ec3 + 081539b commit 418e3f7

File tree

9 files changed

+8348
-7648
lines changed

9 files changed

+8348
-7648
lines changed

.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env"
4+
],
5+
"plugins": [
6+
"@babel/plugin-transform-runtime"
7+
]
8+
}

.eslintrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es6": true,
6+
"jest": true
7+
},
8+
"extends": "eslint:recommended",
9+
"globals": {
10+
"Atomics": "readonly",
11+
"SharedArrayBuffer": "readonly"
12+
},
13+
"parserOptions": {
14+
"ecmaVersion": 2019,
15+
"sourceType": "module"
16+
},
17+
"rules": {
18+
"quotes": [2, "single"],
19+
"require-atomic-updates": "off",
20+
"no-unused-vars": 2
21+
}
22+
}

.travis.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,13 @@ cache:
55
notifications:
66
email: false
77
node_js:
8-
- '9'
9-
before_script:
10-
- npm prune
8+
- '13.9.0'
119
script:
1210
- npm run test
1311
after_success:
1412
- npm run report-coverage
1513
- npm run travis-deploy-once "npm run semantic-release"
1614
branches:
17-
except:
18-
- /^v\d+\.\d+\.\d+$/
19-
addons:
20-
apt:
21-
packages:
22-
- xvfb
23-
install:
24-
- export DISPLAY=':99.0'
25-
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
26-
- npm install
15+
only:
16+
- master
17+

README.md

Lines changed: 54 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# getty-entity-lookup
2+
13
![Picture](http://cwrc.ca/logos/CWRC_logos_2016_versions/CWRCLogo-Horz-FullColour.png)
24

35
[![Travis](https://img.shields.io/travis/cwrc/getty-entity-lookup.svg)](https://travis-ci.org/cwrc/getty-entity-lookup)
@@ -9,178 +11,124 @@
911
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
1012
[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)
1113

12-
# getty-entity-lookup
13-
1414
1. [Overview](#overview)
1515
1. [Installation](#installation)
1616
1. [Use](#use)
1717
1. [API](#api)
1818
1. [Development](#development)
1919

20-
### Overview
20+
## Overview
2121

22-
Finds entities (people, places) in getty. Meant to be used with [cwrc-public-entity-dialogs](https://github.com/cwrc-public-entity-dialogs) where it runs in the browser.
22+
Finds entities (people, places) in getty. Meant to be used with [cwrc-public-entity-dialogs](https://github.com/cwrc-public-entity-dialogs) where it runs in the browser.
2323

2424
Although it will not work in node.js as-is, it does use the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) for http requests, and so could likely therefore use a browser/node.js compatible fetch implementation like: [isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch).
2525

2626
### SPARQL
2727

28-
getty supports sparql, but SPARQL has limited support for full text search. The expectation with SPARQL mostly seems to be that you know exactly what you are matching on
29-
So, a query that exactly details the label works fine:
28+
getty supports sparql, but SPARQL has limited support for full text search. The expectation with SPARQL mostly seems to be that you know exactly what you are matching on. So, a query that exactly details the label works fine:
3029

30+
```sql
3131
SELECT DISTINCT ?s WHERE {
3232
?s ?label "The Rolling Stones"@en .
3333
?s ?p ?o
3434
}
35+
```
3536

36-
We'd like, however, to match with full text search, so we can match on partial strings, variant spellings, etc.
37-
Just in the simple case above, for example, someone searching for The Rolling Stones would have to fully specify 'The Rolling Stones' and not just 'Rolling Stones'. If they left out 'The' then their query won't return the result.
38-
39-
There is a SPARQL CONTAINS operator that can be used within a FILTER, and that matches substrings, which is better, and
40-
CONTAINS seems to work with getty, e.g.
37+
We'd like, however, to match with full text search, so we can match on partial strings, variant spellings, etc. Just in the simple case above, for example, someone searching for The Rolling Stones would have to fully specify 'The Rolling Stones' and not just 'Rolling Stones'. If they left out 'The' then their query won't return the result.
4138

39+
There is a SPARQL CONTAINS operator that can be used within a FILTER, and that matches substrings, which is better, and CONTAINS seems to work with getty, e.g.
4240

43-
```
41+
```text
4442
http://vocab.getty.edu/sparql.json?query=SELECT DISTINCT ?s ?label WHERE {
45-
?s rdfs:label ?label .
46-
FILTER (CONTAINS (?label,"Rolling Stones"))
43+
?s rdfs:label ?label .
44+
FILTER (CONTAINS (?label,"Rolling Stones"))
4745
```
4846

4947
but again, CONTAINS only matches substrings.
5048

51-
There is at least one alternative to CONTAINS - REGEX - but as described
52-
here: https://www.cray.com/blog/dont-use-hammer-screw-nail-alternatives-regex-sparql/ REGEX has even worse performance than CONTAINS.
53-
54-
A further alternative, which we've adopted, is the
55-
custom full text SPARQL search function through which Getty exposes it's underlying lucene index, as described here:
56-
57-
http://vocab.getty.edu/doc/queries/#Full_Text_Search_Query
58-
59-
and here:
60-
61-
http://serials.infomotions.com/code4lib/archive/2014/201402/0596.html
62-
63-
The endpoint does not, however, support HTTPS. And so, we proxy our calls to the lookup through own server:
64-
65-
```https://lookup.services.cwrc.ca/getty```
66-
67-
to thereby allow the CWRC-Writer to make HTTPS calls to the lookup.
68-
We can’t make plain HTTP calls from the CWRC-Writer because the CWRC-Writer may only be
69-
loaded over HTTPS, and any page loaded with HTTPS is not allowed (by many browsers) to make HTTP AJAX calls.
49+
There is at least one alternative to CONTAINS - REGEX - but as described here: [https://www.cray.com/blog/dont-use-hammer-screw-nail-alternatives-regex-sparql/](https://www.cray.com/blog/dont-use-hammer-screw-nail-alternatives-regex-sparql/) REGEX has even worse performance than CONTAINS.
7050

71-
We also proxy calls to retrieve the full page description of an entity, again to allow calls out from a page that was itself
72-
loaded with https. The proxy:
51+
A further alternative, which we've adopted, is the custom full text SPARQL search function through which Getty exposes it's underlying lucene index, as described here: [http://vocab.getty.edu/doc/queries/#Full_Text_Search_Query](http://vocab.getty.edu/doc/queries/#Full_Text_Search_Query) and here: [http://serials.infomotions.com/code4lib/archive/2014/201402/0596.html](http://serials.infomotions.com/code4lib/archive/2014/201402/0596.html)
7352

74-
```https://getty.lookup.services.cwrc.ca```
53+
The endpoint does not, however, support HTTPS. And so, we proxy our calls to the lookup through own server: `https://lookup.services.cwrc.ca/getty` to thereby allow the CWRC-Writer to make HTTPS calls to the lookup. We can’t make plain HTTP calls from the CWRC-Writer because the CWRC-Writer may only be loaded over HTTPS, and any page loaded with HTTPS is not allowed (by many browsers) to make HTTP calls.
7554

76-
which in turn calls
55+
We also proxy calls to retrieve the full page description of an entity, again to allow calls out from a page that was itself loaded with https. The proxy:`https://getty.lookup.services.cwrc.ca` which in turn calls `http://vocab.getty.edu`
7756

78-
```http://vocab.getty.edu```
57+
## Installation
7958

59+
`npm i getty-entity-lookup`
8060

81-
### Installation
61+
## Use
8262

83-
npm i getty-entity-lookup -S
63+
`import gettyLookup from 'getty-entity-lookup';`
8464

85-
### Use
65+
## API
8666

87-
const gettyLookup = require('getty-entity-lookup');
67+
### findPerson(query)
8868

89-
### API
69+
### findPlace(query)
9070

91-
###### findPerson(query)
71+
where the `query` argument is an object:
9272

93-
###### findPlace(query)
94-
95-
96-
<br><br>
97-
where the 'query' argument is an object:
98-
<br>
99-
100-
```
73+
```js
10174
{
102-
entity: The name of the thing the user wants to find.
103-
options: TBD
75+
entity: 'The name of the thing the user wants to find.',
76+
options: 'TBD'
10477
}
10578
```
10679

107-
<br>
108-
and all find* methods return promises that resolve to an object like the following:
109-
<br><br>
80+
and all find methods return promises that resolve to an object like the following:
11081

111-
```
82+
```json
11283
{
113-
id: "http://vocab.getty.edu/ulan/500311165"
114-
115-
name: "University of Pennsylvania, Lloyd P. Jones Gallery"
116-
117-
nameType: "Corporate"
118-
119-
originalQueryString: "jones"
120-
121-
repository: "getty"
122-
123-
uri: "http://vocab.getty.edu/ulan/500311165"
124-
125-
uriForDisplay: "https://getty.lookup.services.cwrc.ca/ulan/500311165"
126-
84+
"id": "http://vocab.getty.edu/ulan/500311165",
85+
"name": "University of Pennsylvania, Lloyd P. Jones Gallery",
86+
"nameType": "Corporate",
87+
"originalQueryString": "jones",
88+
"repository": "getty",
89+
"uri": "http://vocab.getty.edu/ulan/500311165",
90+
"uriForDisplay": "https://getty.lookup.services.cwrc.ca/ulan/500311165"
12791
}
12892
```
129-
<br><br>
130-
There are a further four methods that are mainly made available to facilitate testing (to make it easier to mock calls to the getty service):
13193

132-
###### getPersonLookupURI(query)
94+
There are a further four methods that are mainly made available to facilitate testing (to make it easier to mock calls to the getty service):
13395

134-
###### getPlaceLookupURI(query)
96+
### getPersonLookupURI(query)
13597

98+
### getPlaceLookupURI(query)
13699

137-
<br><br>
138-
where the 'query' argument is the entity name to find and the methods return the getty URL that in turn returns results for the query.
100+
where the `query` argument is the entity name to find and the methods return the getty URL that in turn returns results for the query.
139101

140-
### Development
102+
## Development
141103

142-
[CWRC-Writer-Dev-Docs](https://github.com/jchartrand/CWRC-Writer-Dev-Docs) describes general development practices for CWRC-Writer GitHub repositories, including this one.
104+
[CWRC-Writer-Dev-Docs](https://github.com/cwrc/CWRC-Writer-Dev-Docs) describes general development practices for CWRC-Writer GitHub repositories, including this one.
143105

144-
#### Testing
106+
<!-- ### Testing
145107
146-
The code in this repository is intended to run in the browser, and so we use [browser-run](https://github.com/juliangruber/browser-run) to run [browserified](http://browserify.org) [tape](https://github.com/substack/tape) tests directly in the browser.
108+
The code in this repository is intended to run in the browser, and so we use [browser-run](https://github.com/juliangruber/browser-run) to run [browserified](http://browserify.org) [tape](https://github.com/substack/tape) tests directly in the browser.
147109
148-
We [decorate](https://en.wikipedia.org/wiki/Decorator_pattern) [tape](https://github.com/substack/tape) with [tape-promise](https://github.com/jprichardson/tape-promise) to allow testing with promises and async methods.
110+
We [decorate](https://en.wikipedia.org/wiki/Decorator_pattern) [tape](https://github.com/substack/tape) with [tape-promise](https://github.com/jprichardson/tape-promise) to allow testing with promises and async methods. -->
149111

150-
#### Mocking
112+
### Mocking
151113

152-
We use [fetch-mock](https://github.com/wheresrhys/fetch-mock) to mock http calls (which we make using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) rather than XMLHttpRequest).
114+
We use [fetch-mock](https://github.com/wheresrhys/fetch-mock) to mock http calls (which we make using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) rather than XMLHttpRequest).
153115

154-
We use [sinon](http://sinonjs.org) [fake timers](http://sinonjs.org/releases/v4.0.1/fake-timers/) to test our timeouts, without having to wait for the timeouts.
116+
<!-- We use [sinon](http://sinonjs.org) [fake timers](http://sinonjs.org/releases/v4.0.1/fake-timers/) to test our timeouts, without having to wait for the timeouts.
155117
156-
#### Code Coverage
118+
### Code Coverage
157119
158-
We generate code coverage by instrumenting our code with [istanbul](https://github.com/gotwarlost/istanbul) before [browser-run](https://github.com/juliangruber/browser-run) runs the tests,
120+
We generate code coverage by instrumenting our code with [istanbul](https://github.com/gotwarlost/istanbul) before [browser-run](https://github.com/juliangruber/browser-run) runs the tests,
159121
then extract the coverage (which [istanbul](https://github.com/gotwarlost/istanbul) writes to the global object, i.e., the window in the browser), format it with [istanbul](https://github.com/gotwarlost/istanbul), and finally report (Travis actually does this for us) to [codecov.io](codecov.io)
160122
161-
#### Transpilation
123+
### Transpilation
162124
163-
We use [babelify](https://github.com/babel/babelify) and [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul) to compile our code, tests, and code coverage with [babel](https://github.com/babel/babel)
125+
We use [babelify](https://github.com/babel/babelify) and [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul) to compile our code, tests, and code coverage with [babel](https://github.com/babel/babel) -->
164126

165-
#### Continuous Integration
127+
### Continuous Integration
166128

167129
We use [Travis](https://travis-ci.org).
168130

169-
Note that to allow our tests to run in Electron on Travis, the following has been added to .travis.yml:
170-
171-
```
172-
addons:
173-
apt:
174-
packages:
175-
- xvfb
176-
install:
177-
- export DISPLAY=':99.0'
178-
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
179-
- npm install
180-
```
181-
182-
#### Release
131+
### Release
183132

184133
We follow [SemVer](http://semver.org), which [Semantic Release](https://github.com/semantic-release/semantic-release) makes easy.
185134
Semantic Release also writes our commit messages, sets the version number, publishes to NPM, and finally generates a changelog and a release (including a git tag) on GitHub.
186-

issue_template.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
<!--- Provide an unambiguous set of steps to -->
1717
<!--- reproduce this bug. Screenshots are invaluable. -->
1818
<!--- Links to screen videos or brief .gif files can help a lot too. -->
19+
1920
1.
2021
2.
2122
3.
2223
4.
2324

2425
## Your Environment
26+
2527
* URL:
2628

2729
* Browser Name:

0 commit comments

Comments
 (0)