1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 01:25:17 +01:00

use safe urls for thumbnails and links

This commit is contained in:
Tim Daubenschütz 2015-07-01 10:00:53 +02:00
parent 929c694ad7
commit 1db9921dd8
5 changed files with 21 additions and 9 deletions

View File

@ -57,7 +57,7 @@ let FileDragAndDropPreview = React.createClass({
url={this.props.file.url} url={this.props.file.url}
toggleUploadProcess={this.toggleUploadProcess} toggleUploadProcess={this.toggleUploadProcess}
areAssetsDownloadable={this.props.areAssetsDownloadable} areAssetsDownloadable={this.props.areAssetsDownloadable}
downloadFile={this.handleDownloadFile}/>); downloadUrl={this.props.file.s3UrlSafe}/>);
} else { } else {
previewElement = (<FileDragAndDropPreviewOther previewElement = (<FileDragAndDropPreviewOther
onClick={this.handleDeleteFile} onClick={this.handleDeleteFile}
@ -65,7 +65,7 @@ let FileDragAndDropPreview = React.createClass({
type={this.props.file.type.split('/')[1]} type={this.props.file.type.split('/')[1]}
toggleUploadProcess={this.toggleUploadProcess} toggleUploadProcess={this.toggleUploadProcess}
areAssetsDownloadable={this.props.areAssetsDownloadable} areAssetsDownloadable={this.props.areAssetsDownloadable}
downloadFile={this.handleDownloadFile}/>); downloadUrl={this.props.file.s3UrlSafe}/>);
} }
return ( return (

View File

@ -10,7 +10,7 @@ let FileDragAndDropPreviewImage = React.createClass({
progress: React.PropTypes.number, progress: React.PropTypes.number,
url: React.PropTypes.string, url: React.PropTypes.string,
toggleUploadProcess: React.PropTypes.func, toggleUploadProcess: React.PropTypes.func,
downloadFile: React.PropTypes.func, downloadUrl: React.PropTypes.string,
areAssetsDownloadable: React.PropTypes.bool areAssetsDownloadable: React.PropTypes.bool
}, },
@ -48,7 +48,7 @@ let FileDragAndDropPreviewImage = React.createClass({
// only if assets are actually downloadable, there should be a download icon if the process is already at // only if assets are actually downloadable, there should be a download icon if the process is already at
// 100%. If not, no actionSymbol should be displayed // 100%. If not, no actionSymbol should be displayed
if(this.props.areAssetsDownloadable) { if(this.props.areAssetsDownloadable) {
actionSymbol = <span className="glyphicon glyphicon-download action-file" aria-hidden="true" title="Download file" onClick={this.props.downloadFile}/>; actionSymbol = <a href={this.props.downloadUrl} target="_blank" className="glyphicon glyphicon-download action-file" aria-hidden="true" title="Download file"/>;
} }
} else { } else {

View File

@ -11,7 +11,7 @@ let FileDragAndDropPreviewOther = React.createClass({
progress: React.PropTypes.number, progress: React.PropTypes.number,
areAssetsDownloadable: React.PropTypes.bool, areAssetsDownloadable: React.PropTypes.bool,
toggleUploadProcess: React.PropTypes.func, toggleUploadProcess: React.PropTypes.func,
downloadFile: React.PropTypes.func downloadUrl: React.PropTypes.string
}, },
getInitialState() { getInitialState() {
@ -44,7 +44,7 @@ let FileDragAndDropPreviewOther = React.createClass({
// only if assets are actually downloadable, there should be a download icon if the process is already at // only if assets are actually downloadable, there should be a download icon if the process is already at
// 100%. If not, no actionSymbol should be displayed // 100%. If not, no actionSymbol should be displayed
if(this.props.areAssetsDownloadable) { if(this.props.areAssetsDownloadable) {
actionSymbol = <span className="glyphicon glyphicon-download action-file" aria-hidden="true" title="Download file" onClick={this.props.downloadFile}/>; actionSymbol = <a href={this.props.downloadUrl} target="_blank" className="glyphicon glyphicon-download action-file" aria-hidden="true" title="Download file"/>;
} }
} else { } else {

View File

@ -276,6 +276,11 @@ var ReactS3FineUploader = React.createClass({
return res.json(); return res.json();
}) })
.then((res) =>{ .then((res) =>{
if(res.otherdata) {
file.s3Url = res.otherdata.url_safe;
} else {
throw new Error('Could not find a url to download.');
}
defer.success(res.key); defer.success(res.key);
}) })
.catch((err) => { .catch((err) => {
@ -327,7 +332,7 @@ var ReactS3FineUploader = React.createClass({
if(success) { if(success) {
// fetch blobs for images // fetch blobs for images
response = response.map((file) => { response = response.map((file) => {
file.url = file.s3Url; file.url = file.s3UrlSafe;
file.status = 'online'; file.status = 'online';
file.progress = 100; file.progress = 100;
return file; return file;
@ -390,7 +395,7 @@ var ReactS3FineUploader = React.createClass({
} else { } else {
let fileToDelete = this.state.filesToUpload[fileId]; let fileToDelete = this.state.filesToUpload[fileId];
fileToDelete.status = 'deleted'; fileToDelete.status = 'deleted';
console.log(this.state.uploader.getUploads());
S3Fetcher S3Fetcher
.deleteFile(fileToDelete.s3Key, fileToDelete.s3Bucket) .deleteFile(fileToDelete.s3Key, fileToDelete.s3Bucket)
.then(() => this.onDeleteComplete(fileToDelete.id, null, false)) .then(() => this.onDeleteComplete(fileToDelete.id, null, false))
@ -420,7 +425,6 @@ var ReactS3FineUploader = React.createClass({
}, },
handleUploadFile(files) { handleUploadFile(files) {
console.log(this.state.files);
// If multiple set and user already uploaded its work, // If multiple set and user already uploaded its work,
// cancel upload // cancel upload
if(!this.props.multiple && this.state.filesToUpload.filter((file) => file.status !== 'deleted' && file.status !== 'canceled').length > 0) { if(!this.props.multiple && this.state.filesToUpload.filter((file) => file.status !== 'deleted' && file.status !== 'canceled').length > 0) {

View File

@ -97,6 +97,10 @@
text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black; text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
cursor: pointer; cursor: pointer;
&:link, &:visited, &:hover, &:active {
text-decoration: none;
}
&:hover { &:hover {
color: #d9534f; color: #d9534f;
} }
@ -111,6 +115,10 @@
text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black; text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
cursor: pointer; cursor: pointer;
&:link, &:visited, &:hover, &:active {
text-decoration: none;
}
&:hover { &:hover {
color: #d9534f; color: #d9534f;
} }