settings.py 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. import os
  2. from django.conf import settings
  3. from django.utils.lru_cache import lru_cache
  4. PROJECT_DIR = settings.PROJECT_DIR if getattr(settings, 'PROJECT_DIR') else os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  5. BASE_DIR = settings.BASE_DIR if getattr(settings, 'BASE_DIR') else os.path.dirname(PROJECT_DIR)
  6. DEFAULTS = {
  7. 'PROTECTED_MEDIA_URL': '/protected/',
  8. 'PROTECTED_MEDIA_ROOT': os.path.join(BASE_DIR, 'protected'),
  9. 'PROTECTED_MEDIA_UPLOAD_WHITELIST': [],
  10. 'PROTECTED_MEDIA_UPLOAD_BLACKLIST': ['.sh', '.exe', '.bat', '.ps1', '.app', '.jar', '.py', '.php', '.pl', '.rb'],
  11. 'FRONTEND_BTN_SIZE_DEFAULT': '',
  12. 'FRONTEND_BTN_SIZE_CHOICES': (
  13. ('btn-sm', 'Small'),
  14. ('', 'Default'),
  15. ('btn-lg', 'Large'),
  16. ),
  17. 'FRONTEND_BTN_STYLE_DEFAULT': 'btn-primary',
  18. 'FRONTEND_BTN_STYLE_CHOICES': (
  19. ('btn-primary', 'Primary'),
  20. ('btn-secondary', 'Secondary'),
  21. ('btn-success', 'Success'),
  22. ('btn-danger', 'Danger'),
  23. ('btn-warning', 'Warning'),
  24. ('btn-info', 'Info'),
  25. ('btn-link', 'Link'),
  26. ('btn-light', 'Light'),
  27. ('btn-dark', 'Dark'),
  28. ('btn-outline-primary', 'Outline Primary'),
  29. ('btn-outline-secondary', 'Outline Secondary'),
  30. ('btn-success', 'Outline Success'),
  31. ('btn-outline-danger', 'Outline Danger'),
  32. ('btn-outline-warning', 'Outline Warning'),
  33. ('btn-outline-info', 'Outline Info'),
  34. ('btn-outline-light', 'Outline Light'),
  35. ('btn-outline-dark', 'Outline Dark'),
  36. ),
  37. 'FRONTEND_CAROUSEL_FX_DEFAULT': '',
  38. 'FRONTEND_CAROUSEL_FX_CHOICES': (
  39. ('', 'Slide'),
  40. ('carousel-fade', 'Fade'),
  41. ),
  42. 'FRONTEND_COL_SIZE_DEFAULT': '',
  43. 'FRONTEND_COL_SIZE_CHOICES': (
  44. ('', 'Automatically size'),
  45. ('12', 'Full row'),
  46. ('6', 'Half - 1/2 column'),
  47. ('4', 'Thirds - 1/3 column'),
  48. ('8', 'Thirds - 2/3 column'),
  49. ('3', 'Quarters - 1/4 column'),
  50. ('9', 'Quarters - 3/4 column'),
  51. ('2', 'Sixths - 1/6 column'),
  52. ('10', 'Sixths - 5/6 column'),
  53. ('1', 'Twelfths - 1/12 column'),
  54. ('5', 'Twelfths - 5/12 column'),
  55. ('7', 'Twelfths - 7/12 column'),
  56. ('11', 'Twelfths - 11/12 column'),
  57. ),
  58. 'FRONTEND_COL_BREAK_DEFAULT': 'md',
  59. 'FRONTEND_COL_BREAK_CHOICES': (
  60. ('', 'Always expanded'),
  61. ('sm', 'sm - Expand on small screens (phone, 576px) and larger'),
  62. ('md', 'md - Expand on medium screens (tablet, 768px) and larger'),
  63. ('lg', 'lg - Expand on large screens (laptop, 992px) and larger'),
  64. ('xl', 'xl - Expand on extra large screens (wide monitor, 1200px)'),
  65. ),
  66. 'FRONTEND_NAVBAR_FORMAT_DEFAULT': '',
  67. 'FRONTEND_NAVBAR_FORMAT_CHOICES': (
  68. ('', 'Default Bootstrap Navbar'),
  69. ('codered-navbar-center', 'Centered logo at top'),
  70. ),
  71. 'FRONTEND_NAVBAR_COLOR_SCHEME_DEFAULT': 'navbar-light',
  72. 'FRONTEND_NAVBAR_COLOR_SCHEME_CHOICES': (
  73. ('navbar-light', 'Light - for use with a light-colored navbar'),
  74. ('navbar-dark', 'Dark - for use with a dark-colored navbar'),
  75. ),
  76. 'FRONTEND_NAVBAR_CLASS_DEFAULT': 'bg-light',
  77. 'FRONTEND_NAVBAR_COLLAPSE_MODE_DEFAULT': 'navbar-expand-lg',
  78. 'FRONTEND_NAVBAR_COLLAPSE_MODE_CHOICES': (
  79. ('', 'Never show menu - Always collapse menu behind a button'),
  80. ('navbar-expand-sm', 'sm - Show on small screens (phone size) and larger'),
  81. ('navbar-expand-md', 'md - Show on medium screens (tablet size) and larger'),
  82. ('navbar-expand-lg', 'lg - Show on large screens (laptop size) and larger'),
  83. ('navbar-expand-xl', 'xl - Show on extra large screens (desktop, wide monitor)'),
  84. ),
  85. 'FRONTEND_THEME_HELP': 'Change the color palette of your site with a Bootstrap theme. Powered by Bootswatch https://bootswatch.com/.',
  86. 'FRONTEND_THEME_DEFAULT': '',
  87. 'FRONTEND_THEME_CHOICES': (
  88. ('', 'Default - Classic Bootstrap'),
  89. ('cerulean', 'Cerulean - A calm blue sky'),
  90. ('cosmo', 'Cosmo - An ode to Metro'),
  91. ('cyborg', 'Cyborg - Jet black and electric blue'),
  92. ('darkly', 'Darkly - Flatly in night mode'),
  93. ('flatly', 'Flatly - Flat and modern'),
  94. ('journal', 'Journal - Crisp like a new sheet of paper'),
  95. ('litera', 'Litera - The medium is the message'),
  96. ('lumen', 'Lumen - Light and shadow'),
  97. ('lux', 'Lux - A touch of class'),
  98. ('materia', 'Materia - Material is the metaphor'),
  99. ('minty', 'Minty - A fresh feel'),
  100. ('pulse', 'Pulse - A trace of purple'),
  101. ('sandstone', 'Sandstone - A touch of warmth'),
  102. ('simplex', 'Simplex - Mini and minimalist'),
  103. ('sketchy', 'Sketchy - A hand-drawn look for mockups and mirth'),
  104. ('slate', 'Slate - Shades of gunmetal gray'),
  105. ('solar', 'Solar - A dark spin on Solarized'),
  106. ('spacelab', 'Spacelab - Silvery and sleek'),
  107. ('superhero', 'Superhero - The brave and the blue'),
  108. ('united', 'United - Ubuntu orange and unique font'),
  109. ('yeti', 'Yeti - A friendly foundation'),
  110. ),
  111. 'FRONTEND_TEMPLATES_BLOCKS': {
  112. 'cardblock': (
  113. ('coderedcms/blocks/card_block.html', 'Card'),
  114. ('coderedcms/blocks/card_head.html', 'Card with header'),
  115. ('coderedcms/blocks/card_foot.html', 'Card with footer'),
  116. ('coderedcms/blocks/card_head_foot.html', 'Card with header and footer'),
  117. ('coderedcms/blocks/card_blurb.html', 'Blurb - rounded image and no border'),
  118. ('coderedcms/blocks/card_img.html', 'Cover image - use image as background'),
  119. ),
  120. 'cardgridblock': (
  121. ('coderedcms/blocks/cardgrid_group.html', 'Card group - attached cards of equal size'),
  122. ('coderedcms/blocks/cardgrid_deck.html', 'Card deck - separate cards of equal size'),
  123. ('coderedcms/blocks/cardgrid_columns.html', 'Card masonry - fluid brick pattern'),
  124. ),
  125. 'pagelistblock': (
  126. ('coderedcms/blocks/pagelist_block.html', 'General, simple list'),
  127. ('coderedcms/blocks/pagelist_list_group.html', 'General, list group navigation panel'),
  128. ('coderedcms/blocks/pagelist_article_media.html', 'Article, media format'),
  129. ('coderedcms/blocks/pagelist_article_card_group.html', 'Article, card group - attached cards of equal size'),
  130. ('coderedcms/blocks/pagelist_article_card_deck.html', 'Article, card deck - separate cards of equal size'),
  131. ('coderedcms/blocks/pagelist_article_card_columns.html', 'Article, card masonry - fluid brick pattern'),
  132. ),
  133. # templates that are available for all block types
  134. '*': (
  135. ('', 'Default'),
  136. ),
  137. },
  138. 'FRONTEND_TEMPLATES_PAGES': {
  139. # templates that are available for all page types
  140. '*': (
  141. ('', 'Default'),
  142. ('coderedcms/pages/web_page.html', 'Web page showing title and cover image'),
  143. ('coderedcms/pages/web_page_notitle.html', 'Web page without title and cover image'),
  144. ('coderedcms/pages/base.html', 'Blank page - no navbar or footer'),
  145. ),
  146. },
  147. }
  148. @lru_cache()
  149. def get_config():
  150. config = DEFAULTS.copy()
  151. for var in config:
  152. cr_var = 'CODERED_%s' % var
  153. if hasattr(settings, cr_var):
  154. config[var] = getattr(settings, cr_var)
  155. return config
  156. cr_settings = get_config()
  157. try:
  158. import bootstrap4.bootstrap as bootstrap
  159. except ImportError:
  160. import bootstrap3.bootstrap as bootstrap
  161. get_bootstrap_setting = bootstrap.get_bootstrap_setting