diff --git a/services/web/app/coffee/Features/Compile/CompileController.coffee b/services/web/app/coffee/Features/Compile/CompileController.coffee index 89fbc87e2e..a273d38a35 100755 --- a/services/web/app/coffee/Features/Compile/CompileController.coffee +++ b/services/web/app/coffee/Features/Compile/CompileController.coffee @@ -93,7 +93,12 @@ module.exports = CompileController = getFileFromClsi: (req, res, next = (error) ->) -> project_id = req.params.Project_id - CompileController.proxyToClsi(project_id, "/project/#{project_id}/output/#{req.params.file}", req, res, next) + build = req.params.build + if build? + url = "/project/#{project_id}/build/#{build}/output/#{req.params.file}" + else + url = "/project/#{project_id}/output/#{req.params.file}" + CompileController.proxyToClsi(project_id, url, req, res, next) proxySync: (req, res, next = (error) ->) -> CompileController.proxyToClsi(req.params.Project_id, req.url, req, res, next) diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index 854e852493..709b2541e1 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -113,6 +113,17 @@ module.exports = class Router req.params = params next() ), AuthorizationMiddlewear.ensureUserCanReadProject, CompileController.getFileFromClsi + # direct url access to output files for a specific build (query string not required) + webRouter.get /^\/project\/([^\/]*)\/build\/([0-9a-f-]+)\/output\/(.*)$/, + ((req, res, next) -> + params = + "Project_id": req.params[0] + "build": req.params[1] + "file": req.params[2] + req.params = params + next() + ), AuthorizationMiddlewear.ensureUserCanReadProject, CompileController.getFileFromClsi + webRouter.delete "/project/:Project_id/output", AuthorizationMiddlewear.ensureUserCanReadProject, CompileController.deleteAuxFiles webRouter.get "/project/:Project_id/sync/code", AuthorizationMiddlewear.ensureUserCanReadProject, CompileController.proxySync webRouter.get "/project/:Project_id/sync/pdf", AuthorizationMiddlewear.ensureUserCanReadProject, CompileController.proxySync diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index 8a244495c6..0eab163e99 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -69,20 +69,28 @@ define [ else if response.status == "success" $scope.pdf.view = 'pdf' $scope.shouldShowLogs = false - # define the base url - $scope.pdf.url = "/project/#{$scope.project_id}/output/output.pdf?cache_bust=#{Date.now()}" - # add a query string parameter for the compile group - if response.compileGroup? - $scope.pdf.compileGroup = response.compileGroup - $scope.pdf.url = $scope.pdf.url + "&compileGroup=#{$scope.pdf.compileGroup}" # make a cache to look up files by name fileByPath = {} for file in response.outputFiles fileByPath[file.path] = file - # if the pdf file has a build number, pass it to the clsi + # prepare query string + qs = {} + # define the base url. if the pdf file has a build number, pass it to the clsi in the url if fileByPath['output.pdf']?.build? build = fileByPath['output.pdf'].build - $scope.pdf.url = $scope.pdf.url + "&build=#{build}" + $scope.pdf.url = "/project/#{$scope.project_id}/build/#{build}/output/output.pdf" + # no need to bust cache, build id is unique + else + $scope.pdf.url = "/project/#{$scope.project_id}/output/output.pdf" + qs = { cache_bust : "#{Date.now()}" } + # add a query string parameter for the compile group + if response.compileGroup? + $scope.pdf.compileGroup = response.compileGroup + qs.compileGroup = "#{$scope.pdf.compileGroup}" + # convert the qs hash into a query string and append it + qs_args = ("#{k}=#{v}" for k, v of qs) + $scope.pdf.qs = if qs_args.length then "?" + qs_args.join("&") else "" + $scope.pdf.url += $scope.pdf.qs fetchLogs(fileByPath['output.log']) @@ -101,8 +109,11 @@ define [ $scope.pdf.outputFiles.push file fetchLogs = (outputFile) -> - qs = if outputFile?.build? then "?build=#{outputFile.build}" else "" - $http.get "/project/#{$scope.project_id}/output/output.log" + qs + if outputFile?.build? + logUrl = "/project/#{$scope.project_id}/build/#{outputFile.build}/output/output.log" + else + logUrl = "/project/#{$scope.project_id}/output/output.log" + $http.get logUrl .success (log) -> #console.log ">>", log $scope.pdf.rawLog = log @@ -124,8 +135,12 @@ define [ type: if entry.level == "error" then "error" else "warning" text: entry.message } - # Get the biber log and parse it too - $http.get "/project/#{$scope.project_id}/output/output.blg" + qs + # Get the biber log and parse it + if outputFile?.build? + biberLogUrl = "/project/#{$scope.project_id}/build/#{outputFile.build}/output/output.blg" + else + biberLogUrl = "/project/#{$scope.project_id}/output/output.blg" + $http.get biberLogUrl .success (log) -> window._s = $scope biberLogEntries = BibLogParser.parse(log, {})