Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
},
"homepage": "https://github.com/TACC/Core-CMS",
"devDependencies": {
"@tacc/core-styles": "^2.57.0"
"@tacc/core-styles": "github:TACC/core-styles#850bb31"
}
}
1 change: 1 addition & 0 deletions taccsite_cms/_settings/djangocms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
]
DJANGOCMS_PICTURE_TEMPLATES = [
('no_link_to_ext_image', _('Do not link to external image')),
('portal_logo', _('Portal logo')),
]

########################
Expand Down
13 changes: 7 additions & 6 deletions taccsite_cms/contrib/taccsite_header_logo/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@

from .forms import HeaderLogoForm

HEADER_LOGO_ELEMENT_ID = 'header-logo'
HEADER_LOGO_LINK_CLASS = 'navbar-brand'


@plugin_pool.register_plugin
class HeaderLogoPlugin(PicturePlugin):
"""
Header > "Header logo" plugin

Full Picture plugin; default id="header-logo" when not set in Attributes.
Header > "Header logo" (Picture) plugin
"""
model = Picture
form = HeaderLogoForm
Expand All @@ -24,6 +22,9 @@ class HeaderLogoPlugin(PicturePlugin):
def render(self, context, instance, placeholder):
if not instance.attributes:
instance.attributes = {}
if 'id' not in instance.attributes:
instance.attributes['id'] = HEADER_LOGO_ELEMENT_ID

# To add required attributes
existing_class = instance.attributes.get('class', '')
instance.attributes['class'] = f'{HEADER_LOGO_LINK_CLASS} {existing_class}'.strip()

return super().render(context, instance, placeholder)
14 changes: 7 additions & 7 deletions taccsite_cms/contrib/taccsite_header_logo/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from cms.models import Page
from django.conf import settings
from django.contrib.sites.models import Site
from djangocms_picture.forms import PictureForm

HEADER_LOGO_PICTURE_TEMPLATE = 'portal_logo'


def default_home_page():
site = Site.objects.get_current()
Expand All @@ -12,23 +15,20 @@ class HeaderLogoForm(PictureForm):
"""
Defaults for new Header logo plugins only (admin add form).

With a link, TACC default picture.html puts Attributes (e.g. class mr-5) on
the <a>, not the <img>.
On a TACC/Core-Portal instance, defaults to Portal logo picture template.
"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.instance.pk:
return

if settings.PORTAL_IS_TACC_CORE_PORTAL:
self.initial.setdefault('template', HEADER_LOGO_PICTURE_TEMPLATE)

home = default_home_page()
if home is not None:
self.initial.setdefault('link_page', home.pk)

self.initial.setdefault('height', 50)
self.initial.setdefault('use_no_cropping', True)
self.initial.setdefault('use_automatic_scaling', False)

attributes = dict(self.initial.get('attributes') or {})
attributes.setdefault('class', 'mr-5')
self.initial['attributes'] = attributes
3 changes: 3 additions & 0 deletions taccsite_cms/templates/djangocms_picture/default/picture.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
{# /TACC #}
{% endblock %}
{# /TACC #}
{# TACC (allow attributes to be force-added to <img>): #}
{% block picture_attributes_img %}{% endblock %}
{# /TACC #}
>
{% endlocalize %}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% extends "djangocms_picture/default/picture.html" %}
{% block picture_attributes_img %}class="portal-logo"{% endblock %}
6 changes: 2 additions & 4 deletions taccsite_cms/templates/header_logo_via_settings.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{# @var className #}
{% load static custom_portal_settings %}

{% if settings.LOGO %}
Expand All @@ -7,7 +6,7 @@
{% with settings.LOGO as logo %}
{% with filename=logo|index:1 selectors=logo|index:2 targeturl=logo|index:3 targettype=logo|index:4 accessibility=logo|index:5 corstype=logo|index:6 visibility=logo|index:7 %}
{% if visibility == "True" %}
<a id="header-logo" class="navbar-brand {{className}}" href="{{ targeturl }}" target="{{ targettype }}">
<a class="navbar-brand" href="{{ targeturl }}" target="{{ targettype }}">
<img class="portal-logo {{ selectors }}" src="{% static filename %}" crossorigin="{{ corstype }}" alt="{{ accessibility }}" />
</a>
{% endif %}
Expand All @@ -19,8 +18,7 @@
{# via CMS setting (e.g. CMS developer sets logo image) #}
{% with settings.PORTAL_LOGO as logo %}
<a
id="header-logo"
class="navbar-brand {{className}}"
class="navbar-brand"
href="{{ logo.link_href }}"
{% if logo.link_target %}
target="{{ logo.link_target }}"
Expand Down