change http urls to https

This commit is contained in:
catarak 2016-09-08 22:02:42 -04:00
parent 0e0d3975e1
commit b004fd077f
2 changed files with 56 additions and 36 deletions

View file

@ -3,6 +3,7 @@ import { createFile } from './files';
const textFileRegex = /text\//;
const s3Bucket = `http://${process.env.S3_BUCKET}.s3.amazonaws.com/`;
const s3BucketHttps = `https://s3-us-west-2.amazonaws.com/${process.env.S3_BUCKET}/`;
const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api';
function localIntercept(file, options = {}) {
@ -94,22 +95,22 @@ export function dropzoneCompleteCallback(file) {
url: `${s3Bucket}${file.postData.key}`,
originalFilename: file.name
};
console.log(json, JSON.stringify(json), JSON.stringify(json).replace('"', '\\"'));
// console.log(json, JSON.stringify(json), JSON.stringify(json).replace('"', '\\"'));
inputHidden += `${window.btoa(JSON.stringify(json))}" />`;
// document.getElementById('uploader').appendChild(inputHidden);
document.getElementById('uploader').innerHTML += inputHidden;
const formParams = {
name: file.name,
url: `${s3Bucket}${file.postData.key}`
url: `${s3BucketHttps}${file.postData.key}`
};
console.log(formParams);
createFile(formParams)(dispatch, getState);
} else {
const formParams = {
name: file.name,
content: file.content
};
console.log(formParams);
createFile(formParams)(dispatch, getState);
}
};

View file

@ -8,41 +8,41 @@ mongoose.connection.on('error', () => {
import Project from '../models/project';
let projectsNotToUpdate;
Project.find({'files.name': 'root'})
.exec((err, projects) => {
projectsNotToUpdate = projects.map(project => project.id);
console.log(projectsNotToUpdate);
// let projectsNotToUpdate;
// Project.find({'files.name': 'root'})
// .exec((err, projects) => {
// projectsNotToUpdate = projects.map(project => project.id);
// console.log(projectsNotToUpdate);
Project.find({})
.exec((err, projects) => {
projects.forEach( (project, projectIndex) => {
if (!projectsNotToUpdate.find(projectId => projectId === project.id)) {
const childIdArray = project.files.map(file => file._id.valueOf());
const newId = new ObjectId();
project.files.push({
name: 'root',
_id: newId,
id: newId,
fileType: 'folder',
children: childIdArray,
content: ''
});
// Project.find({})
// .exec((err, projects) => {
// projects.forEach( (project, projectIndex) => {
// if (!projectsNotToUpdate.find(projectId => projectId === project.id)) {
// const childIdArray = project.files.map(file => file._id.valueOf());
// const newId = new ObjectId();
// project.files.push({
// name: 'root',
// _id: newId,
// id: newId,
// fileType: 'folder',
// children: childIdArray,
// content: ''
// });
project.files = project.files.map(file => {
if (file.name === "sketch.js") {
file.isSelected = true;
return file;
}
return file;
});
project.save((err, savedProject) => {
console.log('project', projectIndex, 'is saved.');
});
}
});
});
});
// project.files = project.files.map(file => {
// if (file.name === "sketch.js") {
// file.isSelected = true;
// return file;
// }
// return file;
// });
// project.save((err, savedProject) => {
// console.log('project', projectIndex, 'is saved.');
// });
// }
// });
// });
// });
// Project.find({'files.name': 'root'})
// .exec((err, projects) => {
@ -64,5 +64,24 @@ Project.find({'files.name': 'root'})
// });
// });
const s3Bucket = `http://p5.js-webeditor.s3.amazonaws.com/`;
const s3BucketHttps = `https://s3-us-west-2.amazonaws.com/p5.js-webeditor/`;
Project.find({})
.exec((err, projects) => {
projects.forEach((project, projectIndex) => {
project.files.forEach((file) => {
if (file.url) {
file.url = file.url.replace(s3Bucket, s3BucketHttps);
console.log('Updating', file.name);
console.log(file.url);
}
});
project.save((err, savedProject) => {
console.log('project', projectIndex, 'is saved.');
});
});
});