From 83063b97105c7514d71ec2afaaf66def49116214 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 13 Feb 2019 18:05:35 +0100 Subject: listing citations, known and unknown --- scraper/client/paper/index.js | 8 +++++ scraper/client/paper/paper.address.js | 38 +++++++++++++++++++++ scraper/client/paper/paper.citations.js | 58 +++++++++++++++++++++++++++++++++ scraper/client/paper/paper.css | 16 +++++++++ scraper/client/paper/paper.random.js | 36 ++++++++++++++++++++ scraper/client/paper/paper.unknown.js | 53 ++++++++++++++++++++++++++++++ 6 files changed, 209 insertions(+) create mode 100644 scraper/client/paper/paper.address.js create mode 100644 scraper/client/paper/paper.citations.js create mode 100644 scraper/client/paper/paper.random.js create mode 100644 scraper/client/paper/paper.unknown.js (limited to 'scraper/client/paper') diff --git a/scraper/client/paper/index.js b/scraper/client/paper/index.js index c10ea011..4fad0316 100644 --- a/scraper/client/paper/index.js +++ b/scraper/client/paper/index.js @@ -1,5 +1,9 @@ import Manager from './paper.manager' import Info from './paper.info' +import Citations from './paper.citations' +import UnknownCitations from './paper.unknown' +import Random from './paper.random' +import Address from './paper.address' import './paper.css' // import './search.css' @@ -7,4 +11,8 @@ import './paper.css' export { Manager, Info, + Citations, + UnknownCitations, + Random, + Address, } diff --git a/scraper/client/paper/paper.address.js b/scraper/client/paper/paper.address.js new file mode 100644 index 00000000..2240388f --- /dev/null +++ b/scraper/client/paper/paper.address.js @@ -0,0 +1,38 @@ +import React, { Component } from 'react' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' + +import * as actions from '../actions' + +// import { Loader } from '../common' + +class PaperAddress extends Component { + componentDidMount() { + const { sha256 } = this.props.match.params + this.props.actions.getAddress(sha256) + } + + componentDidUpdate(newProps) { + const { sha256: oldSha256 } = this.props.match.params + const { sha256 } = newProps.match.params + if (sha256 !== oldSha256) { + this.props.actions.getPaperInfo(this.props.match.params.key) + } + } + + render() { + // if (!this.props.match.params.key) return null + // if (this.props.api.address.loading) return + // if (!this.props.api.paperInfo.dataset) return
Metadata not found
+ return null + } +} + +const mapStateToProps = state => ({ + api: state.api, +}) +const mapDispatchToProps = dispatch => ({ + actions: bindActionCreators({ ...actions }, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(PaperAddress) diff --git a/scraper/client/paper/paper.citations.js b/scraper/client/paper/paper.citations.js new file mode 100644 index 00000000..de423a77 --- /dev/null +++ b/scraper/client/paper/paper.citations.js @@ -0,0 +1,58 @@ +import React, { Component } from 'react' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' + +import * as actions from '../actions' + +import { TableObject } from '../common' + +class PaperCitations extends Component { + render() { + const { dataset, citations } = this.props.api.paperInfo + if (!dataset || !citations) return null + console.log('rendering citations...') + return ( +
+

{dataset.name_full}: Citations

+
    + {citations.map((citation, i) => { + let cite = { ...citation } + cite.id = { + _raw: true, + value: {citation.id} + } + cite.pdf = { + _raw: true, + value: cite.pdf ? [pdf] : "no pdf" + } + cite.addresses = { + _raw: true, + value: cite.addresses.map((address, j) => ( +
    {address.address}{', '}{address.type}
    + )) + } + return ( +
  • + +
  • + ) + })} +
+
+ ) + } +} + +const mapStateToProps = state => ({ + api: state.api +}) +const mapDispatchToProps = dispatch => ({ + actions: bindActionCreators({ ...actions }, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(PaperCitations) diff --git a/scraper/client/paper/paper.css b/scraper/client/paper/paper.css index c1a775c1..cd2f8529 100644 --- a/scraper/client/paper/paper.css +++ b/scraper/client/paper/paper.css @@ -1,3 +1,19 @@ .paperInfo { padding: 10px; +} + +.citations ul { + list-style-type: none; + margin: 0; + padding: 0; +} + +.citations li { + list-style-type: none; + margin: 0; + padding-bottom: 40px; +} + +.type { + color: #888; } \ No newline at end of file diff --git a/scraper/client/paper/paper.random.js b/scraper/client/paper/paper.random.js new file mode 100644 index 00000000..aab22172 --- /dev/null +++ b/scraper/client/paper/paper.random.js @@ -0,0 +1,36 @@ +import React, { Component } from 'react' +// import { NavLink } from 'react-router-dom' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' + +import { choice } from '../util' +import { history } from '../store' + +import * as actions from '../actions' + +class PaperRandom extends Component { + componentDidUpdate() { + const { citations } = this.props.api.unknownCitations + if (!citations) return + const citation = choice(citations) + console.log(citation) + if (citation.id) { + history.push('/paper/' + this.props.match.params.key + '/address/' + citation.id) + } + } + + render() { + return ( +
Sending you to a random citation...
+ ) + } +} + +const mapStateToProps = state => ({ + api: state.api +}) +const mapDispatchToProps = dispatch => ({ + actions: bindActionCreators({ ...actions }, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(PaperRandom) diff --git a/scraper/client/paper/paper.unknown.js b/scraper/client/paper/paper.unknown.js new file mode 100644 index 00000000..7a20f398 --- /dev/null +++ b/scraper/client/paper/paper.unknown.js @@ -0,0 +1,53 @@ +import React, { Component } from 'react' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' + +import * as actions from '../actions' + +import { TableObject } from '../common' + +class PaperUnknown extends Component { + render() { + const { dataset } = this.props.api.paperInfo + const { citations } = this.props.api.unknownCitations + if (!dataset || !citations) return null + console.log('rendering unknown citations...') + return ( +
+

{dataset.name_full}: Unknown Citations

+
    + {citations.map((citation, i) => { + let cite = { ...citation } + cite.id = { + _raw: true, + value: {citation.id} + } + cite.pdf = { + _raw: true, + value: cite.pdf ? [pdf] : "no pdf" + } + return ( +
  • + +
  • + ) + })} +
+
+ ) + } +} + // order={['id', 'pdf', 'year']} + +const mapStateToProps = state => ({ + api: state.api +}) +const mapDispatchToProps = dispatch => ({ + actions: bindActionCreators({ ...actions }, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(PaperUnknown) -- cgit v1.2.3-70-g09d2