You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
3.0 KiB

4 years ago
  1. #############################################################################
  2. # Copyright (c) 2018, QuantStack #
  3. # Copyright (c) 2018, Voila Contributors #
  4. # #
  5. # Distributed under the terms of the BSD 3-Clause License. #
  6. # #
  7. # The full license is in the file LICENSE, distributed with this software. #
  8. #############################################################################
  9. import traitlets.config
  10. from traitlets import Unicode, Bool, Dict, List
  11. class VoilaConfiguration(traitlets.config.Configurable):
  12. """Common configuration options between the server extension and the application."""
  13. template = Unicode(
  14. 'default',
  15. config=True,
  16. allow_none=True,
  17. help=(
  18. 'template name to be used by voila.'
  19. )
  20. )
  21. resources = Dict(
  22. allow_none=True,
  23. help="""
  24. extra resources used by templates;
  25. example use with --template=reveal
  26. --VoilaConfiguration.resources="{'reveal': {'transition': 'fade', 'scroll': True}}"
  27. """
  28. ).tag(config=True)
  29. theme = Unicode('light').tag(config=True)
  30. strip_sources = Bool(True, help='Strip sources from rendered html').tag(config=True)
  31. enable_nbextensions = Bool(False, config=True, help=('Set to True for Voila to load notebook extensions'))
  32. file_whitelist = List(
  33. Unicode(),
  34. [r'.*\.(png|jpg|gif|svg)'],
  35. help=r"""
  36. List of regular expressions for controlling which static files are served.
  37. All files that are served should at least match 1 whitelist rule, and no blacklist rule
  38. Example: --VoilaConfiguration.file_whitelist="['.*\.(png|jpg|gif|svg)', 'public.*']"
  39. """,
  40. ).tag(config=True)
  41. file_blacklist = List(
  42. Unicode(),
  43. [r'.*\.(ipynb|py)'],
  44. help=r"""
  45. List of regular expressions for controlling which static files are forbidden to be served.
  46. All files that are served should at least match 1 whitelist rule, and no blacklist rule
  47. Example:
  48. --VoilaConfiguration.file_whitelist="['.*']" # all files
  49. --VoilaConfiguration.file_blacklist="['private.*', '.*\.(ipynb)']" # except files in the private dir and notebook files
  50. """
  51. ).tag(config=True)
  52. language_kernel_mapping = Dict(
  53. {},
  54. help="""Mapping of language name to kernel name
  55. Example mapping python to use xeus-python, and C++11 to use xeus-cling:
  56. --VoilaConfiguration.extension_language_mapping='{"python": "xpython", "C++11": "xcpp11"}'
  57. """,
  58. ).tag(config=True)
  59. extension_language_mapping = Dict(
  60. {},
  61. help='''Mapping of file extension to kernel language
  62. Example mapping .py files to a python language kernel, and .cpp to a C++11 language kernel:
  63. --VoilaConfiguration.extension_language_mapping='{".py": "python", ".cpp": "C++11"}'
  64. ''',
  65. ).tag(config=True)