This commit is contained in:
Daniel Kukula 2024-05-07 06:11:37 +00:00 committed by GitHub
commit aaea2a4f1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 31 additions and 26 deletions

View file

@ -556,10 +556,6 @@ type.
- :py:class:`str`
- the web location of a license copy
* - 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
* - links
- :py:class:`dict`
- a dictionary of link name to link url, e.g. {"homepage": {http://example.com"}

View file

@ -33,10 +33,10 @@ 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 = {"documentation_url": package["docs_html_url"]}
links = {**links, **meta.get("links", {})}
results.append(
{
"template": "packages.html",
@ -46,10 +46,9 @@ def response(resp):
"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", [])),
"links": links,
}
)

View file

@ -47,6 +47,10 @@ 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",
@ -56,10 +60,9 @@ def response(resp):
"content": package.get("description", ""),
"version": package.get("version"),
"maintainer": package.get("author", {}).get("name"),
'publishedDate': publishedDate,
"publishedDate": publishedDate,
"tags": tags,
"homepage": package["links"].get("homepage"),
"source_code_url": package["links"].get("repository"),
"links": links,
}
)

View file

@ -47,17 +47,24 @@
{%- endif -%}
</div>
{%- endif -%}
{%- if result.homepage or result.source_code_url -%}
{%- if result.links -%}
<div class="result_project">{{- '' -}}
<span>{{ _('Project') }}</span>
<span>{{- '' -}}
{%- 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 -%}
{% 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 %}
</span>{{- '' -}}
</div>
{%- endif -%}