import { h, Component } from 'preact' import { Link } from 'react-router-dom' export default class Details extends Component { constructor(){ super() } onWheel(e){ e.stopPropagation() } render() { const painting = this.props.painting if (! painting) return const source_images = findImages(painting.parameters) const parameters = breakUpJSON(painting.parameters) return (

{painting.title}

{painting.medium}
{painting.date}
{painting.image.caption}
{painting.originalImage &&

Original Image

} {painting.parameters &&

Creation Parameters

{parameters}

Source Images

{source_images}
}
) } } class PossiblyBadImage extends Component { constructor(){ super() this.state = { error: false } this.onError = this.onError.bind(this) } onError(){ this.setState({ error: true }) } render(){ if (this.state.error) return return ( ) } } function findImages(s) { s = s || "" const urlRegex = /(https?:\/\/[^\s]+)/g; let match = urlRegex.exec(s); let urls = [] let url; let seen = {}; while (match != null) { url = match[0].replace(/",?/,"") if (url && ! seen[url]) { seen[url] = true urls.push( ) } match = urlRegex.exec(s); } return urls } function breakUpJSON(ss){ return (ss || '').split("} {").map( (s) => { return (
{s}

) }) }