Browse Source

update examples for ci

Eric Charles 5 năm trước cách đây
mục cha
commit
041b9af27c

+ 15 - 14
examples/cell/main.py

@@ -37,7 +37,7 @@ class ExampleHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterH
             "appVersion": version,
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'fullStaticUrl': ujoin(self.base_url, 'static', 'example'), 
+            'fullStaticUrl': ujoin(self.base_url, 'static', 'example_app'), 
             'frontendUrl': ujoin(self.base_url, 'example/'),
         }
         return self.write(
@@ -55,26 +55,27 @@ class ExampleApp(LabServerApp):
 
     default_url = Unicode('/example')
 
+    LabServerApp.lab_config = LabConfig(
+        app_name = 'JupyterLab Example Cell',
+        app_url = '/example_app',
+        static_dir = os.path.join(HERE, 'build'),
+        templates_dir = os.path.join(HERE, 'templates'),
+        app_version = version,
+        app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
+        schemas_dir = os.path.join(HERE, 'build', 'schemas'),
+        themes_dir = os.path.join(HERE, 'build', 'themes'),
+        user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
+        workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
+    )
+
     def initialize_handlers(self):
         """initialize tornado webapp and httpserver.
         """
+        super().initialize_handlers()
         default_handlers = [
             (ujoin(self.serverapp.base_url, 'example'), ExampleHandler),
         ]
         self.serverapp.web_app.add_handlers('.*$', default_handlers)
-        LabServerApp.lab_config = LabConfig(
-            app_name = 'JupyterLab Example Cell',
-            app_url = '/example',
-            static_dir = os.path.join(HERE, 'build'),
-            templates_dir = os.path.join(HERE, 'templates'),
-            app_version = version,
-            app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
-            schemas_dir = os.path.join(HERE, 'build', 'schemas'),
-            themes_dir = os.path.join(HERE, 'build', 'themes'),
-            user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
-            workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
-        )
-        super().initialize_handlers()
 
 
 if __name__ == '__main__':

+ 2 - 0
examples/cell/templates/index.html

@@ -4,6 +4,7 @@
   <title>{{page_config['appName'] | e}}</title>
 </head>
 <body>
+
   {# Copy so we do not modify the page_config with updates. #}
   {% set page_config_full = page_config.copy() %}
     
@@ -25,5 +26,6 @@
       }
     })();
   </script>
+
 </body>
 </html>

+ 14 - 13
examples/console/main.py

@@ -37,7 +37,7 @@ class ExampleHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterH
             "appVersion": version,
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'fullStaticUrl': ujoin(self.base_url, 'static', 'example'), 
+            'fullStaticUrl': ujoin(self.base_url, 'static', 'example_app'), 
             'frontendUrl': ujoin(self.base_url, 'example/'),
         }
         return self.write(
@@ -55,25 +55,26 @@ class ExampleApp(LabServerApp):
 
     default_url = Unicode('/example')
 
+    LabServerApp.lab_config = LabConfig(
+        app_name = 'JupyterLab Example Console',
+        app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
+        app_url = '/example_app',
+        schemas_dir = os.path.join(HERE, 'build', 'schemas'),
+        static_dir = os.path.join(HERE, 'build'),
+        templates_dir = os.path.join(HERE, 'templates'),
+        themes_dir = os.path.join(HERE, 'build', 'themes'),
+        user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
+        workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
+    )
+
     def initialize_handlers(self):
         """initialize tornado webapp and httpserver.
         """
+        super().initialize_handlers()
         default_handlers = [
             (ujoin(self.serverapp.base_url, 'example'), ExampleHandler),
         ]
         self.serverapp.web_app.add_handlers('.*$', default_handlers)
-        LabServerApp.lab_config = LabConfig(
-            app_name = 'JupyterLab Example Console',
-            app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
-            app_url = '/example',
-            schemas_dir = os.path.join(HERE, 'build', 'schemas'),
-            static_dir = os.path.join(HERE, 'build'),
-            templates_dir = os.path.join(HERE, 'templates'),
-            themes_dir = os.path.join(HERE, 'build', 'themes'),
-            user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
-            workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
-        )
-        super().initialize_handlers()
 
 
 if __name__ == '__main__':

+ 2 - 0
examples/console/templates/index.html

@@ -4,6 +4,7 @@
   <title>{{page_config['appName'] | e}}</title>
 </head>
 <body>
+
   {# Copy so we do not modify the page_config with updates. #}
   {% set page_config_full = page_config.copy() %}
     
@@ -25,5 +26,6 @@
       }
     })();
   </script>
+
 </body>
 </html>

+ 15 - 14
examples/filebrowser/main.py

