Fix unfurl fallback img routes
This commit is contained in:
parent
063d7e96a1
commit
6946bc9da9
@ -250,8 +250,8 @@ class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!img) {
|
if (!img) {
|
||||||
// proxy fallback image from the frontend
|
// send local fallback image file
|
||||||
res.sendFile(nodejsPath.join(__dirname, matchedRoute.fallbackImg));
|
res.sendFile(nodejsPath.join(__dirname, matchedRoute.fallbackFile));
|
||||||
} else {
|
} else {
|
||||||
res.contentType('image/png');
|
res.contentType('image/png');
|
||||||
res.send(img);
|
res.send(img);
|
||||||
|
@ -2,6 +2,7 @@ interface Match {
|
|||||||
render: boolean;
|
render: boolean;
|
||||||
title: string;
|
title: string;
|
||||||
fallbackImg: string;
|
fallbackImg: string;
|
||||||
|
fallbackFile: string;
|
||||||
staticImg?: string;
|
staticImg?: string;
|
||||||
networkMode: string;
|
networkMode: string;
|
||||||
}
|
}
|
||||||
@ -30,7 +31,8 @@ const routes = {
|
|||||||
},
|
},
|
||||||
lightning: {
|
lightning: {
|
||||||
title: "Lightning",
|
title: "Lightning",
|
||||||
fallbackImg: '/resources/img/lightning.png',
|
fallbackImg: '/resources/previews/lightning.png',
|
||||||
|
fallbackFile: '/resources/img/lightning.png',
|
||||||
routes: {
|
routes: {
|
||||||
node: {
|
node: {
|
||||||
render: true,
|
render: true,
|
||||||
@ -68,7 +70,8 @@ const routes = {
|
|||||||
},
|
},
|
||||||
mining: {
|
mining: {
|
||||||
title: "Mining",
|
title: "Mining",
|
||||||
fallbackImg: '/resources/img/mining.png',
|
fallbackImg: '/resources/previews/mining.png',
|
||||||
|
fallbackFile: '/resources/img/mining.png',
|
||||||
routes: {
|
routes: {
|
||||||
pool: {
|
pool: {
|
||||||
render: true,
|
render: true,
|
||||||
@ -83,13 +86,15 @@ const routes = {
|
|||||||
|
|
||||||
const networks = {
|
const networks = {
|
||||||
bitcoin: {
|
bitcoin: {
|
||||||
fallbackImg: '/resources/img/dashboard.png',
|
fallbackImg: '/resources/previews/dashboard.png',
|
||||||
|
fallbackFile: '/resources/img/dashboard.png',
|
||||||
routes: {
|
routes: {
|
||||||
...routes // all routes supported
|
...routes // all routes supported
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
liquid: {
|
liquid: {
|
||||||
fallbackImg: '/resources/img/liquid.png',
|
fallbackImg: '/resources/liquid/liquid-network-preview.png',
|
||||||
|
fallbackFile: '/resources/img/liquid',
|
||||||
routes: { // only block, address & tx routes supported
|
routes: { // only block, address & tx routes supported
|
||||||
block: routes.block,
|
block: routes.block,
|
||||||
address: routes.address,
|
address: routes.address,
|
||||||
@ -97,7 +102,8 @@ const networks = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
bisq: {
|
bisq: {
|
||||||
fallbackImg: '/resources/img/bisq.png',
|
fallbackImg: '/resources/bisq/bisq-markets-preview.png',
|
||||||
|
fallbackFile: '/resources/img/bisq.png',
|
||||||
routes: {} // no routes supported
|
routes: {} // no routes supported
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -107,6 +113,7 @@ export function matchRoute(network: string, path: string): Match {
|
|||||||
render: false,
|
render: false,
|
||||||
title: '',
|
title: '',
|
||||||
fallbackImg: '',
|
fallbackImg: '',
|
||||||
|
fallbackFile: '',
|
||||||
networkMode: 'mainnet'
|
networkMode: 'mainnet'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +128,7 @@ export function matchRoute(network: string, path: string): Match {
|
|||||||
|
|
||||||
let route = networks[network] || networks.bitcoin;
|
let route = networks[network] || networks.bitcoin;
|
||||||
match.fallbackImg = route.fallbackImg;
|
match.fallbackImg = route.fallbackImg;
|
||||||
|
match.fallbackFile = route.fallbackFile;
|
||||||
|
|
||||||
// traverse the route tree until we run out of route or tree, or hit a renderable match
|
// traverse the route tree until we run out of route or tree, or hit a renderable match
|
||||||
while (!route.render && route.routes && parts.length && route.routes[parts[0]]) {
|
while (!route.render && route.routes && parts.length && route.routes[parts[0]]) {
|
||||||
@ -128,6 +136,7 @@ export function matchRoute(network: string, path: string): Match {
|
|||||||
parts.shift();
|
parts.shift();
|
||||||
if (route.fallbackImg) {
|
if (route.fallbackImg) {
|
||||||
match.fallbackImg = route.fallbackImg;
|
match.fallbackImg = route.fallbackImg;
|
||||||
|
match.fallbackFile = route.fallbackFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user