From df95e75025785a6b35c52f2b9fec4182395b822b Mon Sep 17 00:00:00 2001 From: vrde Date: Wed, 27 May 2015 17:34:15 +0200 Subject: [PATCH 01/17] WIP --- js/components/ascribe_media/image_viewer.js | 25 -------- .../ascribe_media/resource_viewer.js | 40 +++++++++++++ .../ascribe_table/table_item_subtable.js | 2 +- js/components/edition.js | 11 +++- js/mixins/inject_in_head_mixin.js | 57 +++++++++++++++++++ 5 files changed, 106 insertions(+), 29 deletions(-) delete mode 100644 js/components/ascribe_media/image_viewer.js create mode 100644 js/components/ascribe_media/resource_viewer.js create mode 100644 js/mixins/inject_in_head_mixin.js diff --git a/js/components/ascribe_media/image_viewer.js b/js/components/ascribe_media/image_viewer.js deleted file mode 100644 index fdbd0342..00000000 --- a/js/components/ascribe_media/image_viewer.js +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; - -/** - * This is the component that implements display-specific functionality - */ -let ImageViewer = React.createClass({ - propTypes: { - thumbnail: React.PropTypes.string.isRequired - }, - - render() { - let thumbnail = ; - let aligner = ; - return ( -
-
- {aligner} - {thumbnail} -
-
- ); - } -}); - -export default ImageViewer; \ No newline at end of file diff --git a/js/components/ascribe_media/resource_viewer.js b/js/components/ascribe_media/resource_viewer.js new file mode 100644 index 00000000..4519bcb7 --- /dev/null +++ b/js/components/ascribe_media/resource_viewer.js @@ -0,0 +1,40 @@ +import React from 'react'; +import InjectInHeadMixin from '../../mixins/inject_in_head_mixin'; + +/** + * This is the component that implements display-specific functionality. + * + * ResourceViewer handles the following mimetypes: + * - image + * - video + * - audio + * - pdf + * - other + */ + +let resourceMap = { + 'image': 1 +} + +let ResourceViewer = React.createClass({ + propTypes: { + thumbnail: React.PropTypes.string.isRequired, + mimetype: React.PropTypes.oneOf(['image', 'video', 'audio', 'pdf', 'other']).isRequired + }, + + mixins: [InjectInHeadMixin], + + componentDidMount() { + this.inject('http://antani.com'); + }, + + render() { + return ( +
+ resourceviewer {this.props.thumbnail} {this.props.mimetype} +
+ ); + } +}); + +export default ResourceViewer; diff --git a/js/components/ascribe_table/table_item_subtable.js b/js/components/ascribe_table/table_item_subtable.js index e9bd05f2..c8f4c498 100644 --- a/js/components/ascribe_table/table_item_subtable.js +++ b/js/components/ascribe_table/table_item_subtable.js @@ -55,7 +55,7 @@ let TableItemSubtable = React.createClass({ let numOfColumns = GeneralUtils.sumNumList(listOfRowValues); if(numOfColumns > 10) { - throw new Error('Bootstrap has only 12 columns to assign. You defined ' + numOfColumns + '. Change this in the columnMap you\'re passing to the table.') + throw new Error('Bootstrap has only 12 columns to assign. You defined ' + numOfColumns + '. Change this in the columnMap you\'re passing to the table.'); } else { return bootstrapClasses.join( listOfRowValues[i] + ' ') + listOfRowValues[i]; } diff --git a/js/components/edition.js b/js/components/edition.js index 336bacff..7bb3f221 100644 --- a/js/components/edition.js +++ b/js/components/edition.js @@ -1,5 +1,5 @@ import React from 'react'; -import ImageViewer from './ascribe_media/image_viewer'; +import ResourceViewer from './ascribe_media/resource_viewer'; /** * This is the component that implements display-specific functionality @@ -10,10 +10,15 @@ let Edition = React.createClass({ //}, render() { + let thumbnail = this.props.edition.thumbnail; + let mimetype = this.props.edition.digital_work.mime; + return (
- +
@@ -103,4 +108,4 @@ let EditionDetails = React.createClass({ }); -export default Edition; \ No newline at end of file +export default Edition; diff --git a/js/mixins/inject_in_head_mixin.js b/js/mixins/inject_in_head_mixin.js new file mode 100644 index 00000000..0c83be16 --- /dev/null +++ b/js/mixins/inject_in_head_mixin.js @@ -0,0 +1,57 @@ +let mapAttr = { + link: 'href', + source: 'src' +} + +let mapExt = { + js: 'source', + css: 'link' +} + + +let InjectInHeadMixin = { + /** + * Provide functions to inject `