o
    Hh	                     @   s   d Z ddlZddlmZmZ ddlmZmZ dede	fdd	Z
dede	fd
dZdedefddZdefddZdefddZdefddZdefddZdd ZdS )a  
assets.py

Purpose:
  Manage icon/asset URL helpers and the `/assets` route that serves a limited
  allowlist of root-level files for backward compatibility. Also injects icon
  URLs into templates via a context processor.

Exports:
  - register_assets(app): registers the /assets route and icon context processor
  - brand_icon_url(), tab icon helpers, and internal existence checks
    N)url_forsend_from_directory   )ROOT_DIRSTATIC_PATHfilenamereturnc                 C      t jt jt| S N)ospathexistsjoinr   r    r   #/var/www/html/app_modules/assets.py_static_exists      r   c                 C   r	   r
   )r   r   r   r   r   r   r   r   r   _root_exists   r   r   c                 C   s,   t | r
td| dS t| rtd| dS dS )Nstaticr   assets )r   r   r   r   r   r   r   _url_for_static_or_asset   s
   r   c                  C   s*   dD ]} t | }|r|  S qt dpdS )N)webicon180x180.pnglogocebav2.webplogoceba.webpz	jelen.pngz/favicon.ico)r   )nameurlr   r   r   brand_icon_url#   s   r   c                   C      t dpt S )Ncameraicon.webpr   r   r   r   r   r   tab_icon_camera+      r"   c                   C   r   )Ngalleryicon.pngr!   r   r   r   r   tab_icon_gallery/   r#   r%   c                   C   r   )Nmapicon.pngr!   r   r   r   r   tab_icon_map3   r#   r'   c                 C   s*   |  ddtfdd}| jdd }d S )Nz/assets/<path:filename>r   c                 S   s   h d}| |vr
dS t t| S )N>
   webicon16x16.pngwebicon32x32.pngcamera_render.pngcamera_render1.pngr&   r   r    r$   r   r   )r   i  )r   r   )r   allowedr   r   r   r   8   s   
zregister_assets.<locals>.assetsc                   S   s   t  t t t dS )N)
ICON_BRANDICON_CAMICON_GALLERYICON_MAP)r   r"   r%   r'   r   r   r   r   inject_iconsD   s
   z%register_assets.<locals>.inject_icons)routestrcontext_processor)appr   r1   r   r   r   register_assets7   s   r6   )__doc__r   flaskr   r   pathsr   r   r3   boolr   r   r   r   r"   r%   r'   r6   r   r   r   r   <module>   s    