From 461087ae7d266512b8ae87b8d0ea32f2ea2cb9d3 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Tue, 3 Jul 2018 10:42:59 -0700 Subject: [PATCH 01/11] added missing name attribute to AssetShareButtons --- client/build/containers/AssetInfo/view.js | 1 + client/src/containers/AssetInfo/view.jsx | 1 + 2 files changed, 2 insertions(+) diff --git a/client/build/containers/AssetInfo/view.js b/client/build/containers/AssetInfo/view.js index a405af12..e9b8865a 100644 --- a/client/build/containers/AssetInfo/view.js +++ b/client/build/containers/AssetInfo/view.js @@ -136,6 +136,7 @@ function (_React$Component) { }), content: _react.default.createElement(AssetShareButtons, { host: host, + name: name, shortId: shortId }) })), _react.default.createElement(_Row.default, null, _react.default.createElement(_RowLabeled.default, { diff --git a/client/src/containers/AssetInfo/view.jsx b/client/src/containers/AssetInfo/view.jsx index 12427c27..cf9091d2 100644 --- a/client/src/containers/AssetInfo/view.jsx +++ b/client/src/containers/AssetInfo/view.jsx @@ -99,6 +99,7 @@ class AssetInfo extends React.Component { content={ } From fb47993ef5f0bc2461ff29b10770c4644abe92d7 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Tue, 3 Jul 2018 10:48:37 -0700 Subject: [PATCH 02/11] separated AssetShareButtons component --- .../components/AssetShareButtons/index.js | 36 ++++++++++++++++++ client/build/containers/AssetInfo/view.js | 35 ++++------------- .../src/components/AssetShareButtons/index.js | 38 +++++++++++++++++++ client/src/containers/AssetInfo/view.jsx | 36 +----------------- 4 files changed, 82 insertions(+), 63 deletions(-) create mode 100644 client/build/components/AssetShareButtons/index.js create mode 100644 client/src/components/AssetShareButtons/index.js diff --git a/client/build/components/AssetShareButtons/index.js b/client/build/components/AssetShareButtons/index.js new file mode 100644 index 00000000..81d25996 --- /dev/null +++ b/client/build/components/AssetShareButtons/index.js @@ -0,0 +1,36 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var AssetShareButtons = function AssetShareButtons(_ref) { + var host = _ref.host, + name = _ref.name, + shortId = _ref.shortId; + return _react.default.createElement(SpaceBetween, null, _react.default.createElement("a", { + className: "link--primary", + target: "_blank", + href: "https://twitter.com/intent/tweet?text=".concat(host, "/").concat(shortId, "/").concat(name) + }, "twitter"), _react.default.createElement("a", { + className: "link--primary", + target: "_blank", + href: "https://www.facebook.com/sharer/sharer.php?u=".concat(host, "/").concat(shortId, "/").concat(name) + }, "facebook"), _react.default.createElement("a", { + className: "link--primary", + target: "_blank", + href: "http://tumblr.com/widgets/share/tool?canonicalUrl=".concat(host, "/").concat(shortId, "/").concat(name) + }, "tumblr"), _react.default.createElement("a", { + className: "link--primary", + target: "_blank", + href: "https://www.reddit.com/submit?url=".concat(host, "/").concat(shortId, "/").concat(name, "&title=").concat(name) + }, "reddit")); +}; + +var _default = AssetShareButtons; +exports.default = _default; \ No newline at end of file diff --git a/client/build/containers/AssetInfo/view.js b/client/build/containers/AssetInfo/view.js index e9b8865a..69e29d3e 100644 --- a/client/build/containers/AssetInfo/view.js +++ b/client/build/containers/AssetInfo/view.js @@ -17,6 +17,8 @@ var _Row = _interopRequireDefault(require("@components/Row")); var _SpaceBetween = _interopRequireDefault(require("@components/SpaceBetween")); +var _AssetShareButtons = _interopRequireDefault(require("@components/AssetShareButtons")); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -37,33 +39,10 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || functio function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -var AssetShareButtons = function AssetShareButtons(_ref) { - var host = _ref.host, - name = _ref.name, - shortId = _ref.shortId; - return _react.default.createElement(_SpaceBetween.default, null, _react.default.createElement("a", { - className: "link--primary", - target: "_blank", - href: "https://twitter.com/intent/tweet?text=".concat(host, "/").concat(shortId, "/").concat(name) - }, "twitter"), _react.default.createElement("a", { - className: "link--primary", - target: "_blank", - href: "https://www.facebook.com/sharer/sharer.php?u=".concat(host, "/").concat(shortId, "/").concat(name) - }, "facebook"), _react.default.createElement("a", { - className: "link--primary", - target: "_blank", - href: "http://tumblr.com/widgets/share/tool?canonicalUrl=".concat(host, "/").concat(shortId, "/").concat(name) - }, "tumblr"), _react.default.createElement("a", { - className: "link--primary", - target: "_blank", - href: "https://www.reddit.com/submit?url=".concat(host, "/").concat(shortId, "/").concat(name, "&title=").concat(name) - }, "reddit")); -}; - -var ClickToCopy = function ClickToCopy(_ref2) { - var id = _ref2.id, - value = _ref2.value, - copyToClipboard = _ref2.copyToClipboard; +var ClickToCopy = function ClickToCopy(_ref) { + var id = _ref.id, + value = _ref.value, + copyToClipboard = _ref.copyToClipboard; return _react.default.createElement("input", { id: id, value: value, @@ -134,7 +113,7 @@ function (_React$Component) { label: _react.default.createElement(_Label.default, { value: 'Share:' }), - content: _react.default.createElement(AssetShareButtons, { + content: _react.default.createElement(_AssetShareButtons.default, { host: host, name: name, shortId: shortId diff --git a/client/src/components/AssetShareButtons/index.js b/client/src/components/AssetShareButtons/index.js new file mode 100644 index 00000000..657b14a1 --- /dev/null +++ b/client/src/components/AssetShareButtons/index.js @@ -0,0 +1,38 @@ +import React from 'react'; + +const AssetShareButtons = ({ host, name, shortId }) => { + return ( + + + twitter + + + facebook + + + tumblr + + + reddit + + + ); +}; + +export default AssetShareButtons; diff --git a/client/src/containers/AssetInfo/view.jsx b/client/src/containers/AssetInfo/view.jsx index cf9091d2..9ce7d090 100644 --- a/client/src/containers/AssetInfo/view.jsx +++ b/client/src/containers/AssetInfo/view.jsx @@ -4,41 +4,7 @@ import Label from '@components/Label'; import RowLabeled from '@components/RowLabeled'; import Row from '@components/Row'; import SpaceBetween from '@components/SpaceBetween'; - -const AssetShareButtons = ({ host, name, shortId }) => { - return ( - - - twitter - - - facebook - - - tumblr - - - reddit - - - ); -}; +import AssetShareButtons from '@components/AssetShareButtons'; const ClickToCopy = ({id, value, copyToClipboard}) => { return ( From 082e822e059ddf0084e1400942b2ecf880e0ae02 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Tue, 3 Jul 2018 10:56:00 -0700 Subject: [PATCH 03/11] separated out ClickToCopy component --- client/build/components/ClickToCopy/index.js | 85 ++++++++++++++++++++ client/build/containers/AssetInfo/view.js | 50 ++---------- client/src/components/ClickToCopy/index.jsx | 37 +++++++++ client/src/containers/AssetInfo/view.jsx | 31 +------ 4 files changed, 131 insertions(+), 72 deletions(-) create mode 100644 client/build/components/ClickToCopy/index.js create mode 100644 client/src/components/ClickToCopy/index.jsx diff --git a/client/build/components/ClickToCopy/index.js b/client/build/components/ClickToCopy/index.js new file mode 100644 index 00000000..eebf6845 --- /dev/null +++ b/client/build/components/ClickToCopy/index.js @@ -0,0 +1,85 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _react = _interopRequireDefault(require("react")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } _setPrototypeOf(subClass.prototype, superClass && superClass.prototype); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) { return o.__proto__; }; return _getPrototypeOf(o); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +var ClickToCopy = +/*#__PURE__*/ +function (_React$Component) { + function ClickToCopy(props) { + var _this; + + _classCallCheck(this, ClickToCopy); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(ClickToCopy).call(this, props)); + _this.copyToClipboard = _this.copyToClipboard.bind(_assertThisInitialized(_assertThisInitialized(_this))); + return _this; + } + + _createClass(ClickToCopy, [{ + key: "copyToClipboard", + value: function copyToClipboard(event) { + console.log('event:', event); + console.log('event.target:', event.target); + console.log('event.target.id:', event.target.id); + var elementToCopy = event.target.id; + var element = document.getElementById(elementToCopy); + element.select(); + + try { + document.execCommand('copy'); + } catch (err) { + this.setState({ + error: 'Oops, unable to copy' + }); + } + } + }, { + key: "render", + value: function render() { + var _this$props = this.props, + id = _this$props.id, + value = _this$props.value; + return _react.default.createElement("input", { + id: id, + value: value, + onClick: this.copyToClipboard, + type: "text", + className: "click-to-copy", + readOnly: true, + spellCheck: "false" + }); + } + }]); + + _inherits(ClickToCopy, _React$Component); + + return ClickToCopy; +}(_react.default.Component); + +var _default = ClickToCopy; +exports.default = _default; \ No newline at end of file diff --git a/client/build/containers/AssetInfo/view.js b/client/build/containers/AssetInfo/view.js index 69e29d3e..ce21e896 100644 --- a/client/build/containers/AssetInfo/view.js +++ b/client/build/containers/AssetInfo/view.js @@ -19,6 +19,8 @@ var _SpaceBetween = _interopRequireDefault(require("@components/SpaceBetween")); var _AssetShareButtons = _interopRequireDefault(require("@components/AssetShareButtons")); +var _ClickToCopy = _interopRequireDefault(require("@components/ClickToCopy")); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -39,21 +41,6 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || functio function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -var ClickToCopy = function ClickToCopy(_ref) { - var id = _ref.id, - value = _ref.value, - copyToClipboard = _ref.copyToClipboard; - return _react.default.createElement("input", { - id: id, - value: value, - onClick: copyToClipboard, - type: "text", - className: "click-to-copy", - readOnly: true, - spellCheck: "false" - }); -}; - var AssetInfo = /*#__PURE__*/ function (_React$Component) { @@ -68,24 +55,6 @@ function (_React$Component) { } _createClass(AssetInfo, [{ - key: "copyToClipboard", - value: function copyToClipboard(event) { - console.log('event:', event); - console.log('event.target:', event.target); - console.log('event.target.id:', event.target.id); - var elementToCopy = event.target.id; - var element = document.getElementById(elementToCopy); - element.select(); - - try { - document.execCommand('copy'); - } catch (err) { - this.setState({ - error: 'Oops, unable to copy' - }); - } - } - }, { key: "render", value: function render() { var _this$props$asset = this.props.asset, @@ -122,23 +91,20 @@ function (_React$Component) { label: _react.default.createElement(_Label.default, { value: 'Link:' }), - content: _react.default.createElement(ClickToCopy, { + content: _react.default.createElement(_ClickToCopy.default, { id: 'short-link', - value: "".concat(host, "/").concat(shortId, "/").concat(name, ".").concat(fileExt), - copyToClipboard: this.copyToClipboard + value: "".concat(host, "/").concat(shortId, "/").concat(name, ".").concat(fileExt) }) })), _react.default.createElement(_Row.default, null, _react.default.createElement(_RowLabeled.default, { label: _react.default.createElement(_Label.default, { value: 'Embed:' }), - content: _react.default.createElement("div", null, contentType === 'video/mp4' ? _react.default.createElement(ClickToCopy, { + content: _react.default.createElement("div", null, contentType === 'video/mp4' ? _react.default.createElement(_ClickToCopy.default, { id: 'embed-text-video', - value: ""), - copyToClipboard: this.copyToClipboard - }) : _react.default.createElement(ClickToCopy, { + value: "") + }) : _react.default.createElement(_ClickToCopy.default, { id: 'embed-text-image', - value: ""), - copyToClipboard: this.copyToClipboard + value: "") })) })), _react.default.createElement(_Row.default, null, _react.default.createElement(_SpaceBetween.default, null, _react.default.createElement(_reactRouterDom.Link, { className: "link--primary", diff --git a/client/src/components/ClickToCopy/index.jsx b/client/src/components/ClickToCopy/index.jsx new file mode 100644 index 00000000..17068cbb --- /dev/null +++ b/client/src/components/ClickToCopy/index.jsx @@ -0,0 +1,37 @@ +import React from 'react'; + +class ClickToCopy extends React.Component { + constructor (props) { + super(props); + this.copyToClipboard = this.copyToClipboard.bind(this); + } + copyToClipboard (event) { + console.log('event:', event); + console.log('event.target:', event.target); + console.log('event.target.id:', event.target.id); + const elementToCopy = event.target.id; + const element = document.getElementById(elementToCopy); + element.select(); + try { + document.execCommand('copy'); + } catch (err) { + this.setState({error: 'Oops, unable to copy'}); + } + } + render () { + const {id, value} = this.props; + return ( + + ); + } +} + +export default ClickToCopy; diff --git a/client/src/containers/AssetInfo/view.jsx b/client/src/containers/AssetInfo/view.jsx index 9ce7d090..35971427 100644 --- a/client/src/containers/AssetInfo/view.jsx +++ b/client/src/containers/AssetInfo/view.jsx @@ -5,39 +5,13 @@ import RowLabeled from '@components/RowLabeled'; import Row from '@components/Row'; import SpaceBetween from '@components/SpaceBetween'; import AssetShareButtons from '@components/AssetShareButtons'; - -const ClickToCopy = ({id, value, copyToClipboard}) => { - return ( - - ); -}; +import ClickToCopy from '@components/ClickToCopy'; class AssetInfo extends React.Component { constructor (props) { super(props); this.copyToClipboard = this.copyToClipboard.bind(this); } - copyToClipboard (event) { - console.log('event:', event); - console.log('event.target:', event.target); - console.log('event.target.id:', event.target.id); - const elementToCopy = event.target.id; - const element = document.getElementById(elementToCopy); - element.select(); - try { - document.execCommand('copy'); - } catch (err) { - this.setState({error: 'Oops, unable to copy'}); - } - } render () { const { asset: { shortId, claimData : { channelName, certificateId, description, name, claimId, fileExt, contentType, thumbnail, host } } } = this.props; return ( @@ -81,7 +55,6 @@ class AssetInfo extends React.Component { } /> @@ -98,13 +71,11 @@ class AssetInfo extends React.Component { `} - copyToClipboard={this.copyToClipboard} /> ) : ( `} - copyToClipboard={this.copyToClipboard} /> )} From 01becd0c59c4ee95de4be6ccebb56cd477f079ca Mon Sep 17 00:00:00 2001 From: bill bittner Date: Tue, 3 Jul 2018 11:02:24 -0700 Subject: [PATCH 04/11] fixed various issues --- client/build/components/AssetShareButtons/index.js | 4 +++- client/build/components/ClickToCopy/index.js | 3 --- client/build/containers/AssetInfo/view.js | 12 ++++-------- client/src/components/AssetShareButtons/index.js | 1 + client/src/components/ClickToCopy/index.jsx | 3 --- client/src/containers/AssetInfo/view.jsx | 4 ---- 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/client/build/components/AssetShareButtons/index.js b/client/build/components/AssetShareButtons/index.js index 81d25996..8b54ec2b 100644 --- a/client/build/components/AssetShareButtons/index.js +++ b/client/build/components/AssetShareButtons/index.js @@ -7,13 +7,15 @@ exports.default = void 0; var _react = _interopRequireDefault(require("react")); +var _SpaceBetween = _interopRequireDefault(require("@components/SpaceBetween")); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var AssetShareButtons = function AssetShareButtons(_ref) { var host = _ref.host, name = _ref.name, shortId = _ref.shortId; - return _react.default.createElement(SpaceBetween, null, _react.default.createElement("a", { + return _react.default.createElement(_SpaceBetween.default, null, _react.default.createElement("a", { className: "link--primary", target: "_blank", href: "https://twitter.com/intent/tweet?text=".concat(host, "/").concat(shortId, "/").concat(name) diff --git a/client/build/components/ClickToCopy/index.js b/client/build/components/ClickToCopy/index.js index eebf6845..0c0b93e5 100644 --- a/client/build/components/ClickToCopy/index.js +++ b/client/build/components/ClickToCopy/index.js @@ -43,9 +43,6 @@ function (_React$Component) { _createClass(ClickToCopy, [{ key: "copyToClipboard", value: function copyToClipboard(event) { - console.log('event:', event); - console.log('event.target:', event.target); - console.log('event.target.id:', event.target.id); var elementToCopy = event.target.id; var element = document.getElementById(elementToCopy); element.select(); diff --git a/client/build/containers/AssetInfo/view.js b/client/build/containers/AssetInfo/view.js index ce21e896..55eefee1 100644 --- a/client/build/containers/AssetInfo/view.js +++ b/client/build/containers/AssetInfo/view.js @@ -37,21 +37,17 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } -function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) { return o.__proto__; }; return _getPrototypeOf(o); } - function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } +function _getPrototypeOf(o) { _getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) { return o.__proto__; }; return _getPrototypeOf(o); } + var AssetInfo = /*#__PURE__*/ function (_React$Component) { - function AssetInfo(props) { - var _this; - + function AssetInfo() { _classCallCheck(this, AssetInfo); - _this = _possibleConstructorReturn(this, _getPrototypeOf(AssetInfo).call(this, props)); - _this.copyToClipboard = _this.copyToClipboard.bind(_assertThisInitialized(_assertThisInitialized(_this))); - return _this; + return _possibleConstructorReturn(this, _getPrototypeOf(AssetInfo).apply(this, arguments)); } _createClass(AssetInfo, [{ diff --git a/client/src/components/AssetShareButtons/index.js b/client/src/components/AssetShareButtons/index.js index 657b14a1..dfb0c0b9 100644 --- a/client/src/components/AssetShareButtons/index.js +++ b/client/src/components/AssetShareButtons/index.js @@ -1,4 +1,5 @@ import React from 'react'; +import SpaceBetween from '@components/SpaceBetween'; const AssetShareButtons = ({ host, name, shortId }) => { return ( diff --git a/client/src/components/ClickToCopy/index.jsx b/client/src/components/ClickToCopy/index.jsx index 17068cbb..35b7dba8 100644 --- a/client/src/components/ClickToCopy/index.jsx +++ b/client/src/components/ClickToCopy/index.jsx @@ -6,9 +6,6 @@ class ClickToCopy extends React.Component { this.copyToClipboard = this.copyToClipboard.bind(this); } copyToClipboard (event) { - console.log('event:', event); - console.log('event.target:', event.target); - console.log('event.target.id:', event.target.id); const elementToCopy = event.target.id; const element = document.getElementById(elementToCopy); element.select(); diff --git a/client/src/containers/AssetInfo/view.jsx b/client/src/containers/AssetInfo/view.jsx index 35971427..e251e81d 100644 --- a/client/src/containers/AssetInfo/view.jsx +++ b/client/src/containers/AssetInfo/view.jsx @@ -8,10 +8,6 @@ import AssetShareButtons from '@components/AssetShareButtons'; import ClickToCopy from '@components/ClickToCopy'; class AssetInfo extends React.Component { - constructor (props) { - super(props); - this.copyToClipboard = this.copyToClipboard.bind(this); - } render () { const { asset: { shortId, claimData : { channelName, certificateId, description, name, claimId, fileExt, contentType, thumbnail, host } } } = this.props; return ( From 93d23a37216797780cf9e6eecf043e3e7feed3d4 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Wed, 4 Jul 2018 17:02:43 -0700 Subject: [PATCH 05/11] added check for file name in publish requests --- .../api/claim/publish/parsePublishApiRequestFiles.js | 11 ++++++++++- .../api/claim/publish/validateFileTypeAndSize.js | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/server/controllers/api/claim/publish/parsePublishApiRequestFiles.js b/server/controllers/api/claim/publish/parsePublishApiRequestFiles.js index d7b509e9..66f57be9 100644 --- a/server/controllers/api/claim/publish/parsePublishApiRequestFiles.js +++ b/server/controllers/api/claim/publish/parsePublishApiRequestFiles.js @@ -12,9 +12,18 @@ const parsePublishApiRequestFiles = ({file, thumbnail}) => { throw new Error('no file type found'); } if (!file.size) { - throw new Error('no file type found'); + throw new Error('no file size found'); } // validate the file name + if (!file.name) { + throw new Error('no file name found'); + } + if (file.name.indexOf('.') < 0) { + throw new Error('no file extension found in file name'); + } + if (file.name.indexOf('.') === 0) { + throw new Error('file name cannot start with "."'); + } if (/'/.test(file.name)) { throw new Error('apostrophes are not allowed in the file name'); } diff --git a/server/controllers/api/claim/publish/validateFileTypeAndSize.js b/server/controllers/api/claim/publish/validateFileTypeAndSize.js index ca3d4f17..1c786380 100644 --- a/server/controllers/api/claim/publish/validateFileTypeAndSize.js +++ b/server/controllers/api/claim/publish/validateFileTypeAndSize.js @@ -1,6 +1,7 @@ const logger = require('winston'); const validateFileTypeAndSize = (file) => { + logger.debug('FILE:', file); // check file type and size switch (file.type) { case 'image/jpeg': @@ -27,6 +28,7 @@ const validateFileTypeAndSize = (file) => { logger.debug('publish > file validation > unrecognized file type'); throw new Error('The ' + file.type + ' content type is not supported. Only, .jpeg, .png, .gif, and .mp4 files are currently supported.'); } + // check file name return file; }; From fd4f745dc15755802d5798118bcd83a894e2f8a3 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 6 Jul 2018 17:39:07 -0700 Subject: [PATCH 06/11] removed console log --- .../controllers/api/claim/publish/validateFileTypeAndSize.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/server/controllers/api/claim/publish/validateFileTypeAndSize.js b/server/controllers/api/claim/publish/validateFileTypeAndSize.js index 1c786380..095698e7 100644 --- a/server/controllers/api/claim/publish/validateFileTypeAndSize.js +++ b/server/controllers/api/claim/publish/validateFileTypeAndSize.js @@ -1,7 +1,6 @@ const logger = require('winston'); const validateFileTypeAndSize = (file) => { - logger.debug('FILE:', file); // check file type and size switch (file.type) { case 'image/jpeg': @@ -26,9 +25,8 @@ const validateFileTypeAndSize = (file) => { break; default: logger.debug('publish > file validation > unrecognized file type'); - throw new Error('The ' + file.type + ' content type is not supported. Only, .jpeg, .png, .gif, and .mp4 files are currently supported.'); + throw new Error('The ' + file.type + ' content type is not supported. Only, .jpg, .png, .gif, and .mp4 files are currently supported.'); } - // check file name return file; }; From 5f486e3d5014e03befc0cdc16dbe278b5259b0c5 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 6 Jul 2018 17:41:17 -0700 Subject: [PATCH 07/11] fixed content type error message for accuracy --- server/controllers/api/claim/publish/validateFileTypeAndSize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controllers/api/claim/publish/validateFileTypeAndSize.js b/server/controllers/api/claim/publish/validateFileTypeAndSize.js index 095698e7..7f9ddef4 100644 --- a/server/controllers/api/claim/publish/validateFileTypeAndSize.js +++ b/server/controllers/api/claim/publish/validateFileTypeAndSize.js @@ -25,7 +25,7 @@ const validateFileTypeAndSize = (file) => { break; default: logger.debug('publish > file validation > unrecognized file type'); - throw new Error('The ' + file.type + ' content type is not supported. Only, .jpg, .png, .gif, and .mp4 files are currently supported.'); + throw new Error('The ' + file.type + ' content type is not supported. Only, image/jpg, image/png, image/gif, and video/mp4 content types are currently supported.'); } return file; }; From 6fe04b13ce8c2209c8634268c64fb6650ee847a4 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Sat, 7 Jul 2018 15:03:21 -0700 Subject: [PATCH 08/11] removed default jpg content type and added missing content type error --- server/controllers/assets/utils/serveFile.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/controllers/assets/utils/serveFile.js b/server/controllers/assets/utils/serveFile.js index ab3c167a..7344fdb2 100644 --- a/server/controllers/assets/utils/serveFile.js +++ b/server/controllers/assets/utils/serveFile.js @@ -1,13 +1,16 @@ const logger = require('winston'); const serveFile = ({ filePath, fileType }, res) => { - logger.verbose(`serving file: ${filePath}`); + if (!fileType) { + logger.error(`no fileType provided for ${filePath}`); + } const sendFileOptions = { headers: { 'X-Content-Type-Options': 'nosniff', - 'Content-Type' : fileType || 'image/jpeg', + 'Content-Type' : fileType, }, }; + logger.debug(`fileOptions for ${filePath}:`, sendFileOptions); res.status(200).sendFile(filePath, sendFileOptions); }; From b9776da81007015bbacbb06cca7428d5c79f2f39 Mon Sep 17 00:00:00 2001 From: Electron - Mark Firth Date: Sun, 8 Jul 2018 21:14:50 +1000 Subject: [PATCH 09/11] Fix Error Message Issue Fixes the error message issue shown in the below image. --- client/scss/components/_asset-display.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/scss/components/_asset-display.scss b/client/scss/components/_asset-display.scss index 05b76c92..d7157d5f 100644 --- a/client/scss/components/_asset-display.scss +++ b/client/scss/components/_asset-display.scss @@ -1,6 +1,6 @@ .asset-display { flex: 1 0 auto; - display: flex; + display: block; justify-content: center; align-items: center; } From 7e8fddd87a29e7a8128692e2b5528ca8d7dc3004 Mon Sep 17 00:00:00 2001 From: Electron - Mark Firth Date: Mon, 9 Jul 2018 14:12:56 +1000 Subject: [PATCH 10/11] Fixes Error Message Overflowing While Keeping Alignment Fixes Error Message Overflowing While Keeping Alignment. --- client/scss/components/_asset-display.scss | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/scss/components/_asset-display.scss b/client/scss/components/_asset-display.scss index d7157d5f..6950815b 100644 --- a/client/scss/components/_asset-display.scss +++ b/client/scss/components/_asset-display.scss @@ -1,8 +1,9 @@ .asset-display { flex: 1 0 auto; - display: block; + display: flex; justify-content: center; - align-items: center; + /*align-items: center;*/ + flex-direction: column; } .asset-image, .asset-video { From 9370dc303d4f3379a7e000a42c00c1120fa2b34c Mon Sep 17 00:00:00 2001 From: bill bittner Date: Tue, 10 Jul 2018 13:07:50 -0700 Subject: [PATCH 11/11] changed embedded urls to use /asset route --- client/build/components/AssetPreview/index.js | 2 +- client/build/containers/AssetDisplay/view.js | 4 ++-- client/src/components/AssetPreview/index.jsx | 2 +- client/src/containers/AssetDisplay/view.jsx | 6 ++++-- server/views/embed.handlebars | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/client/build/components/AssetPreview/index.js b/client/build/components/AssetPreview/index.js index c17b70e3..994b75ce 100644 --- a/client/build/components/AssetPreview/index.js +++ b/client/build/components/AssetPreview/index.js @@ -19,7 +19,7 @@ var AssetPreview = function AssetPreview(_ref) { fileExt = _ref$claimData.fileExt, contentType = _ref$claimData.contentType, thumbnail = _ref$claimData.thumbnail; - var directSourceLink = "".concat(claimId, "/").concat(name, ".").concat(fileExt); + var directSourceLink = "asset/".concat(name, "/").concat(claimId); var showUrlLink = "/".concat(claimId, "/").concat(name); return _react.default.createElement(_reactRouterDom.Link, { to: showUrlLink diff --git a/client/build/containers/AssetDisplay/view.js b/client/build/containers/AssetDisplay/view.js index f034edf7..c0d1f013 100644 --- a/client/build/containers/AssetDisplay/view.js +++ b/client/build/containers/AssetDisplay/view.js @@ -82,7 +82,7 @@ function (_React$Component) { case 'image/gif': return _react.default.createElement("img", { className: "asset-image", - src: "/".concat(claimId, "/").concat(name, ".").concat(fileExt), + src: "/asset/".concat(name, "/").concat(claimId), alt: name }); @@ -92,7 +92,7 @@ function (_React$Component) { controls: true, poster: thumbnail }, _react.default.createElement("source", { - src: "/".concat(claimId, "/").concat(name, ".").concat(fileExt) + src: "/asset/".concat(name, "/").concat(claimId) }), _react.default.createElement("p", null, "Your browser does not support the ", _react.default.createElement("code", null, "video"), " element.")); default: diff --git a/client/src/components/AssetPreview/index.jsx b/client/src/components/AssetPreview/index.jsx index ae721a08..e9e10cef 100644 --- a/client/src/components/AssetPreview/index.jsx +++ b/client/src/components/AssetPreview/index.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { Link } from 'react-router-dom'; const AssetPreview = ({ defaultThumbnail, claimData: { name, claimId, fileExt, contentType, thumbnail } }) => { - const directSourceLink = `${claimId}/${name}.${fileExt}`; + const directSourceLink = `asset/${name}/${claimId}`; const showUrlLink = `/${claimId}/${name}`; return ( diff --git a/client/src/containers/AssetDisplay/view.jsx b/client/src/containers/AssetDisplay/view.jsx index 277a4980..c742c851 100644 --- a/client/src/containers/AssetDisplay/view.jsx +++ b/client/src/containers/AssetDisplay/view.jsx @@ -39,7 +39,7 @@ class AssetDisplay extends React.Component { return ( {name} ); @@ -49,7 +49,9 @@ class AssetDisplay extends React.Component { className='asset-video' controls poster={thumbnail} > - +

Your browser does not support the video element.

); diff --git a/server/views/embed.handlebars b/server/views/embed.handlebars index eb6c4839..c0b2e4f5 100644 --- a/server/views/embed.handlebars +++ b/server/views/embed.handlebars @@ -1 +1 @@ - +