From 462403bb4fe6e1878751b4d2b7bba82bf0e34082 Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 18 Jul 2014 12:08:35 +0100 Subject: [PATCH] Finger print Ace files --- .../app/coffee/infrastructure/ExpressLocals.coffee | 2 ++ services/web/app/views/layout.jade | 3 ++- services/web/app/views/project/editor.jade | 5 +++-- services/web/public/coffee/base.coffee | 1 + .../coffee/ide/editor/directives/aceEditor.coffee | 11 ++++++++++- services/web/public/js/ace/ace.js | 1 + 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/services/web/app/coffee/infrastructure/ExpressLocals.coffee b/services/web/app/coffee/infrastructure/ExpressLocals.coffee index 6e14526d88..e35ebef6c3 100644 --- a/services/web/app/coffee/infrastructure/ExpressLocals.coffee +++ b/services/web/app/coffee/infrastructure/ExpressLocals.coffee @@ -18,6 +18,8 @@ for path in [ "#{jsPath}libs/require.js", "#{jsPath}ide.js", "#{jsPath}main.js", + "#{jsPath}libs.js", + "#{jsPath}ace/ace.js", "#{jsPath}libs/pdf.js", "#{jsPath}libs/pdf.worker.js", "/stylesheets/style.css" diff --git a/services/web/app/views/layout.jade b/services/web/app/views/layout.jade index 2e59b6a48f..09a862a8cb 100644 --- a/services/web/app/views/layout.jade +++ b/services/web/app/views/layout.jade @@ -55,7 +55,8 @@ html(itemscope, itemtype='http://schema.org/Product') window.requirejs = { "urlArgs" : "fingerprint=#{fingerprint(jsPath + 'app/main.js')}", "paths" : { - "moment": "libs/moment-2.7.0" + "moment": "libs/moment-2.7.0", + "libs": "#{jsPath}/libs.js?fingerprint=#{fingerprint(jsPath + 'libs.js')}" } }; script( diff --git a/services/web/app/views/project/editor.jade b/services/web/app/views/project/editor.jade index 7801af262b..f8c7311205 100644 --- a/services/web/app/views/project/editor.jade +++ b/services/web/app/views/project/editor.jade @@ -91,7 +91,7 @@ block content "mathjax": "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS_HTML", "moment": "libs/moment-2.7.0" }, - "urlArgs" : "fingerprint=#{fingerprint(jsPath + 'ide.js')}", + "urlArgs" : "fingerprint=#{fingerprint(jsPath + 'ide.js')}-#{fingerprint(jsPath + 'libs.js')}", "waitSeconds": 0, "shim": { "libs/pdfListView/PdfListView": { @@ -105,6 +105,7 @@ block content } } }; + window.aceFingerprint = "#{fingerprint(jsPath + 'ace/ace.js')}" script(type='text/javascript'). ga('send', 'event', 'editor-interaction', 'editor-opened') @@ -117,7 +118,7 @@ block content window.pdfJsWorkerPath = "#{pdfJsWorkerPath}"; script( - data-main=jsPath+'ide.js', + data-main=jsPath+"ide.js", baseurl=jsPath, data-ace-base=jsPath+'ace', src=jsPath+'libs/require.js?fingerprint='+fingerprint(jsPath + 'libs/require.js') diff --git a/services/web/public/coffee/base.coffee b/services/web/public/coffee/base.coffee index 90d522ead8..c156f35434 100644 --- a/services/web/public/coffee/base.coffee +++ b/services/web/public/coffee/base.coffee @@ -3,6 +3,7 @@ define [ "modules/recursionHelper" "utils/underscore" ], () -> + console.log "LOADING BASE" App = angular.module("SharelatexApp", [ "ui.bootstrap" "autocomplete" diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee index 524ed93d09..ce7fa8ab72 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee @@ -9,6 +9,15 @@ define [ "ide/editor/directives/aceEditor/cursor-position/CursorPositionManager" ], (App, Ace, SearchBox, UndoManager, AutoCompleteManager, SpellCheckManager, HighlightsManager, CursorPositionManager) -> EditSession = ace.require('ace/edit_session').EditSession + + # Ace loads its script itself, so we need to hook in to be able to clear + # the cache. + if !ace.config._moduleUrl? + ace.config._moduleUrl = ace.config.moduleUrl + ace.config.moduleUrl = (args...) -> + url = ace.config._moduleUrl(args...) + "?fingerprint=#{window.aceFingerprint}" + console.log "URL", url + return url App.directive "aceEditor", ["$timeout", "$compile", "$rootScope", ($timeout, $compile, $rootScope) -> monkeyPatchSearch($rootScope, $compile) @@ -73,7 +82,7 @@ define [ # Make '/' work for search in vim mode. editor.showCommandLine = (arg) => if arg == "/" - Ace.require("ace/ext/searchbox").Search(editor, true) + ace.require("ace/ext/searchbox").Search(editor, true) if attrs.resizeOn? for event in attrs.resizeOn.split(",") diff --git a/services/web/public/js/ace/ace.js b/services/web/public/js/ace/ace.js index ef80d363f0..1db90ec284 100644 --- a/services/web/public/js/ace/ace.js +++ b/services/web/public/js/ace/ace.js @@ -3465,6 +3465,7 @@ exports.moduleUrl = function(name, component) { } if (path && path.slice(-1) != "/") path += "/"; + console.log(path, component, sep, base); return path + component + sep + base + this.get("suffix"); };