settings.py 7.8 KB

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