Browse Source

[issue-113] Added settings and templating to support a custom banner (both admin and front-end) in any environment that defines CODERED_BANNER.

Sean Harrison 5 years ago
parent
commit
4517f62c65

+ 4 - 0
coderedcms/settings.py

@@ -165,6 +165,10 @@ DEFAULTS = {
         ),
 
     },
+
+    'BANNER': None,
+    'BANNER_BACKGROUND': '#f00',
+    'BANNER_TEXT_COLOR': '#fff',
 }
 
 

+ 2 - 0
coderedcms/static/css/codered-admin.css

@@ -1,3 +1,5 @@
+@import "codered-shared.css";
+
 /* Font sizes and inputs */
 
 html, body {

+ 1 - 0
coderedcms/static/css/codered-front.css

@@ -2,6 +2,7 @@
 CodeRed CMS custom styles
 ********************/
 
+@import "codered-shared.css";
 
 /* Hero Unit */
 

+ 12 - 0
coderedcms/static/css/codered-shared.css

@@ -0,0 +1,12 @@
+.codered-banner {
+    font-size: 1rem;
+    padding: 1rem;
+    width: 100%;
+}
+
+.codered-banner a:link,
+.codered-banner a:visited,
+.codered-banner a:hover,
+.codered-banner a:active {
+    color: inherit;
+}

+ 6 - 0
coderedcms/templates/coderedcms/includes/codered_banner.html

@@ -0,0 +1,6 @@
+{% load coderedcms_tags %}
+		{% if "BANNER"|codered_settings %}
+        <div class="codered-banner" style="background-color:{{ 'BANNER_BACKGROUND'|codered_settings }}; color:{{ 'BANNER_TEXT_COLOR'|codered_settings }};">
+            {{ "BANNER"|codered_settings|safe }}
+        </div>
+        {% endif %}

+ 2 - 0
coderedcms/templates/coderedcms/pages/base.html

@@ -103,6 +103,8 @@
 
     <body class="coderedcms-{{page.content_type.model}} {% if page.get_parent %}parent-page-{{page.get_parent.id}}{% endif %} {% block body_class %}{% endblock %}" id="page-{{page.id}}">
 
+        {% include "coderedcms/includes/codered_banner.html" %}
+
         {% wagtailuserbar %}
 
         {% block ada_skip %}

+ 44 - 9
coderedcms/templates/wagtailadmin/base.html

@@ -1,12 +1,47 @@
 {% extends "wagtailadmin/base.forked.html" %}
-{% load wagtailimages_tags wagtailsettings_tags %}
+{% load wagtailimages_tags wagtailsettings_tags wagtailadmin_tags wagtailcore_tags static i18n %}
 
+{% block furniture %}
+    <div class="nav-wrapper">
+        <div class="inner">
+            <a href="{% url 'wagtailadmin_home' %}" class="logo" title="Admin Dashboard">
+                {% block branding_logo %}
+                    {% if settings.coderedcms.LayoutSettings.logo %}
+                        {% image settings.coderedcms.LayoutSettings.logo max-150x100 as logo_image %}
+                        <img src="{{ logo_image.url }}" alt="Admin Dashboard"/>
+                    {% else %}
+                        {{block.super}}
+                    {% endif %}
+                {% endblock %}
+                <span class="u-hidden@sm">{% trans "Dashboard" %}</span>
+            </a>
+
+            {% menu_search %}
+            {% main_nav %}
+
+        </div>
+        <div class="explorer__wrapper" data-explorer-menu></div>
+    </div>
+
+    {% include "coderedcms/includes/codered_banner.html" %}
+
+    <div class="content-wrapper">
+        <div class="content">
+            {# Always show messages div so it can be appended to by JS #}
+            <div class="messages">
+                {% if messages %}
+                    <ul>
+                        {% for message in messages %}
+                            <li class="{% message_tags message %}">{{ message|safe }}</li>
+                        {% endfor %}
+                    </ul>
+                {% endif %}
+            </div>
+
+            <div id="nav-toggle" class="nav-toggle icon text-replace">{% trans "Menu" %}</div>
+
+            {% block content %}{% endblock %}
+        </div>
+    </div>
+{% endblock %}
 
-{% block branding_logo %}
-    {% if settings.coderedcms.LayoutSettings.logo %}
-        {% image settings.coderedcms.LayoutSettings.logo max-150x100 as logo_image %}
-        <img src="{{ logo_image.url }}" alt="Admin Dashboard"/>
-    {% else %}
-        {{block.super}}
-    {% endif %}
-{% endblock %}

+ 19 - 0
docs/getting_started/django_settings.rst

@@ -46,3 +46,22 @@ different CSS framework or theme variant.
 
     * DO NOT run ``makemigrations`` or ``makemigrations coderedcms``
     * ONLY run migrations for specific apps, i.e. ``makemigrations website``
+
+CODERED_BANNER, CODERED_BANNER_BACKGROUND, CODERED_BANNER_TEXT_COLOR
+--------------------------------------------------------------------
+
+If you define a value for this ``CODERED_BANNER``, CodeRedCMS will show this text in a banner
+on both the front end and in the CMS of your site. This is useful for flagging non-production
+environments like staging. For example::
+
+	CODERED_BANNER = "Staging Environment. Production is over here: <a href='https://example.com'>Example link</a>."
+
+You can include basic HTML code, such as a link, in the banner.
+
+The banner defaults to a background color of red and a text color of white. If you want to
+customize this for a particular environment, you can; for example::
+
+	CODERED_BANNER_BACKGROUND = '#FFFFE0'	# light yellow background
+	CODERED_BANNER_TEXT_COLOR = '#000'		# black text color
+
+