https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/trac/web/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/trac/web/__pycache__/chrome.cpython-310.pyc
o

�k�`��@s�dZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZmZddlTddlTddlmZmZdd	lmZddlTdd
lmZmZmZmZmZm Z m!Z!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6dd
l7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJddlKmLZLmMZMddlNmOZOmPZPddlQmRZRddlSmTZTddlUmVZVmWZWmXZXdZYdZZGdd�de[�Z\Gdd�de[�Z]dd�Z^d@dd�Z_dAdd�Z`dBd d!�ZadCd#d$�Zbifd%d&�Zcd'd(�Zdd)d*�Zed+d,�ZfdDd-d.�ZgdEd/d0�Zh	1	1dFd2d3�Zid4d5�ZjdEd6d7�Zkd8d9�Zld:d;�Zmed<d=��ZnGd>d?�d?eo�ZpdS)Gz�Content presentation for the web layer.

The Chrome module deals with delivering and shaping content to the end
user, mostly targeting (X)HTML generation but not exclusively, RSS or
other forms of web content are also using facilities provided here.

�)�contextmanagerN)�partial)�FileSystemLoader)�IEnvironmentSetupParticipant�ISystemInfoProvider)�*)�RenderingContext�get_mimetype)�IPermissionRequestor)	�as_bool�as_int�get_pkginfo�get_reporter_id�html�pathjoin�presentation�to_list�translation)�Element�Markup�escape�	plaintext�tag�to_fragment�valid_html_bytes)
�exception_to_unicode�
is_obfuscated�javascript_quote�	jinja2env�obfuscate_email_address�pretty_size�shorten_line�to_js_string�
to_unicode�unicode_quote_plus)�pretty_timedelta�datetime_now�format_datetime�format_date�format_time�from_utimestamp�	http_date�utc�get_date_format_jquery_ui�is_24_hours�get_time_format_jquery_ui�	user_time�get_month_names_jquery_ui�get_day_names_jquery_ui�get_timezone_list_jquery_ui�get_first_week_day_jquery_ui�"get_timepicker_separator_jquery_ui�get_period_names_jquery_ui�localtz)�_�get_available_locales)�IRequestHandler�HTTPNotFound)�Href)�IWikiSyntaxProvider)�	format_to�format_to_html�format_to_oneliner)�wiki�timeline�roadmap�browser�tickets�	newticket�search�admin)�login�logout�prefs�help�aboutc@� eZdZdZdd�Zdd�ZdS)�INavigationContributorzZExtension point interface for components that contribute items to the
    navigation.
    cC�dS)z�This method is only called for the `IRequestHandler` processing
        the request.

        It should return the name of the navigation item to be highlighted
        as active/current.
        N���reqrQrQ�1/usr/lib/python3/dist-packages/trac/web/chrome.py�get_active_navigation_itemJ�z1INavigationContributor.get_active_navigation_itemcCrP)a�Should return an iterable object over the list of navigation items
        to add, each being a tuple in the form (category, name, text).

        The category determines the location of the navigation item and
        can be `mainnav` or `metanav`. The name is a unique identifier that
        must match the string returned by get_active_navigation_item.
        The text is typically a link element with text that corresponds
        to the desired label for the navigation item, and an href.
        NrQrRrQrQrT�get_navigation_itemsRrVz+INavigationContributor.get_navigation_itemsN)�__name__�
__module__�__qualname__�__doc__rUrWrQrQrQrTrOEsrOc@rN)�ITemplateProviderz�Extension point interface for components that provide their own
    Jinja2 templates and/or accompanying static resources.

    cCrP)a�Return a list of directories with static resources (such as style
        sheets, images, etc.)

        Each item in the list must be a `(prefix, abspath)` tuple. The
        `prefix` part defines the path in the URL that requests to these
        resources are prefixed with.

        The `abspath` is the absolute path to the directory containing the
        resources on the local file system.
        NrQrQrQrQrT�get_htdocs_dirsdrVz!ITemplateProvider.get_htdocs_dirscCrP)zUReturn a list of directories containing the provided template
        files.
        NrQrQrQrQrT�get_templates_dirsprVz$ITemplateProvider.get_templates_dirsN)rXrYrZr[r]r^rQrQrQrTr\^sr\cCs|j�d�r|SdS)zXHelper function for creating accesskey HTML attribute according
    to preference values�
accesskeysN)�sessionr)rS�keyrQrQrT�	accesskeyvsrbcCs*||||||d�}|j�dg��|�dS)z;Add a `<meta>` tag into the `<head>` of the generated HTML.)�contentz
http-equiv�name�scheme�langzxml:lang�metasN)�chrome�
setdefault�append)rSrc�
http_equivrdrerf�metarQrQrT�add_meta|s�rmcKsnd||f}|j�dt��}||vrdS||||d�}	|	�|�|j�di�}
|
�|g��|	�|�|�dS)zrAdd a link to the chrome info that will be inserted as <link> element in
    the <head> of the generated HTML
    z%s:%s�linksetN)�href�title�type�class�links)rhri�set�updaterj�add)rS�relrorp�mimetype�	classname�attrs�linkidrn�linkrsrQrQrT�add_link�s
r}�text/csscKs&t||�}t|d|fd|i|��dS)a�Add a link to a style sheet to the chrome info so that it gets included
    in the generated HTML page.

    If `filename` is a network-path reference (i.e. starts with a protocol
    or `//`), the return value will not be modified. If `filename` is absolute
    (i.e. starts with `/`), the generated link will be based off the
    application root path. If it is relative, the link will be based off the
    `/chrome/` path.
    �
stylesheetrxN)�chrome_resource_pathr})rS�filenamerxrzrorQrQrT�add_stylesheet�s

r��text/javascriptcCsp|j�dt��}||vrdSt||�}dd|ii}|dkr'|dur'||dd<|j�dg��|�|�|�dS)	a�Add a reference to an external javascript file to the template.

    If `filename` is a network-path reference (i.e. starts with a protocol
    or `//`), the return value will not be modified. If `filename` is absolute
    (i.e. starts with `/`), the generated link will be based off the
    application root path. If it is relative, the link will be based off the
    `/chrome/` path.
    �	scriptsetFrz�srcr�Nrq�scripts)rhrirtr�rjrv)rSr�rxr�ro�scriptrQrQrT�
