- 10 January, 2022
Embedding Gruff In a Web Page
Gruff can be embedded in any web page to use Gruff inside your own web site or web application. The file embedding.html in the Gruff installation folder provides a complete example of this. Display that file in a web browser to see the complete instructions for setting everything up. That same file serves as an example web page, with buttons at the bottom for embedding Gruff into that web page after doing the setup.
A Gruff feature allows a single launcher instance of Gruff to be running as a server and listening for requests from web browsers. It will launch a separate instance of Gruff for each web page that requests one, up to a specified limit. It can optionally use the launcher instance itself for one client, to minimize the number of Gruff executables that are running. Running Gruff as a server uses various command line options that are described under Running Gruff in a Web Browser.
Your web page needs to include an HTML iframe where Gruff will be placed, plus a link or button that asks a remote Gruff server to launch an instance of Gruff for the reader to use in that iframe. You will need to adapt the JavaScript code that’s in embedding.html to make your link or button handle the reply from the Gruff server.
Simply embedding Gruff in an HTML iframe allows a reader to use Gruff by itself as usual inside your web page. A more advanced feature is that your web application can also send custom commands to Gruff. For example, your application could derive a set of triples that it wants Gruff to display, and then send those triples to Gruff. The code in embedding.html also demonstrates this ability. The complete documentation for sending commands to Gruff is at The HTTP Interface to Gruff.