User Tools

Site Tools


webremote:resourceserver

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
webremote:resourceserver [2023/05/09 15:10] – created James Sentmanwebremote:resourceserver [2023/05/09 15:30] (current) – Added warning about not being session protected James Sentman
Line 8: Line 8:
  
 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. 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.
  
 ----- -----
Line 30: Line 32:
  
 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. 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.
 +
 +-----
 +====Examples:====
 +
 +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:
 +
 +<code>
 +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
 +</code>
 +
 +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 [[dictionary:unitinformation:setunitproperty|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 [[dictionary:unitinformation:setdescription|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.1683645023.txt.gz · Last modified: 2023/05/09 15:10 by James Sentman