[release] version 0.5.0-unstable22

This commit is contained in:
Yann Stepienik 2023-05-16 23:41:31 +01:00
parent 550917bf6e
commit a208be1c8a
8 changed files with 37 additions and 42 deletions

View file

@ -69,4 +69,8 @@
.MuiAlert-icon {
align-items: center;
}
.loading-image {
background: url('/assets/images/icons/cosmos_gray.png') no-repeat center center;
}

View file

@ -38,7 +38,7 @@ const RouteOverview = ({ routeConfig }) => {
</div>}>
<Stack spacing={2} direction={isMobile ? 'column' : 'row'} alignItems={isMobile ? 'center' : 'flex-start'}>
<div>
<img src={getFaviconURL(routeConfig)} width="128px" />
<img className="loading-image" alt="" src={getFaviconURL(routeConfig)} width="128px" />
</div>
<Stack spacing={2} >
<strong>Description</strong>

View file

@ -154,7 +154,7 @@ const ProxyManagement = () => {
columns={[
{
title: '',
field: (r) => <img src={getFaviconURL(r)} width="64px" />,
field: (r) => <img className="loading-image" alt="" src={getFaviconURL(r)} width="64px" />,
style: {
textAlign: 'center',
},

View file

@ -147,7 +147,7 @@ const HomePage = () => {
<Box className='app' style={{ padding: 10, color: 'white', background: 'rgba(0,0,0,0.35)', borderRadius: 5 }}>
<Link to={getFullOrigin(route)} target="_blank" style={{ textDecoration: 'none', color: 'white' }}>
<Stack direction="row" spacing={2} alignItems="center">
<img src={getFaviconURL(route)} width="64px" />
<img className="loading-image" alt="" src={getFaviconURL(route)} width="64px" height="64px"/>
<div style={{ width: '100%' }}>
<h3 style={blockStyle}>{route.Name}</h3>

View file

@ -66,7 +66,7 @@ const ContainerOverview = ({ containerInfo, config, refresh }) => {
<Stack spacing={2} direction={isMobile ? 'column' : 'row'} alignItems={isMobile ? 'center' : 'flex-start'}>
<Stack spacing={2} direction={'column'} justifyContent={'center'} alignItems={'center'}>
<div style={{ position: 'relative' }}>
<img className={isUpdating ? 'darken' : ''} src={getFaviconURL(routes && routes[0])} width="128px" />
<img className={"loading-image " + (isUpdating ? 'darken' : '')} alt="" src={getFaviconURL(routes && routes[0])} width="128px" />
{isUpdating ? (
<CircularProgress
style={{ position: 'absolute', top: 'calc(50% - 22.5px)', left: 'calc(50% - 22.5px)' }}

View file

@ -182,7 +182,7 @@ const ServeApps = () => {
}
</Typography>
<Stack direction="row" spacing={2} alignItems="center">
<img src={getFirstRouteFavIcon(app)} width="40px" />
<img className="loading-image" alt="" src={getFirstRouteFavIcon(app)} width="40px" />
<Stack direction="column" spacing={0} alignItems="flex-start" style={{height: '40px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'no-wrap'}}>
<Typography variant="h5" color="text.secondary">
{app.Names[0].replace('/', '')}&nbsp;

View file

@ -1,6 +1,6 @@
{
"name": "cosmos-server",
"version": "0.5.0-unstable21",
"version": "0.5.0-unstable22",
"description": "",
"main": "test-server.js",
"bugs": {

View file

@ -8,7 +8,6 @@ import (
"os"
"io/ioutil"
"encoding/json"
"strconv"
"path"
"go.deanishe.net/favicon"
@ -81,41 +80,34 @@ func GetFavicon(w http.ResponseWriter, req *http.Request) {
return
}
var icons []*favicon.Icon
// follow siteurl and check if any redirect.
respNew, err := http.Get(siteurl)
if err != nil {
utils.Error("FaviconFetch", err)
sendFallback(w)
return
icons = []*favicon.Icon{
&favicon.Icon{URL: "favicon.png", Width: 0},
&favicon.Icon{URL: "/favicon.png", Width: 0},
&favicon.Icon{URL: "favicon.ico", Width: 0},
&favicon.Icon{URL: "/favicon.ico", Width: 0},
}
} else {
siteurl = respNew.Request.URL.String()
icons, err = favicon.Find(siteurl)
if err != nil || len(icons) == 0 {
icons = []*favicon.Icon{
&favicon.Icon{URL: "favicon.png", Width: 0},
&favicon.Icon{URL: "/favicon.png", Width: 0},
&favicon.Icon{URL: "favicon.ico", Width: 0},
&favicon.Icon{URL: "/favicon.ico", Width: 0},
}
}
}
newsiteurl := respNew.Request.URL.String()
icons, err := favicon.Find(newsiteurl)
utils.Debug("Found Favicon: " + strconv.Itoa(len(icons)))
if err != nil {
utils.Error("FaviconFetch", err)
sendFallback(w)
return
}
if len(icons) == 0 {
utils.Error("FaviconFetch", err)
sendFallback(w)
return
}
// if !strings.Contains(icons[iconIndex].URL, "favicon.ico") {
// icons = append(icons, favicon.Icon{URL: "favicon.ico", Width: 0})
// }
// if !strings.Contains(icons[iconIndex].URL, "/favicon.ico") {
// icons = append(icons, favicon.Icon{URL: "/favicon.ico", Width: 0})
// }
for _, icon := range icons {
utils.Debug("Favicon Width: " + icon.URL + " " + strconv.Itoa(icon.Width))
if icon.Width <= 256 {
iconURL := icon.URL
@ -145,6 +137,7 @@ func GetFavicon(w http.ResponseWriter, req *http.Request) {
}
utils.Log("Favicon Trying to fetch " + iconURL)
// Fetch the favicon
resp, err := http.Get(iconURL)
if err != nil {
@ -165,9 +158,8 @@ func GetFavicon(w http.ResponseWriter, req *http.Request) {
// Cache the response
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
utils.Error("FaviconFetch", err)
sendFallback(w)
return
utils.Error("FaviconFetch - cant read ", err)
continue
}
finalImage := CachedImage{
@ -181,12 +173,11 @@ func GetFavicon(w http.ResponseWriter, req *http.Request) {
sendImage(w, cache[siteurl])
return
}
utils.Log("Favicon final fallback ")
sendFallback(w)
return
}
}
utils.Log("Favicon final fallback")
sendFallback(w)
return
} else {
utils.Error("Favicon: Method not allowed" + req.Method, nil)