[release] version 0.5.0-unstable22
This commit is contained in:
parent
550917bf6e
commit
a208be1c8a
|
@ -70,3 +70,7 @@
|
||||||
.MuiAlert-icon {
|
.MuiAlert-icon {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loading-image {
|
||||||
|
background: url('/assets/images/icons/cosmos_gray.png') no-repeat center center;
|
||||||
|
}
|
|
@ -38,7 +38,7 @@ const RouteOverview = ({ routeConfig }) => {
|
||||||
</div>}>
|
</div>}>
|
||||||
<Stack spacing={2} direction={isMobile ? 'column' : 'row'} alignItems={isMobile ? 'center' : 'flex-start'}>
|
<Stack spacing={2} direction={isMobile ? 'column' : 'row'} alignItems={isMobile ? 'center' : 'flex-start'}>
|
||||||
<div>
|
<div>
|
||||||
<img src={getFaviconURL(routeConfig)} width="128px" />
|
<img className="loading-image" alt="" src={getFaviconURL(routeConfig)} width="128px" />
|
||||||
</div>
|
</div>
|
||||||
<Stack spacing={2} >
|
<Stack spacing={2} >
|
||||||
<strong>Description</strong>
|
<strong>Description</strong>
|
||||||
|
|
|
@ -154,7 +154,7 @@ const ProxyManagement = () => {
|
||||||
columns={[
|
columns={[
|
||||||
{
|
{
|
||||||
title: '',
|
title: '',
|
||||||
field: (r) => <img src={getFaviconURL(r)} width="64px" />,
|
field: (r) => <img className="loading-image" alt="" src={getFaviconURL(r)} width="64px" />,
|
||||||
style: {
|
style: {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
},
|
},
|
||||||
|
|
|
@ -147,7 +147,7 @@ const HomePage = () => {
|
||||||
<Box className='app' style={{ padding: 10, color: 'white', background: 'rgba(0,0,0,0.35)', borderRadius: 5 }}>
|
<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' }}>
|
<Link to={getFullOrigin(route)} target="_blank" style={{ textDecoration: 'none', color: 'white' }}>
|
||||||
<Stack direction="row" spacing={2} alignItems="center">
|
<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%' }}>
|
<div style={{ width: '100%' }}>
|
||||||
<h3 style={blockStyle}>{route.Name}</h3>
|
<h3 style={blockStyle}>{route.Name}</h3>
|
||||||
|
|
|
@ -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={isMobile ? 'column' : 'row'} alignItems={isMobile ? 'center' : 'flex-start'}>
|
||||||
<Stack spacing={2} direction={'column'} justifyContent={'center'} alignItems={'center'}>
|
<Stack spacing={2} direction={'column'} justifyContent={'center'} alignItems={'center'}>
|
||||||
<div style={{ position: 'relative' }}>
|
<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 ? (
|
{isUpdating ? (
|
||||||
<CircularProgress
|
<CircularProgress
|
||||||
style={{ position: 'absolute', top: 'calc(50% - 22.5px)', left: 'calc(50% - 22.5px)' }}
|
style={{ position: 'absolute', top: 'calc(50% - 22.5px)', left: 'calc(50% - 22.5px)' }}
|
||||||
|
|
|
@ -182,7 +182,7 @@ const ServeApps = () => {
|
||||||
}
|
}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Stack direction="row" spacing={2} alignItems="center">
|
<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'}}>
|
<Stack direction="column" spacing={0} alignItems="flex-start" style={{height: '40px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'no-wrap'}}>
|
||||||
<Typography variant="h5" color="text.secondary">
|
<Typography variant="h5" color="text.secondary">
|
||||||
{app.Names[0].replace('/', '')}
|
{app.Names[0].replace('/', '')}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cosmos-server",
|
"name": "cosmos-server",
|
||||||
"version": "0.5.0-unstable21",
|
"version": "0.5.0-unstable22",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "test-server.js",
|
"main": "test-server.js",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
57
src/icons.go
57
src/icons.go
|
@ -8,7 +8,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"strconv"
|
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"go.deanishe.net/favicon"
|
"go.deanishe.net/favicon"
|
||||||
|
@ -81,41 +80,34 @@ func GetFavicon(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var icons []*favicon.Icon
|
||||||
|
|
||||||
// follow siteurl and check if any redirect.
|
// follow siteurl and check if any redirect.
|
||||||
respNew, err := http.Get(siteurl)
|
respNew, err := http.Get(siteurl)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Error("FaviconFetch", err)
|
utils.Error("FaviconFetch", err)
|
||||||
sendFallback(w)
|
icons = []*favicon.Icon{
|
||||||
return
|
&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)
|
||||||
|
|
||||||
newsiteurl := respNew.Request.URL.String()
|
if err != nil || len(icons) == 0 {
|
||||||
|
icons = []*favicon.Icon{
|
||||||
icons, err := favicon.Find(newsiteurl)
|
&favicon.Icon{URL: "favicon.png", Width: 0},
|
||||||
|
&favicon.Icon{URL: "/favicon.png", Width: 0},
|
||||||
utils.Debug("Found Favicon: " + strconv.Itoa(len(icons)))
|
&favicon.Icon{URL: "favicon.ico", Width: 0},
|
||||||
if err != nil {
|
&favicon.Icon{URL: "/favicon.ico", Width: 0},
|
||||||
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 {
|
for _, icon := range icons {
|
||||||
utils.Debug("Favicon Width: " + icon.URL + " " + strconv.Itoa(icon.Width))
|
|
||||||
if icon.Width <= 256 {
|
if icon.Width <= 256 {
|
||||||
|
|
||||||
iconURL := icon.URL
|
iconURL := icon.URL
|
||||||
|
@ -145,6 +137,7 @@ func GetFavicon(w http.ResponseWriter, req *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.Log("Favicon Trying to fetch " + iconURL)
|
utils.Log("Favicon Trying to fetch " + iconURL)
|
||||||
|
|
||||||
// Fetch the favicon
|
// Fetch the favicon
|
||||||
resp, err := http.Get(iconURL)
|
resp, err := http.Get(iconURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -165,9 +158,8 @@ func GetFavicon(w http.ResponseWriter, req *http.Request) {
|
||||||
// Cache the response
|
// Cache the response
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Error("FaviconFetch", err)
|
utils.Error("FaviconFetch - cant read ", err)
|
||||||
sendFallback(w)
|
continue
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finalImage := CachedImage{
|
finalImage := CachedImage{
|
||||||
|
@ -181,12 +173,11 @@ func GetFavicon(w http.ResponseWriter, req *http.Request) {
|
||||||
sendImage(w, cache[siteurl])
|
sendImage(w, cache[siteurl])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
utils.Log("Favicon final fallback ")
|
}
|
||||||
|
utils.Log("Favicon final fallback")
|
||||||
sendFallback(w)
|
sendFallback(w)
|
||||||
return
|
return
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
utils.Error("Favicon: Method not allowed" + req.Method, nil)
|
utils.Error("Favicon: Method not allowed" + req.Method, nil)
|
||||||
|
|
Loading…
Reference in a new issue