Skip to content

Instantly share code, notes, and snippets.

View EdwinGuzman's full-sized avatar
🐺
yep

Edwin Guzman EdwinGuzman

🐺
yep
  • The New York Public Library
View GitHub Profile
<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,
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)));
};
}
import React from 'react';
import PropTypes from 'prop-types';
class Select extends React.Component {
constructor(props) {
super(props);
this.state = {
selected: '',
};
// 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">
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' } },
// App.jsx
import HomepageRow from 'dgx-homepage-row-component';
import HomepageStaffPicks from 'dgx-homepage-staff-picks-component';
import FeatureRow from 'dgx-feature-row';
import Banner from 'dgx-content-banner';
import { gaUtils } from 'dgx-react-ga';
const trackHomepage = gaUtils.trackEvent('Homepage');
const trackHomepageRow = (action) => {
return (label) => {
// App.jsx
import HomepageRow from 'dgx-homepage-row-component';
import HomepageStaffPicks from 'dgx-homepage-staff-picks-component';
import { gaUtils } from 'dgx-react-ga';
const trackHomepage = gaUtils.trackEvent('Homepage');
const trackHomepageRow = (action) => {
return (label) => {
return trackHomepage(action, label);
};
// App.jsx
import HomepageRow from 'dgx-homepage-row-component';
import HomepageStaffPicks from 'dgx-homepage-staff-picks-component';
import { gaUtils } from 'dgx-react-ga';
const trackHomepage = gaUtils.trackEvent('Homepage');
class App extends React.Component {
// ...
render () {
// 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.
import ga from 'react-ga';
function GaUtils() {
// other GA related functions
this.trackEvent = category =>
(action, label) => (
// using ES6 object shortcut notation
ga.event({
category,