{# Browser config form fields for the add/edit page. Expects `form`, `applicable` (the set of FetcherConfig fields this base engine can honour - FetcherConfig.applicable_fields()) and `base_label` (read-only base engine name). The base engine is fixed by the page (chosen via the "Add variation" link, or the existing config's base), so it's shown read-only, not as a picker. Gating on `applicable` rather than on capability flags directly is deliberate: it is the same set the save path allows (FetcherConfig.from_submitted), so a field can never be rendered but unsaveable, or hidden but written from its widget default. Laid out as the tab panes of browser-config-form.html (#browser, #language, #request); that page only shows the Language and Request tabs when this engine has a setting in them. The dialog on /settings/browsers (browser-config-modal.html) shows the same panes behind its own tab strip, switched by class rather than by the URL #anchor. #} {% from '_helpers.html' import render_field, render_checkbox_field %} {# A plugin's section (hook browser_config_form_section): its own template if it gave one, otherwise each field of its sub-form in the usual layout #} {% macro render_plugin_section(section) %} {% set subform = form[section.field_name] %}
{{ section.label }} {% if section.description %}

{{ section.description }}

{% endif %} {% if section.template %} {% include section.template %} {% else %} {% for field in subform %} {% if field.type in ('CSRFTokenField', 'HiddenField') %} {{ field() }} {% else %}
{% if field.type == 'BooleanField' %}{{ render_checkbox_field(field) }}{% else %}{{ render_field(field) }}{% endif %} {% if field.description %}{{ field.description }}{% endif %}
{% endif %} {% endfor %} {% endif %}
{% endmacro %} {% macro render_plugin_sections_for_tab(tab) %} {% for section in plugin_sections or [] if section.tab == tab %}{{ render_plugin_section(section) }}{% endfor %} {% endmacro %}
{{ _('Based on the browser') }} {{ base_label }}
{{ render_field(form.label) }} {{ _('A friendly name, e.g. “Mobile” or “German desktop”.') }}
{% if 'browser_type' in applicable %}
{# One tile per browser, with the icon its fetcher gives a variation set to it - the same icon that variation then shows on /settings/browsers and on its watches #}
{% for option in form.browser_type %} {% endfor %}
{% if form.browser_type.errors %}
    {% for error in form.browser_type.errors %}
  • {{ error }}
  • {% endfor %}
{% endif %} {{ _('Which browser engine to launch locally.') }}
{% endif %} {% if 'delete_created_files' in applicable %}
{{ render_checkbox_field(form.delete_created_files) }}
{% endif %}
{% if 'device' in applicable or 'viewport_width' in applicable %}
{{ _('Screen & device') }} {% if 'device' in applicable %}
{{ render_field(form.device) }} {{ _('Load pages as this phone or tablet would: its screen size, touch, mobile layout and User-Agent. Many sites serve a simpler page to phones.') }}
{{ render_field(form.device_scale_factor) }} {{ _('Leave empty for 1. Higher values only make screenshots sharper (and much larger), the page layout stays the same.') }}
{% endif %} {% if 'viewport_width' in applicable %} {# With a device picker above, the size only shows for "Custom size" (to fill in) or a device (to see its size); without one it is always there and optional #}
{{ render_field(form.viewport_width) }}
{{ render_field(form.viewport_height) }}
{% endif %}
{% endif %} {% if 'connection_url' in applicable %}
{{ _('Browser endpoint') }}
{{ render_field(form.connection_url) }} {{ _('Address of the external browser to connect to, e.g. a Bright Data or Oxylabs Scraping Browser.') }} {{ _('More instructions and examples here') }}
{% endif %} {{ render_plugin_sections_for_tab('browser') }}
{% if show_language_tab %}
{{ render_field(form.locale) }} {% for l in locale_choices or [] %}{% endfor %} {{ _('Start typing to search - e.g. de-DE, en-GB.')|safe }}
{{ render_field(form.timezone_id) }} {% for tz in timezone_choices or [] %}{% endfor %} {{ _('Start typing to search - e.g. Europe/Berlin.')|safe }} {# Filled in and shown by the script below once it knows this (the user's own) browser's timezone #}
{{ render_plugin_sections_for_tab('language') }}
{% endif %} {% if show_request_tab %}
{% if 'timeout' in applicable or 'user_agent' in applicable %}
{% if 'timeout' in applicable %}
{{ render_field(form.timeout) }} {{ _('Maximum seconds to wait for the response (plain HTTP client only).') }}
{% endif %} {% if 'user_agent' in applicable %}
{{ render_field(form.user_agent) }} {{ _('Sent as the User-Agent header for requests using this browser, leave blank for the default.') }}
{{ _('Warning: modifying this can increase the uniqueness of your browser and may have unintended consequences.') }}
{% endif %}
{% endif %} {% if 'block_resource_types' in applicable %}
{{ _('Skip downloads (save bandwidth)') }}
{% for opt in form.block_resource_types %} {{ opt() }} {% endfor %}
{{ render_field(form.block_url_patterns) }} {{ _('One address pattern per line, e.g. *.ttf.')|safe }}
{% endif %} {{ render_plugin_sections_for_tab('request') }}
{% endif %} {% for section in plugin_sections or [] if section.has_own_tab %}
{{ render_plugin_section(section) }}
{% endfor %}