JAVASCRIPT
ACTIVATED
COMMUNICATION
USING
STANDARD
SCRIPT
INTERFACE
About Jacussi™ Contact Us Jacussi With Miva Script

Jacussi™ with Miva® script

To use Jacussi with Miva script you will need to install the Jacussi command dispatcher for Miva script which is the file jacussi.mvc.

Configuration Basics

Configurations are accomplished by placing a jacussi.dat in your "mivadata" folder and then you need these two lines:

paths:module_dir=/jmods/ paths:commandfile=jacussicommands.txt

paths:module_dir is the optional sub directory off the Miva script root that you want the system to look in for all requests to Jacussi modules AKA jMods.

paths:commandfile is the required file that lists the authorized Jacussi commands that can be run on the site and maps the command name to the appropriate jMod file. Syntax for the file is simple. Each line contains a command name followed by a question mark, and then an optional mappings the most important of which is the "filename=" file mapping. If no file mapping exists the system assume the jMod is located in the jMod directory and is named the same as the command and has a .mvc extension, if it does exist the system uses that filename instead. The reason why you map the commands to filenames is because often a single jMod will handle multiple commands. For example consider the following command list accompanying the example jacussi.dat above.

coolmod? pagecounter? simple_array?filename=jmodtest.mvc simple_object?filename=jmodtest.mvc complex_object?filename=jmodtest.mvc

If an HTML page requested the pagecounter command then the system is going to use a Miva script MvDO to communicate with the file "/jmods/pagecounter.mvc" but for simple_array command the communication will be with the file "/jmods/jmodtest.mvc" as will be communications for the simple_object, and complex_object commands.

Complete example of use

Assume the following simple HTML page.

<html> <head> <title>Simple Jacussi jWrite Test</test> </head> <body> <h1>Simple Jacussi jWrite Test</h1> <p> This is a simple HTML page demonstrating the call to the pagecounter Jacussi jMod. </p> <p> <script src="/jacussi.mvc?jWrite=pagecounter:testpage"> </script> </p> </body> </html>

Here is that same counter called for this page.

jMod API for Miva scripts

The API for a jMod that uses Miva script is very simple. There are only two required functions: Jacussi_Settings, where you optionally can set new or modify existing system settings, and Jacussi_Commands, where you dispatch. For a simple jMod you wouldn't need anything in the settings function at all and it looks like this:

<MvFUNCTION NAME="Jacussi_Settings" PARAMETERS="module VAR,jacussi VAR" STANDARDOUTPUTLEVEL = ""> </MvFUNCTION>

And in the Jacussi_Commands you are passed the command requested of you and any arguments it may have and you can dispatch in any way you want from there ultimately returning either null, a string, or a structure. Here is an example.

<MvFUNCTION NAME="Jacussi_Commands" PARAMETERS="command, args" STANDARDOUTPUTLEVEL = ""> <MvFUNCTIONRETURN VALUE="{ Format_Date_Time(s.dyn_time_t) }"> </MvFUNCTION> <MvFUNCTION NAME = "Format_Date_Time" PARAMETERS = "time_t" STANDARDOUTPUTLEVEL = ""> <MvFUNCTIONRETURN VALUE = "{ time_t_month( l.time_t, timezone() ) $ '/' $ time_t_dayofmonth( l.time_t, timezone() ) $ '/' $ time_t_year( l.time_t, timezone() ) $ ' ' $ padl( time_t_hour( l.time_t, timezone() ), 2, '0' ) $ ':' $ padl( time_t_min( l.time_t, timezone() ), 2, '0' ) $ ':' $ padl( time_t_sec( l.time_t, timezone() ), 2, '0' ) }"> </MvFUNCTION>

You might use that like this:

<p> This server thinks the current date and time is: <script src="/jacussi.mvc?jWrite=serverdatetime"></script> </p>

Which we can demonstrate here like this. This server thinks the current date and time is:

This far we are only talking about the use of jWrite to output the result of a jMod to the HTML file. but there are performance issues involved in calling Jacussi multiple times for separate write requests, so if you are using more than on call per page you should consider using jSet instead.

Using jSet instead of jWrite.

When using jWrite the output of the jMod is written directly to the rendered HTML page using the standard document.write(), but if you use jWrite then the output is assigned to a JavaScript variable, array, or object. For a simple text value returned like we have been looking at so far, the results would be stored in a JavaScript variable that you could use later on the page, and you can call the jSet once, pass it multiple commands, it will set all the variables, and you only have the overhead of calling Jacussi a single time for that HTML page. Here is an example of a simple page that use jSet. Strings are either output as display or set as the value of a JavaScript variable depending on whether they are called in jSet or jWrite mode and structures are only to be called in jSet mode and are converted to JavaScript objects that the HTML page called can use as it sees fit.

<html> <head> <title>Simple Jacussi jSet Test</test> <script src="/jacussi.mvc?jSet=count:pagecounter:testpage,timestamp:serverdatetime"> </script> </head> <body> <h1>Simple Jacussi jSet Test</h1> <p>This is a simple HTML page demonstrating the use of jSet.</p> <p><script>document.write(count);</script></p> <p> The server thinks the date and time is <script>document.write(timestamp);</script> </p> </body> </html>

Which can be demonstrated here by doing:
Counter output:
Date/Time:

A Quick Confession

So as to avoid confusion, we want you to know that earlier when we said we were demonstrating the jWrite we were really had to use the jSet for the counter because if we didn't we would end up calling the counter twice for each page load and it might confuse people. Not that that reason was needed, because we did the date/time stamp with the jSet as well because we agree with the design philosphy of "Why do it twice when once will suffice". Wise words when you are dealing with dynamic data on the web.

J Jacussi
Bringing the power of server side applications to plain html pages.
Piet Mondrian