
    i                         U d Z ddlmZ ddlmZ dddddd	d
ZddgZdZdZe	e
d<   	 dZe	e
d<   	 dZ	 dZee
d<   	 d Zd Zd Zy)a  Engine to search in collaborative software platforms based on Gitea_ or Forgejo_.

.. _Gitea: https://about.gitea.com/
.. _Forgejo: https://forgejo.org/

Configuration
=============

The engine has the following mandatory setting:

- :py:obj:`base_url`

Optional settings are:

- :py:obj:`sort`
- :py:obj:`order`
- :py:obj:`page_size`

.. code:: yaml

  - name: gitea.com
    engine: gitea
    base_url: https://gitea.com
    shortcut: gitea

  - name: forgejo.com
    engine: gitea
    base_url: https://code.forgejo.org
    shortcut: forgejo

If you would like to use additional instances, just configure new engines in the
:ref:`settings <settings engines>` and set the ``base_url``.


Implementation
==============

    )	urlencode)parserzhttps://about.gitea.comNz1https://docs.gitea.com/next/development/api-usageTFJSON)websitewikidata_idofficial_api_documentationuse_official_apirequire_api_keyresultsitrepos base_urlupdatedsortdesc
   	page_sizec                 &    t         st        d      y )Nzgitea engine: base_url is unset)r   
ValueError)_s    $/root/searxng/searx/engines/gitea.pyinitr   P   s    :;;     c                 b    | t         t        t        |d   d}t         dt	        |       |d<   |S )Npageno)qlimitr   orderpagez/api/v1/repos/search?url)r   r   r   r   r   )queryparamsargss      r   requestr%   U   s8    D5RXYaRbcDj 5io5FGF5MMr   c                    g }| j                         j                  dg       D ]P  }dD cg c]%  }|j                  |      s|j                  |      ' }}|j                  d|j                  d      |j                  d      dj                  |      |j                  d      xs! |j                  di       j                  d      |j                  d	      |j                  di       j                  d
      t	        j
                  |j                  d      xs |j                  d            |j                  dg       |j                  d      |j                  d      |j                  d      d       S |S c c}w )Ndata)languagedescriptionzpackages.htmlhtml_url	full_namez / 
avatar_urlownernameusername
updated_at
created_attopicsstars_countr   	clone_url)templater!   titlecontent	thumbnailpackage_name
maintainerpublishedDatetags
popularityhomepagesource_code_url)jsongetappendjoinr   parse)respr   itemir7   s        r   responserH   \   s5   G		+ 
(CS1txxPQ{488A;SS+xx
++. ::g.!XXl3^txx7L7P7PQ]7^ $ 0"hhw377
C!'dhh|.D.^Q]H^!_2."hh}5 HHY/#'88K#8	

* N) Ts   E9E9)__doc__urllib.parser   dateutilr   about
categoriespagingr   str__annotations__r   r   r   intr   r%   rH    r   r   <module>rS      s   %N #  )"U	 G_
	#  !c  	 	3  6<
r   