|
|
@@ -73,6 +73,12 @@ define [
|
|
|
$scope.pdf.view = 'errors'
|
|
|
$scope.pdf.renderingError = true
|
|
|
|
|
|
+ # abort compile if syntax checks fail
|
|
|
+ $scope.stop_on_validation_error = localStorage("stop_on_validation_error:#{$scope.project_id}") or ide.$scope?.user?.betaProgram
|
|
|
+ $scope.$watch "stop_on_validation_error", (new_value, old_value) ->
|
|
|
+ if new_value? and old_value != new_value
|
|
|
+ localStorage("stop_on_validation_error:#{$scope.project_id}", new_value)
|
|
|
+
|
|
|
$scope.draft = localStorage("draft:#{$scope.project_id}") or false
|
|
|
$scope.$watch "draft", (new_value, old_value) ->
|
|
|
if new_value? and old_value != new_value
|
|
|
@@ -83,10 +89,21 @@ define [
|
|
|
params = {}
|
|
|
if options.isAutoCompile
|
|
|
params["auto_compile"]=true
|
|
|
+ # if the previous run was a check, clear the error logs
|
|
|
+ $scope.pdf.logEntries = [] if $scope.check
|
|
|
+ # keep track of whether this is a compile or check
|
|
|
+ $scope.check = if options.check then true else false
|
|
|
+ event_tracking.sendMB "syntax-check-request" if options.check
|
|
|
+ # send appropriate check type to clsi
|
|
|
+ checkType = switch
|
|
|
+ when $scope.check then "validate" # validate only
|
|
|
+ when options.try then "silent" # allow use to try compile once
|
|
|
+ when $scope.stop_on_validation_error then "error" # try to compile
|
|
|
+ else "silent" # ignore errors
|
|
|
return $http.post url, {
|
|
|
rootDoc_id: options.rootDocOverride_id or null
|
|
|
draft: $scope.draft
|
|
|
- check: if options.check then "validate" else "silent"
|
|
|
+ check: checkType
|
|
|
_csrf: window.csrfToken
|
|
|
}, {params: params}
|
|
|
|
|
|
@@ -105,6 +122,8 @@ define [
|
|
|
$scope.pdf.renderingError = false
|
|
|
$scope.pdf.projectTooLarge = false
|
|
|
$scope.pdf.compileTerminated = false
|
|
|
+ $scope.pdf.compileExited = false
|
|
|
+ $scope.pdf.failedCheck = false
|
|
|
|
|
|
# make a cache to look up files by name
|
|
|
fileByPath = {}
|
|
|
@@ -131,9 +150,10 @@ define [
|
|
|
fetchLogs(fileByPath)
|
|
|
else if response.status in ["validation-fail", "validation-pass"]
|
|
|
$scope.pdf.view = 'pdf'
|
|
|
- $scope.pdf.compileExited = true
|
|
|
$scope.pdf.url = last_pdf_url
|
|
|
$scope.shouldShowLogs = true
|
|
|
+ $scope.pdf.failedCheck = true if response.status is "validation-fail"
|
|
|
+ event_tracking.sendMB "syntax-check-#{response.status}"
|
|
|
fetchLogs(fileByPath, { validation: true })
|
|
|
else if response.status == "exited"
|
|
|
$scope.pdf.view = 'pdf'
|
|
|
@@ -262,7 +282,8 @@ define [
|
|
|
else
|
|
|
warnings.push result
|
|
|
all = [].concat errors, warnings
|
|
|
- logHints = HumanReadableLogs.parse {type: "Validation", all, errors, warnings}
|
|
|
+ logHints = HumanReadableLogs.parse {type: "Syntax", all, errors, warnings}
|
|
|
+ event_tracking.sendMB "syntax-check-return-count", {errors:errors.length, warnings:warnings.length}
|
|
|
accumulateResults logHints
|
|
|
|
|
|
processBiber = (log) ->
|
|
|
@@ -347,6 +368,16 @@ define [
|
|
|
|
|
|
$scope.pdf.compiling = true
|
|
|
|
|
|
+ if options?.force
|
|
|
+ # for forced compile, turn off validation check and ignore errors
|
|
|
+ $scope.stop_on_validation_error = false
|
|
|
+ $scope.shouldShowLogs = false # hide the logs while compiling
|
|
|
+ event_tracking.sendMB "syntax-check-turn-off-checking"
|
|
|
+
|
|
|
+ if options?.try
|
|
|
+ $scope.shouldShowLogs = false # hide the logs while compiling
|
|
|
+ event_tracking.sendMB "syntax-check-try-compile-anyway"
|
|
|
+
|
|
|
ide.$scope.$broadcast("flush-changes")
|
|
|
|
|
|
options.rootDocOverride_id = getRootDocOverride_id()
|