Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/views/content.py
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | def content_display(request, query_string): | ||||
The url that points to it is | The url that points to it is | ||||
:http:get:`/browse/content/[(algo_hash):](hash)/` | :http:get:`/browse/content/[(algo_hash):](hash)/` | ||||
""" | """ | ||||
try: | try: | ||||
algo, checksum = query.parse_hash(query_string) | algo, checksum = query.parse_hash(query_string) | ||||
checksum = hash_to_hex(checksum) | checksum = hash_to_hex(checksum) | ||||
content_data = request_content(query_string, | content_data = request_content(query_string, | ||||
raise_if_unavailable=False) | raise_if_unavailable=False) | ||||
origin_type = request.GET.get('origin_type', None) | |||||
origin_url = request.GET.get('origin_url', None) | origin_url = request.GET.get('origin_url', None) | ||||
selected_language = request.GET.get('language', None) | selected_language = request.GET.get('language', None) | ||||
if not origin_url: | if not origin_url: | ||||
origin_url = request.GET.get('origin', None) | origin_url = request.GET.get('origin', None) | ||||
snapshot_context = None | snapshot_context = None | ||||
if origin_url: | if origin_url: | ||||
try: | try: | ||||
snapshot_context = get_snapshot_context(None, origin_type, | snapshot_context = get_snapshot_context(origin_url=origin_url) | ||||
origin_url) | |||||
except Exception: | except Exception: | ||||
raw_cnt_url = reverse('browse-content', | raw_cnt_url = reverse('browse-content', | ||||
url_args={'query_string': query_string}) | url_args={'query_string': query_string}) | ||||
error_message = \ | error_message = \ | ||||
('The Software Heritage archive has a content ' | ('The Software Heritage archive has a content ' | ||||
'with the hash you provided but the origin ' | 'with the hash you provided but the origin ' | ||||
'mentioned in your request appears broken: %s. ' | 'mentioned in your request appears broken: %s. ' | ||||
'Please check the URL and try again.\n\n' | 'Please check the URL and try again.\n\n' | ||||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |