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

Conversation

f-necas
Copy link
Collaborator

@f-necas f-necas commented Dec 5, 2023

The default favicon points to /assets/favicon.ico. As favicon is often provided in root, it's useful to have it there.

Copy link
Contributor

github-actions bot commented Dec 5, 2023

Affected libs: util-app-config, feature-record, feature-router, feature-map, feature-dataviz, util-shared, feature-search, ui-elements, feature-catalog, ui-catalog, ui-search, ui-widgets, feature-editor, ui-inputs,
Affected apps: datafeeder, datahub, metadata-editor, demo, webcomponents, search, map-viewer, metadata-converter,

  • 🚀 Build and deploy storybook and demo on GitHub Pages
  • 📦 Build and push affected docker images

@coveralls
Copy link

coveralls commented Dec 5, 2023

Coverage Status

coverage: 82.622% (-3.8%) from 86.396%
when pulling 2e5e813 on favicon
into 173df65 on main.

@f-necas f-necas requested a review from jahow December 5, 2023 08:26
Copy link
Member

@fgravin fgravin left a comment

Choose a reason for hiding this comment

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

Could you give more context ?
Who can't put the favicon in the assets ?
Note that it will break all actual configs.

@jahow
Copy link
Collaborator

jahow commented Dec 6, 2023

This is unfortunately susceptible to break all existing favicons. I would rather look for a way to customize the favicon path, for instance on the docker image startup by rewriting parts of the HTML, like we do for adding preload links here:

# check whether the $CUSTOM_ASSETS_PATH directory is present and not empty
if [ -d "${CUSTOM_ASSETS_PATH}" ] && [ "$(ls -A ${CUSTOM_ASSETS_PATH})" ]; then
files_count=$(find ${CUSTOM_ASSETS_PATH} -type f | wc -l)
# copy assets right away
echo "[INFO] Copying ${files_count} custom assets found in ${CUSTOM_ASSETS_PATH}..."
cp ${CUSTOM_ASSETS_PATH}. -r ${APP_FILES_PATH}${ASSETS_PATH}
# add a preload link for each asset that is an image
cd ${CUSTOM_ASSETS_PATH}
images=$(find . -type f -a \( -iname "*.png" -o -iname "*.svg" -o -iname "*.webp" -o -iname "*.jpg" -o -iname "*.jpeg" \))
for image in ${images}
do
echo "[INFO] Adding preload link for ${image}..."
sed -i "s@<!--%PRELOAD_LINKS%-->@<!--%PRELOAD_LINKS%-->\n<link rel=\"preload\" href=\"assets/${image}\" as=\"image\" importance=\"high\" />@" \
${APP_FILES_PATH}index.html
done
else
echo "[INFO] No custom assets found at ${CUSTOM_ASSETS_PATH}"
fi

Outside of a docker usage, I feel like having a favicon point to the correct place should be easier.

@f-necas
Copy link
Collaborator Author

f-necas commented Jan 3, 2024

@jahow Is it ok, if we remove it like this ?

@f-necas f-necas requested a review from fgravin January 3, 2024 13:09
@jahow
Copy link
Collaborator

jahow commented Jan 8, 2024

I'm sorry for all the back and forth on this issue, but I think we shouldn't merge it like that.

The way I see it currently, we should:

  1. remove the favicon like in this PR
  2. add an option in the config file to point to a place for a custom favicon if none is available at /favicon.ico; this is e.g. the case for www.geocat.ch, which gives a 404 for https://www.geocat.ch/favicon.ico

Otherwise we're losing functionality

Revert "feat: allowing larger default integration for datahub's favicon and ME"

This reverts commit 4f960614417ab2ba96f84ea482d107d88fe03f7a.

feat: remove favicon in datafeeder and datahub
@f-necas
Copy link
Collaborator Author

f-necas commented Jan 8, 2024

@jahow I've added the possibility to implement it from toml file.

@jahow jahow added this to the 2.2.0 milestone Jan 8, 2024
@jahow jahow added the breaking change Requires an adaptation by the user to keep feature parity label Jan 8, 2024
Copy link
Collaborator

@jahow jahow left a comment

Choose a reason for hiding this comment

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

This looks better now, thanks! I've left some comments, please wait for 2.1 to be out before merging this.

I added a "breaking change" label so that we can remember that this new setting will be mandatory for people that don't have a favicon at their website's root. Please also update the PR title accordingly, so that it makes sense when it shows up in the changelog 🙂 thanks!

Comment on lines 15 to 24
private setFavicon(faviconPath: string): void {
const link =
document.querySelector("link[rel*='icon']") ||
document.createElement('link')
link['type'] = 'image/x-icon'
link['rel'] = 'icon'
link['href'] = faviconPath
document.getElementsByTagName('head')[0].appendChild(link)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -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

const link =
document.querySelector("link[rel*='icon']") ||
document.createElement('link')
link['type'] = 'image/x-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

@f-necas f-necas requested a review from jahow January 8, 2024 16:43
@f-necas f-necas changed the title Allowing larger default integration for datahub's favicon and ME Set favicon default url to /favicon.ico and make it customizable Jan 8, 2024
@f-necas f-necas changed the title Set favicon default url to /favicon.ico and make it customizable Set favicon default url to /favicon.ico and allow to customize it Jan 8, 2024
Copy link
Collaborator

@jahow jahow left a comment

Choose a reason for hiding this comment

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

All good thanks!

@f-necas f-necas merged commit ed6fbd6 into main Jan 9, 2024
7 checks passed
@f-necas f-necas deleted the favicon branch January 9, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Requires an adaptation by the user to keep feature parity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants