
Open Source RWSERVE plugin
Interscribe
Shoulders of giants

Abstract |
---|
This plugin is used in tandem with the rwt-newton web component to interscribe text references into an existing web page using just-in-time server processing. |
Motivation
This plugin reads a list of references generated via the snrfilter
tool. Each time the plugin is invoked a reference is pulled from the snrfilter document list and inserted into the working document at a designated target point.
A cached copy of the interscribed merge is kept in the interscribe-cache for a specified period of time and used for subsequent HTTP requests.
This plugin may be used with BLUEPHRASE documents or HTML documents.
Customization
This plugin is open source and can be used as is, or enhanced to provide additional features.
The plugin may be used together with Etags, cache-control, and content-encoding (compression).
Download
The plugin module is available from NPM. Before proceeding, you should already have Node.js
and RWSERVE
configured and tested.
This module should be installed on your web server in a well-defined place, so that it can be discovered by RWSERVE
. The standard place for public domain plugins is /srv/rwserve-plugins
.
cd /srv/rwserve-plugins
npm install rwserve-interscribe
Configuration is Everything
Make the software available by declaring it in the plugins
section of your configuration file. For detailed instructions on how to do this, refer to the plugins documentation on the Read Write Tools HTTP/2 Server
website.
TL;DR
plugins {
rwserve-interscribe {
location `/srv/rwserve-plugins/node_modules/rwserve-interscribe/dist/index.js`
config {
interscribe-cache /srv/example.com/interscribe-cache
cache-duration 86400
snrfilter-file /srv/example.com/etc/snrfilter
snr-score-min 4
insertion-target < div id=interscribe-target>
keep-target before
background #777
}
}
router {
`*.blue` *methods=GET,HEAD *plugin=rwserve-blue
`*.blue` *methods=GET,HEAD *plugin=rwserve-interscribe
`*.html` *methods=GET,HEAD *plugin=rwserve-interscribe
}
}
interscribe-cache
- An absolute path to the directory to be used for caching the merged results. Typically this will be adjacent to the host's
public
,dynamic-cache
andencoding-cache
directories. cache-duration
- The time, in seconds, that the merged document should be kept in the cache before being recreated.
snrfilter-file
- The absolute path to the file containing the references.
snr-score-min
- The minimum
snrScore
that must be met for a doument ref to be used. This is an integer value. Document references in thesnrfilter-file
will be discarded if their!snrScore
is less than this. insertion-target
- The HTML text that is searched for, within the current document, and used as the target point. This text should be unique within the document. If it isn't, the first occurrence will be used.
keep-target
-
before
- Keep the target text within the merged document and place it immediately before the interscribed text.after
- Keep the target text within the merged document and place it immediately after the interscribed text.discard
- Discard the target text. background
- The background color to use with the interscribed text. Any HTML color format may be used, like:
gray, #777, rgb(127,127,127)
.
The sample router
shown above will route any GET
or HEAD
request for BLUEPHRASE and HTML document to the `/interscribe`
plugin for processing.
Cookbook
A full configuration file with typical settings for a server running on localhost port 7443, is included in this NPM module at etc/interscribe-config
. To use this configuration file, adjust these variables if they don't match your server setup:
$PLUGIN-PATH='/srv/rwserve-plugins/node_modules/rwserve-interscribe/dist/index.js'
$PRIVATE-KEY='/etc/pki/tls/private/localhost.key'
$CERTIFICATE='/etc/pki/tls/certs/localhost.crt'
$DOCUMENTS-PATH='/srv/rwserve/configuration-docs'
Review
Lessons |
---|
This plugin demonstrates a basic pattern that many plugins follow:
Read Write Tools HTTP/2 Server using npm with these keywords: rwserve, http2, plugins. |
License
The rwserve-interscribe plugin is licensed under the MIT License.

MIT License
Copyright © 2023 Read Write Tools.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Availability
Source code | github |
Package installation | NPM |
Documentation | Read Write Hub |