mirror of
https://github.com/searxng/searxng
synced 2024-10-30 21:20:28 +00:00
[mod] package.html template: additional links (a python dict)
- Closes: https://github.com/searxng/searxng/issues/3456
This commit is contained in:
parent
ac430a9eaf
commit
7dc6a368b6
@ -563,3 +563,7 @@ type.
|
||||
* - source_code_url
|
||||
- :py:class:`str`
|
||||
- the location of the project's source code
|
||||
|
||||
* - links
|
||||
- :py:class:`dict`
|
||||
- additional links in the form of ``{'link_name': 'http://example.com'}``
|
||||
|
@ -33,23 +33,22 @@ def response(resp):
|
||||
results = []
|
||||
for package in resp.json():
|
||||
meta = package["meta"]
|
||||
publishedDate = package.get("inserted_at")
|
||||
if publishedDate:
|
||||
publishedDate = parser.parse(publishedDate)
|
||||
tags = meta.get("licenses", [])
|
||||
published_date = package.get("updated_at")
|
||||
published_date = parser.parse(published_date)
|
||||
links = meta.get("links")
|
||||
results.append(
|
||||
{
|
||||
"template": "packages.html",
|
||||
"url": package["url"],
|
||||
"url": package["html_url"],
|
||||
"title": package["name"],
|
||||
"package_name": package["name"],
|
||||
"content": meta.get("description", ""),
|
||||
"version": meta.get("latest_version"),
|
||||
"maintainer": ", ".join(meta.get("maintainers", [])),
|
||||
"publishedDate": publishedDate,
|
||||
"tags": tags,
|
||||
"homepage": meta.get("links", {}).get("homepage"),
|
||||
"source_code_url": meta.get("links", {}).get("github"),
|
||||
"publishedDate": published_date,
|
||||
"license_name": ", ".join(meta.get("licenses", [])),
|
||||
"homepage": package["docs_html_url"],
|
||||
"links": links,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
{%- endif -%}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{%- if result.homepage or result.source_code_url -%}
|
||||
{%- if result.homepage or result.source_code_url or result.links -%}
|
||||
<div class="result_project">{{- '' -}}
|
||||
<span>{{ _('Project') }}</span>
|
||||
<span>{{- '' -}}
|
||||
@ -58,6 +58,14 @@
|
||||
{%- if result.source_code_url -%}
|
||||
<a href="{{ result.source_code_url }}" target="_blank">{{ _('Source code') }}</a>
|
||||
{%- endif -%}
|
||||
{%- if result.links %}
|
||||
{%- for name, link in result.links.items() -%}
|
||||
{% if not loop.first or result.homepage or result.source_code_url %} | {% endif %}
|
||||
<a href="{{ link }}" target="_blank">
|
||||
{{- _(name) -}}
|
||||
</a>
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
</span>{{- '' -}}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
|
Loading…
Reference in New Issue
Block a user