archivebox.core.viewsο
Module Contentsο
Classesο
Admin-only handoff that lets a snap host mint its own replay cookie. |
|
Serve snapshots by the new URL scheme: / |
|
Serve snapshot directory contents on |
|
Serve snapshot directory contents on a one-domain replay path. |
|
Serve responses from the most recent snapshot when using |
|
Serve original-domain replay content on a one-domain replay path. |
|
A Django view that renders plain text βOKβ for service discovery tools |
Functionsο
Only allow same-snap relative replay paths; grants must never redirect off-host. |
|
A replay cookie is not its own auth source; it must point at a live admin session. |
|
Resolve plugin-relative output paths through ArchiveResult.output_files. |
|
Dataο
APIο
- archivebox.core.views._files_index_target(snapshot: archivebox.core.models.Snapshot, archivefile: str | None) str[source]ο
- archivebox.core.views._find_snapshot_by_ref(snapshot_ref: str) archivebox.core.models.Snapshot | None[source]ο
- archivebox.core.views._admin_login_redirect_or_forbidden(request: django.http.HttpRequest)[source]ο
- archivebox.core.views._replay_cookie_name(snapshot: archivebox.core.models.Snapshot) str[source]ο
- archivebox.core.views._clean_replay_next(path: str | None) str[source]ο
Only allow same-snap relative replay paths; grants must never redirect off-host.
- archivebox.core.views._replay_payload_is_valid(payload: dict, snapshot: archivebox.core.models.Snapshot) bool[source]ο
A replay cookie is not its own auth source; it must point at a live admin session.
Replayed pages can execute hostile JS, so admin cookies stay host-only on admin.. The snap host gets only this host-only HttpOnly cookie, and every request checks that the original Django session still exists and still belongs to an active staff user. Logout, session expiry, user deletion/deactivation, or password auth-hash rotation all make the replay cookie inert without needing admin. to delete a cookie on snap-*.
- archivebox.core.views._has_replay_cookie(request: django.http.HttpRequest, snapshot: archivebox.core.models.Snapshot) bool[source]ο
- archivebox.core.views._private_snapshot_auth_redirect(request: django.http.HttpRequest, snapshot: archivebox.core.models.Snapshot, path: str = '', *, preserve_query: bool = True)[source]ο
- archivebox.core.views._replay_auth_response(request: django.http.HttpRequest, snapshot: archivebox.core.models.Snapshot)[source]ο
- class archivebox.core.views.SnapshotReplayAuthView[source]ο
Bases:
django.views.ViewAdmin-only handoff that lets a snap host mint its own replay cookie.
admin.* cannot set a host-only cookie for snap-* (browsers forbid that), and widening the real Django session cookie to .archivebox.localhost would let XSS in replayed pages hit the admin UI. Instead admin. proves the user is logged in with a short URL grant, then snap-* validates it and sets a snap-host-only cookie.
- class archivebox.core.views.SnapshotView[source]ο
Bases:
django.views.View- static find_snapshots_for_url(path: str)[source]ο
Return a queryset of snapshots matching a URL-ish path. URL only β never tries ID matching.
Use
find_snapshots_for_idseparately if you also want to match by snapshot UUID.
- static find_snapshots_for_id(slug: str)[source]ο
Return a queryset of snapshots matching a (possibly truncated) UUID via prefix or suffix.
Strips non-hex characters from
slug(so input with or without hyphens both work). Requires at least 8 hex chars β shorter inputs return an empty queryset to avoid scanning the entire snapshots table on too-broad matches.
- class archivebox.core.views.SnapshotPathView[source]ο
Bases:
django.views.ViewServe snapshots by the new URL scheme: /
/ / / /β¦
- archivebox.core.views._resolve_archiveresult_relpath(snapshot: archivebox.core.models.Snapshot, rel_path: str) tuple[str, bool][source]ο
Resolve plugin-relative output paths through ArchiveResult.output_files.
- archivebox.core.views._snapshot_sort_key(match_path: str, cache: dict[str, float]) tuple[float, str][source]ο
- archivebox.core.views._replay_path_visible(request: django.http.HttpRequest, path: pathlib.Path) bool[source]ο
- archivebox.core.views._latest_response_match(request: django.http.HttpRequest, domain: str, rel_path: str, *, data_root: pathlib.Path) tuple[pathlib.Path, pathlib.Path] | None[source]ο
- archivebox.core.views._latest_responses_root(request: django.http.HttpRequest, domain: str, *, data_root: pathlib.Path) pathlib.Path | None[source]ο
- archivebox.core.views._latest_snapshot_for_domain(request: django.http.HttpRequest, domain: str) archivebox.core.models.Snapshot | None[source]ο
- archivebox.core.views._original_request_url(domain: str, path: str = '', query_string: str = '') str[source]ο
- archivebox.core.views._serve_responses_path(request, responses_root: pathlib.Path, rel_path: str, show_indexes: bool)[source]ο
- archivebox.core.views._serve_snapshot_replay(request: django.http.HttpRequest, snapshot: archivebox.core.models.Snapshot, path: str = '')[source]ο
- archivebox.core.views._serve_original_domain_replay(request: django.http.HttpRequest, domain: str, path: str = '')[source]ο
- class archivebox.core.views.SnapshotHostView[source]ο
Bases:
django.views.ViewServe snapshot directory contents on
.<listen_host>/ .
- class archivebox.core.views.SnapshotReplayView[source]ο
Bases:
django.views.ViewServe snapshot directory contents on a one-domain replay path.
- class archivebox.core.views.OriginalDomainHostView[source]ο
Bases:
django.views.ViewServe responses from the most recent snapshot when using
.<listen_host>/ .
- class archivebox.core.views.OriginalDomainReplayView[source]ο
Bases:
django.views.ViewServe original-domain replay content on a one-domain replay path.
- class archivebox.core.views.PublicIndexView[source]ο
Bases:
django.views.generic.list.ListView- _ordered_public_page_from_order_index(*, page_number: int, page_size: int) list[archivebox.core.models.Snapshot] | None[source]ο
- class archivebox.core.views.AddView[source]ο
Bases:
django.contrib.auth.mixins.UserPassesTestMixin,django.views.generic.FormView- _get_custom_config_overrides(form: archivebox.core.forms.AddLinkForm) dict[source]ο
- _create_crawl_from_form(form, *, created_by_id=None) archivebox.crawls.models.Crawl[source]ο
- class archivebox.core.views.HealthCheckView[source]ο
Bases:
django.views.ViewA Django view that renders plain text βOKβ for service discovery tools