From 5b6f40414a9f8605140bd6fd66b66ac0b6d57e62 Mon Sep 17 00:00:00 2001 From: Snoweuph Date: Fri, 11 Oct 2024 05:51:00 +0200 Subject: [PATCH] [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 --- searx/engines/gitea.py | 17 ++++++++++++----- 1 file 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 ` 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'), } )