Sfoglia il codice sorgente

add worcount file param

Henrique Dias 11 anni fa
parent
commit
d228fd88ab

+ 15 - 12
services/web/app/coffee/Features/Compile/ClsiManager.coffee

@@ -106,15 +106,18 @@ module.exports = ClsiManager =
 								resources: resources
 								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
+

+ 2 - 1
services/web/app/coffee/Features/Compile/CompileController.coffee

@@ -105,7 +105,8 @@ module.exports = CompileController =
 
 
 	wordCount: (req, res, next) ->
 	wordCount: (req, res, next) ->
 		project_id = req.params.Project_id
 		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?
 			return next(error) if error?
 			res.contentType("application/json")
 			res.contentType("application/json")
 			res.send 200, body
 			res.send 200, body

+ 2 - 2
services/web/app/coffee/Features/Compile/CompileManager.coffee

@@ -91,7 +91,7 @@ module.exports = CompileManager =
 			else
 			else
 				ProjectRootDocManager.setRootDocAutomatically project_id, callback
 				ProjectRootDocManager.setRootDocAutomatically project_id, callback
 		
 		
-	wordCount: (project_id, callback = (error) ->) ->
+	wordCount: (project_id, file, callback = (error) ->) ->
 		CompileManager.getProjectCompileLimits project_id, (error, limits) ->
 		CompileManager.getProjectCompileLimits project_id, (error, limits) ->
 			return callback(error) if error?
 			return callback(error) if error?
-			ClsiManager.wordCount project_id, limits, callback
+			ClsiManager.wordCount project_id, file, limits, callback