Web Developer documentation
Constellation Browser does not open HTML pages, instead it opens JSON files using a special format named "particle".
It is possible to run your own webserver to host your own Particle websites.
No direct URL input is possible from within the browser. For users to visit it, you will have to request to get it listed at:
- The browser’s Directory: send an e-mail to pablo@particlegs.com to get it listed there, with the website title and URL.
- Another, already listed website’s referral links or directories, if they have any.
Requirements for a webserver
- Support http:// or https:// protocols.
- Serve an index.json at the root, using Particle formatting as shown in the next section.
Testing your website locally
You can use the Constellation Browser to test your website locally on port 80. In order to do that:
- Run a server that at least serves your files statically on localhost at port 80. For instance, on Mac you could go to the root folder of your website via the Terminal and type: python3 -m http.server 80
- On the Playdate Simulator, open the Constellation Browser and you’ll land at the homepage. If you aren’t there, select "homepage" from the Playdate Menu within the app.
- Scroll down to "Making your own website", and select the option once it becomes focused. Then press the "A" button.
- Scroll down to the link to 127.0.0.1:80, and press the "A" button.
- ???
- Happy testing!
Testing a remote website
It is possible to add custom URLs to favorites to test your servers hosted on a staging or production server. In order to do so:
- Connect your Playdate to your computer.
- Enter Data Disk Mode.
- Open the Data folder, then locate the folder named user.XXXXX.com.particle.browser - XXXXX will be a set of numbers.
- Edit favorites.json - If it's not there, you can create it.
- Add your item to favorites. The file should look something like this:
[
"https://browser.particlestudios.eu/",
"http://127.0.0.1/"
]
- Exit Data Disk Mode.
- Open Constellation Browser on your Playdate, push the Menu button, and select Favorites
- Select your custom defined address.
Particle formatting
Particle formatting is a way to structure your website’s index.json file.
A basic structure is the following:
{
"format": "particle",
"title": "Sample website",
"content": [
{
"type": "paragraph",
"text": "*Welcome to the interwebs!*",
"style": {
"text-align": "center"
}
},
{
"type": "paragraph",
"text": "Hello world!\nWe support line breaks *and some basic styling!*"
},
{
"type": "button",
"label": "Go to the pond folder",
"action": "/pond/"
},
{
"type": "button",
"label": "Go to the duck file",
"action": "/pond/duck"
},
{
"type": "paragraph",
"text": "The browser also supports inline images. Behold, a heart!"
},
{
"type": "image",
"width": 7,
"height": 7,
"pixels": "011011 1111111 1111111 1111111 011111 00111 0001",
"style": {
"scale": 3
}
},
{
"type": "list",
"items": [
"*Reason 1 ducks are awesome:* They cuack.",
"*Reason 2 ducks are awesome:* They waddle."
]
}
]
}
See the currently used index.json shown when opening the browser
The top-level properties are:
- format: The format of the file. Must be "particle" for the browser to even attempt to parse the JSON as a valid layout.
- title
: The page title. Shown at the header.
- content: An array of objects that represent the content of the website.
Content types
-
paragraph: A block of text.
- text - The contents of the block. Supports the same markup styling as Playdate text would.
- style - An object that can contain styling properties like:
- text-align - Can be ["left"], "center" or "right".
-
list: A bullet list. Available from v1.1.0 onwards.
- items - An array of strings, supporting the same formatting options such as bold, italic and line breaks that paragraphs support.
-
button: A button that can be pressed.
- label - The label of the button.
-
action - Destination. Do not include the ".json" extension. Can either be:
- A full URL, ending in a slash /
For instance, setting action to "http://mywebsite.com/" will request the file http://mywebsite.com/index.json
- An absolute path to a folder within the current server (ends with slash).
For instance, at http://mywebsite.com/, setting action to "/folder/" will request the file http://mywebsite.com/folder/index.json
- An absolute path to a page within the current server (ends without a slash).
For instance, at http://mywebsite.com/, setting action to "/folder/duck" will request the file http://mywebsite.com/folder/duck.json
-
separator: A simple horizontal line to visually separate parts of the document.
-
image: An image defined as a sequence of pixels.
- width - The width of the image in pixels, between 1 and 16.
- height - The height of the image in pixels, between 1 and 16.
- pixels - A sequence of pixels where 0 is white, and 1 is black.
- For instance, a fully black square of 2x2 would be defined as "1111".
- Can also use a whitespace to indicate a new line and thus avoiding to fill the entire line with several 0, reducing loading times. Can also be used as a visual guide to know when each line begins. On the example above, that would be: "11 11".
- style - An object that can contain the following properties:
- scale - The scale on which the image will be rendered, multiplying the size of each pixel by the scale provided. It is 2 by default, but it can be any integer between 1 and 4.