add_script�s	
r�cKs&|j�di�}|�|�|�|�dS)aAdd data to be made available in javascript scripts as global variables.

    The keys in `data` and the keyword argument names provide the names of the
    global variables. The values are converted to JSON and assigned to the
    corresponding variables.
    �script_dataN)rhriru)rS�data�kwargsr�rQrQrT�add_script_data�s
r�cG�t|d||�dS)z�Add a non-fatal warning to the request object.

    When rendering pages, all warnings will be rendered to the user. Note that
    the message is escaped (and therefore converted to `Markup`) before it is
    stored in the request object.
    �warningsN��_add_message�rS�msg�argsrQrQrT�add_warning��r�cGr�)z�Add an informational notice to the request object.

    When rendering pages, all notices will be rendered to the user. Note that
    the message is escaped (and therefore converted to `Markup`) before it is
    stored in the request object.
    �noticesNr�r�rQrQrT�
add_notice�r�r�cCsH|r||;}t|t�stt|��}||j|vr"|j|�|�dSdS�N)�
isinstancerrrhrj)rSrdr�r�rQrQrTr��s
�r�cCs2|rtj|||d�}n|}|j�dg��|�dS)z/Add an entry to the current page's ctxtnav bar.�rorp�ctxtnavN)r�arhrirj)rS�elm_or_labelrorp�elmrQrQrT�add_ctxtnav�sr�c	s|jd�d}}t�fdd�dD��sdSd�vr-�dd}tj||d|d	dd
�}t|tjtd�|p7||s;dndd
��|r[d�vr[�dd}t|tj||d|d	d��d�vrr�dd}tj||d|d	dd
�}t|tj|py|td�|s�dndd
��dS)a"Add Previous/Up/Next navigation links.

       :param        req: a `Request` object
       :param prev_label: the label to use for left (previous) link
       :param   up_label: the label to use for the middle (up) link
       :param next_label: the label to use for right (next) link
    rsNc3s�|]}|�vVqdSr�rQ)�.0�lnk�rsrQrT�	<genexpr>�s�zprevnext_nav.<locals>.<genexpr>)�prev�up�nextr�rrorp)rorp�class_z&larr; �missing�r�r�r�r�z &rarr;)rh�anyrr�r��spanr)	rS�
prev_label�
next_label�up_label�	prev_link�	next_linkr�r��next_rQr�rT�prevnext_nav�s.
�
��
�r�Fc	CsH|r|r|jn|j}|j}nd}d}tt||||d�||d�}||_|S)aOCreate a rendering context from a request.

    The `perm` and `href` properties of the context will be initialized
    from the corresponding properties of the request object.

    >>> from trac.test import Mock, MockPerm
    >>> req = Mock(href=Mock(), perm=MockPerm())
    >>> context = web_context(req)
    >>> context.href is req.href
    True
    >>> context.perm is req.perm
    True

    :param      req: the HTTP request object
    :param resource: the `Resource` object or realm
    :param       id: the resource identifier
    :param  version: the resource version
    :param  absurls: whether URLs generated by the ``href`` object should
                     be absolute (including the protocol scheme and host
                     name)
    :return: a new rendering context
    :rtype: `RenderingContext`

    :since: version 1.0
    N)�id�version�parent)ro�perm)�abs_hrefror�r�ResourcerS)	rS�resourcer�r�r��absurlsror��selfrQrQrT�web_context
s
��r�cCs|jr
|jj|d�S|S)z�Return an "authenticated" link to `link` for authenticated users.

    If the user is anonymous, returns `link` unchanged. For authenticated
    users, returns a link to `/login` that redirects to `link` after
    authentication.
    )�referer)�is_authenticatedrorI)rSr|rQrQrT�	auth_link4sr�c
Cs<|j}|r|�di��dg�}|�dg�}|�di�}n4|�di��dg�|�di��dg�}|�dg�|�dg�}i}|�|�d	i��|�|�d
i��g}|�dd�|pZd
D��|�dd�|pfi��D��t�}|r~|�tjd�|�dd��|D]}|d}	|�t�dt	|	d�t	|	�d��f��q�|S)z�Get script elements from chrome info of the request object during
    rendering template or after rendering.

    :param      req: the HTTP request object.
    :param use_late: if True, `late_links` will be used instead of `links`.
    �
late_linksr�late_scripts�late_script_data�early_linksrs�
early_scriptsr��early_script_datar�css,�|]}dt|d�t|d�fVqdS)zjQuery.loadStyleSheet(%s, %s);rorqN)r")r�r|rQrQrTr�Us���z%chrome_info_script.<locals>.<genexpr>rQcss&�|]\}}d|t�|�fVqdS)z
var %s=%s;N)r�to_json)r�rd�valuerQrQrTr�Xs���
r�)rqrzzjQuery.loadScript(%s, %s)r�rq)
rh�getru�extend�itemsrrjr��joinr")
rS�use_laterhrsr�r�rc�fragmentr�rzrQrQrT�chrome_info_script@s<�
�

���r�cCs\|�d�r|S|�d�rd|jvrt|jd�|dd��S|�d�r&|jn|jj}||�S)aGet the path for a chrome resource given its `filename`.

    If `filename` is a network-path reference (i.e. starts with a protocol
    or `//`), the return value will not be modified. If `filename` is absolute
    (i.e. starts with `/`), the generated link will be based off the
    application root path. If it is relative, the link will be based off the
    `/chrome/` path.
    )�http://�https://z//zcommon/�htdocs_location�N�/)�
startswithrhr<ro)rSr�rorQrQrTr�gs
	r�cCs>dD]}t|j|�D]\}}t|d�|jd||f<qqdS)zdSave warnings and notices in case of redirect, so that they can
    be displayed after the redirect.�r�r�F�chrome.%s.%dN)�	enumeraterhrr`)rS�url�	permanent�type_�i�messagerQrQrT�_save_messagesys
��r�ccst�|�|��*zdVWnty'}zt|td|jjt|�d���d}~wwWd�dS1s3wYdS)z{Traps any runtime exception raised when working with a
    component, logs the error and adds a warning for the user.

    Nz!%(component)s failed with %(exc)s)�	component�exc)�component_guard�	Exceptionr�r8�	__class__rXr)�envrSr��erQrQrTr��s�
����"�r�c@s|eZdZdZeeeeee	e
�dZdZe
e�Ze
e	�Zedddd�Zedddd	�Zed
ddd�Zed
d
dd�Zed
dddddid�Zed
dddddid�Zed
dddddid�Zedd�Zedd�Zedddd�Zedd d!d"�Zedd#d$d%�Z e!dd&d'd(�Z"e!dd)d'd*�Z#ed
d+d,d-�Z$ed
d.d/d0�Z%ed
d1d,d2�Z&ed
d3d/d4�Z'ed
d5d/d6�Z(e)d
d7d8d9�Z*e+d
d:d;d<�Z,ed
d=d/d>�Z-d?Z.d?Z/d?Z0id@e1�dAe2�dBe3�dCe4�dDe5j6�dEe5j5�dFe7j8�dGe9�dHe:j;�dIe<�dJe=�dKe>�dLe?�dMe@�dNeA�dOeB�dPeCjD�eEeFeGeHeIeJe5jKe5jLeMeNdQ�
�ZOdRdS�ZPdTdU�ZQdVdW�ZRdXdY�ZSdZd[�ZTd\d]�ZUd^d_�ZVd`da�ZWdbdc�ZXddde�ZYdfdg�ZZdhdi�Z[djdk�Z\d�dldm�Z]dndo�Z^d�dpdq�Z_drds�Z`dtdu�Zadvdw�Zbd�dxdy�Zcdzd{�Zdee�fd|�Zgd}d~�Zhdd��Zid�d�d��Zjd�d�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�d�d��Zqd�d�d��Zrd�d��Zsd�d�d��Ztd�d�d��Zud�d�d��Zv		?d�d�d��Zwd�d�d��Zxd�d�d��Zyd?S)��ChromezaWeb site chrome assembly manager.

    Chrome is everything that is not actual page content.
    TF�inherit�
templates_dir�a"Path to the //shared templates directory//.

        Templates in that directory are loaded in addition to those in the
        environments `templates` directory, but the latter take precedence.

        Non-absolute paths are relative to the Environment `conf`
        directory.
        �
htdocs_dira�Path to the //shared htdocs directory//.

        Static resources in that directory are mapped to /chrome/shared
        under the environment URL, in addition to common and site locations.

        This can be useful in site.html for common interface customization
        of multiple Trac environments.

        Non-absolute paths are relative to the Environment `conf`
        directory.
        (''since 1.0'')�trac�auto_reloadz7Automatically reload template files after modification.r�asBase URL for serving the core static resources below
        `/chrome/common/`.

        It can be left empty, and Trac will simply serve those resources
        itself.

        Advanced users can use this together with
        [TracAdmin trac-admin ... deploy <deploydir>] to allow serving the
        static resources for Trac directly from the web server.
        Note however that this only applies to the `<deploydir>/htdocs/common`
        directory, the other deployed resources (i.e. those from plugins)
        will not be made available this way and additional rewrite
        rules will be needed in the web server.�jquery_locationa�Location of the jQuery !JavaScript library (version %(version)s).

        An empty value loads jQuery from the copy bundled with Trac.

        Alternatively, jQuery could be loaded from a CDN, for example:
        http://code.jquery.com/jquery-%(version)s.min.js,
        http://ajax.aspnetcdn.com/ajax/jQuery/jquery-%(version)s.min.js or
        https://ajax.googleapis.com/ajax/libs/jquery/%(version)s/jquery.min.js.

        (''since 1.0'')r�z1.12.4)�doc_args�jquery_ui_locationa�Location of the jQuery UI !JavaScript library (version %(version)s).

        An empty value loads jQuery UI from the copy bundled with Trac.

        Alternatively, jQuery UI could be loaded from a CDN, for example:
        https://ajax.googleapis.com/ajax/libs/jqueryui/%(version)s/jquery-ui.min.js
        or
        http://ajax.aspnetcdn.com/ajax/jquery.ui/%(version)s/jquery-ui.min.js.

        (''since 1.0'')z1.12.1�jquery_ui_theme_locationaLocation of the theme to be used with the jQuery UI !JavaScript
        library (version %(version)s).

        An empty value loads the custom Trac jQuery UI theme from the copy
        bundled with Trac.

        Alternatively, a jQuery UI theme could be loaded from a CDN, for
        example:
        https://ajax.googleapis.com/ajax/libs/jqueryui/%(version)s/themes/start/jquery-ui.css
        or
        http://ajax.aspnetcdn.com/ajax/jquery.ui/%(version)s/themes/start/jquery-ui.css.

        (''since 1.0'')�mainnava�Configures the main navigation bar,
        which by default contains //Wiki//, //Timeline//, //Roadmap//,
        //Browse Source//, //View Tickets//, //New Ticket//, //Search// and
        //Admin//.

        The `label`, `href`, and `order` attributes can be specified. Entries
        can be disabled by setting the value of the navigation item to
        `disabled`.

        The following example renames the link to WikiStart to //Home//,
        links the //View Tickets// entry to a specific report and disables
        the //Search// entry.
        {{{#!ini
        [mainnav]
        wiki.label = Home
        tickets.href = /report/24
        search = disabled
        }}}

        See TracNavigation for more details.
        �metanava�Configures the meta navigation
        entries, which by default are //Login//, //Logout//, //Preferences//,
        ''!Help/Guide'' and //About Trac//. The allowed attributes are the
        same as for `[mainnav]`. Additionally, a special entry is supported -
        `logout.redirect` is the page the user sees after hitting the logout
        button. For example:

        {{{#!ini
        [metanav]
        logout.redirect = wiki/Logout
        }}}

        See TracNavigation for more details.
        �header_logor|z%URL to link to, from the header logo.r�zsite/your_project_logo.pnga�URL of the image to use as header logo.
        It can be absolute, server relative or relative.

        If relative, it is relative to one of the `/chrome` locations:
        `site/your-logo.png` if `your-logo.png` is located in the `htdocs`
        folder within your TracEnvironment;
        `common/your-logo.png` if `your-logo.png` is located in the
        folder mapped to the [#trac-section htdocs_location] URL.
        Only specifying `your-logo.png` is equivalent to the latter.�altz8(please configure the [header_logo] section in trac.ini)z%Alternative text for the header logo.�width���z)Width of the header logo image in pixels.�heightz*Height of the header logo image in pixels.�show_email_addresses�falsez�Show email addresses instead of usernames. If false, email
        addresses are obfuscated for users that don't have EMAIL_VIEW
        permission.
        �show_full_names�truez5Show full names instead of usernames. (//since 1.2//)�never_obfuscate_mailtoz�Never obfuscate `mailto:` links explicitly written in the wiki,
        even if `show_email_addresses` is false or the user doesn't have
        EMAIL_VIEW permission.
        �resizable_textareaszBMake `<textarea>` fields resizable. Requires !JavaScript.
        �
wiki_toolbarszJAdd a simple toolbar on top of Wiki <textarea>s.
        (''since 1.0.2'')�auto_preview_timeoutg@aInactivity timeout in seconds after which the automatic wiki preview
        triggers an update. This option can contain floating-point values. The
        lower the setting, the more requests will be made to the server. Set
        this to 0 to disable automatic preview.
        �default_dateinfo_format)�relative�absolutez�The date information format. Valid options are 'relative' for
        displaying relative format and 'absolute' for displaying absolute
        format. (''since 1.0'')�use_chunked_encodingz�If enabled, send contents as chunked encoding in HTTP/1.1.
        Otherwise, send contents with `Content-Length` header after entire of
        the contents are rendered. (''since 1.0.6'')N�allr�rr�date�datetime�find_elementr�groupbyr+rr�operatorrrr�pprint)
r r%�
quote_plus�reversedr!�sorted�time�	timedeltar#r,ccs��ddl}t|��d�}d|fVzddl}Wnty"d}Ynw|durBt|��d�}t�s;|d7}|j�d�d|fVdSdS)Nrr��Jinja2z (translations unavailable)zLocale data is missing�Babel)�jinja2r
r��babel�ImportErrorr9�log�warning)r�r�inforrQrQrT�get_system_info}s �
��zChrome.get_system_infocsRd�fdd�	}|ddd�|dd�|d	d
��fdd�}|d
t�|dt�dS)z:Add the sample templates to the environment templates dir.r�cs`tj��jj|d�}t|ddd��}|�d||||f�Wd�dS1s)wYdS)Nz.sample�w�utf-8)�encodinga�{#  This file allows customizing the appearance of the Trac installation.

    Add your customizations to the %s here
    and rename the file to %s.

    Note that it will take precedence over a global %s placed
    in the directory specified by [inherit] templates_dir.

    More information about site appearance customization can be found here:

      https://trac.edgewall.org/wiki/TracInterfaceCustomization#SiteAppearance
#}
%s
)�os�pathr�r�r��open�write)r��kind�example�	site_path�fileobj�r�rQrT�write_sample_template�s�
�"�z9Chrome.environment_created.<locals>.write_sample_templatezsite_head.htmlzthe end of the HTML <head>zR
<link rel="stylesheet" type="text/css" href="${href.chrome('site/style.css')}"/>
zsite_header.htmlz$the start of the HTML <body> contentzsite_footer.htmlz"the end of the HTML <body> contentcs2t|d�D]\}}�jj�||dt|��qdS)N��.order)r�r��configrt�float)�section�defaultr�rdr$rQrT�add_nav_order_options�s�z9Chrome.environment_created.<locals>.add_nav_order_optionsr�r�N)r�)�default_mainnav_order�default_metanav_order)r�r%r,rQr$rT�environment_created�s���
zChrome.environment_createdcCrP�NFrQr$rQrQrT�environment_needs_upgrade��z Chrome.environment_needs_upgradecCsdSr�rQr$rQrQrT�upgrade_environment�r2zChrome.upgrade_environmentcCs:t�d|j�}|r|�d�|jd<|�d�|jd<dSdS)Nz+/chrome/(?P<prefix>[^/]+)/+(?P<filename>.+)�prefixr�T)�re�match�	path_info�groupr�)r�rSr6rQrQrT�
match_request�s��zChrome.match_requestcs�|jd�|jd}g}|jD]B}�fdd�|��pgD�D]2}|�|�tj�tj�||��}tj�||g�|krBt	t
d|d���tj�|�rP|�|t
|��qq|j�d||�td|��)	Nr4r�cs0g|]}|d�kr|drtj�|d��qS)rr&)rr�normpath)r��dir�r4rQrT�
<listcomp>�s�z*Chrome.process_request.<locals>.<listcomp>zInvalid chrome path %(path)s.)rzFile %s not found in any of %szFile %s not found)r��template_providersr]rjrrr:r��commonprefix�	TracErrorr8�isfile�	send_filer	rrr;)r�rSr��dirs�providerr;rrQr<rT�process_request�s&





