Fix icons in visualize.py
This commit is contained in:
		
							parent
							
								
									4104057771
								
							
						
					
					
						commit
						3408ba3c45
					
				
					 1 changed files with 13 additions and 2 deletions
				
			
		
							
								
								
									
										15
									
								
								visualize.py
									
										
									
									
									
								
							
							
						
						
									
										15
									
								
								visualize.py
									
										
									
									
									
								
							|  | @ -18,6 +18,12 @@ icon_overrides = { | ||||||
|     "woodpecker": None, |     "woodpecker": None, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | icon_format = { | ||||||
|  |     "linkwarden": "webp", | ||||||
|  |     "telegraf": "webp", | ||||||
|  |     "tiny-tiny-rss": "webp", | ||||||
|  | } | ||||||
|  | 
 | ||||||
| template_host = """ | template_host = """ | ||||||
| 'serguzim.net'.{host}: {{ | 'serguzim.net'.{host}: {{ | ||||||
|     label: {host} |     label: {host} | ||||||
|  | @ -28,7 +34,7 @@ template_service = """ | ||||||
| {key}: {{ | {key}: {{ | ||||||
|     label: {label} |     label: {label} | ||||||
|     label.near: top-left |     label.near: top-left | ||||||
|     icon: https://cdn.jsdelivr.net/gh/selfhst/icons/webp/{icon}.webp |     icon: {icon} | ||||||
|     icon.near: top-right |     icon.near: top-right | ||||||
| }} | }} | ||||||
| """ | """ | ||||||
|  | @ -53,6 +59,11 @@ external: { | ||||||
| } | } | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
|  | def get_icon(svc): | ||||||
|  |     svc = icon_overrides.get(svc, svc) or 'docker' | ||||||
|  |     fmt = icon_format.get(svc, 'svg') | ||||||
|  |     return f'https://cdn.jsdelivr.net/gh/selfhst/icons/{fmt}/{svc}.{fmt}' | ||||||
|  | 
 | ||||||
| def service_key(svc, data): | def service_key(svc, data): | ||||||
|     return f"'serguzim.net'.{data['host']}.{svc}" |     return f"'serguzim.net'.{data['host']}.{svc}" | ||||||
| 
 | 
 | ||||||
|  | @ -95,7 +106,7 @@ def parse_services(services): | ||||||
|         result.append(template_service.format( |         result.append(template_service.format( | ||||||
|             key=svc_key, |             key=svc_key, | ||||||
|             label="\\n".join([svc] + domains), |             label="\\n".join([svc] + domains), | ||||||
|             icon=icon_overrides.get(svc, svc) or "docker", |             icon=get_icon(svc) | ||||||
|         )) |         )) | ||||||
| 
 | 
 | ||||||
|         for backup in data.get("backup") or []: |         for backup in data.get("backup") or []: | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue