Przeglądaj źródła

Finger print Ace files

James Allen 12 lat temu
rodzic
commit
462403bb4f

+ 2 - 0
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"

+ 2 - 1
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(

+ 3 - 2
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')

+ 1 - 0
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"

+ 10 - 1
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(",")

+ 1 - 0
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");
 };