Skip to content
Snippets Groups Projects
Commit d22e74f0 authored by Nikos Marinos's avatar Nikos Marinos
Browse files

work with Koosum

parent 13dcdd67
No related branches found
No related tags found
2 merge requests!93Shared data model,!94Dev
......@@ -25,6 +25,7 @@ const path = require('path')
const { exec } = require('child_process')
const config = require('config')
const rfr = require('rfr')
const xsweetConverter = rfr('server/xsweet-conversion')
const { bulkUploaderEmail } = rfr('server/email')
// global.globalPath = ''
......@@ -164,25 +165,26 @@ function runProcess(packagePath) {
createTempDir().then(tmpPath =>
extractFiles(packagePath, tmpPath).then(tmpPath =>
parseManifest(tmpPath, packageName, submitter).then(parsedInfo =>
parseXml(parsedInfo.metaXml).then(xmlObj =>
convertFromInk(pubsweetServer, parsedInfo, token).then(
async convertedManuscript => {
const manuscriptDb = await createManuscript(
pubsweetServer,
xmlObj,
parsedInfo,
convertedManuscript,
tmpPath,
submitter,
packageName,
error => {
logger.error(error)
tidyUp(packagePath, tmpPath, null, true)
},
)
tidyUp(packagePath, tmpPath, manuscriptDb)
},
),
parseXml(parsedInfo.metaXml).then(
async xmlObj => {
// convertFromInk(pubsweetServer, parsedInfo, token).then(
// async convertedManuscript => {
const manuscriptDb = await createManuscript(
pubsweetServer,
xmlObj,
parsedInfo,
// convertedManuscript,
tmpPath,
submitter,
packageName,
error => {
logger.error(error)
tidyUp(packagePath, tmpPath, null, true)
},
)
tidyUp(packagePath, tmpPath, manuscriptDb)
},
// ),
),
),
),
......@@ -518,7 +520,7 @@ async function createManuscript(
pubsweetServer,
xmlObj,
parsedInfo,
htmlManuscript,
// htmlManuscript,
tmpPath,
submitter,
packageName,
......@@ -639,6 +641,7 @@ async function createManuscript(
)
}
/*
if (htmlManuscript) {
const fileURI = `${tmpPath}/preview.html`
promises.push(
......@@ -664,6 +667,7 @@ async function createManuscript(
}),
)
}
*/
let manuscriptdb
await Promise.all(promises)
......@@ -679,6 +683,14 @@ async function createManuscript(
submitter.userId,
'submitter',
)
const files = parsedInfo.files
const manuscriptFileURI = files.filter(
tmp => tmp.type === 'manuscript',
)[0].fileURI
await xsweetConverter.xsweetConvert(manuscriptFileURI, manuscriptdb.id)
const input = {
id: manuscriptdb.id,
status: 'submitted',
......@@ -689,6 +701,7 @@ async function createManuscript(
return manuscriptdb
}
/*
function convertFromInk(pubsweetServer, parsedInfo, token) {
const manuscript = parsedInfo.files.find(file => file.type === 'manuscript')
if (manuscript && manuscript.filename.endsWith('.docx')) {
......@@ -718,6 +731,7 @@ function convertFromInk(pubsweetServer, parsedInfo, token) {
resolve(null)
})
}
*/
function validateEmail(email) {
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
......
......@@ -12,19 +12,20 @@ const db = require('../utils/db.js')
// '/home/yogmatee/projects/xmlValidation_files/xweet_files/tiana.docx'
/*
xsweetConvert(
'/home/yogmatee/projects/xmlValidation_files/xweet_files/tiana.docx',
'EMS90002',
)
*/
function xsweetConvert(fileUrl, manuscriptId) {
module.exports.xsweetConvert = function xsweetConvert(fileUrl, manuscriptId) {
const options = {
method: 'POST',
uri: 'http://localhost:3000/convertDocxToHTML',
formData: {
docx: fs.createReadStream(
'/home/yogmatee/projects/xmlValidation_files/xweet_files/tiana.docx',
),
docx: fs.createReadStream(fileUrl),
},
headers: {
/* 'content-type': 'multipart/form-data' */
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment