From d3ebdb64b2dc7f6a918d8858601d7fb041b58c11 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Tue, 23 Aug 2016 15:31:09 +0100 Subject: [PATCH 01/10] precompile the jade partial views --- services/web/app/coffee/infrastructure/Modules.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/web/app/coffee/infrastructure/Modules.coffee b/services/web/app/coffee/infrastructure/Modules.coffee index 2df8907f7e..0dfbf3fa22 100644 --- a/services/web/app/coffee/infrastructure/Modules.coffee +++ b/services/web/app/coffee/infrastructure/Modules.coffee @@ -25,14 +25,14 @@ module.exports = Modules = for module in @modules for view, partial of module.viewIncludes or {} @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) -> - partials = Modules.viewIncludes[view] or [] + compiledPartials = Modules.viewIncludes[view] or [] html = "" - for partial in partials - compiler = jade.compile(partial, doctype: "html") - html += compiler(locals) + for compiledPartial in compiledPartials + d = new Date() + html += compiledPartial(locals) return html moduleIncludesAvailable: (view) -> From 74bc157e7c2df1d4a6f46d1c4897341454f160a4 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 24 Aug 2016 16:05:22 +0100 Subject: [PATCH 02/10] added force recompile option --- .../web/app/views/project/editor/pdf.jade | 16 +++++++++++++++ .../ide/pdf/controllers/PdfController.coffee | 20 ++++++++++++++++++- .../public/stylesheets/app/editor/pdf.less | 4 ++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/services/web/app/views/project/editor/pdf.jade b/services/web/app/views/project/editor/pdf.jade index 492f75f582..2dfcb0a0eb 100644 --- a/services/web/app/views/project/editor/pdf.jade +++ b/services/web/app/views/project/editor/pdf.jade @@ -36,6 +36,15 @@ div.full-size.pdf(ng-controller="PdfController") i.fa.fa-fw(ng-class="{'fa-check': draft}") |  #{translate("fast")}  span.subdued [draft] + 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.dropdown-header #{translate("file_checks")} li a(href, ng-click="recompile({check:true})") @@ -204,6 +213,13 @@ div.full-size.pdf(ng-controller="PdfController") p.entry-content(ng-show="entry.content") {{ entry.content.trim() }} + p.force-recompile(ng-if="$first && !check && stop_on_validation_error") + a.btn.btn-info( + href, + ng-disabled="pdf.compiling", + ng-click="recompile({force:true})" + ) + span() #{translate("force_recompile")} p .files-dropdown-container a.btn.btn-default.btn-sm( diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index a31a336885..d6c19cd0ea 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -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,17 @@ define [ params = {} if options.isAutoCompile params["auto_compile"]=true + # keep track of whether this is a compile or check + $scope.check = if options.check then true else false + # send appropriate check type to clsi + checkType = switch + when $scope.check then "validate" # validate only + 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} @@ -347,6 +360,11 @@ define [ $scope.pdf.compiling = true + if options?.force + # for forced compile, turn off validation check + $scope.stop_on_validation_error = false + $scope.shouldShowLogs = false # hide the logs while compiling + ide.$scope.$broadcast("flush-changes") options.rootDocOverride_id = getRootDocOverride_id() diff --git a/services/web/public/stylesheets/app/editor/pdf.less b/services/web/public/stylesheets/app/editor/pdf.less index 2183798650..12c86a6190 100644 --- a/services/web/public/stylesheets/app/editor/pdf.less +++ b/services/web/public/stylesheets/app/editor/pdf.less @@ -161,6 +161,10 @@ .dropdown { position: relative; } + .force-recompile { + margin-top: 10px; + text-align: right; + } } .synctex-controls { From 7f2041504889b6f6baee870c839f086009f64984 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 24 Aug 2016 16:48:45 +0100 Subject: [PATCH 03/10] only set compileExited on compile errors --- .../web/public/coffee/ide/pdf/controllers/PdfController.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index d6c19cd0ea..2ad662dc34 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -118,6 +118,7 @@ define [ $scope.pdf.renderingError = false $scope.pdf.projectTooLarge = false $scope.pdf.compileTerminated = false + $scope.pdf.compileExited = false # make a cache to look up files by name fileByPath = {} @@ -144,7 +145,6 @@ 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 fetchLogs(fileByPath, { validation: true }) From 9a1934465a82a6e1896b048d70fc41a70f6cf22e Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 25 Aug 2016 15:51:56 +0100 Subject: [PATCH 04/10] clean up syntax check options on menu --- .../web/app/views/project/editor/pdf.jade | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/services/web/app/views/project/editor/pdf.jade b/services/web/app/views/project/editor/pdf.jade index 2dfcb0a0eb..dbbb71ced7 100644 --- a/services/web/app/views/project/editor/pdf.jade +++ b/services/web/app/views/project/editor/pdf.jade @@ -45,7 +45,6 @@ div.full-size.pdf(ng-controller="PdfController") 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.dropdown-header #{translate("file_checks")} li a(href, ng-click="recompile({check:true})") i.fa.fa-fw() @@ -114,6 +113,21 @@ div.full-size.pdf(ng-controller="PdfController") strong #{translate("compile_error")}. span #{translate("generic_failed_compile_message")}. + .alert.alert-danger(ng-show="pdf.failedCheck") + div + strong #{translate("failed_compile_check")}. + div(ng-show="!check") + a( + href, + ng-disabled="pdf.compiling", + ng-click="recompile({try:true})" + ) #{translate("failed_compile_check_try")} + a( + 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") .alert( ng-class="{\ @@ -213,13 +227,6 @@ div.full-size.pdf(ng-controller="PdfController") p.entry-content(ng-show="entry.content") {{ entry.content.trim() }} - p.force-recompile(ng-if="$first && !check && stop_on_validation_error") - a.btn.btn-info( - href, - ng-disabled="pdf.compiling", - ng-click="recompile({force:true})" - ) - span() #{translate("force_recompile")} p .files-dropdown-container a.btn.btn-default.btn-sm( From 588be162554f50848795df5504aed834a6536bdb Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 25 Aug 2016 15:52:37 +0100 Subject: [PATCH 05/10] handle try/turn off options for syntax check --- .../coffee/ide/pdf/controllers/PdfController.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index 2ad662dc34..0c3136c4f6 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -89,11 +89,14 @@ 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 # 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, { @@ -119,6 +122,7 @@ define [ $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 = {} @@ -147,6 +151,7 @@ define [ $scope.pdf.view = 'pdf' $scope.pdf.url = last_pdf_url $scope.shouldShowLogs = true + $scope.pdf.failedCheck = true if response.status is "validation-fail" fetchLogs(fileByPath, { validation: true }) else if response.status == "exited" $scope.pdf.view = 'pdf' @@ -365,6 +370,9 @@ define [ $scope.stop_on_validation_error = false $scope.shouldShowLogs = false # hide the logs while compiling + if options?.try + $scope.shouldShowLogs = false # hide the logs while compiling + ide.$scope.$broadcast("flush-changes") options.rootDocOverride_id = getRootDocOverride_id() From 696a7206c17aac1cb406968f782c8fa37267bb73 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 25 Aug 2016 16:55:29 +0100 Subject: [PATCH 06/10] clean up display of error message --- .../web/app/views/project/editor/pdf.jade | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/services/web/app/views/project/editor/pdf.jade b/services/web/app/views/project/editor/pdf.jade index dbbb71ced7..682cfaa5c4 100644 --- a/services/web/app/views/project/editor/pdf.jade +++ b/services/web/app/views/project/editor/pdf.jade @@ -114,19 +114,19 @@ div.full-size.pdf(ng-controller="PdfController") span #{translate("generic_failed_compile_message")}. .alert.alert-danger(ng-show="pdf.failedCheck") - div + .card strong #{translate("failed_compile_check")}. - div(ng-show="!check") - a( - href, - ng-disabled="pdf.compiling", - ng-click="recompile({try:true})" - ) #{translate("failed_compile_check_try")} - a( - href, - ng-disabled="pdf.compiling", - ng-click="recompile({force:true})" - ) #{translate("failed_compile_check_ignore")} + div(ng-show="!check") + a.text-info( + href, + ng-disabled="pdf.compiling", + ng-click="recompile({try:true})" + ) #{translate("failed_compile_check_try")} ( + 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") .alert( From 092d7da4793674749ad1d8882a9de254d3d71c98 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 25 Aug 2016 16:55:49 +0100 Subject: [PATCH 07/10] use Syntax error for consistency in file check --- .../web/public/coffee/ide/pdf/controllers/PdfController.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index 0c3136c4f6..b3f7de4db6 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -280,7 +280,7 @@ 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} accumulateResults logHints processBiber = (log) -> From 3c59de31dfdb71d2f20e558d62f41d9719f5c2ad Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 26 Aug 2016 15:14:57 +0100 Subject: [PATCH 08/10] finalise display of syntax check error message --- .../web/app/views/project/editor/pdf.jade | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/services/web/app/views/project/editor/pdf.jade b/services/web/app/views/project/editor/pdf.jade index 682cfaa5c4..4463043435 100644 --- a/services/web/app/views/project/editor/pdf.jade +++ b/services/web/app/views/project/editor/pdf.jade @@ -48,7 +48,7 @@ div.full-size.pdf(ng-controller="PdfController") li a(href, ng-click="recompile({check:true})") i.fa.fa-fw() - |  #{translate("run_syntax_check")} + |  #{translate("run_syntax_check_now")} a( href ng-click="stop()" @@ -114,19 +114,21 @@ div.full-size.pdf(ng-controller="PdfController") span #{translate("generic_failed_compile_message")}. .alert.alert-danger(ng-show="pdf.failedCheck") - .card - strong #{translate("failed_compile_check")}. - div(ng-show="!check") - a.text-info( - href, - ng-disabled="pdf.compiling", - ng-click="recompile({try:true})" - ) #{translate("failed_compile_check_try")} ( - a.text-info( - href, - ng-disabled="pdf.compiling", - ng-click="recompile({force:true})" - ) #{translate("failed_compile_check_ignore")}) + 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") .alert( From 74959e794767596919ee01b9c3d30ea2564de1bc Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 26 Aug 2016 15:21:18 +0100 Subject: [PATCH 09/10] add Grunt task to run without parallel watch --- services/web/Gruntfile.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/services/web/Gruntfile.coffee b/services/web/Gruntfile.coffee index 63d0eb6f79..4307621af5 100644 --- a/services/web/Gruntfile.coffee +++ b/services/web/Gruntfile.coffee @@ -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 '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' From 7bf3b9daf91d4488ca4202c4627aa0b4532a4572 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 26 Aug 2016 15:54:01 +0100 Subject: [PATCH 10/10] add event tracking for syntax check --- .../public/coffee/ide/pdf/controllers/PdfController.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index b3f7de4db6..c79d654dbc 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -93,6 +93,7 @@ define [ $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 @@ -152,6 +153,7 @@ define [ $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' @@ -281,6 +283,7 @@ define [ warnings.push result all = [].concat 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) -> @@ -366,12 +369,14 @@ define [ $scope.pdf.compiling = true if options?.force - # for forced compile, turn off validation check + # 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")