add csv, don't include s3 js/css/json/txt/csv files as blobs
This commit is contained in:
parent
1d7aaa9981
commit
99df998e11
3 changed files with 7 additions and 5 deletions
|
@ -24,7 +24,7 @@ class FileUploader extends React.Component {
|
||||||
thumbnailWidth: 200,
|
thumbnailWidth: 200,
|
||||||
thumbnailHeight: 200,
|
thumbnailHeight: 200,
|
||||||
// TODO what is a good list of MIME types????
|
// TODO what is a good list of MIME types????
|
||||||
acceptedFiles: 'image/*,audio/*,text/javascript,text/html,text/css,application/json,application/x-font-ttf,application/x-font-truetype,text/plain',
|
acceptedFiles: 'image/*,audio/*,text/javascript,text/html,text/css,application/json,application/x-font-ttf,application/x-font-truetype,text/plain,text/csv',
|
||||||
dictDefaultMessage: 'Drop files here to upload or click to use the file browser',
|
dictDefaultMessage: 'Drop files here to upload or click to use the file browser',
|
||||||
accept: this.props.dropzoneAcceptCallback,
|
accept: this.props.dropzoneAcceptCallback,
|
||||||
sending: this.props.dropzoneSendingCallback,
|
sending: this.props.dropzoneSendingCallback,
|
||||||
|
|
|
@ -51,8 +51,8 @@ function validate(formProps) {
|
||||||
|
|
||||||
if (!formProps.name) {
|
if (!formProps.name) {
|
||||||
errors.name = 'Please enter a name';
|
errors.name = 'Please enter a name';
|
||||||
} else if (!formProps.name.match(/(.+\.js$|.+\.css$|.+\.json$|.+\.txt$)/i)) {
|
} else if (!formProps.name.match(/(.+\.js$|.+\.css$|.+\.json$|.+\.txt$|.+\.csv$)/i)) {
|
||||||
errors.name = 'File must be of type JavaScript, CSS, JSON, or TXT.';
|
errors.name = 'File must be of type JavaScript, CSS, JSON, TXT, or CSV.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
|
|
|
@ -167,19 +167,21 @@ class PreviewFrame extends React.Component {
|
||||||
|
|
||||||
htmlFile = hijackConsoleLogsScript() + htmlFile;
|
htmlFile = hijackConsoleLogsScript() + htmlFile;
|
||||||
const mediaFiles = this.props.files.filter(file => file.url);
|
const mediaFiles = this.props.files.filter(file => file.url);
|
||||||
const textFiles = this.props.files.filter(file => file.name.match(/(.+\.json$|.+\.txt$)/i));
|
const textFiles = this.props.files.filter(file => file.name.match(/(.+\.json$|.+\.txt$|.+\.csv$)/i) && file.url === undefined);
|
||||||
|
console.log(textFiles);
|
||||||
|
|
||||||
const jsFiles = [];
|
const jsFiles = [];
|
||||||
this.props.jsFiles.forEach(jsFile => {
|
this.props.jsFiles.forEach(jsFile => {
|
||||||
const newJSFile = { ...jsFile };
|
const newJSFile = { ...jsFile };
|
||||||
let jsFileStrings = newJSFile.content.match(/(['"])((\\\1|.)*?)\1/gm);
|
let jsFileStrings = newJSFile.content.match(/(['"])((\\\1|.)*?)\1/gm);
|
||||||
const jsFileRegex = /^('|")(?!(http:\/\/|https:\/\/)).*\.(png|jpg|jpeg|gif|bmp|mp3|wav|aiff|ogg|json|txt)('|")$/i;
|
const jsFileRegex = /^('|")(?!(http:\/\/|https:\/\/)).*\.(png|jpg|jpeg|gif|bmp|mp3|wav|aiff|ogg|json|txt|csv)('|")$/i;
|
||||||
jsFileStrings = jsFileStrings || [];
|
jsFileStrings = jsFileStrings || [];
|
||||||
jsFileStrings.forEach(jsFileString => {
|
jsFileStrings.forEach(jsFileString => {
|
||||||
if (jsFileString.match(jsFileRegex)) {
|
if (jsFileString.match(jsFileRegex)) {
|
||||||
const filePath = jsFileString.substr(1, jsFileString.length - 2);
|
const filePath = jsFileString.substr(1, jsFileString.length - 2);
|
||||||
const filePathArray = filePath.split('/');
|
const filePathArray = filePath.split('/');
|
||||||
const fileName = filePathArray[filePathArray.length - 1];
|
const fileName = filePathArray[filePathArray.length - 1];
|
||||||
|
console.log(fileName);
|
||||||
mediaFiles.forEach(file => {
|
mediaFiles.forEach(file => {
|
||||||
if (file.name === fileName) {
|
if (file.name === fileName) {
|
||||||
newJSFile.content = newJSFile.content.replace(filePath, file.url); // eslint-disable-line
|
newJSFile.content = newJSFile.content.replace(filePath, file.url); // eslint-disable-line
|
||||||
|
|
Loading…
Reference in a new issue