Pārlūkot izejas kodu

HUE-6720 [editor] Correctly reference static contents from within the web worker

Johan Ahlen 8 gadi atpakaļ
vecāks
revīzija
6c7136238e

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -3543,7 +3543,7 @@
 
       var apiHelper = ApiHelper.getInstance();
       var activeTokens = [];
-      var aceSqlWorker = new Worker('/static/desktop/js/aceSqlWorker.js?bust=' + Math.random());
+      var aceSqlWorker = new Worker('/desktop/workers/aceSqlWorker.js');
       var workerIsReady = false;
 
       self.disposeFunctions.push(function () {

+ 18 - 18
desktop/core/src/desktop/static/desktop/js/aceSqlWorker.js → desktop/core/src/desktop/templates/ace_sql_worker.mako

@@ -1,23 +1,23 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+## Licensed to Cloudera, Inc. under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  Cloudera, Inc. licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##     http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
 
 var version = 20;
-importScripts('/static/desktop/js/autocomplete/sqlParseSupport.js?version=' + version);
-importScripts('/static/desktop/js/autocomplete/sql.js?version=' + version);
-importScripts('/static/desktop/js/sqlFunctions.js?version=' + version);
+importScripts('${ static('desktop/js/autocomplete/sqlParseSupport.js') }' + '?version=' + version);
+importScripts('${ static('desktop/js/autocomplete/sql.js') }' + '?version=' + version);
+importScripts('${ static('desktop/js/sqlFunctions.js') }' + '?version=' + version);
 
 (function () {
 

+ 3 - 0
desktop/core/src/desktop/urls.py

@@ -105,6 +105,9 @@ dynamic_patterns += patterns('desktop.views',
   # Jasmine
   (r'^jasmine', 'jasmine'),
 
+  # Web workers
+  (r'^desktop/workers/aceSqlWorker.js', 'ace_sql_worker'),
+
   # Unsupported browsers
   (r'^boohoo$','unsupported'),
 

+ 4 - 0
desktop/core/src/desktop/views.py

@@ -320,6 +320,10 @@ def memory(request):
 def jasmine(request):
   return render('jasmine.mako', request, None)
 
+
+def ace_sql_worker(request):
+  return HttpResponse(render('ace_sql_worker.mako', request, None), content_type="application/javascript")
+
 def assist_m(request):
   return render('assist_m.mako', request, None)