summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorSnoweuph <snow+git@euph.email>2024-10-11 05:51:00 +0200
committerBnyro <bnyro@tutanota.com>2024-10-14 14:39:11 +0200
commit5b6f40414a9f8605140bd6fd66b66ac0b6d57e62 (patch)
tree5e5fc4c342402db74fe74612d14bcd3439406c1e /searx
parent7e8b330b3e9f5b7381dcf8bdcbcdf2cf2d94f2cd (diff)
downloadsearxng-5b6f40414a9f8605140bd6fd66b66ac0b6d57e62.tar.gz
searxng-5b6f40414a9f8605140bd6fd66b66ac0b6d57e62.zip
[mod] engine gitea: compatible with modern gitea or forgejo
Without this patch the Gitea Search Engine is only partially compatible with modern gitea or forgejo: - Fixing some JSON Fields - Using Repository Avatar when Available To Verify My results you can look at the Modern API doc and results, its available on all Gitea and Forgejo instance by Default. Heres an Search API result of Mine: - https://git.euph.dev/api/v1/repos/search?q=ccna
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/gitea.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/searx/engines/gitea.py b/searx/engines/gitea.py
index 3775938ed..446d84472 100644
--- a/searx/engines/gitea.py
+++ b/searx/engines/gitea.py
@@ -1,7 +1,8 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-"""Engine to search in collaborative software platforms based on Gitea_.
+"""Engine to search in collaborative software platforms based on Gitea_ or Forgejo_.
.. _Gitea: https://about.gitea.com/
+.. _Forgejo: https://forgejo.org/
Configuration
=============
@@ -23,6 +24,11 @@ Optional settings are:
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``.
@@ -95,13 +101,14 @@ def response(resp):
'url': item.get('html_url'),
'title': item.get('full_name'),
'content': ' / '.join(content),
- 'img_src': item.get('owner', {}).get('avatar_url'),
+ # Use Repository Avatar and fall back to Owner Avatar if not set.
+ 'thumbnail': item.get('avatar_url') or item.get('owner', {}).get('avatar_url'),
'package_name': item.get('name'),
- 'maintainer': item.get('owner', {}).get('login'),
+ 'maintainer': item.get('owner', {}).get('username'),
'publishedDate': parser.parse(item.get("updated_at") or item.get("created_at")),
'tags': item.get('topics', []),
- 'popularity': item.get('stargazers_count'),
- 'homepage': item.get('homepage'),
+ 'popularity': item.get('stars_count'),
+ 'homepage': item.get('website'),
'source_code_url': item.get('clone_url'),
}
)