From 893a306da066d18064fe9e9ae0b75d1454261d12 Mon Sep 17 00:00:00 2001 From: Bruno Roemers Date: Wed, 24 Nov 2021 12:18:45 +0100 Subject: [PATCH] 85123: Fallback to favicon of default theme and src/assets/images/favicon.ico --- src/app/app.component.ts | 38 +++++++++++++++++++++++++++------- src/assets/images/favicon.ico | Bin 0 -> 15086 bytes 2 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 src/assets/images/favicon.ico diff --git a/src/app/app.component.ts b/src/app/app.component.ts index f138753596..9dc2b5a5ab 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -31,7 +31,7 @@ import { AuthService } from './core/auth/auth.service'; import { CSSVariableService } from './shared/sass-helper/sass-helper.service'; import { MenuService } from './shared/menu/menu.service'; import { HostWindowService } from './shared/host-window.service'; -import {HeadTagConfig, ThemeConfig} from '../config/theme.model'; +import { HeadTagConfig, ThemeConfig } from '../config/theme.model'; import { Angulartics2DSpace } from './statistics/angulartics/dspace-provider'; import { environment } from '../environments/environment'; import { models } from './core/core.module'; @@ -292,20 +292,44 @@ export class AppComponent implements OnInit, AfterViewInit { const themeConfig = this.themeService.getThemeConfigFor(themeName); const headTagConfigs = themeConfig?.headTags; - // if the current theme does not have head tags, we inherit the head tags of the parent if (isEmpty(headTagConfigs)) { const parentThemeName = themeConfig.extends; - return isNotEmpty(parentThemeName) ? this.createHeadTags(parentThemeName) : []; + if (isNotEmpty(parentThemeName)) { + // inherit the head tags of the parent theme + return this.createHeadTags(parentThemeName); + } + + const defaultThemeName = DEFAULT_THEME_CONFIG.name; + if ( + isEmpty(defaultThemeName) || + themeName === defaultThemeName || + themeName === BASE_THEME_NAME + ) { + // last resort, use fallback favicon.ico + return [ + this.createHeadTag({ + 'tagName': 'link', + 'attributes': { + 'rel': 'icon', + 'href': 'assets/images/favicon.ico', + 'sizes': 'any', + } + }) + ]; + } + + // inherit the head tags of the default theme + return this.createHeadTags(DEFAULT_THEME_CONFIG.name); } return headTagConfigs.map(this.createHeadTag.bind(this)); } - private createHeadTag(themeHeadTag: HeadTagConfig): HTMLElement { - const tag = this.document.createElement(themeHeadTag.tagName); + private createHeadTag(headTagConfig: HeadTagConfig): HTMLElement { + const tag = this.document.createElement(headTagConfig.tagName); - if (isNotEmpty(themeHeadTag.attributes)) { - Object.entries(themeHeadTag.attributes) + if (isNotEmpty(headTagConfig.attributes)) { + Object.entries(headTagConfig.attributes) .forEach(([key, value]) => tag.setAttribute(key, value)); } diff --git a/src/assets/images/favicon.ico b/src/assets/images/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..a5dfd5e3226ca4dd5990a674f5b053afbe1f4d38 GIT binary patch literal 15086 zcmdU$50F(=9mnso$TR=2s3;)Nt|>}tfn!RcvVi8K*jSoY4mn!XXpQ~BY&3QDG0vDx z777`El8nm6X-1m_6U&LUF)PQ)NFhTBBh4fgp=_0v*XMip{$7W(=iYbkdv9U)&3yKE z?(h80@Ao_B-h1x3=Ry>M)#10^{4EEalV8Cs2%Zb{W?NJ)+XMMq zPS2C)#n9@f`(1Huwj)G1AJq7djiv|51F@e1^IG$tvS(7)*l)LGyoF?xtUXjmF20i^^AM`<|?v z>Z!x$c=$<z*AsY}5L-kha6>$up}BK92$2A8B!=*E;62pzAoxE~`%S*{rNw z>aD}?XF$*2toV0Re-zvUMdtwX`#aiBsW;EGcKAF3o&k#!l255UHf?Ywd>phsHs(?O z9NYpAL)x{bbNyi`wDwKQJ;`Yw{M`$oyiK<~%ZFR1+(3O?1)(+HYv|X)^`O4Y@tDo= zXxC@0GWL2muv|m(&00SEdi;%q8zAd?({-ypy7X{-AB^*TrX6Fe^B&5(s!MB|rN?Ip zH1|~fjgS5FY>2$zAiljcpz|n8v?cFn9HDP~=Y@TAw^I6!RzN{a|Swxoge) z(X2V&t;4qI&o6u)0^fkwA#}a#-AQ$tS6#MqthM@KZjM=HY@3olep*0zp9jAHjiaBt z^3&Q*>(#TN6J{i+JPq2i^7ZSmUjlv{_qbPWu+clVa{D}d!9(lG74UmVT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