Schema definition for the Selector Handler Plugin, which provides CSS selector-based HTML manipulation via HTTP Range headers.
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 |
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. |
<tr itemscope itemtype="https://rustybeam.net/schema/SelectorHandlerPlugin">
<span itemprop="library">file://./plugins/librusty_beam_selector_handler.so</span>
</tr>
<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>
The Selector Handler Plugin processes HTTP Range headers with CSS selector syntax:
// 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"]'
}
});
div
, table
, tr
.user
, .config-row
#header
, #main-content
[itemtype]
, [data-id="123"]
table tr
, form input
h1, h2, h3
:first-child
, :last-of-type
Range: selector={css-selector}
. Only HTML files are processed for selectors; other file types are served normally.
This schema inherits from the HandlerPlugin schema, which provides:
config_file
- Configuration file pathrulesfile
- Rules file pathAnd ultimately from the base Plugin schema, which provides:
library
- Plugin library pathplugin
- Base plugin reference propertyThe Selector Handler Plugin includes special handling for HTML elements that require structural preservation:
<td>
, <tr>
, <thead>
, <tbody>
<li>
, <ol>
, <ul>
<option>
, <optgroup>
root_dir
property must be a valid directory pathroot_dir
must be readable by the servername
property should be unique if multiple selector handler plugins are usedWhen a selector matches elements, the plugin returns:
text/html
(preserves HTML structure)selector {css-selector}
(documents the selector used)// 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();
}