Serving HTML from the Niagara Station File System

Files can be served from the Station’s shared File System via…

https://yourIpAddress/file/index.html

…or via the File ORD scheme…

https://yourIpAddress/ord/file:^index.html|view:web:FileDownloadView

Why is ‘view:web:FileDownloadView’ required? This is a special Servlet that guarantees you get the file content rather than a view on the file. As you can see, the first example looks clearer and causes less confusion.

noSnoop

HTML and CSS content served from the file system for all versions of Niagara snoops the content being served. For instance, ‘module’ ORD schemes are replaced with module servlet requests.

This can cause some unwanted consequences and confusion for web developers. This snooping can be disabled for HTML by adding this to the top of the file…

<!-- @noSnoop -->

The snooping for CSS can be disabled by adding this to the top of the file…

/* @noSnoop */

RequireJS Config

When serving static content from the Station’s file system you may want to load BajaScript, d3, jQuery, underscore and other libraries in your own JavaScript modules. From Niagara 4.4 onwards, the configuration information can be referenced via the ‘/requirejs/config.js’ path. To demonstrate here’s a vanilla HTML file that could be placed in a Station’s shared folder…

<!DOCTYPE html>
<!-- @noSnoop -->
<html>
<head>
  <title>This is a BajaScript test page</title>
  <script type='text/javascript'  src='/requirejs/config.js'></script>
  <script type='text/javascript'  src='/module/js/com/tridium/js/ext/require/require.min.js?'></script>
</head>
<body>
  <h1>BajaScript test page!</h1>
  <script>
    require(["baja!"], function (baja) {
      baja.Ord.make("station:|slot:/").get()
        .then(function (station) {
          alert("Station name: " + station.getStationName());
        });
    });
  </script>
</body>
</html>

Viewing Niagara Help on a browser (served as static HTML files)

Niagara Help documents can also be served as static HTML resources and viewed from a web browser. A few common ways of accessing help are,

Help pages do not need a profile and it is recommended that they be viewed in a popup. This will ensure there is no web shell surrounding the help pages. For example, if you want to launch help on click of a hyperlink or button in the Web UI, simply call the Hx utility function to do it for you,

  hx.popup("/ord/module://workbench/com/tridium/workbench/media/contents.html");

What else?

The way we use script tags for injecting BajaScript has changed in Niagara 4. Click here to find out more information.