settings.py 7.9 KB

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