import * as React from 'react'; import { AppDataStore } from './data/AppDataStore'; import { Talk, Book } from './data/Document'; import { suggestions } from './data/suggestions'; import { get } from 'lodash'; import { databind, Bound, SearchBox, MoreLikeThis, DetailLayout, PaginationData, SearchParams } from 'solrkit'; function thumbnailUrl(url: string) { return ( 'http://img.youtube.com/vi/' + url.replace(/.*v=/, '') + '/mqdefault.jpg' ); } const PlayIcon = ({selected}: {selected: boolean}) => ( ); const CheckmarkIcon = () => ( ); const Watched = ({id}: {id: string}) => ( (get(localStorage, 'watched' + id, '') + '' === 'true') ? ( ) : null ); class VideoThumbnail extends React.Component< { talk: Talk onClick: () => void }, {hover: boolean}> { constructor() { super(); this.state = { hover: false }; this.onMouseEnter = this.onMouseEnter.bind(this); this.onMouseLeave = this.onMouseLeave.bind(this); } onMouseEnter() { this.setState({hover: true}); } onMouseLeave() { this.setState({hover: false}); } render() { const talk = this.props.talk; return ( ); } } class VideoPlayer extends React.Component { youtubeId(url: String) { return url.replace(/.*v=/, ''); } render() { const url = this.props.url_s; const ytUrl: string | undefined = url ? ( 'https://www.youtube.com/embed/' + this.youtubeId(url) + '?modestbranding=true' ) : undefined; return ( {this.props.title_s} { get( this, 'props.speakerName_ss', [] ).map( (speaker: String) => ( More talks by {speaker} { books.length > 0 ? ( Books by {speaker} ) : null } {books.filter( (book) => book.thumbnail_url_s.length > 'https://covers.openlibrary.org/b/id/-1-M.jpg'.length ).map( (book: Book, index: number) => { const replacedAuthor = book.author_key_s.replace(/ /g, '+'); const replacedTitle = book.title_s.replace(/ /g, '+'); const amazonUrl = `https://www.amazon.com/s/ref=as_li_ss_tl` + `?url=search-alias=aps&field-keywords='${replacedAuthor}'%20'${replacedTitle}'` + `&linkCode=ll2&tag=findlectures-20&linkId=e74a25c0b9b62f51431008f4dfeae781`; return ( ); } )} } /> ) ) } ); } } interface DetailAppProps { id: string; } const dataStore = new AppDataStore('talks'); class DetailPageApp extends React.Component { private left: () => JSX.Element; private right: () => JSX.Element; private header: () => JSX.Element; constructor() { super(); this.left = databind( dataStore.talks.onGet, dataStore.talks, (talk: Talk) => () ); this.right = databind( dataStore.talks.onMoreLikeThis, dataStore.talks, (talks: Talk[]) => ( ( talk.url_s.indexOf('youtube.com') > 0 ? ( (window as any).location = '/view/' + talk.id } /> (window as any).location = '/view/' + talk.id } > {talk.title_s} ) : null ) } />) ); this.header = databind( dataStore.talks.onMoreLikeThis, dataStore.talks, (talk: Document) => ( { (window as any).location = 'https://www.findlectures.com/?q=' + params.query.replace(/ /g, '%20'); } } /> ) ); } init() { dataStore.talks.doGet(this.props.id); dataStore.talks.doMoreLikeThis(this.props.id); } componentWillReceiveProps() { this.init(); } componentDidMount() { this.init(); const key = 'watched' + this.props.id; const today = new Date(); window.localStorage[key] = 'Watched ' + today.getDate() + ' ' + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][today.getMonth()] + ' ' + today.getFullYear(); } componentWillUnmount() { // dataStore.clearEvents(); } render() { return ( ); } } export { DetailPageApp };
More talks by {speaker}
{ books.length > 0 ? (