css_templates.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. import textwrap
  18. from superset import db
  19. from superset.models.core import CssTemplate
  20. def load_css_templates():
  21. """Loads 2 css templates to demonstrate the feature"""
  22. print("Creating default CSS templates")
  23. obj = db.session.query(CssTemplate).filter_by(template_name="Flat").first()
  24. if not obj:
  25. obj = CssTemplate(template_name="Flat")
  26. css = textwrap.dedent(
  27. """\
  28. .navbar {
  29. transition: opacity 0.5s ease;
  30. opacity: 0.05;
  31. }
  32. .navbar:hover {
  33. opacity: 1;
  34. }
  35. .chart-header .header{
  36. font-weight: @font-weight-normal;
  37. font-size: 12px;
  38. }
  39. /*
  40. var bnbColors = [
  41. //rausch hackb kazan babu lima beach tirol
  42. '#ff5a5f', '#7b0051', '#007A87', '#00d1c1', '#8ce071', '#ffb400', '#b4a76c',
  43. '#ff8083', '#cc0086', '#00a1b3', '#00ffeb', '#bbedab', '#ffd266', '#cbc29a',
  44. '#ff3339', '#ff1ab1', '#005c66', '#00b3a5', '#55d12e', '#b37e00', '#988b4e',
  45. ];
  46. */
  47. """
  48. )
  49. obj.css = css
  50. db.session.merge(obj)
  51. db.session.commit()
  52. obj = db.session.query(CssTemplate).filter_by(template_name="Courier Black").first()
  53. if not obj:
  54. obj = CssTemplate(template_name="Courier Black")
  55. css = textwrap.dedent(
  56. """\
  57. h2 {
  58. color: white;
  59. font-size: 52px;
  60. }
  61. .navbar {
  62. box-shadow: none;
  63. }
  64. .navbar {
  65. transition: opacity 0.5s ease;
  66. opacity: 0.05;
  67. }
  68. .navbar:hover {
  69. opacity: 1;
  70. }
  71. .chart-header .header{
  72. font-weight: @font-weight-normal;
  73. font-size: 12px;
  74. }
  75. .nvd3 text {
  76. font-size: 12px;
  77. font-family: inherit;
  78. }
  79. body{
  80. background: #000;
  81. font-family: Courier, Monaco, monospace;;
  82. }
  83. /*
  84. var bnbColors = [
  85. //rausch hackb kazan babu lima beach tirol
  86. '#ff5a5f', '#7b0051', '#007A87', '#00d1c1', '#8ce071', '#ffb400', '#b4a76c',
  87. '#ff8083', '#cc0086', '#00a1b3', '#00ffeb', '#bbedab', '#ffd266', '#cbc29a',
  88. '#ff3339', '#ff1ab1', '#005c66', '#00b3a5', '#55d12e', '#b37e00', '#988b4e',
  89. ];
  90. */
  91. """
  92. )
  93. obj.css = css
  94. db.session.merge(obj)
  95. db.session.commit()