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/search/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

�k�`�-�@s�ddlZddlZddlmZmZddlTddlmZddlm	Z	ddl
mZmZddl
mZmZmZmZddlmZdd	lmZdd
lmZddlmZddlmZmZmZmZmZm Z m!Z!m"Z"dd
l#m$Z$ddl%m&Z&Gdd�de'�Z(dS)�N)�	IntOption�
ListOption)�*)�IPermissionRequestor)�
ISearchSource)�format_datetime�	user_time)�Markup�escape�find_element�tag)�	Paginator)�quote_query_string)�_)�IRequestHandler)�INavigationContributor�ITemplateProvider�	accesskey�add_link�
add_notice�add_stylesheet�add_warning�web_context)�IWikiSyntaxProvider)�extract_linkc@s�eZdZdZeeeeee	�e
e�ZdZ
edddd�Zedddd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Z d(d)�Z!d*d+�Z"d,S)-�SearchModulez$Controller for the search sub-system�
�search�min_query_length�zIMinimum length of query string allowed when performing a search.
        �default_disabled_filtersapSpecifies which search filters should be disabled by
               default on the search page. This will also restrict the
               filters for the quick search function. The filter names
               defined by default components are: `wiki`, `ticket`,
               `milestone` and `changeset`.  For plugins, look for
               their implementation of the ISearchSource interface, in
               the `get_search_filters()` method, the first member of
               returned tuple. Once disabled, search filters can still
               be manually enabled by the user on the search page.
               )�doccCsdS�Nr���self�reqr#r#�4/usr/lib/python3/dist-packages/trac/search/web_ui.py�get_active_navigation_itemB�z'SearchModule.get_active_navigation_itemccs<�d|jvrddtjtd�|j��t|d�d�fVdSdS)N�SEARCH_VIEW�mainnavr�Search�)�hrefr)�permr�arr.rrr$r#r#r'�get_navigation_itemsEs�
�
��z!SearchModule.get_navigation_itemscCsdgS)Nr*r#�r%r#r#r'�get_permission_actionsMsz#SearchModule.get_permission_actionscCst�d|j�duS)Nz/search(?:/opensearch)?$)�re�match�	path_infor$r#r#r'�
match_requestRs�zSearchModule.match_requestc
Cs|j�d�|jdkrdiddifS|j�d�}g}|jD]}|�|�|�p'g�q|jdd�d	�|�	||�}|�
||||�}|r�|j�d
d�}|�|||�|d<|�
d
�r]|dd�}|�||�}|rx|�|||�}	|	rx|�|�|||	��|r�|r�d�|�|jd<t|d�d|fS)Nr*z/search/opensearchzopensearch.xml�content_typez%application/opensearchdescription+xml�qcSs|d��S)N�)�lower)�fr#r#r'�<lambda>asz.SearchModule.process_request.<locals>.<lambda>)�key�noquickjumpF�	quickjump�!r:�,�search.filterszcommon/css/search.csszsearch.html)r/�requirer6�args�get�search_sources�extend�get_search_filters�sort�_get_selected_filters�
_prepare_data�getbool�_check_quickjump�
startswith�_parse_query�
_do_search�update�_prepare_results�join�sessionr)
r%r&�query�available_filters�source�filters�datar?�terms�resultsr#r#r'�process_requestVs4
�


zSearchModule.process_requestcC�gS�Nr#r2r#r#r'�get_htdocs_dirsxr)zSearchModule.get_htdocs_dirscCst�dd�gS)Nztrac.search�	templates)�
pkg_resources�resource_filenamer2r#r#r'�get_templates_dirs{szSearchModule.get_templates_dirscCr^r_r#r2r#r#r'�get_wiki_syntax�r)zSearchModule.get_wiki_syntaxccs�d|jfVdSr")�_format_linkr2r#r#r'�get_link_resolvers�s�zSearchModule.get_link_resolversc	Csj|�|�\}}}|r |jj|d�}|r|dt|dd��7}n	|j��t|�}||7}tj|d|d�S)N)r9�&r:r)�class_r.)�
split_linkr.rrrr0)	r%�	formatter�ns�target�label�pathrV�fragmentr.r#r#r'rf�s�zSearchModule._format_linkcsj�fdd�|D�}|s3�j�d�}|r*tdd�|D����fdd�|�d�D�}|S�fdd�|D�}|S)zUReturn selected filters or the default filters if none was
        selected.
        cs"g|]
}|d�jvr|d�qS)r)rE��.0r<)r&r#r'�
<listcomp>�s"z6SearchModule._get_selected_filters.<locals>.<listcomp>rCcSsg|]}|dd��qS)r�r#rqr#r#r'rs�s�csg|]}|�vr|�qSr#r#rq)�available_filters_dictr#r'rs�s�rBcsBg|]}|d�jvrt|�dkst|�dkr|dr|d�qS)rrrt)r �lenrqr2r#r'rs�s
 �)rUrF�dict�split)r%r&rWrY�session_filtersr#)rur&r%r'rK�s��z"SearchModule._get_selected_filterscs�fdd�|D�|dgd�S)Ncs(g|]}|d|d|d�vd��qS)rr:)�namern�activer#rq�rYr#r'rs�s
�

�z.SearchModule._prepare_data.<locals>.<listcomp>)rYrVr@r\r#)r%r&rVrWrYr#r|r'rL�s

��zSearchModule._prepare_datac	Cs�d}|ddkr|j�|�}|}td|d�}n#t|d�}tt|j||�d�}|dur:|j�d�}|j	}|j�dd	�}|r}|�
|jpBd�sFd
}|rQ|t�
|�|d�S|j�d�d
}	|j�d|fdg�}
t|ttdt|	�t|�t|
�d���|�|�dSdS)zLook for search shortcutsNr�/zBrowse repository path %(path)s)rorr.�title�T)r.rz�description�
TracSearchz#Quicksearchesr9)r?r:z�You arrived here through the <a href="%(help_url)s">quick-jump</a> search feature. To instead search for the term <strong>%(term)s</strong>, click <a href="%(search_url)s">here</a>.)�help_url�term�
search_url)r.�browserrrrr�env�attribrF�childrenrO�	base_pathr�em�wikirrr	r
�redirect)r%r&r?�kwd�quickjump_hrefrzr��context�linkr�r�r#r#r'rN�s6

�
��zSearchModule._check_quickjumpcCs\g}t�d|�D]#}|dur+|��r+|d|dkr&|ddvr&|dd�}|�|�q|S)z�Break apart a search query into its various search terms.

        Terms are grouped implicitly by word boundary, or explicitly by (single
        or double) quotes.
        z(".*?")|('.*?')|(\s+)Nr���z'"r:)r4rx�strip�append)r%rVr[r�r#r#r'�_get_search_terms�s
�zSearchModule._get_search_termscCsH|�|�}|rt|�dkst|d�|jkr|St|td|jd��dS)zMParse query and refuse those which would result in a huge result set
        r:rzGSearch query too short. Query must be at least %(num)s characters long.��numN)r�rvrrr)r%r&rVr[r#r#r'rP�s
�zSearchModule._parse_querycCs:g}|jD]}|�|�|||�pg�qt|dd�dd�S)NcSs|dS)Nrtr#)�xr#r#r'r=�sz)SearchModule._do_search.<locals>.<lambda>T)r>�reverse)rGrH�get_search_results�sorted)r%r&r[rYr\rXr#r#r'rQ�s
�zSearchModule._do_searchc

s�|jjdddd�}zt||d|j�}Wnty1t|td|d��d}t||d|j�}Ynwt|�D]\}}|d|dt|t	|d�|d|d	d
�||<q6g}|�
d�}|D]$}	|jjdd
�|D�|j�
d�|	dd�}
|�|
dt|	�td|	d�g�q\gd���fdd
�|D�|_ddt|jd�dd�|_|jr�|jjt|dgt|��|j�
d�|ddd�}t|d|td��|jr�|jjt|dgt|��|j�
d�|ddd�}t|d|td��|jjt|dgt|��|j�
d�dd�}
||
d�S)N�pager:)�minzPage %(page)s is out of range.)r�rrtrr-)r.r~�date�author�excerpt�cSsg|]}|df�qS)�onr#rqr#r#r'rssz1SearchModule._prepare_results.<locals>.<listcomp>r9)r9r�r?zPage %(num)dr�)r.�class�stringr~csg|]	}tt�|���qSr#)rw�zip)rr�p��fieldsr#r'rss�currentr��nextz	Next Page�prevz
Previous Page)r9r?)r\�	page_href)rE�getintr
�RESULTS_PER_PAGE�	TracErrorrr�	enumeraterr�get_shown_pagesr.rrFr��str�shown_pagesr��current_page�
has_next_pager�rvr�has_previous_page)
r%r&rYr\r��idx�result�pagedatar��
shown_pager��	next_href�	prev_hrefr#r�r'rS�s\��

�
�����
zSearchModule._prepare_resultsN)#�__name__�
__module__�__qualname__�__doc__�
implementsrrrrr�ExtensionPointrrGr�rrrr r(r1r3r7r]r`rdrergrfrKrLrNr�rPrQrSr#r#r#r'r%s>���"
#r))rbr4�trac.configrr�	trac.core�	trac.permr�trac.search.apir�trac.util.datefmtrr�trac.util.htmlr	r
rr�trac.util.presentationr
�trac.util.textr�trac.util.translationr�trac.web.apir�trac.web.chromerrrrrrrr�
trac.wiki.apir�trac.wiki.formatterr�	Componentrr#r#r#r'�<module>s (

https://t.me/RX1948 - 2025