�
���
zChrome.process_requestcCsdgS)zt`EMAIL_VIEW` permission allows for showing email addresses even
        if `[trac] show_email_addresses` is `false`.�
EMAIL_VIEWrQr$rQrQrT�get_permission_actions�szChrome.get_permission_actionscCs$dt�dd�fd|jfd|jjfgS)N�commonr��htdocs�shared�site)�
pkg_resources�resource_filename�shared_htdocs_dirr�r�r$rQrQrTr]�s
�zChrome.get_htdocs_dirsc	Cs"ttd|jj|jt�dd�g��S)Nr��	templates)�list�filterr�r��shared_templates_dirrLrMr$rQrQrTr^�s

�zChrome.get_templates_dirscCsgSr�rQr$rQrQrT�get_wiki_syntax�r2zChrome.get_wiki_syntaxccs�d|jfVdS)NrI)�_format_linkr$rQrQrT�get_link_resolvers�s�zChrome.get_link_resolverscCs4|�|�\}}}|j�d|�||}tj||d�S)NrK�ro)�
split_linkrorhrr�)r��	formatter�ns�file�label�queryr�rorQrQrTrT�szChrome._format_linkcCs&g}|jD]}|�|��pg�q|S)z>Return a list of the names of all known templates directories.)r>r�r^)r�rCrDrQrQrT�get_all_templates_dirs�s
zChrome.get_all_templates_dirscCs�|j�d�gigigggd�}||_|jp|j�d�}|�d�d|d<t|d|j���t|d|j���t|d|j�d	��t	|d
�t
||jpLd�|dur^t|j
d
d�r^t
|d�t
|d�|jdurwt|j�dkrwt
|d|j�t
|d�t
|d�t
|d�|�|�|d<|dr�|dd}|dd}t|d||d�|�|j|j�|d<|�||�|d<d|d<|�t�|S)z�Prepare the basic chrome data for the request.

        :param     req: the request object
        :param handler: the `IRequestHandler` instance that is processing the
                        request
        zPrepare chrome data for request)rgrsr�r�r�r�r�rHr�r��startrGrL�	TracGuidezcommon/css/trac.csszcommon/js/jquery.jsN�jquery_noconflictFzcommon/js/noconflict.jszcommon/js/babel.js�en_USzcommon/js/messages/%s.jszcommon/js/trac.jszcommon/js/search.jszcommon/js/folding.js�iconr�rx)rx�logo�navz
theme.html�theme)r�debugrhr�ro�rstripr}rArGr�r�r��getattrr��locale�str�
get_icon_data�
get_logo_datar�rW�add_redirect_listenerr�)r�rS�handlerrhr�r�rxrQrQrT�prepare_requests@�
�





zChrome.prepare_requestcCs�i}|jj}}|r?|�d�s5|�d�dkr5d|vr'|j�|�}|j�|�}n|j�d|�}|j�d|�}t|�}|||d�}|S)Nr�z://r�rH)r��abs_srcrx)r��project_iconr��findr�rhror	)r�rSrb�icon_src�icon_abs_srcrxrQrQrTrk<s�zChrome.get_icon_datacCs�i}|j}|rO|p
|}|�d�r|}nd|vr"|�|�}|�|�}n|�d|�}|�d|�}|jdkr6|jnd}|jdkr@|jnd}|j|||j||d�}|S|j|jd�}|S)N)r�r�r�r�rHr�)r|r��src_absr�r�r�)r|r�)�logo_srcr�rh�
logo_width�logo_height�	logo_link�logo_alt)r�ror�rcrv�logo_src_absr�r�rQrQrTrlLs(

��zChrome.get_logo_datac	s���fdd�}i}d}�jD];}t�j�|��*|���pgD]\}}}	||||	�|�|i�|<q||ur:|���}Wd�n1sDwYqd}
t|
t|
��D]\\}}�j|}|D]P}d|vr�||�	|g�vr�d}	||vr�|||vr�||||||<|||=|||�	d�}	||||	�}
|
|�|i�|<|
dr�|
d��
�j�kr�|}q^qSi}|��D]=\}}|�|g�t
t|���dd�d	�D]&\}}
|
d
r�|
dr�|
dr�|
d�jvr�||�||
d||kd��q�q�|S)
Nc	s��j|}|�|d�}|�|d�}|r|�d�r�j|}t|t�r:|jdkr:|}|r2||jd<|r9||d�}n|s>|rJtj|pE|pE||d�}n|}|�	|d�|�
|dtd	��||||�|d
�d�S)Nz.hrefz.labelr�r�rrVTr'�infz.permission)�enabled�orderr[ror|r�)r(r�r�ror�rr�childrenr��getbool�getfloatr))�categoryrd�textr*ror[r|�rSr�rQrT�get_item_attributesjs,



�
�z8Chrome.get_navigation_items.<locals>.get_item_attributes)r�r��.r|rocSs|dd|dfS)Nr&r~rrQ)�	name_attrrQrQrT�<lambda>�sz-Chrome.get_navigation_items.<locals>.<lambda>�rar}r�)rdr[�active)�navigation_contributorsr�r�rWrirU�ziprr(r�ror7r�r
�iterr�rj)r�rSrnr��	all_itemsr��contributorr�rdr��
categories�other_categoryr*�
attributes�	nav_items�category_itemsrQr�rTrWhsj
�
�
���	


�
���
�����zChrome.get_navigation_itemscCsdddd�}i}d}||jj|�}||j|�}||jj�}||j�}t||||f�r0||||d�}|S)z�Returns a dictionary containing the lists of files present in the
        site and shared templates and htdocs directories.
        Ncs,tj�|�sgSt�fdd�t�|�D��S)Nc3s*�|]}�dus
|���rt|�VqdSr�)�endswithr#)r�rd��suffixrQrTr��s���zMChrome.get_interface_customization_files.<locals>.list_dir.<locals>.<genexpr>)rr�isdirr
�listdir)rr�rQr�rT�list_dir�sz:Chrome.get_interface_customization_files.<locals>.list_dir)z.htmlz.txt)zsite-templateszshared-templateszsite-htdocsz
shared-htdocsr�)r�r�rRr�rNr�)r�r��files�exts�site_templates�shared_templates�site_htdocs�
shared_htdocsrQrQrT�!get_interface_customization_files�s

�z(Chrome.get_interface_customization_filescCs$|rd|vr|�|�r|�|�}|S)zeReturns the author email from the `email_map` if `author`
        doesn't look like an email address.�@)r�)r��author�	email_maprQrQrT�author_email�s
