
    Hh	                         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Z
dede	fd	Zdedefd
ZdefdZdefdZdefdZdefdZd Zy)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                     t         j                  j                  t         j                  j                  t        |             S N)ospathexistsjoinr   r   s    EC:\Users\algun\Documents\ceba web\Ceba - Github\app_modules\assets.py_static_existsr      s$    77>>"'',,{H=>>    c                     t         j                  j                  t         j                  j                  t        |             S r   )r   r   r   r   r   r   s    r   _root_existsr      s$    77>>"'',,x:;;r   c                 d    t        |       rt        d|       S t        |       rt        d|       S y)Nstaticr   assets )r   r   r   r   s    r   _url_for_static_or_assetr      s/    hx(33Hx(33r   c                  P    dD ]  } t        |       }|s|c S  t        d      xs dS )N)webicon180x180.pnglogocebav2.webplogoceba.webpz	jelen.pngz/favicon.ico)r   )nameurls     r   brand_icon_urlr!   #   s1    J&t,J K $K0BNBr   c                  0    t        d      xs
 t               S )Ncameraicon.webpr   r!    r   r   tab_icon_camerar&   +       #$56J.:JJr   c                  0    t        d      xs
 t               S )Ngalleryicon.pngr$   r%   r   r   tab_icon_galleryr*   /   r'   r   c                  0    t        d      xs
 t               S )Nmapicon.pngr$   r%   r   r   tab_icon_mapr-   3   s    #M2Fn6FFr   c                 d    | j                  d      dt        fd       }| j                  d        }y )Nz/assets/<path:filename>r   c                 4    h d}| |vryt        t        |       S )N>
   webicon16x16.pngwebicon32x32.pngcamera_render.pngcamera_render1.pngr,   r   r#   r)   r   r   )r   i  )r   r   )r   alloweds     r   r   zregister_assets.<locals>.assets8   s#    
 7""8X66r   c                  P    t               t               t               t               dS )N)
ICON_BRANDICON_CAMICON_GALLERYICON_MAP)r!   r&   r*   r-   r%   r   r   inject_iconsz%register_assets.<locals>.inject_iconsD   s%     )*'),.$	
 	
r   )routestrcontext_processor)appr   r:   s      r   register_assetsr?   7   s?    YY()	7 	7 *	7 	
 
r   )__doc__r   flaskr   r   pathsr   r   r<   boolr   r   r   r!   r&   r*   r-   r?   r%   r   r   <module>rD      s    
 . (?S ?T ?<3 <4 <s s C CK KK# KGc G
r   