mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
add wordcount clsi handler
This commit is contained in:
parent
662050b3f9
commit
77c2162872
4 changed files with 25 additions and 1 deletions
|
@ -106,3 +106,15 @@ module.exports = ClsiManager =
|
|||
resources: resources
|
||||
}
|
||||
|
||||
wordCount: (project_id, options, callback = (error, response) ->) ->
|
||||
compilerUrl = @_getCompilerUrl(options?.compileGroup)
|
||||
request.get {
|
||||
url: "#{compilerUrl}/project/#{project_id}/wordcount"
|
||||
}, (error, response, body) ->
|
||||
return callback(error) if error?
|
||||
if 200 <= response.statusCode < 300
|
||||
callback null, body
|
||||
else
|
||||
error = new Error("CLSI returned non-success code: #{response.statusCode}")
|
||||
logger.error err: error, project_id: project_id, "CLSI returned failure code"
|
||||
callback error, body
|
||||
|
|
|
@ -102,3 +102,10 @@ module.exports = CompileController =
|
|||
proxy.pipe(res)
|
||||
proxy.on "error", (error) ->
|
||||
logger.warn err: error, url: url, "CLSI proxy error"
|
||||
|
||||
wordCount: (req, res, next) ->
|
||||
project_id = req.params.Project_id
|
||||
CompileManager.wordCount project_id, (error, body) ->
|
||||
return next(error) if error?
|
||||
res.contentType("application/json")
|
||||
res.send 200, body
|
||||
|
|
|
@ -91,3 +91,7 @@ module.exports = CompileManager =
|
|||
else
|
||||
ProjectRootDocManager.setRootDocAutomatically project_id, callback
|
||||
|
||||
wordCount: (project_id, callback = (error) ->) ->
|
||||
CompileManager.getProjectCompileLimits project_id, (error, limits) ->
|
||||
return callback(error) if error?
|
||||
ClsiManager.wordCount project_id, limits, callback
|
||||
|
|
|
@ -111,6 +111,7 @@ module.exports = class Router
|
|||
webRouter.delete "/project/:Project_id/output", SecurityManager.requestCanAccessProject, CompileController.deleteAuxFiles
|
||||
webRouter.get "/project/:Project_id/sync/code", SecurityManager.requestCanAccessProject, CompileController.proxySync
|
||||
webRouter.get "/project/:Project_id/sync/pdf", SecurityManager.requestCanAccessProject, CompileController.proxySync
|
||||
webRouter.get "/project/:Project_id/wordcount", SecurityManager.requestCanAccessProject, CompileController.wordCount
|
||||
|
||||
webRouter.delete '/Project/:Project_id', SecurityManager.requestIsOwner, ProjectController.deleteProject
|
||||
webRouter.post '/Project/:Project_id/restore', SecurityManager.requestIsOwner, ProjectController.restoreProject
|
||||
|
|
Loading…
Reference in a new issue