zChrome.author_emailcCs,|�||�}tj|�|||�|�||�d�S)a`Format a username to HTML.

        Calls `Chrome.format_author` to format the username, and wraps
        the formatted username in a `span` with class `trac-author`,
        `trac-author-anonymous` or `trac-author-none`.

        :param req: the `Request` object.
        :param author: the author string to be formatted.
        :param email_map: dictionary mapping usernames to email addresses.
        :param resource: optional `Resource` object for `EMAIL_VIEW`
                         fine-grained permissions checks.

        :since 1.1.6: accepts the optional `resource` keyword parameter.
        r�)r�rr��
format_author�author_class)r�rSr�r�r�rQrQrT�
authorinfo�s
�zChrome.authorinfocCsBd}|dkrd}d|S|sd}d|S|r||jkrd}d|S)Nr��	anonymousz
-anonymousz-nonez-userztrac-author)�authname)r�rSr�r�rQrQrTr��s��zChrome.author_classz".*<([^@]+)@[^@]+>\s*|([^@]+)@[^@]+cCs<d}|j�|pd�}|r|�d�p|�d�}|�d|p|�S)Nr�r&�)�_long_author_rer6r8r�)r�r��	shortenedr6rQrQrT�authorinfo_short�s
zChrome.authorinfo_shortcCs
t|d�S)z)Split a CC: value in a list of addresses.z[;,])r)r��cc_fieldrQrQrT�cc_lists
zChrome.cc_listcCs�|dkrtd�S|std�S|jjdd�}|jr&||vr&||d}|r&|S|dur8|j}|s8|r8d|�|�v}|r<|St|�S)a�Format a username in plain text.

        If `[trac]` `show_email_addresses` is `False`, email addresses
        will be obfuscated when the user doesn't have `EMAIL_VIEW`
        (for the resource) and the optional parameter `show_email` is
        `None`. Returns translated `anonymous` or `none`, when the
        author string is `anonymous` or evaluates to `False`,
        respectively.

        :param req: a `Request` or `RenderingContext` object.
        :param author: the author string to be formatted.
        :param resource: an optional `Resource` object for performing
                         fine-grained permission checks for `EMAIL_VIEW`.
        :param show_email: an optional parameter that allows explicit
                           control of e-mail obfuscation.

        :since 1.1.6: accepts the optional `resource` keyword parameter.
        :since 1.2: Full name is returned when `[trac]` `show_full_names`
                    is `True`.
        :since 1.2: Email addresses are obfuscated when
                    `show_email_addresses` is False and `req` is Falsy.
                    Previously email addresses would not be obfuscated
                    whenever `req` was Falsy (typically `None`).
        r�z(none)T)�as_dictrNrF)r8r��get_known_usersr�r�r�r)r�rSr�r��
show_email�usersrdrQrQrTr�szChrome.format_author�, cs$��fdd���|�D�}|�|�S)aJNormalize a list of e-mails and obfuscate them if needed.

        :param context: the context in which the check for obfuscation should
                        be done
        :param   value: a string containing a comma-separated list of e-mails
        :param     sep: the separator to use when rendering the list again
        csg|]}���|��qSrQ)r�)r�r���contextr�rQrTr=4s�z(Chrome.format_emails.<locals>.<listcomp>)r�r�)r�r�r��sep�	formattedrQr�rT�
format_emails,s�
zChrome.format_emailscCs0i}|jr|j��D]\}}}|r|||<q
|S)z+Get the email addresses of all known users.)r�r�r�)r�r��usernamerd�emailrQrQrT�
get_email_map8s�zChrome.get_email_mapcCs|jr
t|d�dSdS)z^Make `<textarea class="trac-resizable">` fields resizable if enabled
        by configuration.zcommon/js/resizer.jsN)r�r��r�rSrQrQrT�add_textarea_gripsCs�zChrome.add_textarea_gripscCs|jrt|d�|�|�dS)z:Add wiki toolbars to `<textarea class="wikitext">` fields.zcommon/js/wikitoolbar.jsN)r�r�r�r�rQrQrT�add_wiki_toolbarsIs
zChrome.add_wiki_toolbarscCs2t|d�|jjd|jdd�}t|||jd�dS)z+Setup auto-preview for `<textarea>` fields.zcommon/js/auto_preview.jszui.auto_preview_timeoutr)�min)r��
form_tokenN)r�r`�as_floatr�r�r�)r�rSr�rQrQrT�add_auto_previewOs
�
�zChrome.add_auto_previewcCs�t||jpd�t||jpd�t|d�t|d�|jdk}t|j�}|�d�}|�d�r0dnd	t	|d	d
��dt	|d
d��}|rJt
|�nd
}t|t|�t
|�t|j�t|j�t|j�t|�t|�t|�||||d�d�t|d�d
S)z@Add a reference to the jQuery UI script and link the stylesheet.zcommon/js/jquery-ui.jsz"common/css/jquery-ui/jquery-ui.csszcommon/js/jquery-ui-addons.jszcommon/css/jquery-ui-addons.css�iso8601z%z�-r�r&��<�N)�month_names�	day_names�date_format�time_format�ampm�period_names�first_week_day�timepicker_separator�
show_timezone�default_timezone�
timezone_list�timezone_iso8601)�	jquery_uizcommon/js/jquery-ui-i18n.js)r�r�r�r��lc_timer&�tz�strftimer��intr3r�r1r2r-r/r.r6r4r5)r�rS�
is_iso8601�now�tzoffsetr�r�rQrQrT�
add_jquery_uiXsB
�
�




"�
��

�zChrome.add_jquery_uic
	s|duri}�jjdd�|d<�o�j��r�jn�jj�d}�jjdkr(�}n
�jjr2t�jj�}�jj�jj�jj�jj	|�jjd�|d<�jj
}dt|oSt�
|��i|d	<�rc|d	��j�n|d	��j���jj�d
��d>��fdd
�	��fdd�}��fdd�}��fdd�}�fdd�}	�r��j�d�j�n�j}
�o��j}|r�|j}|jr�|d|j7}nd}|�id�j�d�r�t��nd�dt�d|�d|�dtt�j��dtt�j��d tt�j��d!tt�j��d"��d#��d$��d%�o��j�d&��o�j �d'��r�j!nd(�d)|�d*|�id+t�j"��#�d,��d-t�j$���d.�j%�d/t�j&���d0�j'�d1tt(j)���d2|	�d|�d3|
�d4��d5tt*�t+��d6tt*�t,��d7tt*�t-��d8tt.j.j/��of�j0d9��d:t1�d;tt2�j��d<tt3�j���d=tt4�j�i��|�r�|�|�|S)?a�Fills a dictionary with the standard set of fields expected
        by templates.

        :param req: a `Request` object; if `None`, no request related fields
                    will be set
        :param data: user-provided `dict`, which can be used to override
                     the defaults; if `None`, the defaults will be returned
        :param d: `dict` which is populated with the defaults; if `None`,
                  an empty `dict` will be used
        Nzhttps://trac.edgewall.org/)r��homepager�r�)rd�descrr�rH�
