This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="api_documentation_all_container container"> | |
<div class="row"> | |
<div class="span9"> | |
<div class="docs-wrapper"> | |
<section id="the-new-york-public-library-digital-collections-api"> | |
<h2>The New York Public Library Digital Collections API</h2> | |
<p>For more than a century, The New York Public Library has amassed an extraordinary trove of rare and unique material | |
covering the full spectrum of recorded knowledge. Now, for the first time, significant portions of the Library's | |
digitized collections are available as machine-readable data: over one million objects and records for you to search, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const makeCurry = (fn) => { | |
const slice = [].slice; | |
return function curriedFn() { | |
let args = slice.call(arguments); | |
if (args.length < fn.length) { | |
return () => { | |
return curriedFn.apply(null, args.concat(slice.call(arguments))); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
class Select extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
selected: '', | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Search.jsx | |
class Search extends React.Component { | |
// Other class functions... | |
render() { | |
// Here we can pass the class that we want this “omni-search” component to have as a React prop. | |
const style = this.props.style; | |
return ( | |
<form onKeyPress={this.triggerSubmit} method="POST"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var endpoint = 'https://refinery.nypl.org/api/nypl/ndo/v0.1/staff-picks/staff-pick-lists?filter[list-type]=monthly&fields[staff-pick-tag]=tag&fields[staff-pick-age]=age&fields[staff-pick-item]=title,author,catalog-slug,image-slug,tags,ebook-uri&page[size]=1&include=previous-list,next-list,picks.item.tags,picks.age'; | |
var filters = [ { type: 'staff-pick-tag', | |
id: 'action-packed', | |
attributes: { tag: 'Action-packed' }, | |
links: { self: 'https://refinery.nypl.org/api/nypl/ndo/v0.1/staff-picks/staff-pick-tags/action-packed' } }, | |
{ type: 'staff-pick-tag', | |
id: 'adventure', | |
attributes: { tag: 'Adventure' }, | |
links: { self: 'https://refinery.nypl.org/api/nypl/ndo/v0.1/staff-picks/staff-pick-tags/adventure' } }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In the New Arrivals app, code reduced for brevity | |
// utils.js | |
import { gaUtils } from 'dgx-react-ga'; | |
const trackNewArrivals = gaUtils.trackEvent('New Arrivals'); | |
export default { trackNewArrivals }; | |
// The `trackNewArrivals` function can now be used throughout the app wherever | |
// utils.js is imported and will track every event with a 'New Arrivals' category. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ga from 'react-ga'; | |
function GaUtils() { | |
// other GA related functions | |
this.trackEvent = category => | |
(action, label) => ( | |
// using ES6 object shortcut notation | |
ga.event({ | |
category, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ga from 'react-ga'; | |
ga.event({ category: '', action: '', label: '' }); | |
// We can use this function in our applications: | |
// In the New Arrivals app | |
ga.event({ category: 'New Arrivals', action: 'click', label: 'list view' }); | |
ga.event({ category: 'New Arrivals', action: 'click', label: 'grid view' }); | |
// In the Staff Picks app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const booksByTolkien = bookBy('J. R. R. Tolkien'); | |
const booksByHerbert = bookBy('Frank Herbert'); | |
// Better than: | |
const booksByTolkien = (book) => { | |
console.log(`J. R. R. Tolkien wrote ${book}.`); | |
} | |
const booksByHerbert = (book) => { | |
console.log(`Frank Herbert wrote ${book}.`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const booksByRowling = (book) => { | |
console.log(`J. K. Rowling wrote ${book}.`); | |
} |
NewerOlder