diff --git a/swh/web/common/middlewares.py b/swh/web/common/middlewares.py index 84fd1e6a..d3f55bcf 100644 --- a/swh/web/common/middlewares.py +++ b/swh/web/common/middlewares.py @@ -1,71 +1,73 @@ -# Copyright (C) 2018-2019 The Software Heritage developers +# Copyright (C) 2018-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information from htmlmin import minify import sentry_sdk from swh.web.common.utils import prettify_html class HtmlPrettifyMiddleware(object): """ Django middleware for prettifying generated HTML in development mode. """ def __init__(self, get_response): self.get_response = get_response def __call__(self, request): response = self.get_response(request) if "text/html" in response.get("Content-Type", ""): if hasattr(response, "content"): content = response.content response.content = prettify_html(content) elif hasattr(response, "streaming_content"): content = b"".join(response.streaming_content) response.streaming_content = prettify_html(content) return response class HtmlMinifyMiddleware(object): """ Django middleware for minifying generated HTML in production mode. """ def __init__(self, get_response=None): self.get_response = get_response def __call__(self, request): response = self.get_response(request) if "text/html" in response.get("Content-Type", ""): try: - minified_html = minify(response.content.decode("utf-8")) + minified_html = minify( + response.content.decode("utf-8"), convert_charrefs=False + ) response.content = minified_html.encode("utf-8") except Exception as exc: sentry_sdk.capture_exception(exc) return response class ThrottlingHeadersMiddleware(object): """ Django middleware for inserting rate limiting related headers in HTTP response. """ def __init__(self, get_response=None): self.get_response = get_response def __call__(self, request): resp = self.get_response(request) if "RateLimit-Limit" in request.META: resp["X-RateLimit-Limit"] = request.META["RateLimit-Limit"] if "RateLimit-Remaining" in request.META: resp["X-RateLimit-Remaining"] = request.META["RateLimit-Remaining"] if "RateLimit-Reset" in request.META: resp["X-RateLimit-Reset"] = request.META["RateLimit-Reset"] return resp diff --git a/swh/web/templates/browse/help.html b/swh/web/templates/browse/help.html index 09b35738..37af9eac 100644 --- a/swh/web/templates/browse/help.html +++ b/swh/web/templates/browse/help.html @@ -1,189 +1,189 @@ {% extends "./layout.html" %} {% comment %} Copyright (C) 2017-2020 The Software Heritage developers See the AUTHORS file at the top-level directory of this distribution License: GNU Affero General Public License version 3, or any later version See top-level LICENSE file for more information {% endcomment %} {% block navbar-content %}

How to browse the archive ?

{% endblock %} {% block browse-content %}

Overview

This web application aims to provide HTML views to easily navigate in the Software Heritage archive. This is an ongoing development and new features and improvements will be progressively added over time.

URI scheme

The current URI scheme of that web application is described below and depends on the type of Software Heritage object to browse. Its exhaustive documentation can be consulted from the official Software Heritage development documentation

Context-independent browsing

Context-independent URLs provide information about objects (e.g., revisions, directories, contents, persons, …), independently of the contexts where they have been found (e.g., specific software origins, branches, commits, …).

Below are some examples of endpoints used to just render the corresponding information for user consumption:

Where hyperlinks are created when browsing these kind of endpoints, they always point to other context-independent browsing URLs.

Context-dependent browsing

Context-dependent URLs provide information about objects, limited to specific contexts where the objects have been found.

Currently, browsing the Software Heritage objects in the context of an origin is available. Below are some examples of such endpoints:

Search software origins to browse

In order to facilitate the browsing of the archive and generate relevant entry points to it, a search interface is available. Currently, it enables to search software origins from the URLs they were retrieved from. More search criteria will be added in the future. {% endblock %}