Skip to content

Commit

Permalink
Merge 38f8984 into c797f2d
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanshaikley committed Nov 21, 2016
2 parents c797f2d + 38f8984 commit 3a4e531
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
20 changes: 9 additions & 11 deletions api/routes/atom-routes.js
Expand Up @@ -78,8 +78,7 @@ export function createAtom(req, res) {
})
.then(function() {
if (type !== 'jupyter' || !req.body.versionContent) { return undefined; }
// return Request.post('http://jupyter-dd419b35.e87eb116.svc.dockerapp.io/convert', { });
return request.post('http://jupyter-dd419b35.e87eb116.svc.dockerapp.io/convert').send({form: { url: req.body.versionContent.url } });
return request.post('http://jupyter-dd419b35.e87eb116.svc.dockerapp.io/convert').send({ url: req.body.versionContent.url, type: 'jupyter' });
})
.then(function(response) {
if (type !== 'jupyter' || !req.body.versionContent) { return undefined; }
Expand Down Expand Up @@ -853,8 +852,8 @@ export function deleteContributor(req, res) {
}
app.post('/deleteContributor', deleteContributor);

// Saves a docx content as the new version content of an Atom
export function uploadDocx(req, res) {
// Saves docx or PDF content as the new version content of an Atom
export function upload(req, res) {
if (!req.user) {
return res.status(403).json('Not Logged In');
}
Expand All @@ -873,17 +872,16 @@ export function uploadDocx(req, res) {

let versionID;
// This should be made more intelligent to use images, video thumbnails, etc when possible - if the atom type is image, video, etc.

request.post(process.env.CONVERT_SERVER_URL + '/convertDocx')
.send({form: { url: req.body.url } })
request.post(process.env.CONVERT_SERVER_URL + '/convert')
.send({ url: req.body.url, type: type })
.then(function(versionContent) {
const tasks = [
// Link.createLink('author', userID, newAtomID, userID, now),
];

const newVersion = new Version({
type: 'markdown',
message: 'Imported docx',
message: 'Imported ' + type,
parent: atomID,
content: JSON.parse(versionContent.text),
isPublished: false,
Expand All @@ -896,7 +894,6 @@ export function uploadDocx(req, res) {
tasks.push(newVersion.save());

const informJake = new Promise(function(resolve, reject) {
console.log("INFORMING JAKE")
const collabUrl = process.env.COLLAB_SERVER_URL.indexOf('localhost') !== -1
? 'http://' + process.env.COLLAB_SERVER_URL
: 'https://' + process.env.COLLAB_SERVER_URL;
Expand All @@ -907,7 +904,7 @@ export function uploadDocx(req, res) {
.send({ document_id: atomID, contents: JSON.stringify(JSON.parse(versionContent.text).docJSON) })
.then(function() {
resolve();
}).catch((err) => { console.log("Aaah " + err); reject(err); })
}).catch((err) => { console.log(err); reject(err); })
});

tasks.push(informJake);
Expand Down Expand Up @@ -939,4 +936,5 @@ export function uploadDocx(req, res) {
return res.status(500).json(error);
});
}
app.post('/uploadDocx', uploadDocx);

app.post('/upload', upload);
3 changes: 1 addition & 2 deletions api/routes/version-routes.js
Expand Up @@ -34,8 +34,7 @@ export function saveVersion(req, res) {

const checkAndSaveJupyter = new Promise(function(resolve) {
if (newVersion.type === 'jupyter') {
// const query = Request.post('http://jupyter-dd419b35.e87eb116.svc.dockerapp.io/convert', {form: { url: req.body.newVersion.content.url } });
const query = request.post('http://jupyter-dd419b35.e87eb116.svc.dockerapp.io/convert').send({form: { url: req.body.versionContent.url } });
const query = request.post('http://jupyter-dd419b35.e87eb116.svc.dockerapp.io/convert').send({ url: req.body.versionContent.url, type: 'jupyter' });
resolve(query);
} else {
resolve();
Expand Down
13 changes: 8 additions & 5 deletions translations/languages/en.json
Expand Up @@ -57,8 +57,8 @@
"tableEditor.HeaderRow": "Header Row",
"notFound.pageDoesntExist": "Doh - That page does not seem to exist!",
"notFound.PerhapsLogin": "Perhaps you need to Login to access this page. Click to Login",
"previewEditor.SetToInsert": "Set To Insert",
"pub.AddComment": "Add Comment",
"previewEditor.SetToInsert": "Insert",
"pub.AddComment": "Add Discussion",
"footer.about": "About",
"footer.code": "Code",
"footer.Feedback": "Feedback",
Expand Down Expand Up @@ -161,12 +161,16 @@
"JournalProfileCollections.Description": "Collections let you organize the pubs featured by this journal. Add pubs to collections on the {featured} page.",
"JournalProfileDetails.Description": "Used as the Journal's preview image in search results and throughout the site.",
"JournalProfileDetails.Description2": "Use to describe longer details, peer-review process, featuring standards, etc. This text will appear at pubpub.org/{slug}/about.",
"journalProfileFeatured.SearchForPubToFeature": "Search for Pub to Feature",
"journalProfileFeatured.FeaturePub": "Feature Pub",
"JournalProfileFeatured.AddToCollections": "Add to collections",
"login.ForgotPassword": "Forgot Password?",
"login.newToPubPub": "New to PubPub? Click to Sign Up!",
"manage.YourCommunityP1": "Click or Drag files to add",
"manage.createImage": "Create Image",
"manage.createReference": "Create Reference",
"manage.createLatex": "Create LaTeX",
"manage.InsertImage": "Insert Image",
"manage.InsertReference": "Insert Reference",
"managesingle.YourCommunityP1": "Click or Drag files to add",
"resetPassword.Success": "Password Reset successful!",
"resetPassword.ClickToLogin": "Click to Login",
"resetPassword.NewPassword": "New Password",
Expand Down Expand Up @@ -369,7 +373,6 @@
"global.Email": "Email",
"global.Password": "Password",
"global.PasswordReset": "Password Reset",
"global.ResetPassword": "Reset Password",
"global.Explore": "Explore",
"global.draftVersion": "Draft Version",
"global.abstract": "abstract",
Expand Down

0 comments on commit 3a4e531

Please sign in to comment.