This commit is contained in:
Henry Oswald 2016-08-30 13:08:09 +01:00
commit cbb4ee88cc
5 changed files with 71 additions and 10 deletions

View file

@ -381,6 +381,7 @@ module.exports = (grunt) ->
grunt.registerTask 'test:modules:unit', 'Run the unit tests for the modules', ['compile:modules:server', 'compile:modules:unit_tests'].concat(moduleUnitTestTasks) grunt.registerTask 'test:modules:unit', 'Run the unit tests for the modules', ['compile:modules:server', 'compile:modules:unit_tests'].concat(moduleUnitTestTasks)
grunt.registerTask 'run', "Compile and run the web-sharelatex server", ['compile', 'env:run', 'parallel'] grunt.registerTask 'run', "Compile and run the web-sharelatex server", ['compile', 'env:run', 'parallel']
grunt.registerTask 'runq', "Compile and run the web-sharelatex server", ['compile', 'env:run', 'exec']
grunt.registerTask 'default', 'run' grunt.registerTask 'default', 'run'

View file

@ -25,14 +25,14 @@ module.exports = Modules =
for module in @modules for module in @modules
for view, partial of module.viewIncludes or {} for view, partial of module.viewIncludes or {}
@viewIncludes[view] ||= [] @viewIncludes[view] ||= []
@viewIncludes[view].push fs.readFileSync(Path.join(MODULE_BASE_PATH, module.name, "app/views", partial + ".jade")) @viewIncludes[view].push jade.compile(fs.readFileSync(Path.join(MODULE_BASE_PATH, module.name, "app/views", partial + ".jade")), doctype: "html")
moduleIncludes: (view, locals) -> moduleIncludes: (view, locals) ->
partials = Modules.viewIncludes[view] or [] compiledPartials = Modules.viewIncludes[view] or []
html = "" html = ""
for partial in partials for compiledPartial in compiledPartials
compiler = jade.compile(partial, doctype: "html") d = new Date()
html += compiler(locals) html += compiledPartial(locals)
return html return html
moduleIncludesAvailable: (view) -> moduleIncludesAvailable: (view) ->

View file

@ -36,11 +36,19 @@ div.full-size.pdf(ng-controller="PdfController")
i.fa.fa-fw(ng-class="{'fa-check': draft}") i.fa.fa-fw(ng-class="{'fa-check': draft}")
|  #{translate("fast")}  |  #{translate("fast")} 
span.subdued [draft] span.subdued [draft]
li.dropdown-header #{translate("file_checks")} li.dropdown-header #{translate("compile_time_checks")}
li
a(href, ng-click="stop_on_validation_error = true")
i.fa.fa-fw(ng-class="{'fa-check': stop_on_validation_error}")
|  #{translate("stop_on_validation_error")}
li
a(href, ng-click="stop_on_validation_error = false")
i.fa.fa-fw(ng-class="{'fa-check': !stop_on_validation_error}")
|  #{translate("ignore_validation_errors")}
li li
a(href, ng-click="recompile({check:true})") a(href, ng-click="recompile({check:true})")
i.fa.fa-fw() i.fa.fa-fw()
|  #{translate("run_syntax_check")} |  #{translate("run_syntax_check_now")}
a( a(
href href
ng-click="stop()" ng-click="stop()"
@ -105,6 +113,23 @@ div.full-size.pdf(ng-controller="PdfController")
strong #{translate("compile_error")}. strong #{translate("compile_error")}.
span #{translate("generic_failed_compile_message")}. span #{translate("generic_failed_compile_message")}.
.alert.alert-danger(ng-show="pdf.failedCheck")
strong #{translate("failed_compile_check")}.
p
p.text-center(ng-show="!check")
a.text-info(
href,
ng-disabled="pdf.compiling",
ng-click="recompile({try:true})"
) #{translate("failed_compile_check_try")}
|  #{translate("failed_compile_option_or")} 
a.text-info(
href,
ng-disabled="pdf.compiling",
ng-click="recompile({force:true})"
) #{translate("failed_compile_check_ignore")}
| .
div(ng-repeat="entry in pdf.logEntries.all", ng-controller="PdfLogEntryController") div(ng-repeat="entry in pdf.logEntries.all", ng-controller="PdfLogEntryController")
.alert( .alert(
ng-class="{\ ng-class="{\

View file

@ -73,6 +73,12 @@ define [
$scope.pdf.view = 'errors' $scope.pdf.view = 'errors'
$scope.pdf.renderingError = true $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.draft = localStorage("draft:#{$scope.project_id}") or false
$scope.$watch "draft", (new_value, old_value) -> $scope.$watch "draft", (new_value, old_value) ->
if new_value? and old_value != new_value if new_value? and old_value != new_value
@ -83,10 +89,21 @@ define [
params = {} params = {}
if options.isAutoCompile if options.isAutoCompile
params["auto_compile"]=true 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, { return $http.post url, {
rootDoc_id: options.rootDocOverride_id or null rootDoc_id: options.rootDocOverride_id or null
draft: $scope.draft draft: $scope.draft
check: if options.check then "validate" else "silent" check: checkType
_csrf: window.csrfToken _csrf: window.csrfToken
}, {params: params} }, {params: params}
@ -105,6 +122,8 @@ define [
$scope.pdf.renderingError = false $scope.pdf.renderingError = false
$scope.pdf.projectTooLarge = false $scope.pdf.projectTooLarge = false
$scope.pdf.compileTerminated = false $scope.pdf.compileTerminated = false
$scope.pdf.compileExited = false
$scope.pdf.failedCheck = false
# make a cache to look up files by name # make a cache to look up files by name
fileByPath = {} fileByPath = {}
@ -131,9 +150,10 @@ define [
fetchLogs(fileByPath) fetchLogs(fileByPath)
else if response.status in ["validation-fail", "validation-pass"] else if response.status in ["validation-fail", "validation-pass"]
$scope.pdf.view = 'pdf' $scope.pdf.view = 'pdf'
$scope.pdf.compileExited = true
$scope.pdf.url = last_pdf_url $scope.pdf.url = last_pdf_url
$scope.shouldShowLogs = true $scope.shouldShowLogs = true
$scope.pdf.failedCheck = true if response.status is "validation-fail"
event_tracking.sendMB "syntax-check-#{response.status}"
fetchLogs(fileByPath, { validation: true }) fetchLogs(fileByPath, { validation: true })
else if response.status == "exited" else if response.status == "exited"
$scope.pdf.view = 'pdf' $scope.pdf.view = 'pdf'
@ -262,7 +282,8 @@ define [
else else
warnings.push result warnings.push result
all = [].concat errors, warnings 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 accumulateResults logHints
processBiber = (log) -> processBiber = (log) ->
@ -347,6 +368,16 @@ define [
$scope.pdf.compiling = true $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") ide.$scope.$broadcast("flush-changes")
options.rootDocOverride_id = getRootDocOverride_id() options.rootDocOverride_id = getRootDocOverride_id()

View file

@ -161,6 +161,10 @@
.dropdown { .dropdown {
position: relative; position: relative;
} }
.force-recompile {
margin-top: 10px;
text-align: right;
}
} }
.synctex-controls { .synctex-controls {