mirror of https://github.com/searxng/searxng.git
cr suggestions
This commit is contained in:
parent
8a400c8969
commit
df5fb8acc5
|
@ -556,6 +556,10 @@ type.
|
|||
- :py:class:`str`
|
||||
- the web location of a license copy
|
||||
|
||||
* - links
|
||||
- :py:class:`dict`
|
||||
- a dictionary of link name to link url, e.g. {"homepage": {http://example.com"}
|
||||
* - homepage
|
||||
- :py:class:`str`
|
||||
- the url of the project's homepage
|
||||
|
||||
* - source_code_url
|
||||
- :py:class:`str`
|
||||
- the location of the project's source code
|
||||
|
|
|
@ -35,8 +35,6 @@ def response(resp):
|
|||
meta = package["meta"]
|
||||
published_date = package.get("updated_at")
|
||||
published_date = parser.parse(published_date)
|
||||
links = {"documentation_url": package["docs_html_url"]}
|
||||
links = {**links, **meta.get("links", {})}
|
||||
results.append(
|
||||
{
|
||||
"template": "packages.html",
|
||||
|
@ -48,8 +46,19 @@ def response(resp):
|
|||
"maintainer": ", ".join(meta.get("maintainers", [])),
|
||||
"publishedDate": published_date,
|
||||
"license_name": ", ".join(meta.get("licenses", [])),
|
||||
"links": links,
|
||||
"homepage": package["docs_html_url"],
|
||||
"source_code_url": get_source_code_url(meta.get("links", {})),
|
||||
}
|
||||
)
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def get_source_code_url(links):
|
||||
for k, v in links.items():
|
||||
if k.lower() in ["source", "github", "gitlab"]:
|
||||
return v
|
||||
|
||||
for k, v in links.items():
|
||||
if "github" in v or "gitlab" in v:
|
||||
return v
|
||||
|
|
|
@ -47,10 +47,6 @@ def response(resp):
|
|||
if publishedDate:
|
||||
publishedDate = parser.parse(publishedDate)
|
||||
tags = list(entry.get("flags", {}).keys()) + package.get("keywords", [])
|
||||
links = {
|
||||
"homepage": package["links"].get("homepage"),
|
||||
"source_code_url": package["links"].get("repository"),
|
||||
}
|
||||
results.append(
|
||||
{
|
||||
"template": "packages.html",
|
||||
|
@ -60,9 +56,10 @@ def response(resp):
|
|||
"content": package.get("description", ""),
|
||||
"version": package.get("version"),
|
||||
"maintainer": package.get("author", {}).get("name"),
|
||||
"publishedDate": publishedDate,
|
||||
'publishedDate': publishedDate,
|
||||
"tags": tags,
|
||||
"links": links,
|
||||
"homepage": package["links"].get("homepage"),
|
||||
"source_code_url": package["links"].get("repository"),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -47,24 +47,17 @@
|
|||
{%- endif -%}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{%- if result.links -%}
|
||||
{%- if result.homepage or result.source_code_url -%}
|
||||
<div class="result_project">{{- '' -}}
|
||||
<span>{{ _('Project') }}</span>
|
||||
<span>{{- '' -}}
|
||||
{% for name, link in result.links.items() %}
|
||||
{% if not loop.first %} | {% endif %}
|
||||
<a href="{{ link }}" target="_blank">
|
||||
{% if name == 'homepage' %}
|
||||
{{ _('Project homepage') }}
|
||||
{% elif name == 'documentation_url' %}
|
||||
{{ _('Documenation') }}
|
||||
{% elif name == 'source_code_url' %}
|
||||
{{ _('Source code') }}
|
||||
{% else %}
|
||||
{{ name }}
|
||||
{% endif %}
|
||||
</a>
|
||||
{% endfor %}
|
||||
{%- if result.homepage -%}
|
||||
<a href="{{ result.homepage }}" target="_blank">{{ _('Project homepage') }}</a>
|
||||
{%- endif -%}
|
||||
{%- if result.homepage and result.source_code_url %} | {% endif -%}
|
||||
{%- if result.source_code_url -%}
|
||||
<a href="{{ result.source_code_url }}" target="_blank">{{ _('Source code') }}</a>
|
||||
{%- endif -%}
|
||||
</span>{{- '' -}}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
|
|
Loading…
Reference in New Issue