PlayerIO

The fastest way to build online games without breaking a sweat.

Sitebox Basics

All Sitebox sites share a few common features. They’re all completely hosted by PlayerIO, they all use Sitebox templates for dynamic output and they all store their files in GameFS.

Editing your site

When you create a site and give it a name, you also get a special folder in your GameFS with that name. This folder contains all the templates and other assets for your site, so editing your site simply involves managing and editing these GameFS files.

You can either do this with the web interface in the Control Panel, or you can use an SFTP client to edit the files

Most SFTP clients support editing files directly over SFTP, and some text editors even have built-in SFTP support. We recommend you use a real text editor over SFTP, since you'll get syntax highlighting, proper indention and whatever other features your editor provides

You can find the SFTP information (server,username,password) inside the Sitebox Control Panel.

 

Mapping URLs to files in GameFS

All templates and assets in a Sitebox site have a public url. This url is different from the GameFS public url of a file in that it allows parsing of the template. If you were to access a template through the GameFS public url, it would not be parsed or processed, you would only get the raw file as it is.

When a request comes in to the base hosting url of a site, Sitebox figures out which GameFS folder the request corresponds to and uses the remaining part of the url to figure out which template to render.

For example:

Sitebox App Root Sitebox Page Path
http://game-id.fb.playerio.com/fb/my-facebook-app/ games/aroundtheworld

In the url above, Sitebox will notice that the sitebox app root "http://game-id.fb.playerio.com/fb/my-facebook-app/" is a Facebook App, and that it corresponds to the "/my-facebook-app/" folder in the GameFS of the game that has the gameId "game-id".

Next, it will combine the containing GameFS folder path with the Page Path and look for that file. If the page path does not have an extension, ".html" is appended automatically.

Therefore, in our case, it will look for a "aroundtheworld.html" file in the "/my-facebook-app/games/" GameFS folder of the game.

If the file exists, it is loaded as a template, and rendered as the response to the request.

Index files: "index.html"

If the page path ends with a slash, Sitebox automatically appends "index.html" to the page path when it looks for the template.

So, for instance, if the Page Path is "/" Sitebox will look for the file "/my-facebook-app/index.html" in the GameFS for the game

File not found: "not-found.html"

If Sitebox cannot find the template matching the request, it will look for a file called "not-found.html" in the same folder as the current Page Path.

Continuing the example above, if there is no file at the location "/my-facebook-app/games/aroundtheworld.html", Sitebox will look for the file "/my-facebook-app/games/not-found.html" and render that instead.

The original page path will be passed to the template in the variable sitebox_page_path, so this feature can be used to build simple catch-all urls. For instance, you might use it to have urls such as /world/<world-id> load a page that automatically goes to the world identified by <world-id>.

If both the original page path, and the "not-found.html" in the same directory does not exist, a generic "file not found" message will be displayed.

Resource Urls

In order to provide the best possible performance, only the dynamic html output from templates is served directly from Sitebox. The rest (javascript files, flash files, images etc..) are served directly from the GameFS Content Delivery Network.

This has one implication: The files are not stored on the same servers, so trying to embed an image like this <img src=”myfile.jpg”> will not work. Instead, you have to use the {% url %} tag when you want to reference static resources.

The {% url %} tag will look up the current CDN url in GameFS and print out the direct url to the current version of the file. Example:

Since it’s very common for CSS files to contain paths to other resources, for instance to background images, the {% url %} tag will automatically process any .css files and replace these resource paths with urls directly to the latest version in the GameFS CDN.