Merge pull request #4204 from mempool/mononaut/unfurl-symlink-fallbacks
Use symlink to avoid duplicate unfurler fallback images
This commit is contained in:
		
						commit
						d8900d40c7
					
				| @ -251,7 +251,7 @@ class Server { | |||||||
| 
 | 
 | ||||||
|       if (!img) { |       if (!img) { | ||||||
|         // send local fallback image file
 |         // send local fallback image file
 | ||||||
|         res.sendFile(nodejsPath.join(__dirname, matchedRoute.fallbackFile)); |         res.sendFile(nodejsPath.join(__dirname, matchedRoute.fallbackImg)); | ||||||
|       } else { |       } else { | ||||||
|         res.contentType('image/png'); |         res.contentType('image/png'); | ||||||
|         res.send(img); |         res.send(img); | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								unfurler/src/resources
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								unfurler/src/resources
									
									
									
									
									
										Symbolic link
									
								
							| @ -0,0 +1 @@ | |||||||
|  | ../../frontend/src/resources | ||||||
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 94 KiB | 
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 289 KiB | 
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 1.8 MiB | 
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 96 KiB | 
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 289 KiB | 
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 607 KiB | 
| @ -2,7 +2,6 @@ interface Match { | |||||||
|   render: boolean; |   render: boolean; | ||||||
|   title: string; |   title: string; | ||||||
|   fallbackImg: string; |   fallbackImg: string; | ||||||
|   fallbackFile: string; |  | ||||||
|   staticImg?: string; |   staticImg?: string; | ||||||
|   networkMode: string; |   networkMode: string; | ||||||
| } | } | ||||||
| @ -32,7 +31,6 @@ const routes = { | |||||||
|   lightning: { |   lightning: { | ||||||
|     title: "Lightning", |     title: "Lightning", | ||||||
|     fallbackImg: '/resources/previews/lightning.png', |     fallbackImg: '/resources/previews/lightning.png', | ||||||
|     fallbackFile: '/resources/img/lightning.png', |  | ||||||
|     routes: { |     routes: { | ||||||
|       node: { |       node: { | ||||||
|         render: true, |         render: true, | ||||||
| @ -71,7 +69,6 @@ const routes = { | |||||||
|   mining: { |   mining: { | ||||||
|     title: "Mining", |     title: "Mining", | ||||||
|     fallbackImg: '/resources/previews/mining.png', |     fallbackImg: '/resources/previews/mining.png', | ||||||
|     fallbackFile: '/resources/img/mining.png', |  | ||||||
|     routes: { |     routes: { | ||||||
|       pool: { |       pool: { | ||||||
|         render: true, |         render: true, | ||||||
| @ -87,14 +84,12 @@ const routes = { | |||||||
| const networks = { | const networks = { | ||||||
|   bitcoin: { |   bitcoin: { | ||||||
|     fallbackImg: '/resources/previews/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/liquid/liquid-network-preview.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, | ||||||
| @ -103,7 +98,6 @@ const networks = { | |||||||
|   }, |   }, | ||||||
|   bisq: { |   bisq: { | ||||||
|     fallbackImg: '/resources/bisq/bisq-markets-preview.png', |     fallbackImg: '/resources/bisq/bisq-markets-preview.png', | ||||||
|     fallbackFile: '/resources/img/bisq.png', |  | ||||||
|     routes: {} // no routes supported
 |     routes: {} // no routes supported
 | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| @ -113,7 +107,6 @@ export function matchRoute(network: string, path: string): Match { | |||||||
|     render: false, |     render: false, | ||||||
|     title: '', |     title: '', | ||||||
|     fallbackImg: '', |     fallbackImg: '', | ||||||
|     fallbackFile: '', |  | ||||||
|     networkMode: 'mainnet' |     networkMode: 'mainnet' | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -128,7 +121,6 @@ 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]]) { | ||||||
| @ -136,7 +128,6 @@ 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