diff --git a/package-lock.json b/package-lock.json index 1031dc2aa..32ad80a10 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "minimist": "^1.2.6" }, "devDependencies": { - "@tacc/core-styles": "^2.57.0" + "@tacc/core-styles": "github:TACC/core-styles#850bb31" }, "engines": { "node": ">=20", @@ -1511,8 +1511,7 @@ }, "node_modules/@tacc/core-styles": { "version": "2.57.0", - "resolved": "https://registry.npmjs.org/@tacc/core-styles/-/core-styles-2.57.0.tgz", - "integrity": "sha512-MRYts9CdayXrlJfLPRO1fBiWIicNFFoUs4h0lUbcsl8PAT9/YZU3bjY1TzcCe36OUUxi1ENjciU348LTa7EXcQ==", + "resolved": "git+ssh://git@github.com/TACC/core-styles.git#850bb31b2c4fda66c649a7f764bd811c49afab40", "dev": true, "license": "MIT", "bin": { @@ -5747,10 +5746,9 @@ } }, "@tacc/core-styles": { - "version": "2.57.0", - "resolved": "https://registry.npmjs.org/@tacc/core-styles/-/core-styles-2.57.0.tgz", - "integrity": "sha512-MRYts9CdayXrlJfLPRO1fBiWIicNFFoUs4h0lUbcsl8PAT9/YZU3bjY1TzcCe36OUUxi1ENjciU348LTa7EXcQ==", + "version": "git+ssh://git@github.com/TACC/core-styles.git#850bb31b2c4fda66c649a7f764bd811c49afab40", "dev": true, + "from": "@tacc/core-styles@github:TACC/core-styles#850bb31", "requires": {} }, "ansi-regex": { diff --git a/package.json b/package.json index ba720132b..ae2627081 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/taccsite_cms/_settings/djangocms_plugins.py b/taccsite_cms/_settings/djangocms_plugins.py index 8c54345c5..40ead9e43 100644 --- a/taccsite_cms/_settings/djangocms_plugins.py +++ b/taccsite_cms/_settings/djangocms_plugins.py @@ -41,6 +41,7 @@ ] DJANGOCMS_PICTURE_TEMPLATES = [ ('no_link_to_ext_image', _('Do not link to external image')), + ('portal_logo', _('Portal logo')), ] ######################## diff --git a/taccsite_cms/contrib/taccsite_header_logo/cms_plugins.py b/taccsite_cms/contrib/taccsite_header_logo/cms_plugins.py index 25dc0470b..4d91e8ad8 100644 --- a/taccsite_cms/contrib/taccsite_header_logo/cms_plugins.py +++ b/taccsite_cms/contrib/taccsite_header_logo/cms_plugins.py @@ -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 @@ -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) diff --git a/taccsite_cms/contrib/taccsite_header_logo/forms.py b/taccsite_cms/contrib/taccsite_header_logo/forms.py index 787b9a680..2692dad83 100644 --- a/taccsite_cms/contrib/taccsite_header_logo/forms.py +++ b/taccsite_cms/contrib/taccsite_header_logo/forms.py @@ -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() @@ -12,8 +15,7 @@ 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 , not the . + On a TACC/Core-Portal instance, defaults to Portal logo picture template. """ def __init__(self, *args, **kwargs): @@ -21,14 +23,12 @@ def __init__(self, *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 diff --git a/taccsite_cms/templates/djangocms_picture/default/picture.html b/taccsite_cms/templates/djangocms_picture/default/picture.html index c082c6222..3f7ccc687 100644 --- a/taccsite_cms/templates/djangocms_picture/default/picture.html +++ b/taccsite_cms/templates/djangocms_picture/default/picture.html @@ -66,6 +66,9 @@ {# /TACC #} {% endblock %} {# /TACC #} + {# TACC (allow attributes to be force-added to ): #} + {% block picture_attributes_img %}{% endblock %} + {# /TACC #} > {% endlocalize %} diff --git a/taccsite_cms/templates/djangocms_picture/portal_logo/picture.html b/taccsite_cms/templates/djangocms_picture/portal_logo/picture.html new file mode 100644 index 000000000..03e6af734 --- /dev/null +++ b/taccsite_cms/templates/djangocms_picture/portal_logo/picture.html @@ -0,0 +1,2 @@ +{% extends "djangocms_picture/default/picture.html" %} +{% block picture_attributes_img %}class="portal-logo"{% endblock %} diff --git a/taccsite_cms/templates/header_logo_via_settings.html b/taccsite_cms/templates/header_logo_via_settings.html index 12e3233fb..55b432de9 100644 --- a/taccsite_cms/templates/header_logo_via_settings.html +++ b/taccsite_cms/templates/header_logo_via_settings.html @@ -1,4 +1,3 @@ -{# @var className #} {% load static custom_portal_settings %} {% if settings.LOGO %} @@ -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" %} - {% endif %} @@ -19,8 +18,7 @@ {# via CMS setting (e.g. CMS developer sets logo image) #} {% with settings.PORTAL_LOGO as logo %}