Support configurable images in wordcount end point

This commit is contained in:
James Allen
2016-01-19 14:12:41 +00:00
parent 4497352a3a
commit 86cf05c732
4 changed files with 13 additions and 9 deletions

View File

@@ -70,8 +70,10 @@ module.exports = CompileController =
wordcount: (req, res, next = (error) ->) ->
file = req.query.file || "main.tex"
project_id = req.params.project_id
image = req.query.image
logger.log {image, file, project_id}, "word count request"
CompileManager.wordcount project_id, file, (error, result) ->
CompileManager.wordcount project_id, file, image, (error, result) ->
return next(error) if error?
res.send JSON.stringify {
texcount: result

View File

@@ -112,14 +112,14 @@ module.exports = CompileManager =
}
return results
wordcount: (project_id, file_name, callback = (error, pdfPositions) ->) ->
logger.log project_id:project_id, file_name:file_name, "running wordcount"
wordcount: (project_id, file_name, image, callback = (error, pdfPositions) ->) ->
logger.log project_id:project_id, file_name:file_name, image:image, "running wordcount"
file_path = "$COMPILE_DIR/" + file_name
command = [ "texcount", '-inc', file_path, "-out=" + file_path + ".wc"]
directory = Path.join(Settings.path.compilesDir, project_id)
timeout = 10 * 1000
CommandRunner.run project_id, command, directory, timeout, (error) ->
CommandRunner.run project_id, command, directory, image, timeout, (error) ->
return callback(error) if error?
try
stdout = fs.readFileSync(directory + "/" + file_name + ".wc", "utf-8")