Integrating applications and the World Wide Web
Matthijs van Doorn
Vrije Universiteit
Faculty of Mathematics and Computer Science
De Boelelaan 1081a
1081 HV Amsterdam
The Netherlands
thijs@cs.vu.nl
http://www.cs.vu.nl/~thijs/
Anton Eliëns
Vrije Universiteit
Faculty of Mathematics and Computer Science
De Boelelaan 1081a
1081 HV Amsterdam
The Netherlands
eliens@cs.vu.nl
http://www.cs.vu.nl/~eliens/
- Abstract:
-
This paper describes how to integrate the World Wide Web (WWW) with
applications.
By means of the web widget, which is part of Hush, the WWW is made
available to Tcl/Tk/Hush programmers. Apart from using WWW as part of an
application, it also allows one to embed scripts into a web page. This results
in a mutual integration of applications and the WWW.
Both forms of integration will be described. Some new possibilities of
embedded scripts such as inline MPEG, interactive games and navigation
facilities will be discussed.
- Keywords:
-
WWW, embedded scripts, integration, Hush, Tcl/Tk
What is Hush?
Hush [Hush95] (Hyper Utility Shell) is a C++ library that
can be used to build applications with a graphical user interface.
It contains classes that provide convenient yet flexible access to the
functionality offered by the Tcl/Tk [TclTk94] toolkit and its extensions.
Tcl is an interpreted script language, Tk is a window and graphics toolkit
based on X11. Hush provides a C++ class interface on top of Tcl/Tk.
It provides flexible access to script languages. Not only Tcl, but also
other script languages such as Python [Phyton] are supported.
New widgets, written in C++, can be accessed from the script language.
The Hush library is intended to support the needs of both novice
and experienced (window) programmers. Although Hush can be used to write
all sorts of programs with a graphical user interface, it mainly focusses on
hypermedia applications (i.e. the combination of hypertext and multimedia).
Currently Hush provides several hypermedia extensions, including
a MPEG widget. MPEG is a widely used video standard.
Hush also includes a C++ API and a Tcl interface [Music94] for Csound, a software sound
synthesis package developed at MIT's Media Lab.
Another extension is the web widget, described in this paper,
which gives access to the World Wide Web.
World Wide Web
The "World Wide Web", also refered to as WWW [WWW], W3 or simply "The Web",
is a distributed hypermedia project started by CERN.
To access WWW, you need a browser program (e.g. Mosaic).
The browser can fetch documents from servers set up by information providers.
An important feature missing in current WWW browsing systems is the lack of
integration with other applications. That should change, because the WWW can
be a very valuable part of an application [Ercim94].
This paper describes two forms of integration:
- Integrating WWW in applications (use WWW as part of a program).
- Integrating applications in WWW (embedding scripts in a WWW page).
Using WWW as part of an application
Starting up a separate browser from
an application is not the most natural way of accessing information.
Users who are viewing information should not necessarily be aware of the
fact that the documents are coming from the World Wide Web. Therefore
it is desirable that the WWW can be accessed as an integral part of an
application. The web widget can be used to accomplish this.
The Tcl/Tk/Hush environment offers numerous widgets which can be used
to build a graphical user interface, e.g. button,
scrollbar and listbox. These widgets are not only
accessible from a Tcl script, but also from C++ (because of the Hush API).
The web widget is a new widget, implemented in C++. It can be used
exactly the same way as a standard widget in Tcl/Tk.
The following Tcl-script builds a very simple WWW browser
by creating a web widget together with a back button:
web .w -home "http://www.cs.vu.nl/"
button .b -text "Back" -command {.w back}
pack .w
pack .b
The '-home' option is used to specify the URL of the home page.
If the button is pressed, the attached command ".w back" will be executed.
This will notify the web to go one page back in history. The "pack" commands
place the created widgets on the screen.
The previous example was written in Tcl. In C++ the same functionality can be achieved
as follows:
web *w = new web(".w");
w->home("http://www.cs.vu.nl/");
button *b = new button(".w", "-command {.w back}");
b->text("Back");
w->pack();
b->pack();
Note that ".w back" is still a Tcl command. It is also possible to bind
a C++ handler function or object to the button.
The web widget makes it possible to access the WWW from within an application.
It can be used to view HTML files which are stored locally, but
because of the network facilities the information can also be retrieved from
servers all over the world.
For example, it is possible to provide all on-line help as WWW-pages.
Advantages of this approach are:
- All help can be written in HTML, which is becoming a standard markup
language.
- Help is not limited to text, because images, animations etc. can
be used.
- The on-line help files can be stored in one location. Users
from all over the world can access this information, without even
noticing they are getting it through the network. This will enable
application builders to change the
on-line help information, e.g. provide up-to-date FAQ (frequently asked
questions) lists, correct errors in the help text, announce patches or
new versions etc.
- The help information will also be available separate from your
application. Future
users can get access to the on-line help by using browsers like
Mosaic, even though they have not installed the application (yet).
Of course usage of the WWW within an application is not limited to on-line
help. It can also be used to provide other information, to represent the output
of some processes (e.g simulations) or the web widget may simply be used
for it's hypertext capabilities without employing the network.
Because the web widget itself runs in the same Hush environment as the
program, the look-and-feel of the browser can be adjusted to fit
the needs of the situation.
Embedding scripts into WWW pages
The previous section described the usage of the WWW as part of a program.
It dealt with the integration of WWW in an application.
There is however another form of integration as well: integrating
a program into a WWW page.
Most graphical based WWW browsers support inline images with
the <img> tag. Using inline images can result in attractive web pages.
It would nice if other kind of objects could be embedded as well (for
example videoclips). Allowing to embed an arbitrary script with commands is
even better, because this way almost anything can be included as an inline
object in a web page.
Otherwise a new version of a browser should have been made to enable the
embedding of a new kind of object.
The web widget makes it possible to embed an arbitrary script.
The script
is executed when the page is displayed. Currently only Tcl-based scripts can
be used, but using other languages should be possible as well, because
the Hush framework also supports other script languages.
To include a Tcl-script in a web page, HTML is extended with a new
tag <hush>. It supports an attribute 'tcl', which contains
the Tcl code that will be executed. For example, to include a button
in a web page, the following HTML code can be used:
<hush tcl="button this.b">
</hush>
This creates a button called "this.b -text Back -command \"this.b">
</hush>
It creates a button labeled "Back", which executes "thiswidget' variable can
also be used to influence the browser from within a web page in some other
way (e.g. changing the color of the widget, resizing the window etc).
The previous four examples just give an indication of the possibilities. In
principal almost anything can be done.
Accessing remote files in Tcl scripts
It is not very convenient to include a complete Tcl-script into a HTML
page, especially if the code gets bigger than the two instructions of the
example above.
Tcl offers a 'source' command, which executes code in a given file:
<hush tcl="source /usr/local/www/tcl/inline.tcl">
Sorry, this browser does not support embedded scripts.
</hush>
This works, but the problem is that it can only be used locally. If a remote
user
accesses this web page, it is not possible to open the
file /usr/local/www/tcl/inline.tcl
because it is stored on a non-local disk. We had the same problem with the
inline MPEG example above. Therefore the script should be
retrieve from the remote site by using the "urlfile" command:
<hush tcl="source [urlfile www.cs.vu.nl/tcl/inline.tcl]">
Sorry, this browser does not support embedded scripts.
</hush>
Calling "urlfile" results in getting the file of which the URL is specified
in the argument, storing it locally in a temporary directory, and returning
the name of this temporary file.
So "[urlfile www.cs.vu.nl/tcl/inline.tcl]" will be substituted by e.g.
"/tmp/inline.tcl", a local copy of inline.tcl. Then the "source" command is
used to execute the script.
The usage of the "urlfile" command is not limited to the "tcl" attribute. It
can also be used in the Tcl-script itself. For example, the contents of the
"inline.tcl" script mentioned in the previous example could be:
button this.m
This creates a button with the image "press_me.gif", which is retrieved from
a remote site. The "urlfile" command allows you to split code in separate
files and to use external files (e.g. images), while still being able to
execute it remotely.
All filenames used in scripts should be specified as URL's, otherwise the
script cannot be used by remote users, because they don't have access to the
local filesystem.
Security
The embedded scripts are executed at the client's side under the user's
account, not on the server's side. This is necessary because scripts
require special permissions only the local user has, e.g. often graphical
objects will be created on the screen. Another advantage of this client
side computation approach is that it will not put extra load on the server.
But executing scripts locally which are written by some unknown remote
user can be very dangerous (e.g. it could contain commands like
"/bin/rm -rf *" to delete all your files).
Therefore the script should be executed in an environment which assures us
no damage can be done. A possible choice is Safe-Tcl [SafeTcl].
Originally Safe-Tcl is developed to allow the sending of scripts by
email that will be executed when they arrive or when the message is read
(this is called active mail). Because
that could cause damage, they are executed in a safe environment where all
dangerous commands are removed. Almost the same security problem arises
when embedding scripts in a web page. In the web widget the script should
also be executed in a protected environment.
Conclusions and future plans
Integrating the World Wide Web with applications can enhance the functionality
of both the application and the web.
We have explored two forms of integration. First of all the WWW can be used
as part of an application e.g. as on-line help which has several advantages.
Secondly a script can be embedded into a web page, which offers new
possibilities. We have seen some examples of embedded scripts: inline Mpeg,
sound and interactive games.
Influencing the browser from the embedded script might be useful
in some occasions, as we have seen in the inline back button
example. The 'urlfile' command enables scripts to access remote files.
Because of the security risks that arise when executing the scripts,
it is necessary to run them in a safe environment. Safe-Tcl seems to be a
good starting point. Exploring this is the next step.
References
- [Hush95]
-
"Hush -- A C++ API for Tcl/Tk", Anton Eliëns, submitted to
The X Resources
- [TclTk94]
-
"An Introduction To Tcl and Tk", John Ousterhout, Addison-Wesley
- [Ercim94]
-
Discussions at the ERCIM/W4G workshop, 29th November - 1st December
1994, CWI Amsterdam
- [Python]
-
"The Python Programming Language", Guido van Rossum, CWI
- [SafeTcl]
-
"EMail With A Mind of Its Own: The Safe-Tcl Language for Enabled MailSafe-Tcl", Nathaniel S. Borenstein
- [WWW]
-
The World Wide Web Initiative, CERN
- [Music94]
-
"Music in Time-based Hypermedia", J.R. van Ossenbruggen,
A. Eliëns, European Conference on Hypermedia Technology 1994
Proceedings
Matthijs van Doorn (thijs@cs.vu.nl),
Anton Eliëns (eliens@cs.vu.nl)