lab.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!DOCTYPE html>
  2. <!--
  3. Copyright (c) Jupyter Development Team.
  4. Distributed under the terms of the Modified BSD License.
  5. -->
  6. <html>
  7. <head>
  8. <meta charset="utf-8">
  9. <title>{% block title %}{{page_title}}{% endblock %}</title>
  10. {% block stylesheet %}
  11. {% for css_file in jupyterlab_css %}
  12. <link href="{{ css_file }}" rel="stylesheet">
  13. {% endfor %}
  14. {% endblock %}
  15. <script id="jupyter-config-data" type="application/json">{
  16. {% for key, value in jupyterlab_config.items() -%}
  17. "{{ key }}": "{{ value }}",
  18. {% endfor -%}
  19. "baseUrl": "{{base_url | urlencode}}",
  20. "wsUrl": "{{ws_url | urlencode}}"
  21. }</script>
  22. {% block favicon %}<link rel="shortcut icon" type="image/x-icon" href="{{ base_url }}static/base/images/favicon.ico">{% endblock %}
  23. {% for bundle_file in jupyterlab_bundles %}
  24. <script src="{{ bundle_file }}" type="text/javascript" charset="utf-8"></script>
  25. {% endfor %}
  26. {% if mathjax_url %}
  27. <script type="text/javascript" src="{{mathjax_url}}?config={{mathjax_config}}&amp;delayStartupUntil=configured" charset="utf-8"></script>
  28. {% endif %}
  29. {% block meta %}
  30. {% endblock %}
  31. </head>
  32. <body>
  33. {% block script %}
  34. <script>
  35. var loader = jupyter.loader;
  36. delete jupyter.loader;
  37. var createLab = loader.require("{{ jupyterlab_main }}").createLab;
  38. var lab = jupyter.lab = createLab(loader);
  39. var plugins = [];
  40. /**
  41. * Get the plugins for an entry point.
  42. */
  43. var getEntryPoint = function (entryPoint) {
  44. var plugins = loader.require(entryPoint);
  45. try {
  46. plugins = loader.extractPlugins(plugins);
  47. } catch (err) {
  48. console.error(err);
  49. plugins = [];
  50. }
  51. return plugins;
  52. }
  53. {% for plugin_entry in plugin_entries %}
  54. plugins = plugins.concat(getEntryPoint("{{ plugin_entry }}"));
  55. {% endfor %}
  56. lab.registerPlugins(plugins);
  57. lab.start();
  58. </script>
  59. {% endblock %}
  60. <script type="text/javascript">
  61. function _remove_token_from_url() {
  62. if (window.location.search.length <= 1) {
  63. return;
  64. }
  65. var search_parameters = window.location.search.slice(1).split('&');
  66. for (var i = 0; i < search_parameters.length; i++) {
  67. if (search_parameters[i].split('=')[0] === 'token') {
  68. // remote token from search parameters
  69. search_parameters.splice(i, 1);
  70. var new_search = '';
  71. if (search_parameters.length) {
  72. new_search = '?' + search_parameters.join('&');
  73. }
  74. var new_url = window.location.origin +
  75. window.location.pathname +
  76. new_search +
  77. window.location.hash;
  78. window.history.replaceState({}, "", new_url);
  79. return;
  80. }
  81. }
  82. }
  83. _remove_token_from_url();
  84. </script>
  85. </body>
  86. </html>