Browse Source

Show CodeRed CMS version in wagtail admin (#42)

* Show CodeRed CMS version in wagtail admin

* Forking wagtailadmin base template and adding shortversion

* Update menu_settings_menu_item.html
Vince Salvino 6 years ago
parent
commit
8010d43b9d

+ 4 - 0
coderedcms/__init__.py

@@ -0,0 +1,4 @@
+release = ['0', '10', '0']
+
+__version__ = "{0}.{1}.{2}".format(release[0], release[1], release[2])
+__shortversion__ = "{0}.{1}".format(release[0], release[1])

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

@@ -296,6 +296,9 @@ label {
 }
 
 @media screen and (min-width:50em) {
+    li.submenu-active .nav-submenu {
+        width: 220px;
+    }
     li.submenu-active .nav-submenu a {
         padding-left:1em;
         width:100%;

+ 47 - 0
coderedcms/templates/wagtailadmin/base.forked.html

@@ -0,0 +1,47 @@
+{# This is a direct fork of wagtailadmin/base.html with the title of the logo anchor changed #}
+
+{% extends "wagtailadmin/admin_base.html" %}
+{% load wagtailadmin_tags wagtailcore_tags staticfiles i18n %}
+
+{% block furniture %}
+    <div class="nav-wrapper">
+        <div class="inner">
+            <a href="{% url 'wagtailadmin_home' %}" class="logo" title="Admin Dashboard">
+                {% block branding_logo %}
+                    {# Mobile-only logo: #}
+                    <div class="wagtail-logo-container__mobile u-hidden@medium">
+                        <img class="wagtail-logo wagtail-logo__full" src="{% static 'wagtailadmin/images/wagtail-logo.svg' %}" alt="Wagtail" width="80" />
+                    </div>
+
+                    {# Desktop logo (animated): #}
+                    {% include "wagtailadmin/shared/animated_logo.html" %}
+                {% endblock %}
+                <span class="u-hidden@medium">{% trans "Dashboard" %}</span>
+            </a>
+
+            {% menu_search %}
+            {% main_nav %}
+
+        </div>
+        <div class="explorer__wrapper" data-explorer-menu></div>
+    </div>
+
+    <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 %}

+ 2 - 2
coderedcms/templates/wagtailadmin/base.html

@@ -1,11 +1,11 @@
-{% extends "wagtailadmin/base.html" %}
+{% extends "wagtailadmin/base.forked.html" %}
 {% load wagtailimages_tags wagtailsettings_tags %}
 
 
 {% 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 Home"/>
+        <img src="{{ logo_image.url }}" alt="Admin Dashboard"/>
     {% else %}
         {{block.super}}
     {% endif %}

+ 2 - 3
coderedcms/templates/wagtailadmin/shared/main_nav.html

@@ -1,5 +1,4 @@
-{% load wagtailadmin_tags static %}
-{% load i18n %}
+{% load wagtailadmin_tags static coderedcms_tags i18n %}
 <nav class="nav-main">
     <ul>
         {{ menu_html }}
@@ -18,7 +17,7 @@
             </ul>
 
             <div class="power-by">
-              <a href="https://github.com/coderedcorp/coderedcms" target="_blank">
+              <a href="https://github.com/coderedcorp/coderedcms" target="_blank" title="CodeRed CMS v {% coderedcms_version %}">
                 powered by <img src="{% static 'img/codered.png' %}" alt="CodeRed" />
               </a>
             </div>

+ 6 - 0
coderedcms/templates/wagtailadmin/shared/menu_settings_menu_item.html

@@ -0,0 +1,6 @@
+{% extends "wagtailadmin/shared/menu_settings_menu_item.html" %}
+{% load coderedcms_tags %}
+
+{% block menu_footer %}
+    <li class="footer"><div class="menu-item"><p class="wagtail-version">CodeRed&nbsp;CMS v&nbsp;{% coderedcms_version %}</p></div></li>
+{% endblock %}

+ 5 - 1
coderedcms/templatetags/coderedcms_tags.py

@@ -9,7 +9,7 @@ from django.utils.formats import localize
 from wagtail.core.models import Collection
 from wagtail.images.models import Image
 
-from coderedcms import utils
+from coderedcms import utils, __version__
 from coderedcms.blocks import CoderedAdvSettings
 from coderedcms.forms import SearchForm
 from coderedcms.models import Footer, Navbar
@@ -43,6 +43,10 @@ def is_advanced_setting(obj):
 def is_file_form(form):
     return any([isinstance(field.field.widget, ClearableFileInput) for field in form])
 
+@register.simple_tag
+def coderedcms_version():
+    return __version__
+
 @register.simple_tag
 def generate_random_id():
     return ''.join(random.choice(string.ascii_letters + string.digits) for n in range(20))

+ 2 - 1
setup.py

@@ -1,5 +1,6 @@
 import os
 from setuptools import find_packages, setup
+from coderedcms import __version__
 
 with open(os.path.join(os.path.dirname(__file__), 'README.md'), encoding='utf8') as readme:
     README = readme.read()
@@ -9,7 +10,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
 
 setup(
     name='coderedcms',
-    version='0.9.1',
+    version=__version__,
     packages=find_packages(),
     include_package_data=True,
     license='BSD License',