Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set favicon default url to /favicon.ico and allow to customize it #713

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion apps/datafeeder/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"tsConfig": "apps/datafeeder/tsconfig.app.json",
"aot": true,
"assets": [
"apps/datafeeder/src/favicon.ico",
"apps/datafeeder/src/assets",
{
"glob": "*",
Expand Down
1 change: 0 additions & 1 deletion apps/datafeeder/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<title>Datafeeder</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&family=Permanent+Marker&display=swap"
Expand Down
1 change: 0 additions & 1 deletion apps/datahub/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"polyfills": "apps/datahub/src/polyfills.ts",
"tsConfig": "apps/datahub/tsconfig.app.json",
"assets": [
"apps/datahub/src/favicon.ico",
"apps/datahub/src/assets",
{
"glob": "*",
Expand Down
20 changes: 18 additions & 2 deletions apps/datahub/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
import { Component } from '@angular/core'
import { Component, OnInit } from '@angular/core'
import { getGlobalConfig } from '@geonetwork-ui/util/app-config'

@Component({
selector: 'datahub-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {}
export class AppComponent implements OnInit {
ngOnInit(): void {
const favicon = getGlobalConfig().FAVICON
if (favicon) this.setFavicon(favicon)
}

private setFavicon(faviconPath: string): void {
const link =
document.querySelector("link[rel*='icon']") ||
document.createElement('link')
link['type'] = 'image/x-icon'
link['rel'] = 'icon'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will make the favicon fail if it is in another format, e.g. PNG; to remove

link['href'] = faviconPath
document.getElementsByTagName('head')[0].appendChild(link)
}
}
Binary file removed apps/datahub/src/assets/favicon.ico
Binary file not shown.
1 change: 0 additions & 1 deletion apps/datahub/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<title>Datahub</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
Expand Down
3 changes: 3 additions & 0 deletions conf/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ proxy_path = ""
# More information about the translation can be found in the docs (https://geonetwork.github.io/geonetwork-ui/main/docs/reference/i18n.html)
# languages = ['en', 'fr', 'de']

# Use it to set custom location for favicon
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Use it to set custom location for favicon
# Use it to set custom location for the favicon; by default, the path `/favicon.ico` will be used

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think this setting should go in the "theme" section

# favicon = "assets/favicon.ico"

### VISUAL THEME

# All parameters are expressed in CSS format, see:
Expand Down
2 changes: 2 additions & 0 deletions libs/util/app-config/src/lib/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export function loadAppConfig() {
'login_url',
'web_component_embedder_url',
'languages',
'favicon',
],
warnings,
errors
Expand All @@ -126,6 +127,7 @@ export function loadAppConfig() {
WEB_COMPONENT_EMBEDDER_URL:
parsedGlobalSection.web_component_embedder_url,
LANGUAGES: parsedGlobalSection.languages,
FAVICON: parsedGlobalSection.favicon,
} as GlobalConfig)

const parsedLayersSections = parseMultiConfigSection(
Expand Down
1 change: 1 addition & 0 deletions libs/util/app-config/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface GlobalConfig {
LOGIN_URL?: string
WEB_COMPONENT_EMBEDDER_URL?: string
LANGUAGES?: string[]
FAVICON?: string
}

export interface LayerConfig {
Expand Down
Loading