Add Dashboard Icons integration

This commit is contained in:
Dale Davies
2023-04-15 14:50:06 +01:00
parent a7e371d3bd
commit 5c652b454e
2 changed files with 16 additions and 16 deletions

View File

@@ -71,11 +71,20 @@ class Site {
'timeout' => 86400
]);
$rawimage = $favicon->get($this->url, \Favicon\FaviconDLType::RAW_IMAGE);
if (!$rawimage) {
$rawimage = file_get_contents($defaulticon);
}
} else {
$rawimage = file_get_contents($this->config->get('sitesdir').'/icons/'.$this->iconname);
// If the icon name has a file extension the n try to retrieve it locally, otherwise
// see if we can get it from Dashboard Icons.
if (pathinfo($this->iconname, PATHINFO_EXTENSION)) {
$file = $this->config->get('sitesdir').'/icons/'.$this->iconname;
} else {
$file = 'https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/svg/'.$this->iconname.'.svg';
}
$rawimage = file_get_contents($file);
}
// If we didnt manage to get any icon data from any of the above methods then return
// the default icon.
if (!$rawimage) {
$rawimage = file_get_contents($defaulticon);
}
$imagedata = new stdClass();
$imagedata->mimetype = (new \finfo(FILEINFO_MIME_TYPE))->buffer($rawimage);

View File

@@ -5,27 +5,18 @@
"newtab": false
},
"sites": [
{
"name": "Github",
"url" : "https://github.com/daledavies/jump",
"description": "This is an example description",
"nofollow": false,
"newtab": true
},
{
"name": "Docker Hub",
"url" : "https://hub.docker.com/r/daledavies/jump"
},
{
"name": "Bitwarden",
"url" : "https://bitwarden.com/",
"description": "This is another example of a site with a description",
"icon": "bitwarden.png",
"icon": "bitwarden",
"tags": ["stuff"]
},
{
"name": "Gitea",
"url" : "https://git.example.com",
"description": "This uses an icon from the Dashboard Icons repository",
"icon": "gitea.png",
"tags": ["stuff"]
},