archivebox.core.templatetags.core_tags

Module Contents

Functions

snapshot_url_text

Emphasize the hostname while preserving the exact selectable URL.

plugin_ui

Optional plugin UI must never prevent the host page from rendering.

_is_web_subdomain_alias

Hide the informational mismatch banner on the conventional public web alias.

_normalize_output_files

_snapshot_id

_coerce_output_file_size

_count_media_files

_list_media_files

_resolve_snapshot_output_file

_is_text_preview_path

_is_image_preview_path

_is_root_snapshot_output_path

_static_snapshot_base_url

_snapshot_base_url_for_context

_snapshot_url_for_context

_build_snapshot_preview_url

_render_text_preview

_render_fallback_card

_render_text_file_preview

split

index

file_size

grid_file_size

intcomma

result_list

Monkey patched result

_machine_health_stats

Cached wrapper around the Machine-admin stats util.

system_warnings_banner

Render the top-of-page warning banner for one of the conditions below, in priority order (highest first):

url_replace

admin_base_url

web_base_url

static_export_root_url

snapshot_base_url

snapshot_detail_url

Keep the trusted snapshot detail page on web.*, not the replay host.

snapshot_url

snapshot_files_url

snapshot_zip_url

snapshot_role_output_url

snapshot_result_file_url

Build a saved-file URL from one ArchiveResult declaration.

snapshot_thumbnail

snapshot_index_row

snapshot_preview_url

plugin_icon

Render the icon for a plugin.

plugin_card

Render the card template for an archive result.

render_plugin_card_document

Render one plugin card template for the trusted snapshot-origin frame.

output_card

plugin_full

Render the full template for an archive result.

plugin_name

Get the base name of a plugin (strips numeric prefix).

api_token

Return an API token string for the logged-in user, creating one if needed.

Data

register

CARD_OVERFLOW_STYLE

_TEXT_PREVIEW_EXTS

_IMAGE_PREVIEW_EXTS

_STATIC_URL_SAFE

_VIDEO_FILE_EXTS

_AUDIO_FILE_EXTS

_MEDIA_FILE_EXTS

_BROWSER_VIDEO_FILE_EXTS

_BROWSER_AUDIO_FILE_EXTS

_LOW_DISK_THRESHOLD_GB

_HIGH_MEMORY_THRESHOLD_PCT

_HIGH_LOAD_MULTIPLE

_HEALTH_CHECK_INTERVAL_SECONDS

_health_cache

API

archivebox.core.templatetags.core_tags.register[source]

β€˜Library(…)’

archivebox.core.templatetags.core_tags.CARD_OVERFLOW_STYLE[source]

β€˜<style>html,body{height:100%!important;min-height:0!important}html,body,body *{overflow:clip!importa…’

archivebox.core.templatetags.core_tags.snapshot_url_text(url)[source]

Emphasize the hostname while preserving the exact selectable URL.

archivebox.core.templatetags.core_tags.plugin_ui(context, plugin: str, slot: str)[source]

Optional plugin UI must never prevent the host page from rendering.

archivebox.core.templatetags.core_tags._TEXT_PREVIEW_EXTS[source]

(β€˜.json’, β€˜.jsonl’, β€˜.txt’, β€˜.csv’, β€˜.tsv’, β€˜.xml’, β€˜.yml’, β€˜.yaml’, β€˜.md’, β€˜.log’)

archivebox.core.templatetags.core_tags._IMAGE_PREVIEW_EXTS[source]

(β€˜.png’, β€˜.jpg’, β€˜.jpeg’, β€˜.gif’, β€˜.webp’, β€˜.bmp’, β€˜.ico’, β€˜.avif’)

archivebox.core.templatetags.core_tags._STATIC_URL_SAFE[source]

β€œ/@-._~!$&’()*+,;=”

archivebox.core.templatetags.core_tags._VIDEO_FILE_EXTS[source]

None

archivebox.core.templatetags.core_tags._AUDIO_FILE_EXTS[source]

None

archivebox.core.templatetags.core_tags._MEDIA_FILE_EXTS[source]

None

archivebox.core.templatetags.core_tags._BROWSER_VIDEO_FILE_EXTS[source]

None

archivebox.core.templatetags.core_tags._BROWSER_AUDIO_FILE_EXTS[source]

None

archivebox.core.templatetags.core_tags._is_web_subdomain_alias(browser_url: str, configured_base_url: str) → bool[source]

Hide the informational mismatch banner on the conventional public web alias.

This is deliberately presentation-only: request routing and the restriction on state-changing requests continue to use the configured BASE_URL.

archivebox.core.templatetags.core_tags._normalize_output_files(output_files: Any) → dict[str, dict[str, Any]][source]
archivebox.core.templatetags.core_tags._snapshot_id(value: Any) → Any[source]
archivebox.core.templatetags.core_tags._coerce_output_file_size(value: Any) → int | None[source]
archivebox.core.templatetags.core_tags._count_media_files(result) → int[source]
archivebox.core.templatetags.core_tags._list_media_files(result, *, include_filesystem_fallback=True) → list[dict][source]
archivebox.core.templatetags.core_tags._resolve_snapshot_output_file(snapshot_dir: str | pathlib.Path | None, raw_output_path: str | None) → pathlib.Path | None[source]
archivebox.core.templatetags.core_tags._is_text_preview_path(raw_output_path: str | None) → bool[source]
archivebox.core.templatetags.core_tags._is_image_preview_path(raw_output_path: str | None) → bool[source]
archivebox.core.templatetags.core_tags._is_root_snapshot_output_path(raw_output_path: str | None) → bool[source]
archivebox.core.templatetags.core_tags._static_snapshot_base_url(context, snapshot) → str[source]
archivebox.core.templatetags.core_tags._snapshot_base_url_for_context(context, snapshot) → str[source]
archivebox.core.templatetags.core_tags._snapshot_url_for_context(context, snapshot, path: str = '') → str[source]
archivebox.core.templatetags.core_tags._build_snapshot_preview_url(snapshot_id: str, path: str = '', request=None, config=None, plugin: str = '', base_url: str | None = None) → str[source]
archivebox.core.templatetags.core_tags._render_text_preview(plugin: str, icon_html: str, snippet: str) → str[source]
archivebox.core.templatetags.core_tags._render_fallback_card(plugin: str, icon_html: str, fallback_label: str) → str[source]
archivebox.core.templatetags.core_tags._render_text_file_preview(snapshot_dir: str | pathlib.Path | None, raw_output_path: str | None, plugin: str, icon_html: str) → str | None[source]
archivebox.core.templatetags.core_tags.split(value, separator: str = ',')[source]
archivebox.core.templatetags.core_tags.index(value, position)[source]
archivebox.core.templatetags.core_tags.file_size(num_bytes: float, decimal_places: int = 1) → str[source]
archivebox.core.templatetags.core_tags.grid_file_size(num_bytes: float | None) → str[source]
archivebox.core.templatetags.core_tags.intcomma(value: int | str | None) → str[source]
archivebox.core.templatetags.core_tags.result_list(context, cl)[source]

Monkey patched result

archivebox.core.templatetags.core_tags._LOW_DISK_THRESHOLD_GB[source]

1.0

archivebox.core.templatetags.core_tags._HIGH_MEMORY_THRESHOLD_PCT[source]

95.0

archivebox.core.templatetags.core_tags._HIGH_LOAD_MULTIPLE[source]

3

archivebox.core.templatetags.core_tags._HEALTH_CHECK_INTERVAL_SECONDS[source]

30

archivebox.core.templatetags.core_tags._health_cache: dict[source]

None

archivebox.core.templatetags.core_tags._machine_health_stats() → dict[source]

Cached wrapper around the Machine-admin stats util.

The Machine list/change pages already render disk / mem / load via archivebox.machine.detect.get_host_stats() β€” we reuse the same call so the banner thresholds line up 1:1 with what’s shown on /admin/machine/. Cached for 30s because the inclusion tag fires on every page render and get_host_stats shells into several psutil probes.

archivebox.core.templatetags.core_tags.system_warnings_banner(context)[source]

Render the top-of-page warning banner for one of the conditions below, in priority order (highest first):

  1. mode="unconfigured"β€” BASE_URL is empty and the operator has not selected safe single-domain routing. That mode intentionally uses each device’s connection address, including LAN and Tailscale IPs.

  2. mode="base_url_mismatch" β€” the browser reached ArchiveBox through an origin that differs from the configured canonical BASE_URL.

  3. mode="unsafe" β€” SERVER_SECURITY_MODE explicitly enables a lower-security replay mode.

  4. mode="low_disk" β€” DATA_DIR has <1 GiB free; new archive jobs will start failing on ENOSPC.

  5. mode="high_memory" β€” virtual memory utilization at/above 95%; the host is one OOM-kill from a crash.

  6. mode="high_load" β€” 15-minute load average exceeds 3 Γ— CPU count (the kernel’s own sustained-load EMA, so no rolling buffer of ours is needed).

Config/security warnings come first because they affect correctness + security and need explicit operator action; host-health warnings come after and reuse machine.detect.get_host_stats (the same function that populates the Machine admin page), cached for 30s.

archivebox.core.templatetags.core_tags.url_replace(context, **kwargs)[source]
archivebox.core.templatetags.core_tags.admin_base_url(context) → str[source]
archivebox.core.templatetags.core_tags.web_base_url(context) → str[source]
archivebox.core.templatetags.core_tags.static_export_root_url(context) → str[source]
archivebox.core.templatetags.core_tags.snapshot_base_url(context, snapshot) → str[source]
archivebox.core.templatetags.core_tags.snapshot_detail_url(context, snapshot) → str[source]

Keep the trusted snapshot detail page on web.*, not the replay host.

archivebox.core.templatetags.core_tags.snapshot_url(context, snapshot, path: str = '') → str[source]
archivebox.core.templatetags.core_tags.snapshot_files_url(context, snapshot, path: str = '') → str[source]
archivebox.core.templatetags.core_tags.snapshot_zip_url(context, snapshot, path: str = '') → str[source]
archivebox.core.templatetags.core_tags.snapshot_role_output_url(context, snapshot, role: str, fallback_to_default: bool = False) → str[source]
archivebox.core.templatetags.core_tags.snapshot_result_file_url(context, snapshot, result, path: str) → str[source]

Build a saved-file URL from one ArchiveResult declaration.

archivebox.core.templatetags.core_tags.snapshot_thumbnail(context, snapshot, admin=False, width='100px', height='100px')[source]
archivebox.core.templatetags.core_tags.snapshot_index_row(context, link) → str[source]
archivebox.core.templatetags.core_tags.snapshot_preview_url(context, snapshot, path: str = '', result=None) → str[source]
archivebox.core.templatetags.core_tags.plugin_icon(plugin: str) → str[source]

Render the icon for a plugin.

Usage: {% plugin_icon β€œscreenshot” %}

archivebox.core.templatetags.core_tags.plugin_card(context, result) → str[source]

Render the card template for an archive result.

Usage: {% plugin_card result %}

Context variables passed to template: - result: ArchiveResult object - snapshot: Parent Snapshot object - output_path: Path to output relative to snapshot dir (from embed_path()) - plugin: Plugin base name

archivebox.core.templatetags.core_tags.render_plugin_card_document(context, result) → str[source]

Render one plugin card template for the trusted snapshot-origin frame.

archivebox.core.templatetags.core_tags.output_card(snapshot, output_path: str, plugin: str) → str[source]
archivebox.core.templatetags.core_tags.plugin_full(context, result) → str[source]

Render the full template for an archive result.

Usage: {% plugin_full result %}

archivebox.core.templatetags.core_tags.plugin_name(value: str) → str[source]

Get the base name of a plugin (strips numeric prefix).

Usage: {{ result.plugin|plugin_name }}

archivebox.core.templatetags.core_tags.api_token(context) → str[source]

Return an API token string for the logged-in user, creating one if needed.