swh.web.badges package#
Submodules#
Module contents#
- swh.web.badges.get_logo_data() str [source]#
Get data-URI for Software Heritage SVG logo to embed it in the generated badges.
- swh.web.badges.swh_badge(request: HttpRequest, object_type: str, object_id: str, object_swhid: str | None = '') HttpResponse [source]#
Generate a Software Heritage badge for a given object type and id.
- Parameters:
request – input http request
object_type – The type of swh object to generate a badge for, either content, directory, revision, release, origin or snapshot
object_id – The id of the swh object, either an url for origin type or a sha1 for other object types
object_swhid – If provided, the object SWHID will not be recomputed
- Returns:
HTTP response with content type image/svg+xml containing the SVG badge data. If the provided parameters are invalid, HTTP 400 status code will be returned. If the object cannot be found in the archive, HTTP 404 status code will be returned.
- swh.web.badges.swh_badge_swhid(request: HttpRequest, object_swhid: str) HttpResponse [source]#
Generate a Software Heritage badge for a given object SWHID.
- Parameters:
request (django.http.HttpRequest) – input http request
object_swhid (str) – a SWHID of an archived object
- Returns:
- An http response with content type
image/svg+xml containing the SVG badge data. If any error occurs, a status code of 400 will be returned.
- Return type:
django.http.HttpResponse