This tutorial describes how to create a Folder Listing web script that mimics the
behavior of the dir command in Microsoft Windows, or ls in
Linux and Mac OS X.
Given a folder path, the web script lists the contents of that folder in the repository in abbreviated or verbose form depending on a user provided flag.
- Creating a description document This task creates a web script description document for a Folder Listing web script.
- Creating a controller script The description document describes the Folder Listing web script and a JavaScript controller script implements its behavior. The controller establishes the folder to list from the invoked URI and query the repository for that folder ensuring error conditions are catered for.
- Parsing the web script URI A web script is invoked when a URI is requested that matches one of the URI templates defined by the web script. The web script might need to access the requested URI to allow it to extract arguments that might have been passed in as URI query parameters or embedded as values in the URI path.
- Calling services Controller scripts have access to services provided by SkyVault Content Services. This allows a web script to query or perform operations against content residing in the repository. Services are exposed as root objects and each service provides its own API to program against.
- Constructing the model The controller script creates a model for subsequent rendering by a response template. A model is a map of values indexed by their name, which can be read from and written to by the controller script.
- Creating a response template The final stage of web script execution is to render a response back to the initiating client in an appropriate format based on the client's preference. A response template written in FreeMarker is responsible for rendering each format provided by the web script.
- Registering and testing web scripts The web script index provides some administration of web scripts, in particular, for those developers creating new web scripts.
- Creating multiple response templates A web script can support multiple response formats to allow it to be used by a variety of clients. For example, it can render an HTML response for human consumption in a web browser, and a JSON response for machine consumption by other clients.
- Debugging a controller script The SkyVault Content Services server provides a built-in JavaScript Debugger that can be applied to web scripts. It is a useful tool for diagnosing the cause of issues and for stepping through the controller scripts of others to learn how they have implemented capabilities and used services.
Parent topic: Web Script tutorials