Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/views/revision.py
# Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import hashlib | import hashlib | ||||
import json | import json | ||||
import textwrap | import textwrap | ||||
from django.http import JsonResponse | from django.http import JsonResponse | ||||
from django.shortcuts import render | from django.shortcuts import render | ||||
from django.template.defaultfilters import filesizeformat | |||||
from django.utils.safestring import mark_safe | from django.utils.safestring import mark_safe | ||||
from swh.model.hashutil import hash_to_bytes | from swh.model.hashutil import hash_to_bytes | ||||
from swh.model.identifiers import ( | from swh.model.identifiers import ( | ||||
CONTENT, | CONTENT, | ||||
DIRECTORY, | DIRECTORY, | ||||
REVISION, | REVISION, | ||||
SNAPSHOT, | SNAPSHOT, | ||||
▲ Show 20 Lines • Show All 489 Lines • ▼ Show 20 Lines | else: | ||||
) | ) | ||||
for f in files: | for f in files: | ||||
query_params["path"] = path + f["name"] | query_params["path"] = path + f["name"] | ||||
f["url"] = reverse( | f["url"] = reverse( | ||||
"browse-revision", | "browse-revision", | ||||
url_args={"sha1_git": sha1_git}, | url_args={"sha1_git": sha1_git}, | ||||
query_params=query_params, | query_params=query_params, | ||||
) | ) | ||||
if f["length"] is not None: | |||||
f["length"] = filesizeformat(f["length"]) | |||||
if f["name"].lower().startswith("readme"): | if f["name"].lower().startswith("readme"): | ||||
readmes[f["name"]] = f["checksums"]["sha1"] | readmes[f["name"]] = f["checksums"]["sha1"] | ||||
readme_name, readme_url, readme_html = get_readme_to_display(readmes) | readme_name, readme_url, readme_html = get_readme_to_display(readmes) | ||||
top_right_link = { | top_right_link = { | ||||
"url": get_revision_log_url(sha1_git, snapshot_context), | "url": get_revision_log_url(sha1_git, snapshot_context), | ||||
"icon": swh_object_icons["revisions history"], | "icon": swh_object_icons["revisions history"], | ||||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |