.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.gitea Namespace Reference

Functions

 init (_)
 
 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['it', 'repos']
 
bool paging = True
 
str base_url = ''
 
str sort = "updated"
 
str order = "desc"
 
int page_size = 10
 

Detailed Description

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 engine>` and set the ``base_url``.


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

Function Documentation

◆ init()

searx.engines.gitea.init ( _)

Definition at line 80 of file gitea.py.

80def init(_):
81 if not base_url:
82 raise ValueError('gitea engine: base_url is unset')
83
84

◆ request()

searx.engines.gitea.request ( query,
params )

Definition at line 85 of file gitea.py.

85def request(query, params):
86 args = {'q': query, 'limit': page_size, 'sort': sort, 'order': order, 'page': params['pageno']}
87 params['url'] = f"{base_url}/api/v1/repos/search?{urlencode(args)}"
88
89 return params
90
91

◆ response()

searx.engines.gitea.response ( resp)

Definition at line 92 of file gitea.py.

92def response(resp):
93 results = []
94
95 for item in resp.json().get('data', []):
96 content = [item.get(i) for i in ['language', 'description'] if item.get(i)]
97
98 results.append(
99 {
100 'template': 'packages.html',
101 'url': item.get('html_url'),
102 'title': item.get('full_name'),
103 'content': ' / '.join(content),
104 # Use Repository Avatar and fall back to Owner Avatar if not set.
105 'thumbnail': item.get('avatar_url') or item.get('owner', {}).get('avatar_url'),
106 'package_name': item.get('name'),
107 'maintainer': item.get('owner', {}).get('username'),
108 'publishedDate': parser.parse(item.get("updated_at") or item.get("created_at")),
109 'tags': item.get('topics', []),
110 'popularity': item.get('stars_count'),
111 'homepage': item.get('website'),
112 'source_code_url': item.get('clone_url'),
113 }
114 )
115
116 return results

Variable Documentation

◆ about

dict searx.engines.gitea.about
Initial value:
1= {
2 "website": 'https://about.gitea.com',
3 "wikidata_id": None,
4 "official_api_documentation": 'https://docs.gitea.com/next/development/api-usage',
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 44 of file gitea.py.

◆ base_url

str searx.engines.gitea.base_url = ''

Definition at line 56 of file gitea.py.

◆ categories

list searx.engines.gitea.categories = ['it', 'repos']

Definition at line 53 of file gitea.py.

◆ order

str searx.engines.gitea.order = "desc"

Definition at line 69 of file gitea.py.

◆ page_size

int searx.engines.gitea.page_size = 10

Definition at line 76 of file gitea.py.

◆ paging

bool searx.engines.gitea.paging = True

Definition at line 54 of file gitea.py.

◆ sort

str searx.engines.gitea.sort = "updated"

Definition at line 59 of file gitea.py.