SalsaScript Tutorial (1, 2, 3, 4, 5)

Part II - Creating a Package

Packages are the name given to individual applications that run under the Salsa framework. Packages can have unique file naming conventions to take advantage of Salsa hooks and redirects, which we'll describe later. For the purpose of this tutorial, we will be creating a simple package that consists of just a SalsaScript file within it's own package directory.

If you are using WebDAV, this is just a matter of creating the folder on the server. If you are using Subversion, you will have to create the folder locally and then add the folder via Subversion.

Types of packages

There are three types of packages, which differ only by who has access to them. To change the package type from the default, create or edit the WEB-INF/package.xml file in your package directory. Package types cascade to subfolders, unless there is another package.xml file overriding that directory. This way, you don't need to have a package.xml file in every package.

Default Package

By default, your package is only accessible to Campaign Managers inside the Salsa Headquarters. The general public does not have access to pages inside the package. Traditionally, the default package lives in the subdirectory 'hq/' of the main directory. It is accessible via the URL:

/salsa/hq/p/[filePath]
Public Package
If the package.xml permissionType is "public", then the page is available to the general public for organizations that have installed it. Traditionally, the default package lives in the subdirectory 'public/' of the main directory. It is then accessible via:
http://www.[node domain].org/o/[organization ID]/p/d/[filePath]
Node/Admin Package
If the package.xml permissionType is "admin", then the page is only available to partners on a node. Partners and Node Admins have access to multiple organizations, and are frequently part of SalsaLabs staff. If you're not sure if you're a Partner or Node Admin, you're not. Admin packages are accessible via the URL:
/salsa/admin/p/[filePath]

Creating a Simple "Hello World" File

Now that your package is created, we can create a sample SalsaScript file to make sure everything is working right

  • Create a file called index.sjs for the package homepage in the root of the package directory you created.
  • Edit the index.sjs file to include the following:
    <? print('Hello World!'); ?>
  • Open the address for the script in a browser to see if it worked. The URL should be of the form:
    http://sandbox.salsalabs.com/o/8001/p/salsa/packageName/index.sjs

    Where 8001 would be replaced with your organization number, and "packageName" would be replaced with the name of your package. The result should look like this:

    Hello World!

    For more code examples of the SalsaScript language, please check out our SalsaScript Introduction

Continue to Page 3 - Creating a SalsaScript News Aggregator