Ver Fonte

[notebook] Extract require configuration to separate file

So that it can be reused where needed.
Johan Ahlen há 10 anos atrás
pai
commit
61b0989a7c

+ 50 - 0
desktop/core/src/desktop/templates/require.mako

@@ -0,0 +1,50 @@
+## 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.
+
+<%def name="config()">
+  <script src="${ static('desktop/ext/js/require.js') }"></script>
+  <script>
+    define('jquery', [], function() {
+      return jQuery;
+    });
+    require.config({
+      baseUrl: "${ static('') }",
+      paths: {
+        "jquery.ui.sortable": "desktop/ext/js/jquery/plugins/jquery-ui-1.10.4.draggable-droppable-sortable.min",
+        "knockout": "desktop/ext/js/knockout.min",
+        "ko.charts" : "desktop/js/ko.charts",
+        "knockout-mapping" : "desktop/ext/js/knockout-mapping.min",
+        "knockout-sortable" : "desktop/ext/js/knockout-sortable.min",
+        "knockout-deferred-updates" : "desktop/ext/js/knockout-deferred-updates.min",
+        "ko.editable" : "desktop/js/ko.editable",
+        "ko.hue-bindings" : "desktop/js/ko.hue-bindings"
+      },
+      shim: {
+        "knockout": { exports: "ko" },
+        "knockout-mapping": { deps: ["knockout"] },
+        "knockout-sortable": { deps: ["knockout", "jquery", "jquery.ui.sortable"] },
+        "knockout-deferred-updates": { deps: ["knockout"] },
+        "ko.editable": { deps: ["knockout"] },
+        "ace.extended": { deps: ["ace"] },
+        "ace.ext-language-tools": { deps: ["ace"] }
+      },
+      deps: ["knockout", "knockout-mapping"],
+      callback: function(ko, mapping) {
+        ko.mapping = mapping;
+      }
+    });
+  </script>
+</%def>

+ 3 - 32
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -21,6 +21,8 @@ from django.utils.translation import ugettext as _
 from desktop.views import _ko
 %>
 
+<%namespace name="require" file="/require.mako" />
+
 <%def name="includes()">
 <link rel="stylesheet" href="${ static('desktop/css/common_dashboard.css') }">
 <link rel="stylesheet" href="${ static('notebook/css/notebook.css') }">
@@ -103,38 +105,7 @@ from desktop.views import _ko
 <script src="${ static('desktop/js/hue.utils.js') }"></script>
 
 
-<script src="${ static('desktop/ext/js/require.js') }"></script>
-<script>
-  define('jquery', [], function() {
-    return jQuery;
-  });
-  require.config({
-    baseUrl: "${ static('') }",
-    paths: {
-      "jquery.ui.sortable": "desktop/ext/js/jquery/plugins/jquery-ui-1.10.4.draggable-droppable-sortable.min",
-      "knockout": "desktop/ext/js/knockout.min",
-      "ko.charts" : "desktop/js/ko.charts",
-      "knockout-mapping" : "desktop/ext/js/knockout-mapping.min",
-      "knockout-sortable" : "desktop/ext/js/knockout-sortable.min",
-      "knockout-deferred-updates" : "desktop/ext/js/knockout-deferred-updates.min",
-      "ko.editable" : "desktop/js/ko.editable",
-      "ko.hue-bindings" : "desktop/js/ko.hue-bindings"
-    },
-    shim: {
-      "knockout": { exports: "ko" },
-      "knockout-mapping": { deps: ["knockout"] },
-      "knockout-sortable": { deps: ["knockout", "jquery", "jquery.ui.sortable"] },
-      "knockout-deferred-updates": { deps: ["knockout"] },
-      "ko.editable": { deps: ["knockout"] },
-      "ace.extended": { deps: ["ace"] },
-      "ace.ext-language-tools": { deps: ["ace"] }
-    },
-    deps: ["knockout", "knockout-mapping"],
-    callback: function(ko, mapping) {
-      ko.mapping = mapping;
-    }
-  });
-</script>
+${ require.config() }
 
 </%def>