User Tools

Site Tools


Web Remote Resource Server:

Added in XTension 9.5.3 you can now serve up small images or other items that might be useful when making displays via the various controls that can insert HTML into a page. The Unit Description As HTML control inserts the Description of the Unit into an iFrame, and the Unit Property As HTML control inserts your html inline. If you have images to display, possibly for something like a custom weather state icon or something similar, you can now use the built in resource server to serve that up to the browsers.

This is currently only available for the full sized Web Remote and has not been added to the Mobile web Remote. Please let me know if that is a thing that you need.

Resources should be kept reasonable in size as they have to be fully loaded into memory before being served. Sending multi megabyte movies or similar may cause a problem or run very slow. Resource files are not cached in memory in the server, but are read from disk when asked for so serving large files or from slow disk drives will not be as fast as using a truly optimized static page web server such as apache. It does have the advantage of being self contained and being served on the same port so that you do not need to pass through or forward several different ports to the Mac or any of those complexities. Not to mention managing an apache server.

An ETag system is used for cache control in the browser. A browser will not reload a file that has not changed. If you, or a program updates a file in a way that changes the modification date this will also change the ETag. The next request from the browser will load and cache locally the new version of the file.

Note that resources served this way are not protected by making sure that a valid session is logged in. Any non-logged in user may request and get the files in this folder. However no resource listing is generated, you must link to the actual file.

Resource Folder:

The resource folder will be created inside your Database upon the first launch of a Web Remote instance after the update to 9.5.3. To find the active database in the Finder most easily use the Database menu in XTension and select “Reveal Database In Finder” Because the database is a bundle in order to open it and find the internal folders you will need to control or right click on it in the Finder and select “Show Package Contents”

Once inside the Database you’ll find a folder named “Web Remote Resources” Any file you place into this will be available to be served from the built in Web Remote instance.

All Instances of the Web Remote running on the machine will share the same Resources folder.

Linking To Files:

The path to use when linking to a file in the root of the Web Remote Resources folder will start with /special/resources/ so a link to your file might look something like /special/resources/your_file_name.jpg

You can add more folders inside the Web Remote Resources folder as needed.

Links including the “..” convention to back up a folder will return an error in order to protect you from someone serving themselves up other files on your computer.

All of the most commonly used Mime Types are supported and guessed at via the file extension. If you find that you need to serve up an unusual file type that does not work properly please let me know what the file extension is and what the mime-type should be and I can add it to the supported types list.

There is currently no way to force a download of the file rather than just have the browser load it. This could be done fairly easily. If this is a thing that you need please let me know and I can add that to the features list.


If you wished to create a custom control that would display the weather icon from a file called “partly_sunny.jpeg” you could do so via the Unit Property as HTML or the Unit Description as HTML controls. In this example I’ll use the Unit Property as that does not use an iFrame and is loaded inline with the rest of the page rather than as a separate request and so is faster to load.

Create a new Pseudo Unit called something like “Weather Conditions Display”

In a script that is updated from a weather source you might choose what image to display. Talking to a weather service is beyond the scope of this example and we will just set the image to the partly cloudy example. Note that when creating HTML in AppleScript you will have to escape any double quotes that you need to include. The example below demonstrates that. Create a Global Script that does something like this:

set currentImageLink to “/special/resources/partly_sunny.jpeg”

set theDisplayHTML to “<img src=\”” & currentImageLink & “\”>”

set Unit Property “current conditions” in Unit “Weather Conditions Display” to theDisplayHTML

and run the script. You will now have a Unit Property named “current conditions” in the Unit “Weather Conditions Display” This also assumes you have a file called “partly_sunny.jpeg” in the Web Remote Resources folder.

On a Web Remote page, or a View create a New Control and select “Unit Property As HTML” as the control type. Select the Unit from the popup and for the Property Name enter “current conditions” now resize the control and decide if you wish to show the standard background box around it or not. Save the control and you will be looking at an image link that you can change at any time by rebuilding the HTML and setting it to the Unit Property again.

Any time the Unit Property is updated that HTML will be pushed to any web page displaying that control. No refreshing or other manual reloading to display it is necessary. More info on Unit Properties and how to use them.

If you were creating a more complex display that needed to be in an iFrame to display properly you could do exactly the same, but instead of setting the Unit Property, use the Set Description verb to set the description of the Pseudo unit to the html. Then in the View or Web Remote page create a control of the “Unit Description as HTML” type and it will work the same way except the HTML will be loaded separately into an iFrame isolated from the rest of the page structure.

webremote/resourceserver.txt · Last modified: 2023/05/09 15:30 by James Sentman