This document provides the specification for writing Guile applets for use with the SurfIt! demo browser.
application/guile
. This is the default type for the file
extension .scm
.
An applet can be inlined within a HTML document.
<a href="applet.scm" rel=embed>
fallback_html
</a>
applet.scm
will be loaded, inserted into the
page, and run when the document containing it is first loaded.
fallback_html
will be displayed by browsers that don't
support Guile applets.
An applet may also be invoked when a hyperlink is followed.
<a href="applet.scm"
fallback_html
</a>
applet.scm
will
be loaded and executed. The original document will be cleared from
the page only if the applet explicitly requests it to be.
fallback_html
will be displayed by browsers that don't
support Guile applets.
Every applet is required to include the applet library:
(require 'applet)
Every applet is required to define a routine to be called by the browser when the browser requires the applet to terminate execution:
(define-applet-terminate routine)
routine
is a routine having no
arguments that will be invoked by the browser when the applet is
required to terminate execution. If the applet is visible it should
destroy the Tk canvas upon which it is visible, free up any other
resources it might have allocated, and then exit.
An applet will persist for as long as it is accessible -- either externally through it's being displayed on a page, or internally through the Scheme environment.
An applet has access to all the features of a regular Guile Scheme program and to the gtcl/gtk Guile extensions. The features of gtk allow the Guile applet to interactively display itself within the parent document.
Note: While Guile provides the ability to control namespaces, and this is necessary to provide a secure environment within which applets can be run, this has not been done for the SurfIt! Guile demo browser. The SurfIt! Guile demo browser is mainly intended as a research prototype, not a production web browser.
browser-window-name
(browser-window args)
browser-window-name
is a string containing the Tk window
name of the browser window. browser-window
is the
corresponding Tcl proc to which window commands can be sent.
applet-window-name
(applet-window args)
applet-window-name
is a string containing a Tk window
name for a frame that can be used to contain the applet.
applet-window
is the corresponding Tcl proc to which
window commands can be sent. The frame still needs inserting into the
browser window, assuming the applet is visible.
applet-embedindex
applet-embedindex
is a string containing the offset
within the browser window of the applet's anchor. Most commonly this
is used when insert the applet into the browser window at the same
location as the original html:
(browser-window 'window 'create applet-embedindex
:window applet-window-name)
.
(applet-newpage)
(applet-parsehtml html)
html
and
renders the result adding it to bottom of the browser window.
(applet-loadurl url)
url
retrieved
using a HTTP GET request. This routine is equivalent to
(applet-loaddata url applet-parsehtml)
.
(applet-loaddata url callback)
url
using a HTTP GET request, and then immediately
returns. Later on, once the object has been fully loaded,
(callback result) will be asynchronously invoked,
with the string result
containing the data for the
requested object.
-
(applet-posturl url datavar postdata)
-
This routine initiates the loading and rendering in the applet window
the results of posting
postdata
to the URL
url
using a HTTP POST request. datavar
is a
string containing the name to use for a global Tcl variable that
accumulates intermediate results. postdata
must be an
association list of the form ((name1, value1), (name2, value2),
...)
mapping from unencoded strings representing field names to
unencoded strings representing the data values associated with these
field names. This routine is equivalent to (applet-postdata url
datavar postdata applet-parsehtml)
.
-
(applet-postdata url datavar callback postdata)
-
This routine initiates the posting of
postdata
to the URL
url
using a HTTP POST request, and then immediately
returns. Later on, once the resulting return value has been fully
loaded, (callback result) will be asynchronously
invoked, with the string result
containing the resulting
data. datavar
is a string containing the name to use for
a global Tcl variable that accumulates intermediate results.
postdata
must be an association list of the form
((name1, value1), (name2, value2), ...)
mapping from
unencoded strings representing field names to unencoded strings
representing the data values associated with these field names.