diff --git a/app/classes/aapbRecordHelpers.jsx b/app/classes/aapbRecordHelpers.jsx deleted file mode 100644 index 535a727..0000000 --- a/app/classes/aapbRecordHelpers.jsx +++ /dev/null @@ -1,190 +0,0 @@ -import { Component } from 'react' - -export function handleAapbRecordGroup(aapbRecordGroup, key) { - // this func is where we split by whitespace v - var guids = parseAapbRecordGroup(aapbRecordGroup.value.guids) - - // preserve these flags' effect for each aapb_record_group - var showThumbnail = aapbRecordGroup.value.show_thumbnail - var showTitle = aapbRecordGroup.value.show_title - - return ( - - ) -} - -export function parseAapbRecordGroup(string) { - return string.split(/\s+/) -} - -async function retrieveAapbRecord(guid) { - return await fetch(window.ENV.AAPB_HOST + '/api/' + guid + '.json') - .then(response => response.json()) - .catch(e => console.log(`Error retrieving record from AAPB: ${e}`)) -} - -export class AAPBRecord extends Component { - constructor(props) { - super(props) - this.state = { - embedPlayer: true, - showThumbnail: props.showThumbnail, - showTitle: props.showTitle, - } - } - - async componentDidMount() { - var hyphenGuid = this.props.guid.replace(/cpb-aacip./, 'cpb-aacip-') - var record = await retrieveAapbRecord(hyphenGuid) - this.setState({ guid: hyphenGuid, pbcore: record }) - } - - aapbThumbnailURL(guid) { - const S3_BASE = 'https://s3.amazonaws.com/americanarchive.org' - return `${S3_BASE}/thumbnail/${guid}.jpg` - } - - aapbCatalogURL(guid) { - return `${window.ENV.AAPB_HOST}/catalog/${guid}` - } - - aapbTitle(pbcore) { - if (pbcore?.pbcoreDescriptionDocument?.pbcoreTitle?.text) { - // there is one title - return pbcore.pbcoreDescriptionDocument.pbcoreTitle.text - } else if (pbcore?.pbcoreDescriptionDocument?.pbcoreTitle?.length > 0) { - // there are multiple titles - return pbcore.pbcoreDescriptionDocument.pbcoreTitle - .map(titleObj => { - return titleObj.text - }) - .join('; ') - } else { - return 'Untitled Record' - } - } - - embed(guid, startTime, endTime) { - var times - if (startTime || endTime) { - times = `?start=${startTime}&end=${endTime}` - } - var url = `${window.ENV.AAPB_HOST}/openvault/${guid}${times || ''}` - return ( - -