mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-06 15:49:01 +02:00
add worcount file param
This commit is contained in:
@@ -106,15 +106,18 @@ 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
|
||||
wordCount: (project_id, file, options, callback = (error, response) ->) ->
|
||||
ClsiManager._buildRequest project_id, options, (error, req) ->
|
||||
compilerUrl = ClsiManager._getCompilerUrl(options?.compileGroup)
|
||||
filename = file || req.compile.rootResourcePath
|
||||
request.get {
|
||||
url: "#{compilerUrl}/project/#{project_id}/wordcount?file=#{filename}"
|
||||
}, (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
|
||||
|
||||
|
||||
@@ -105,7 +105,8 @@ module.exports = CompileController =
|
||||
|
||||
wordCount: (req, res, next) ->
|
||||
project_id = req.params.Project_id
|
||||
CompileManager.wordCount project_id, (error, body) ->
|
||||
file = req.query.file || false
|
||||
CompileManager.wordCount project_id, file, (error, body) ->
|
||||
return next(error) if error?
|
||||
res.contentType("application/json")
|
||||
res.send 200, body
|
||||
|
||||
@@ -91,7 +91,7 @@ module.exports = CompileManager =
|
||||
else
|
||||
ProjectRootDocManager.setRootDocAutomatically project_id, callback
|
||||
|
||||
wordCount: (project_id, callback = (error) ->) ->
|
||||
wordCount: (project_id, file, callback = (error) ->) ->
|
||||
CompileManager.getProjectCompileLimits project_id, (error, limits) ->
|
||||
return callback(error) if error?
|
||||
ClsiManager.wordCount project_id, limits, callback
|
||||
ClsiManager.wordCount project_id, file, limits, callback
|
||||
|
||||
Reference in New Issue
Block a user