From 3c31988e9ab808f36e8ae6105266c5effcb11ad0 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 10 Jun 2016 16:06:02 +0100 Subject: [PATCH 1/4] enable on-demand viewing of pdfs for per-user compiles --- .../coffee/ide/pdfng/directives/pdfRenderer.coffee | 3 ++- .../coffee/ide/pdfng/directives/pdfViewer.coffee | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/ide/pdfng/directives/pdfRenderer.coffee b/services/web/public/coffee/ide/pdfng/directives/pdfRenderer.coffee index 5639d670f0..e634afea3a 100644 --- a/services/web/public/coffee/ide/pdfng/directives/pdfRenderer.coffee +++ b/services/web/public/coffee/ide/pdfng/directives/pdfRenderer.coffee @@ -12,7 +12,8 @@ define [ constructor: (@url, @options) -> # PDFJS.disableFontFace = true # avoids repaints, uses worker more - # PDFJS.disableAutoFetch = true # enable this to prevent loading whole file + if @options.disableAutoFetch + PDFJS.disableAutoFetch = true # prevent loading whole file # PDFJS.disableStream # PDFJS.disableRange @scale = @options.scale || 1 diff --git a/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee b/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee index f0ec8d61b1..4b6209717c 100644 --- a/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee +++ b/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee @@ -27,13 +27,21 @@ define [ $scope.document.destroy() if $scope.document? $scope.loadCount = if $scope.loadCount? then $scope.loadCount + 1 else 1 # TODO need a proper url manipulation library to add to query string - $scope.document = new PDFRenderer($scope.pdfSrc + '&pdfng=true' , { + url = $scope.pdfSrc + # add 'pdfng=true' to show that we are using the angular pdfjs viewer + queryStringExists = url.match(/\?/) + url = url + (if not queryStringExists then '?' else '&') + 'pdfng=true' + # for isolated compiles, load the pdf on-demand because nobody will overwrite it + onDemandLoading = window.location?.search?.match(/isolated=true/)? + $scope.document = new PDFRenderer(url, { scale: 1, + disableAutoFetch: if onDemandLoading then true else undefined navigateFn: (ref) -> # this function captures clicks on the annotation links $scope.navigateTo = ref $scope.$apply() progressCallback: (progress) -> + return if onDemandLoading is true # don't show progress for on-demand page loading $scope.$emit 'progress', progress loadedCallback: () -> $scope.$emit 'loaded' From 5ad0c06770803c99f8d9e7e8db1eed16fe8f06f6 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 28 Jun 2016 17:19:02 +0100 Subject: [PATCH 2/4] Regex now matches new folder nomenclature. --- .../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 610915ec3a..ab85755c36 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -237,7 +237,7 @@ define [ return null normalizeFilePath = (path) -> - path = path.replace(/^(.*)\/compiles\/[0-9a-f]{24}\/(\.\/)?/, "") + path = path.replace(/^(.*)\/compiles\/[0-9a-f]{24}-[0-9a-f]{24}\/(\.\/)?/, "") path = path.replace(/^\/compile\//, "") rootDocDirname = ide.fileTreeManager.getRootDocDirname() From d037cb93a9f0a3330ffe28f7c56902fdcd49167d Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 29 Jun 2016 10:42:51 +0100 Subject: [PATCH 3/4] Wiki styles clean-up. --- services/web/public/stylesheets/app/wiki.less | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/services/web/public/stylesheets/app/wiki.less b/services/web/public/stylesheets/app/wiki.less index 2bc962961f..5f7462d02c 100644 --- a/services/web/public/stylesheets/app/wiki.less +++ b/services/web/public/stylesheets/app/wiki.less @@ -41,11 +41,6 @@ .example { max-width: 100%; - & > div { - display: block !important; - width: auto !important; - } - .code { pre { background-color: @gray-lightest; @@ -60,9 +55,9 @@ padding-top: 10px; img { - width: auto !important; - height: auto !important; - max-width: 100% !important; + width: auto; + height: auto; + max-width: 100%; box-shadow: 0 1px 3px @gray-light; border-radius: 6px; } From 36e09e3b0c6324505ad56f255b8926b182b645fc Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 29 Jun 2016 14:19:16 +0100 Subject: [PATCH 4/4] Make the user id portion of the path optional. --- .../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 ab85755c36..b9b8d234dd 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -237,7 +237,7 @@ define [ return null normalizeFilePath = (path) -> - path = path.replace(/^(.*)\/compiles\/[0-9a-f]{24}-[0-9a-f]{24}\/(\.\/)?/, "") + path = path.replace(/^(.*)\/compiles\/[0-9a-f]{24}(-[0-9a-f]{24})?\/(\.\/)?/, "") path = path.replace(/^\/compile\//, "") rootDocDirname = ide.fileTreeManager.getRootDocDirname()