Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

:sparkles: Re: #196 - Adds option for different favicon API for each app

Alicia Sykesb756e65d2ebe
diff --git a/docs/icons.md b/docs/icons.md
index 668233ed..ceea692b 100644
--- a/docs/icons.md
+++ b/docs/icons.md
@@ -42,6 +42,10 @@ The default favicon API is [Favicon Kit](https://faviconkit.com/), a free and re
You can also force Dashy to always get favicons from the root of the domain, and not use an external service, by setting `appConfig.faviconApi` to `local`.
+To use a different favicon API for certain items, then set `icon: favicon-[api]`, e.g. `favicon-clearbit`
+
+If for a given service none of the APIs work in your situation, and nor does local, then the best option is to find the path of the services logo or favicon, and set the icon to the URL of the raw image.
+
### Generative Icons
Uses a unique and programmatically generated icon for a given service. This is particularly useful when you have a lot of similar services with a different IP or port, and no specific icon. These icons are generated with [ipsicon.io](https://ipsicon.io/). To use this option, just set an item's to: `icon: generative`.
diff --git a/src/components/LinkItems/ItemIcon.vue b/src/components/LinkItems/ItemIcon.vue
index c4b503ae..6f7c392b 100644
--- a/src/components/LinkItems/ItemIcon.vue
+++ b/src/components/LinkItems/ItemIcon.vue
@@ -89,18 +89,32 @@ export default {
return emojiCode; // Emoji is a glyph already, just return
},
/* Get favicon URL, for items which use the favicon as their icon */
- getFavicon(fullUrl) {
+ getFavicon(fullUrl, specificApi) {
if (this.shouldUseDefaultFavicon(fullUrl)) { // Check if we should use local icon
const urlParts = fullUrl.split('/');
if (urlParts.length >= 2) return `${urlParts[0]}/${urlParts[1]}/${urlParts[2]}/${iconCdns.faviconName}`;
} else if (fullUrl.includes('http')) { // Service is running publicly
const host = this.getHostName(fullUrl);
- const faviconApi = this.config.appConfig.faviconApi || defaultFaviconApi;
+ const faviconApi = specificApi || this.config.appConfig.faviconApi || defaultFaviconApi;
const endpoint = faviconApiEndpoints[faviconApi];
return endpoint.replace('$URL', host);
}
return '';
},
+ /* Get the URL for a favicon, but using the non-default favicon API */
+ getCustomFavicon(fullUrl, faviconIdentifier) {
+ const faviconApi = faviconIdentifier.split('favicon-')[1];
+ if (!faviconApi) {
+ ErrorHandler('Favicon API not specified');
+ } else if (!Object.keys(faviconApiEndpoints).includes(faviconApi)) {
+ ErrorHandler(`The specified favicon API, '${faviconApi}' cannot be found.`);
+ } else {
+ return this.getFavicon(fullUrl, faviconApi);
+ }
+ // Error encountered, favicon service not found
+ this.broken = true;
+ return undefined;
+ },
/* If using favicon for icon, and if service is running locally (determined by local IP) */
/* or if user prefers local favicon, then return true */
shouldUseDefaultFavicon(fullUrl) {
@@ -127,6 +141,7 @@ export default {
case 'url': return img;
case 'img': return this.getLocalImagePath(img);
case 'favicon': return this.getFavicon(url);
+ case 'custom-favicon': return this.getCustomFavicon(url, img);
case 'generative': return this.getGenerativeIcon(url);
case 'mdi': return img; // Material design icons
case 'simple-icons': return this.getSimpleIcon(img);
@@ -145,6 +160,7 @@ export default {
else if (img.includes('fa-')) imgType = 'font-awesome';
else if (img.includes('mdi-')) imgType = 'mdi';
else if (img.includes('si-')) imgType = 'si';
+ else if (img.includes('favicon-')) imgType = 'custom-favicon';
else if (img === 'favicon') imgType = 'favicon';
else if (img === 'generative') imgType = 'generative';
else if (this.isEmoji(img).isEmoji) imgType = 'emoji';