mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge branch 'master' of github.com:sharelatex/web-sharelatex
This commit is contained in:
commit
2e2354c574
1 changed files with 67 additions and 51 deletions
|
@ -92,7 +92,7 @@ define [
|
||||||
$scope.pdf.qs = if qs_args.length then "?" + qs_args.join("&") else ""
|
$scope.pdf.qs = if qs_args.length then "?" + qs_args.join("&") else ""
|
||||||
$scope.pdf.url += $scope.pdf.qs
|
$scope.pdf.url += $scope.pdf.qs
|
||||||
|
|
||||||
fetchLogs(fileByPath['output.log'])
|
fetchLogs(fileByPath['output.log'], fileByPath['output.blg'])
|
||||||
|
|
||||||
IGNORE_FILES = ["output.fls", "output.fdb_latexmk"]
|
IGNORE_FILES = ["output.fls", "output.fdb_latexmk"]
|
||||||
$scope.pdf.outputFiles = []
|
$scope.pdf.outputFiles = []
|
||||||
|
@ -108,56 +108,72 @@ define [
|
||||||
file.name = file.path
|
file.name = file.path
|
||||||
$scope.pdf.outputFiles.push file
|
$scope.pdf.outputFiles.push file
|
||||||
|
|
||||||
fetchLogs = (outputFile) ->
|
fetchLogs = (logFile, blgFile) ->
|
||||||
if outputFile?.build?
|
|
||||||
logUrl = "/project/#{$scope.project_id}/build/#{outputFile.build}/output/output.log"
|
getFile = (name, file) ->
|
||||||
else
|
if file?.build?
|
||||||
logUrl = "/project/#{$scope.project_id}/output/output.log"
|
url = "/project/#{$scope.project_id}/build/#{file.build}/output/#{name}"
|
||||||
$http.get logUrl
|
else
|
||||||
.success (log) ->
|
url = "/project/#{$scope.project_id}/output/#{name}"
|
||||||
#console.log ">>", log
|
return $http.get url
|
||||||
$scope.pdf.rawLog = log
|
|
||||||
logEntries = LogParser.parse(log, ignoreDuplicates: true)
|
# accumulate the log entries
|
||||||
#console.log ">>", logEntries
|
logEntries =
|
||||||
$scope.pdf.logEntries = logEntries
|
all: []
|
||||||
$scope.pdf.logEntries.all = logEntries.errors.concat(logEntries.warnings).concat(logEntries.typesetting)
|
errors: []
|
||||||
# # # #
|
warnings: []
|
||||||
proceed = () ->
|
|
||||||
$scope.pdf.logEntryAnnotations = {}
|
accumulateResults = (newEntries) ->
|
||||||
for entry in logEntries.all
|
for key in ['all', 'errors', 'warnings']
|
||||||
if entry.file?
|
logEntries[key] = logEntries[key].concat newEntries[key]
|
||||||
entry.file = normalizeFilePath(entry.file)
|
|
||||||
entity = ide.fileTreeManager.findEntityByPath(entry.file)
|
# use the parsers for each file type
|
||||||
if entity?
|
processLog = (log) ->
|
||||||
$scope.pdf.logEntryAnnotations[entity.id] ||= []
|
$scope.pdf.rawLog = log
|
||||||
$scope.pdf.logEntryAnnotations[entity.id].push {
|
{errors, warnings, typesetting} = LogParser.parse(log, ignoreDuplicates: true)
|
||||||
row: entry.line - 1
|
all = [].concat errors, warnings, typesetting
|
||||||
type: if entry.level == "error" then "error" else "warning"
|
accumulateResults {all, errors, warnings}
|
||||||
text: entry.message
|
|
||||||
}
|
processBiber = (log) ->
|
||||||
# Get the biber log and parse it
|
{errors, warnings} = BibLogParser.parse(log, {})
|
||||||
if outputFile?.build?
|
all = [].concat errors, warnings
|
||||||
biberLogUrl = "/project/#{$scope.project_id}/build/#{outputFile.build}/output/output.blg"
|
accumulateResults {all, errors, warnings}
|
||||||
else
|
|
||||||
biberLogUrl = "/project/#{$scope.project_id}/output/output.blg"
|
# output the results
|
||||||
$http.get biberLogUrl
|
handleError = () ->
|
||||||
.success (log) ->
|
$scope.pdf.logEntries = []
|
||||||
window._s = $scope
|
$scope.pdf.rawLog = ""
|
||||||
biberLogEntries = BibLogParser.parse(log, {})
|
|
||||||
if $scope.pdf.logEntries
|
annotateFiles = () ->
|
||||||
entries = $scope.pdf.logEntries
|
$scope.pdf.logEntries = logEntries
|
||||||
all = biberLogEntries.errors.concat(biberLogEntries.warnings)
|
$scope.pdf.logEntryAnnotations = {}
|
||||||
entries.all = entries.all.concat(all)
|
for entry in logEntries.all
|
||||||
entries.errors = entries.errors.concat(biberLogEntries.errors)
|
if entry.file?
|
||||||
entries.warnings = entries.warnings.concat(biberLogEntries.warnings)
|
entry.file = normalizeFilePath(entry.file)
|
||||||
proceed()
|
entity = ide.fileTreeManager.findEntityByPath(entry.file)
|
||||||
.error (e) ->
|
if entity?
|
||||||
# it's not an error for the output.blg file to not be present
|
$scope.pdf.logEntryAnnotations[entity.id] ||= []
|
||||||
proceed()
|
$scope.pdf.logEntryAnnotations[entity.id].push {
|
||||||
# # # #
|
row: entry.line - 1
|
||||||
.error () ->
|
type: if entry.level == "error" then "error" else "warning"
|
||||||
$scope.pdf.logEntries = []
|
text: entry.message
|
||||||
$scope.pdf.rawLog = ""
|
}
|
||||||
|
|
||||||
|
# retrieve the logfile and process it
|
||||||
|
response = getFile('output.log', logFile)
|
||||||
|
.success processLog
|
||||||
|
.error handleError
|
||||||
|
|
||||||
|
if blgFile? # retrieve the blg file if present
|
||||||
|
response.success () ->
|
||||||
|
getFile('output.blg', blgFile)
|
||||||
|
# ignore errors in biber file
|
||||||
|
.success processBiber
|
||||||
|
# display the combined result
|
||||||
|
.then annotateFiles
|
||||||
|
else # otherwise just display the result
|
||||||
|
response.success annotateFiles
|
||||||
|
|
||||||
|
|
||||||
getRootDocOverride_id = () ->
|
getRootDocOverride_id = () ->
|
||||||
doc = ide.editorManager.getCurrentDocValue()
|
doc = ide.editorManager.getCurrentDocValue()
|
||||||
|
|
Loading…
Reference in a new issue