Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/views/origin.py
# Copyright (C) 2017-2019 The Software Heritage developers | # Copyright (C) 2017-2019 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 | ||||
from django.shortcuts import render, redirect | from django.shortcuts import render, redirect | ||||
from swh.web.common import service | |||||
from swh.web.common.origin_visits import get_origin_visits | |||||
from swh.web.common.utils import reverse, format_utc_iso_date, parse_timestamp | |||||
from swh.web.common.exc import handle_view_exception | |||||
from swh.web.browse.utils import get_snapshot_context | |||||
from swh.web.browse.browseurls import browse_route | |||||
from .utils.snapshot_context import ( | from swh.web.browse.browseurls import browse_route | ||||
from swh.web.browse.snapshot_context import ( | |||||
browse_snapshot_directory, | browse_snapshot_directory, | ||||
browse_snapshot_content, | browse_snapshot_content, | ||||
browse_snapshot_log, | browse_snapshot_log, | ||||
browse_snapshot_branches, | browse_snapshot_branches, | ||||
browse_snapshot_releases, | browse_snapshot_releases, | ||||
get_snapshot_context, | |||||
) | ) | ||||
from swh.web.common import service | |||||
from swh.web.common.exc import handle_view_exception | |||||
from swh.web.common.origin_visits import get_origin_visits | |||||
from swh.web.common.utils import reverse, format_utc_iso_date, parse_timestamp | |||||
@browse_route( | @browse_route( | ||||
r"origin/(?P<origin_url>.+)/visit/(?P<timestamp>.+)/directory/", | r"origin/(?P<origin_url>.+)/visit/(?P<timestamp>.+)/directory/", | ||||
r"origin/(?P<origin_url>.+)/visit/(?P<timestamp>.+)" "/directory/(?P<path>.+)/", | r"origin/(?P<origin_url>.+)/visit/(?P<timestamp>.+)/directory/(?P<path>.+)/", | ||||
r"origin/(?P<origin_url>.+)/directory/", | r"origin/(?P<origin_url>.+)/directory/", | ||||
r"origin/(?P<origin_url>.+)/directory/(?P<path>.+)/", | r"origin/(?P<origin_url>.+)/directory/(?P<path>.+)/", | ||||
view_name="browse-origin-directory", | view_name="browse-origin-directory", | ||||
) | ) | ||||
def origin_directory_browse(request, origin_url, timestamp=None, path=None): | def origin_directory_browse(request, origin_url, timestamp=None, path=None): | ||||
"""Django view for browsing the content of a directory associated | """Django view for browsing the content of a directory associated | ||||
to an origin for a given visit. | to an origin for a given visit. | ||||
The url scheme that points to it is the following: | The url scheme that points to it is the following: | ||||
* :http:get:`/browse/origin/(origin_url)/directory/[(path)/]` | * :http:get:`/browse/origin/(origin_url)/directory/[(path)/]` | ||||
* :http:get:`/browse/origin/(origin_url)/visit/(timestamp)/directory/[(path)/]` | * :http:get:`/browse/origin/(origin_url)/visit/(timestamp)/directory/[(path)/]` | ||||
""" | """ | ||||
return browse_snapshot_directory( | return browse_snapshot_directory( | ||||
request, origin_url=origin_url, timestamp=timestamp, path=path | request, origin_url=origin_url, timestamp=timestamp, path=path | ||||
) | ) | ||||
@browse_route( | @browse_route( | ||||
r"origin/(?P<origin_url>.+)/visit/(?P<timestamp>.+)" "/content/(?P<path>.+)/", | r"origin/(?P<origin_url>.+)/visit/(?P<timestamp>.+)/content/(?P<path>.+)/", | ||||
r"origin/(?P<origin_url>.+)/content/(?P<path>.+)/", | r"origin/(?P<origin_url>.+)/content/(?P<path>.+)/", | ||||
view_name="browse-origin-content", | view_name="browse-origin-content", | ||||
) | ) | ||||
def origin_content_browse(request, origin_url, path=None, timestamp=None): | def origin_content_browse(request, origin_url, path=None, timestamp=None): | ||||
"""Django view that produces an HTML display of a content | """Django view that produces an HTML display of a content | ||||
associated to an origin for a given visit. | associated to an origin for a given visit. | ||||
The url scheme that points to it is the following: | The url scheme that points to it is the following: | ||||
▲ Show 20 Lines • Show All 135 Lines • Show Last 20 Lines |