@@ -38,7 +38,7 @@ class ExampleHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterH
             "appVersion": version,
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'fullStaticUrl': ujoin(self.base_url, 'static', 'example'), 
+            'fullStaticUrl': ujoin(self.base_url, 'static', 'example_app'), 
             'frontendUrl': ujoin(self.base_url, 'example/'),
         }
         return self.write(
@@ -56,26 +56,27 @@ class ExampleApp(LabServerApp):
 
     default_url = Unicode('/example')
 
+    LabServerApp.lab_config = LabConfig(
+        app_name = 'JupyterLab Example File Browser',
+        app_url = '/example_app',
+        static_dir = os.path.join(HERE, 'build'),
+        templates_dir = os.path.join(HERE, 'templates'),
+        app_version = version,
+        app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
+        schemas_dir = os.path.join(HERE, 'build', 'schemas'),
+        themes_dir = os.path.join(HERE, 'build', 'themes'),
+        user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
+        workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
+    )
+
     def initialize_handlers(self):
         """initialize tornado webapp and httpserver.
         """
+        super().initialize_handlers()
         default_handlers = [
             (ujoin(self.serverapp.base_url, 'example'), ExampleHandler),
         ]
         self.serverapp.web_app.add_handlers('.*$', default_handlers)
-        LabServerApp.lab_config = LabConfig(
-            app_name = 'JupyterLab Example File Browser',
-            app_url = '/example',
-            static_dir = os.path.join(HERE, 'build'),
-            templates_dir = os.path.join(HERE, 'templates'),
-            app_version = version,
-            app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
-            schemas_dir = os.path.join(HERE, 'build', 'schemas'),
-            themes_dir = os.path.join(HERE, 'build', 'themes'),
-            user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
-            workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
-        )
-        super().initialize_handlers()
 
 
 if __name__ == '__main__':

+ 2 - 0
examples/filebrowser/templates/index.html

@@ -4,6 +4,7 @@
   <title>{{page_config['appName'] | e}}</title>
 </head>
 <body>
+
   {# Copy so we do not modify the page_config with updates. #}
   {% set page_config_full = page_config.copy() %}
     
@@ -25,5 +26,6 @@
       }
     })();
   </script>
+
 </body>
 </html>

+ 15 - 14
examples/notebook/main.py

@@ -40,8 +40,8 @@ class ExampleHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterH
             # Use camelCase here, since that's what the lab components expect
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'notebookPath': 'test.ipynb',
-            'fullStaticUrl': ujoin(self.base_url, 'static', 'example'), 
+            'notebookPath': os.path.join(HERE, 'test.ipynb'),
+            'fullStaticUrl': ujoin(self.base_url, 'static', 'example_app'), 
             'frontendUrl': ujoin(self.base_url, 'example/'),
             # FIXME: Don't use a CDN here
             'mathjaxUrl': "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js",
@@ -62,25 +62,26 @@ class ExampleApp(LabServerApp):
 
     default_url = Unicode('/example')
 
+    LabServerApp.lab_config = LabConfig(
+        app_name = 'JupyterLab Example Notebook',
+        app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
+        app_url = '/example_app',
+        schemas_dir = os.path.join(HERE, 'build', 'schemas'),
+        static_dir = os.path.join(HERE, 'build'),
+        templates_dir = os.path.join(HERE, 'templates'),
+        themes_dir = os.path.join(HERE, 'build', 'themes'),
+        user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
+        workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
+    )
+
     def initialize_handlers(self):
         """initialize tornado webapp and httpserver.
         """
+        super().initialize_handlers()
         default_handlers = [
             (ujoin(self.serverapp.base_url, 'example'), ExampleHandler),
         ]
         self.serverapp.web_app.add_handlers('.*$', default_handlers)
-        LabServerApp.lab_config = LabConfig(
-            app_name = 'JupyterLab Example Notebook',
-            app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
-            app_url = '/example',
-            schemas_dir = os.path.join(HERE, 'build', 'schemas'),
-            static_dir = os.path.join(HERE, 'build'),
-            templates_dir = os.path.join(HERE, 'templates'),
-            themes_dir = os.path.join(HERE, 'build', 'themes'),
-            user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
-            workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
-        )
-        super().initialize_handlers()
 
 
 if __name__ == '__main__':

+ 2 - 1
examples/notebook/templates/index.html

@@ -4,6 +4,7 @@
   <title>{{page_config['appName'] | e}}</title>
 </head>
 <body>
+
   {# Copy so we do not modify the page_config with updates. #}
   {% set page_config_full = page_config.copy() %}
     
@@ -15,7 +16,6 @@
   </script>
   <script src="{{page_config['fullStaticUrl'] | e}}/bundle.js" main="index"></script>
 
-
   <script type="text/javascript">
     /* Remove token from URL. */
     (function () {
@@ -26,5 +26,6 @@
       }
     })();
   </script>
+
 </body>
 </html>

+ 22 - 19
examples/terminal/main.py

@@ -39,41 +39,44 @@ class ExampleHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterH
             "appVersion": version,
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'fullStaticUrl': ujoin(self.base_url, 'static', 'example'), 
+            'fullStaticUrl': ujoin(self.base_url, 'static', 'example_app'), 
             'frontendUrl': ujoin(self.base_url, 'example/'),
             'terminalsAvailable': available
         }
-        return self.write(self.render_template('index.html',
-                                               static=self.static_url,
-                                               base_url=self.base_url,
-                                               token=self.settings['token'],
-                                               terminals_available=available,
-                                               page_config=config_data))
+        return self.write(
+            self.render_template('index.html',
+            static=self.static_url,
+            base_url=self.base_url,
+            token=self.settings['token'],
+            terminals_available=available,
+            page_config=config_data)
+            )
 
 
 class ExampleApp(LabServerApp):
 
     default_url = Unicode('/example')
 
+    LabServerApp.lab_config = LabConfig(
+        app_name = 'JupyterLab Example Terminal',
+        app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
+        app_url = '/example_app',
+        schemas_dir = os.path.join(HERE, 'build', 'schemas'),
+        static_dir = os.path.join(HERE, 'build'),
+        templates_dir = os.path.join(HERE, 'templates'),
+        themes_dir = os.path.join(HERE, 'build', 'themes'),
+        user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
+        workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
+    )
+
     def initialize_handlers(self):
         """initialize tornado webapp and httpserver.
         """
+        super().initialize_handlers()
         default_handlers = [
             (ujoin(self.serverapp.base_url, 'example'), ExampleHandler),
         ]
         self.serverapp.web_app.add_handlers('.*$', default_handlers)
-        LabServerApp.lab_config = LabConfig(
-            app_name = 'JupyterLab Example Console',
-            app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
-            app_url = '/example',
-            schemas_dir = os.path.join(HERE, 'build', 'schemas'),
-            static_dir = os.path.join(HERE, 'build'),
-            templates_dir = os.path.join(HERE, 'templates'),
-            themes_dir = os.path.join(HERE, 'build', 'themes'),
-            user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
-            workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
-        )
-        super().initialize_handlers()
 
 
 if __name__ == '__main__':

+ 3 - 0
examples/terminal/templates/index.html

@@ -4,6 +4,7 @@
   <title>{{page_config['appName'] | e}}</title>
 </head>
 <body>
+
   {# Copy so we do not modify the page_config with updates. #}
   {% set page_config_full = page_config.copy() %}
     
@@ -13,6 +14,7 @@
   <script id="jupyter-config-data" type="application/json">
     {{ page_config_full | tojson }}
   </script>
+
   <script src="{{page_config['fullStaticUrl'] | e}}/bundle.js" main="index"></script>
 
   <script type="text/javascript">
@@ -25,5 +27,6 @@
       }
     })();
   </script>
+
 </body>
 </html>

+ 1 - 1
packages/services/examples/browser-require/index.html

@@ -38,6 +38,6 @@
         }
     });
     </script>
-    <script src="{{base_url | e}}static/example/index.js"></script>
+    <script src="{{base_url | e}}static/example_app/index.js"></script>
   </body>
 </html>

+ 9 - 8
packages/services/examples/browser-require/main.py

@@ -24,7 +24,7 @@ class ExampleHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterH
             # Use camelCase here, since that's what the lab components expect
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'fullStaticUrl': ujoin(self.base_url, 'static', 'example'), 
+            'fullStaticUrl': ujoin(self.base_url, 'static', 'example_app'), 
             'frontendUrl': ujoin(self.base_url, 'example/'),
         }
         return self.write(
@@ -42,20 +42,21 @@ class ExampleApp(LabServerApp):
 
     default_url = Unicode('/example')
 
+    LabServerApp.lab_config = LabConfig(
+        app_name = 'JupyterLab Example Service Browser Require',
+        app_url = '/example_app',
+        static_dir = os.path.join(HERE, 'static'),
+        templates_dir = os.path.join(HERE),
+    )
+
     def initialize_handlers(self):
         """initialize tornado webapp and httpserver.
         """
+        super().initialize_handlers()
         default_handlers = [
             (ujoin(self.serverapp.base_url, 'example'), ExampleHandler),
         ]
         self.serverapp.web_app.add_handlers('.*$', default_handlers)
-        LabServerApp.lab_config = LabConfig(
-            app_name = 'JupyterLab Example Service Browser Require',
-            app_url = '/example',
-            static_dir = os.path.join(HERE, 'static'),
-            templates_dir = os.path.join(HERE),
-        )
-        super().initialize_handlers()
 
 
 if __name__ == '__main__':

+ 14 - 13
packages/services/examples/browser/main.py

@@ -30,7 +30,7 @@ class ExampleHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterH
             "appVersion": version,
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'fullStaticUrl': ujoin(self.base_url, 'static', 'example'), 
+            'fullStaticUrl': ujoin(self.base_url, 'static', 'example_app'), 
             'frontendUrl': ujoin(self.base_url, 'example/'),
         }
         return self.write(
@@ -48,6 +48,19 @@ class ExampleApp(LabServerApp):
 
     default_url = Unicode('/example')
 
+    LabServerApp.lab_config = LabConfig(
+        app_name = 'JupyterLab Example Service',
+        app_url = '/example_app',
+        static_dir = os.path.join(HERE, 'build'),
+        templates_dir = os.path.join(HERE, 'templates'),
+        app_version = version, 
+        app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
+        schemas_dir = os.path.join(HERE, 'build', 'schemas'),
+        themes_dir = os.path.join(HERE, 'build', 'themes'),
+        user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
+        workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
+    )
+
     def initialize_handlers(self):
         """initialize tornado webapp and httpserver.
         """
@@ -55,18 +68,6 @@ class ExampleApp(LabServerApp):
             (ujoin(self.serverapp.base_url, 'example'), ExampleHandler),
         ]
         self.serverapp.web_app.add_handlers('.*$', default_handlers)
-        LabServerApp.lab_config = LabConfig(
-            app_name = 'JupyterLab Example Cell',
-            app_url = '/example',
-            static_dir = os.path.join(HERE, 'build'),
-            templates_dir = os.path.join(HERE, 'templates'),
-            app_version = version, 
-            app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
-            schemas_dir = os.path.join(HERE, 'build', 'schemas'),
-            themes_dir = os.path.join(HERE, 'build', 'themes'),
-            user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
-            workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
-        )
         super().initialize_handlers()
 
 

+ 1 - 1
packages/services/examples/browser/templates/index.html

@@ -11,7 +11,7 @@
       {{ page_config_full | tojson }}
     </script>
   
-    <script src="{{base_url | e}}static/example/bundle.js"></script>
+    <script src="{{base_url | e}}static/example_app/bundle.js"></script>
     <pre id='output'></pre>
   </body>
 </html>

+ 16 - 15
packages/services/examples/typescript-browser-with-output/main.py

@@ -29,7 +29,7 @@ class ExampleHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterH
             "appVersion": version,
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'fullStaticUrl': ujoin(self.base_url, 'static', 'example'), 
+            'fullStaticUrl': ujoin(self.base_url, 'static', 'example_app'), 
             'frontendUrl': ujoin(self.base_url, 'example/'),
         }
         return self.write(
@@ -38,7 +38,7 @@ class ExampleHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterH
                 static=self.static_url,
                 base_url=self.base_url,
                 token=self.settings['token'],
-                page_config=config_data
+                page_config=config_data,
                 )
             )
 
@@ -47,26 +47,27 @@ class ExampleApp(LabServerApp):
 
     default_url = Unicode('/example')
 
+    LabServerApp.lab_config = LabConfig(
+        app_name = 'JupyterLab Example Cell',
+        app_url = '/example_app',
+        static_dir = os.path.join(HERE, 'build'),
+        templates_dir = os.path.join(HERE, 'templates'),
+        app_version = version,
+        app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
+        schemas_dir = os.path.join(HERE, 'build', 'schemas'),
+        themes_dir = os.path.join(HERE, 'build', 'themes'),
+        user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
+        workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
+    )
+
     def initialize_handlers(self):
         """initialize tornado webapp and httpserver.
         """
+        super().initialize_handlers()
         default_handlers = [
             (ujoin(self.serverapp.base_url, 'example'), ExampleHandler),
         ]
         self.serverapp.web_app.add_handlers('.*$', default_handlers)
-        LabServerApp.lab_config = LabConfig(
-            app_name = 'JupyterLab Example Cell',
-            app_url = '/example',
-            static_dir = os.path.join(HERE, 'build'),
-            templates_dir = os.path.join(HERE, 'templates'),
-            app_version = version,
-            app_settings_dir = os.path.join(HERE, 'build', 'application_settings'),
-            schemas_dir = os.path.join(HERE, 'build', 'schemas'),
-            themes_dir = os.path.join(HERE, 'build', 'themes'),
-            user_settings_dir = os.path.join(HERE, 'build', 'user_settings'),
-            workspaces_dir = os.path.join(HERE, 'build', 'workspaces'),
-        )
-        super().initialize_handlers()
 
 
 if __name__ == '__main__':

+ 1 - 1
packages/services/examples/typescript-browser-with-output/templates/index.html

@@ -11,7 +11,7 @@
       {{ page_config_full | tojson }}
     </script>
 
-    <script src="{{base_url | e}}static/example/bundle.js"></script>
+    <script src="{{page_config['fullStaticUrl'] | e}}/bundle.js" main="index"></script>
     <span id='outputarea'></span>
   </body>
 </html>