Merge pull request #647 from sharelatex/ho-clsi-domain

PDF download takes optional domain paramater
This commit is contained in:
Henry Oswald 2018-06-13 11:30:17 +01:00 committed by GitHub
commit b24b110037
3 changed files with 16 additions and 6 deletions

View file

@ -13,6 +13,7 @@ ClsiCookieManager = require("./ClsiCookieManager")
Path = require("path")
module.exports = CompileController =
compile: (req, res, next = (error) ->) ->
res.setTimeout(5 * 60 * 1000)
project_id = req.params.Project_id
@ -43,6 +44,7 @@ module.exports = CompileController =
compileGroup: limits?.compileGroup
clsiServerId:clsiServerId
validationProblems:validationProblems
pdfDownloadDomain: Settings.pdfDownloadDomain
}
stopCompile: (req, res, next = (error) ->) ->

View file

@ -333,6 +333,9 @@ module.exports = settings =
# (otherwise each user has their own directory)
# disablePerUserCompiles: true
# Domain the client (pdfjs) should download the compiled pdf from
# pdfDownloadDomain: "http://compiles.sharelatex.test:3014"
# Maximum size of text documents in the real-time editing system.
max_doc_length: 2 * 1024 * 1024 # 2mb

View file

@ -228,7 +228,7 @@ define [
# keep last url
last_pdf_url = $scope.pdf.url
pdfDownloadDomain = response.pdfDownloadDomain
# Reset everything
$scope.pdf.error = false
$scope.pdf.timedout = false
@ -244,6 +244,11 @@ define [
$scope.pdf.compileInProgress = false
$scope.pdf.autoCompileDisabled = false
buildPdfDownloadUrl = (path)->
if pdfDownloadDomain?
return "#{pdfDownloadDomain}#{path}"
else
return path
# make a cache to look up files by name
fileByPath = {}
if response?.outputFiles?
@ -269,7 +274,7 @@ define [
fetchLogs(fileByPath)
else if response.status in ["validation-fail", "validation-pass"]
$scope.pdf.view = 'pdf'
$scope.pdf.url = last_pdf_url
$scope.pdf.url = buildPdfDownloadUrl last_pdf_url
$scope.shouldShowLogs = true
$scope.pdf.failedCheck = true if response.status is "validation-fail"
event_tracking.sendMB "syntax-check-#{response.status}"
@ -277,7 +282,7 @@ define [
else if response.status == "exited"
$scope.pdf.view = 'pdf'
$scope.pdf.compileExited = true
$scope.pdf.url = last_pdf_url
$scope.pdf.url = buildPdfDownloadUrl last_pdf_url
$scope.shouldShowLogs = true
fetchLogs(fileByPath)
else if response.status == "autocompile-backoff"
@ -315,12 +320,12 @@ define [
# define the base url. if the pdf file has a build number, pass it to the clsi in the url
if fileByPath['output.pdf']?.url?
$scope.pdf.url = fileByPath['output.pdf'].url
$scope.pdf.url = buildPdfDownloadUrl fileByPath['output.pdf'].url
else if fileByPath['output.pdf']?.build?
build = fileByPath['output.pdf'].build
$scope.pdf.url = "/project/#{$scope.project_id}/build/#{build}/output/output.pdf"
$scope.pdf.url = buildPdfDownloadUrl "/project/#{$scope.project_id}/build/#{build}/output/output.pdf"
else
$scope.pdf.url = "/project/#{$scope.project_id}/output/output.pdf"
$scope.pdf.url = buildPdfDownloadUrl "/project/#{$scope.project_id}/output/output.pdf"
# check if we need to bust cache (build id is unique so don't need it in that case)
if not fileByPath['output.pdf']?.build?
qs.cache_bust = "#{Date.now()}"