{# Plugin Configuration Partial - Server-side rendered form #} {# This template is loaded via HTMX when a plugin tab is clicked #} {# ===== MACROS FOR FORM FIELD GENERATION ===== #} {# Render a single form field based on schema type #} {% macro render_field(key, prop, value, prefix='', plugin_id='') %} {% set full_key = (prefix ~ '.' ~ key) if prefix else key %} {% set field_id = (plugin_id ~ '-' ~ full_key)|replace('.', '-')|replace('_', '-') %} {% set label = prop.title if prop.title else key|replace('_', ' ')|title %} {% set description = prop.description if prop.description else '' %} {% set field_type = prop.type if prop.type is string else (prop.type[0] if prop.type is iterable else 'string') %} {# Handle nested objects recursively #} {% if field_type == 'object' and prop.properties %} {{ render_nested_section(key, prop, value, prefix, plugin_id) }} {% else %}
{{ description }}
{% endif %} {# Boolean checkbox #} {% if field_type == 'boolean' %} {# Enum dropdown #} {% elif prop.enum %} {# Number input #} {% elif field_type in ['number', 'integer'] %} {# Array - check if it's an array of objects first, then file upload widget #} {% elif field_type == 'array' %} {% set items_schema = prop.get('items') or {} %} {% set is_array_of_objects = items_schema.get('type') == 'object' and items_schema.get('properties') %} {% if is_array_of_objects %} {# Array of objects widget (like custom_feeds with name, url, enabled, logo) #} {% set item_properties = items_schema.get('properties', {}) %} {% set max_items = prop.get('maxItems', 50) %} {% set array_value = value if value is not none and value is iterable and value is not string else (prop.default if prop.default is defined and prop.default is iterable and prop.default is not string else []) %}{{ prop_description }}
{% endif %} {% elif prop_schema.get('type') == 'boolean' %} {# Boolean checkbox #} {% else %} {# Regular text/string input #} {% if prop_description %}{{ prop_description }}
{% endif %} {% endif %}Drag and drop images here or click to browse
Max {{ max_files }} files, {{ max_size_mb }}MB each (PNG, JPG, GIF, BMP)
Remember to save configuration after upload
{{ img.get('original_filename') or img.get('filename', 'Image') }}
{% if img.get('size') %}{{ (img.get('size') / 1024)|round }} KB{% endif %} {% if img.get('uploaded_at') %} • {{ img.get('uploaded_at') }}{% endif %}
{% if has_schedule %}Scheduled
{% endif %}Separate multiple values with commas
{% endif %} {# Text input (default) #} {% else %} {% endif %}{{ plugin.description or 'Plugin configuration' }}