SelectorHandlerPlugin Schema

Schema definition for the Selector Handler Plugin, which provides CSS selector-based HTML manipulation via HTTP Range headers.

Schema Information

Property Value
Schema URL https://rustybeam.net/schema/SelectorHandlerPlugin
Parent Schema https://rustybeam.net/schema/HandlerPlugin
Description CSS selector processing for HTML manipulation using HTTP Range headers

Properties

Property Type Cardinality Description
name https://rustybeam.net/schema/Text 0..1 Plugin instance name for logging and identification. Defaults to "selector-handler" if not specified.
root_dir https://rustybeam.net/schema/Text 0..1 Root directory for serving files. Defaults to "." (current directory). Used as base path for file resolution.

Usage Examples

Basic Selector Handler Configuration

<tr itemscope itemtype="https://rustybeam.net/schema/SelectorHandlerPlugin">
    <span itemprop="library">file://./plugins/librusty_beam_selector_handler.so</span>
</tr>

Custom Root Directory

<tr itemscope itemtype="https://rustybeam.net/schema/SelectorHandlerPlugin">
    <span itemprop="library">file://./plugins/librusty_beam_selector_handler.so</span>
    <span itemprop="root_dir">./examples/guestbook</span>
    <span itemprop="name">guestbook_selector</span>
</tr>

CSS Selector Usage

The Selector Handler Plugin processes HTTP Range headers with CSS selector syntax:

Client-Side Usage Examples

// Fetch specific table rows
fetch('/data.html', {
    headers: {
        'Range': 'selector=table tr.user'
    }
});

// Get form inputs only
fetch('/form.html', {
    headers: {
        'Range': 'selector=form input, form select'
    }
});

// Extract microdata items
fetch('/config.html', {
    headers: {
        'Range': 'selector=[itemtype="https://rustybeam.net/schema/Plugin"]'
    }
});

Supported CSS Selectors

Range Header Format
The plugin intentionally "abuses" the HTTP Range header for CSS selector processing. Use the format: Range: selector={css-selector}. Only HTML files are processed for selectors; other file types are served normally.

Schema Inheritance

This schema inherits from the HandlerPlugin schema, which provides:

And ultimately from the base Plugin schema, which provides:

HTML Structure Preservation

The Selector Handler Plugin includes special handling for HTML elements that require structural preservation:

Validation Rules

Plugin Pipeline Placement
The Selector Handler Plugin should be placed after authentication and authorization plugins but before the File Handler Plugin. This ensures that selector processing happens on authorized content.

Use Cases

Response Format

When a selector matches elements, the plugin returns:

Integration with Other Plugins

JavaScript Integration

// DOM-aware primitives integration
document.querySelector('[itemtype="https://rustybeam.net/schema/Plugin"]')
    .POST(newPluginHTML)
    .then(response => {
        // Plugin added successfully
    });

// Fetch configuration data
async function getPluginConfig() {
    const response = await fetch('/config.html', {
        headers: {
            'Range': 'selector=[itemtype="https://rustybeam.net/schema/Plugin"]'
        }
    });
    return response.text();
}

See Also