Commit 763b547c authored by Sam Muirhead's avatar Sam Muirhead

add OAuth proxy and connect to Noun Project API

- Darius Kazemi helped me by putting together an OAuth proxy which allows me to
send API requests to the NP API.
- Search field and button added, @print media query finished
- search-results.html works!
parent 1870423d
......@@ -9,7 +9,8 @@
</head>
<body>
<svg xmlns="https://www.w3.org/2000/svg" viewBox="0 0 1123 794" width="1123" height="794">
<svg id="page" xmlns="https://www.w3.org/2000/svg" viewBox="0 0 1123 794" width="1123" height="794">
<defs>
<svg id="cc-by" height="32" width="70" viewBox="5 -3.5 140 64">
......@@ -200,6 +201,12 @@
<use href="#panel-0" transform="scale(2) translate(280.75,0)"/>
</svg>
<form action="/url-where-you-want-to-submit-form-data">
<input type="text" placeholder="12345">
<button type="submit">Add ID</button></form>
<button type="button" id="printButton" onclick="window.print()" >Print!</button>
</body>
<script type="application/javascript" src="./populate-credits.js"></script>
......
var crypto = require('crypto');
var OAuth = require('oauth-request');
const express = require('express')
const app = express()
const cors = require('cors');
const port = 3000
app.get('/', cors(), (req, res) => {
console.log(req.query);
let term = req.query.term;
getImages(term).then((data) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.json(data)
});
});
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
function getImages(term) {
return new Promise((resolve, reject) => {
var twitter = OAuth({
consumer: {
key: 'xxxxxx',
secret: 'xxxxxx'
// ENTER YOUR NOUN PROJECT KEY & SECRET HERE
},
signature_method: 'HMAC-SHA1',
hash_function: function(base_string, key) {
return crypto.createHmac('sha1', key).update(base_string).digest('base64');
}
});
twitter.get({
url: 'https://api.thenounproject.com/icons/' + term,
qs: {
limit: 8
},
json: true
}, function(err, res, icons) {
resolve(icons);
});
});
}
1.3.5 / 2018-02-28
==================
* deps: mime-types@~2.1.18
- deps: mime-db@~1.33.0
1.3.4 / 2017-08-22
==================
* deps: mime-types@~2.1.16
- deps: mime-db@~1.29.0
1.3.3 / 2016-05-02
==================
* deps: mime-types@~2.1.11
- deps: mime-db@~1.23.0
* deps: negotiator@0.6.1
- perf: improve `Accept` parsing speed
- perf: improve `Accept-Charset` parsing speed
- perf: improve `Accept-Encoding` parsing speed
- perf: improve `Accept-Language` parsing speed
1.3.2 / 2016-03-08
==================
* deps: mime-types@~2.1.10
- Fix extension of `application/dash+xml`
- Update primary extension for `audio/mp4`
- deps: mime-db@~1.22.0
1.3.1 / 2016-01-19
==================
* deps: mime-types@~2.1.9
- deps: mime-db@~1.21.0
1.3.0 / 2015-09-29
==================
* deps: mime-types@~2.1.7
- deps: mime-db@~1.19.0
* deps: negotiator@0.6.0
- Fix including type extensions in parameters in `Accept` parsing
- Fix parsing `Accept` parameters with quoted equals
- Fix parsing `Accept` parameters with quoted semicolons
- Lazy-load modules from main entry point
- perf: delay type concatenation until needed
- perf: enable strict mode
- perf: hoist regular expressions
- perf: remove closures getting spec properties
- perf: remove a closure from media type parsing
- perf: remove property delete from media type parsing
1.2.13 / 2015-09-06
===================
* deps: mime-types@~2.1.6
- deps: mime-db@~1.18.0
1.2.12 / 2015-07-30
===================
* deps: mime-types@~2.1.4
- deps: mime-db@~1.16.0
1.2.11 / 2015-07-16
===================
* deps: mime-types@~2.1.3
- deps: mime-db@~1.15.0
1.2.10 / 2015-07-01
===================
* deps: mime-types@~2.1.2
- deps: mime-db@~1.14.0
1.2.9 / 2015-06-08
==================
* deps: mime-types@~2.1.1
- perf: fix deopt during mapping
1.2.8 / 2015-06-07
==================
* deps: mime-types@~2.1.0
- deps: mime-db@~1.13.0
* perf: avoid argument reassignment & argument slice
* perf: avoid negotiator recursive construction
* perf: enable strict mode
* perf: remove unnecessary bitwise operator
1.2.7 / 2015-05-10
==================
* deps: negotiator@0.5.3
- Fix media type parameter matching to be case-insensitive
1.2.6 / 2015-05-07
==================
* deps: mime-types@~2.0.11
- deps: mime-db@~1.9.1
* deps: negotiator@0.5.2
- Fix comparing media types with quoted values
- Fix splitting media types with quoted commas
1.2.5 / 2015-03-13
==================
* deps: mime-types@~2.0.10
- deps: mime-db@~1.8.0
1.2.4 / 2015-02-14
==================
* Support Node.js 0.6
* deps: mime-types@~2.0.9
- deps: mime-db@~1.7.0
* deps: negotiator@0.5.1
- Fix preference sorting to be stable for long acceptable lists
1.2.3 / 2015-01-31
==================
* deps: mime-types@~2.0.8
- deps: mime-db@~1.6.0
1.2.2 / 2014-12-30
==================
* deps: mime-types@~2.0.7
- deps: mime-db@~1.5.0
1.2.1 / 2014-12-30
==================
* deps: mime-types@~2.0.5
- deps: mime-db@~1.3.1