admin_href�admin_trac_url�project�footerrh)r�rcFc	s�|sdS|dkrt�t|�}nt�t|�}tt�}t||�}|s(�j�d�j�}||kr2t	d|d�nt	d|d�}|dkrE|s@|n|}|}n-|rJ|}n&�j
dkrVt	d	|d
�}n|dkrat	d|d�}nt	d
t�t|�t�t|�d�}|}tj
||d�S)Nr�r�dateinfozin %(relative)s)rz%(relative)s agorr�zat %(iso8601)s)r�zon %(date)s�rzon %(date)s at %(time)s)rr)rp)r0r(r'r&r7r%r`r�rr8r�r)rr�)	r�format�dateonlyrr�r�	in_or_agor[rpr�rQrT�pretty_dateinfo�s<
��
�


�z-Chrome.populate_data.<locals>.pretty_dateinfocs�|ddd�S)NrT)r�r�rQr�)r�rQrTr��sz&Chrome.populate_data.<locals>.dateinfoc�t�j|�fi|��Sr���get_resource_urlr��r�r�)ror�rQrT�get_rel_url��z)Chrome.populate_data.<locals>.get_rel_urlcr�r�r�r�)r�r�rQrT�get_abs_url�r�z)Chrome.populate_data.<locals>.get_abs_urlcst�|�}|r
td�|SdS)Nzaccesskey="%s"r�)rbrr�rRrQrT�accesskey_attr�s
z,Chrome.populate_data.<locals>.accesskey_attrr�r��enr�r�r��url_of�
abs_url_of�name_of�shortname_of�
summary_of�
resource_linkrSr�ror�r�r�z<trac>ri�	trac_langr�)r�r�r�r�r��captioned_buttonrb�dateinfo_formatr�r'r(r)�
fromtimestamp)r�r*�wiki_to�wiki_to_html�wiki_to_onelinerr0)5r��trac_versionror��project_admin_trac_urlr<�project_name�project_description�project_url�
project_admin�project_footerrr�gettextrurhr�rlr`r�rri�language�	territoryr�r�r�get_resource_name�get_resource_shortname�get_resource_summary�render_resource_linkr�r�r�r�r�r�r�r�r�rr�r0r'r(r)rr�r�r*r>r?r@)
r�rSr��dr�r�r�r�r�r�r�rir�rQ)r�ror�rSr�rT�
populate_datays�
�

��� ��
���������	�
���

����������������� �!�
"
��$�'�(�)�-
zChrome.populate_datacCs�|js:|��}tt|�|jdd�|_|jj�|j���|jj�t	j
�|jjjtd�t�
|j�|jjdd�|_|rB|j�|�S|j�|�S)a�Retrieves a template with the given name.

        This simply loads the template. If you want to make use of the
        "standard" Trac API for templates, also call `populate_data`,
        or consider using the shortcut method `prepare_template`
        instead.

        :param text: in text mode (``True``) XML/HTML auto-escape of
                     variable expansion is disabled.
        T)�loaderr��
autoescape)�unicodeF)r)�jenvr]rrr��globalsru�_default_context_data�copyr�	functionsr#r�
jinja2_update�overlay�	jenv_text�get_template)r�r�r��jinja2_dirsrQrQrT�
load_templates�zChrome.load_templatecCs�|�d�}|�d�}|�d�}|�d�}|�d�}	|durd}ddd	��|d
�}
|
dkr^dD]/}z$t��D]}t|j�d||f��}
|
|j|vrR|j|�|
�q5Wq.ty]Yq.w|durf|
dk}|�	|||||�\}}|j�d
�}|j�d�}|j�d�}|j�
|||igid��|�di��
|jd
|jd|jdd��|s�|r�|	r�|�||||	�S|�
|||�}|�d�S||dd<z	|�||||	�WSty�|j�
ddd|||d���w)a�Renders the ``filename`` template using ``data`` for the context.

        It attempts to load a Jinja2 template, augments the provided
        *data* with standard data, and renders it according to the
        options provided in *metadata*.

        The options that can be specified in ``metadata`` are
        ``content_type``, ``text``, ``domain``, ``fragment`` and ``iterable``.

        When ``fragment`` is ``True``, or ``text`` is ``True``, we generate
        some content which does not need all of the chrome related data,
        typically HTML fragments, XML or plain text.

        If ``iterable`` is ``True``, we use `generate_template_stream` to
        produce the output (iterable of UTF-8 encoded bytes),
        otherwise we use `render_template_string` and UTF-8 encode the
        result.

        :since 1.5.1: The ``fragment``, ``iterable`` and ``method`` parameters
            have been removed. Use the ``metadata`` dictionary with keys of
            the same name. The ``method`` key of ``metadata`` is no longer
            supported, use ``text=True`` to indicate that the template is a
            plain text one, with no need for HTML/XML escaping to take place.
        �content_typer��domainr��iterableN�	text/htmlr)r"z
text/plain�xmlr�r�rsr�r�)r�r�r�rsr�r�rh)r�r�r�r)r��	itertools�countrr`�poprhrj�KeyError�prepare_templateruri�generate_template_stream�render_template_string�encoder�)r�rSr�r��metadatarr�r r�r!�methodr�r�r��templatersr�r��srQrQrT�render_template-s|




��
�����
��
�

�
��zChrome.render_templatecC�$|�|||||�\}}|�|||�S)a�Produces content ready to be sent from the given template
        *filename* and input *data*, with minimal overhead.

        It calls `prepare_template` to augment the *data* with the
        usual helper functions that can be expected in Trac templates,
        including the translation helper functions adapted to the given
        *domain*, except for some of the chrome "late" data.

        If you don't need that and don't want the overhead, use
        `load_template` and `generate_template_stream` directly.

        The generated output is suitable to pass directly to
        `Request.send`, see `generate_template_stream` for details.

        See also `render_fragment`, which returns a string instead.

        )r(r)�r�rSr�r�r�r r.rQrQrT�generate_fragment�s�zChrome.generate_fragmentcCr1)a�Produces a string from given template *filename* and input *data*,
        with minimal overhead.

        It calls `prepare_template` to augment the *data* with the
        usual helper functions that can be expected in Trac templates,
        including the translation helper functions adapted to the given
        *domain*, except for some of the chrome "late" data.

        If you don't need that and don't want the overhead, use
        `load_template` and `render_template_string` directly.

        :rtype: the generated output is a `str` string if *text*
                is ``True``, or a `Markup` string otherwise.

        See also `generate_fragment`, which produces an output
        suitable to pass directly to `Request.send` instead.

        )r(r*r2rQrQrT�render_fragment�s�zChrome.render_fragmentc	CsN|�||�}|rttj�}t�||�}|�tt||���|�||�}||fS)aPrepares the rendering of a Jinja2 template.

        This loads the template and prepopulates a data `dict` with
        the "standard" Trac API for templates.

        :param req: a `Request` instance (optional)
        :param filename: the name of a Jinja2 template, which must be
                         found in one of the template directories (see
                         `get_templates_dirs`)
        :param data: user specified data dictionary, used to override
                     the default context set from the request *req*
                     (see `populate_data`)
        :param text: in text mode (``True``) XML/HTML auto-escape of
                     variable expansion is disabled.

        :rtype: a pair of Jinja2 `Template` and a `dict`.

        )	rrPrr�domain_functionsru�dictr�r)	r�rSr�r�r�r r.�symbolsr5rQrQrTr(�s
zChrome.prepare_templatecs\|�|����d�|s|dur|jr|��|�S|r"�fdd�}n�fdd�}d�|��S)a�Returns the rendered template in a form that can be "sent".

        This will be either a single UTF-8 encoded `btyes` object, or an
        iterable made of chunks of the above.

        :param template: the Jinja2 template
        :type template: ``jinja2.Template``

        :param text: in text mode (``True``) the generated bytes will
                     not be sanitized (see `valid_html_bytes`).

        :param iterable: determine whether the output should be
                         generated in chunks or as a single `btyes`; if
                         `None`, the `use_chunked_encoding` property
                         will be used to determine this instead

        :rtype: `btyes` or an iterable of `btyes`, depending on *iterable*

        .. note:

        Turning off the XML/HTML auto-escape feature for variable
        expansions has to be disabled when loading the template (see
        `load_template`), so remember to stay consistent with the
        *text* parameter.

        �KNc3s��D]}|�d�VqdS�Nr)r+��chunk��streamrQrT�generate�s��z1Chrome.generate_template_stream.<locals>.generatec3s ��D]
}t|�d��VqdSr9)rr+r:r<rQrTr>�s���)r=�enable_bufferingr�iterable_contentr�)r�r.r�r�r!r>rQr<rTr)�s

zChrome.generate_template_streamcCs|�|�}|r	|St|�S)aCRenders the template as a str or Markup string.

        :param template: the Jinja2 template
        :type template: ``jinja2.Template``

        :param text: in text mode (``True``) the generated string
                     will not be wrapped in `Markup`

        :rtype: `str` if *text* is ``True``, `Markup` otherwise.

        .. note:

        Turning off the XML/HTML auto-escape feature for variable
        expansions has to be disabled when loading the template (see
        `load_template`), so remember to stay consistent with the
        *text* parameter.

        )�renderr)r�r.r�r��stringrQrQrTr*�s
zChrome.render_template_stringcks��z |r|D]}|�d�VqWdS|D]
}t|�d��VqWdSty)�tyN}z|j�d|jj|r;dndt|dd��WYd}~dSd}~ww)z�Generate an iterable object which iterates `btyes` instances
        from the given stream instance.

        :param text: in text mode (``True``) XML/HTML auto-escape of
                     variable expansion is disabled.
        rz.Jinja2 %s error while rendering %s template %sr�zXML/HTMLT)�	tracebackN)	r+r�
TracBaseErrorr�r�errorr�rXr)r�r=r�r�r;r�rQrQrTrAs&���

���zChrome.iterable_contentr��NN)r��NNN)F)FN)zrXrYrZr[�
implementsrrr
r:r\r=�required�is_valid_default_handler�ExtensionPointrOr�r>�
PathOptionrRrN�
BoolOptionr��Optionr�r�r�r��
ConfigSectionr�r�ryrvrz�	IntOptionrwrxr�r�r�r�r��FloatOptionr��ChoiceOptionrrrOrrrr�rrrrrrrr$rr+rrr	rrrr
�pformatr r%r$rr!r
rrr#r,rrr/r1r3r9rErGr]r^rSrUrTr]rorkrlrWr�r�r�r�r5�compiler�r�r�r�r�r�r�r�r�r�rrr0r3r4r(r)r*rArQrQrQrTr��sT��
�
��	�	��

���������������������	�
���
������ '	
6
L




(	
!

[


�
+r�)NNNNrH)r~)r�rGr�)NFFFF)qr[�
contextlibrrr$r	�os.pathrrLr
r5�	functoolsrrr�trac.apirr�trac.config�	trac.core�trac.mimeview.apirr	�	trac.permr
�
trac.resource�	trac.utilrrr
rrrrrr�trac.util.htmlrrrrrrr�trac.util.textrrrrrr r!r"r#r$�trac.util.datefmtr%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7�trac.util.translationr8r9�trac.web.apir:r;�
trac.web.hrefr<�	trac.wikir=�trac.wiki.formatterr>r?r@r-r.�	InterfacerOr\rbrmr}r�r�r�r�r�r�r�r�r�r�r�r�r�r��	Componentr�rQrQrQrT�<module>sf,$0T






	
	#
�'
'


https://t.me/RX1948 - 2025