@@ -0,0 +1,286 @@
1++++
2+title = "Guide"
3+weight = 4
4+template = "doc.html"
5++++
6+
7+In this document we'll walk through an example of creating and publishing a desk that others can install. We'll create a simple "Hello World!" front-end with a "Hello" tile to launch it. For simplicity, the desk won't include an actual Gall agent, but we'll note everything necessary if there were one.
8+
9+## Create desk
10+
11+To begin, we'll need to clone the [urbit git repo](https://github.com/urbit/urbit) from the Unix terminal:
12+
13+```
14+[user@host ~]$ git clone https://github.com/urbit/urbit urbit-git
15+```
16+
17+Once that's done, we can navigate to the `pkg` directory in our cloned repo:
18+
19+```
20+[user@host ~]$ cd urbit-git/pkg
21+[user@host pkg]$ ls .
22+arvo btc-wallet garden grid interface npm webterm
23+base-dev docker-image garden-dev herb landscape symbolic-merge.sh
24+bitcoin ent ge-additions hs libaes_siv urbit
25+```
26+
27+Each desk defines its own `mark`s, in its `/mar` folder. There are no longer shared system marks that all userspace code knows, nor common libraries in `/lib` or `/sur`. Each desk is completely self-contained. This means any new desk will need a number of base files.
28+
29+To make the creation of a new desk easier, `base-dev` and `garden-dev` contain symlinks to all `/sur`, `/lib` and `/mar` files necessary for interacting with the `%base` and `%garden` desks respectively. These dev desks can be copied and merged with the `symbolic-merge.sh` included.
30+
31+Let's create a new `hello` desk:
32+
33+```
34+[user@host pkg]$ mkdir hello
35+[user@host pkg]$ ./symbolic-merge.sh base-dev hello
36+[user@host pkg]$ ./symbolic-merge.sh garden-dev hello
37+[user@host pkg]$ cd hello
38+[user@host hello]$ ls
39+lib mar sur
40+```
41+
42+### `sys.kelvin`
43+
44+Our desk must include a `sys.kelvin` file which specifies the kernel version it's compatible with. Let's create that:
45+
46+```
47+[user@host hello]$ echo "[%zuse 420]" > sys.kelvin
48+[user@host hello]$ cat sys.kelvin
49+[%zuse 420]
50+```
51+
52+### `desk.ship`
53+
54+We can also add a `desk.ship` file to specify the original publisher of this desk. We'll try this on a fakezod so let's just add `~zod` as the publisher:
55+
56+```
57+[user@host hello]$ echo "~zod" > desk.ship
58+[user@host hello]$ cat desk.ship
59+~zod
60+```
61+
62+### `desk.bill`
63+
64+If we had Gall agents in this desk which should be automatically started when the desk is installed, we'd add them to a `hoon` list in the `desk.bill` file. It would look something like this:
65+
66+```hoon
67+:~ %some-app
68+ %another
69+==
70+```
71+
72+In this example we're not adding any agents, so we'll simply omit the `desk.bill` file.
73+
74+### `desk.docket-0`
75+
76+The final file we need is `desk.docket-0`. This one's more complicated, so we'll open it in our preferred text editor:
77+
78+```
79+[user@host hello]$ nano desk.docket-0
80+```
81+
82+In the text editor, we'll add the following:
83+
84+```hoon
85+:~ title+'Hello'
86+ info+'A simple hello world app.'
87+ color+0x81.88c9
88+ image+'https://media.urbit.org/docs/userspace/dist/wut.svg'
89+ base+'hello'
90+ glob-ames+[~zod 0v0]
91+ version+[0 0 1]
92+ website+'https://urbit.org/docs/userspace/dist/guide'
93+ license+'MIT'
94+==
95+```
96+
97+You can refer to the [Docket File](/docs/userspace/dist/docket) documentation for more details of what is required. In brief, the `desk.docket-0` file contains a `hoon` list of [clauses](/docs/userspace/dist/docket) which configure the appearance of the app tile, the source of the [glob](/docs/userspace/dist/glob), and some other metadata.
98+
99+We've given the app a [`%title`](/docs/userspace/dist/docket#title) of "Hello", which will be displayed on the app tile and will be the name of the app when others browse to install it. We've given the app tile a [`%color`](/docs/userspace/dist/docket#color) of `#8188C9`, and also specified the URL of an [`%image`](/docs/userspace/dist/docket#image) to display on the tile.
100+
101+The [`%base`](/docs/userspace/dist/docket#base) clause specifies the base URL path for the app. We've specified "hello" so it'll be `http://localhost:8080/apps/hello/...` in the browser. For the [glob](/docs/userspace/dist/glob), we've used a clause of [`%glob-ames`](/docs/userspace/dist/docket#glob-ames), which means the glob will be served from a ship over Ames, as opposed to being served over HTTP with a [`%glob-http`](/docs/userspace/dist/docket#glob-http) clause or having an Eyre binding with a [`%site`](/docs/userspace/dist/docket#site) clause. You can refer to the [glob](/docs/userspace/dist/glob) documentation for more details of the glob options. In our case we've specified `[~zod 0v0]`. Since `~zod` is the fakeship we'll install it on, the `%docket` agent will await a separate upload of the `glob`, so we can just specify `0v0` here as it'll get overwritten later.
102+
103+The [`%version`](/docs/userspace/dist/docket#version) clause specifies the version as a triple of major version, minor version and patch version. The rest is just some additional informative metadata which will be displayed in _App Info_.
104+
105+So let's save that to the `desk.docket-0` file and have a look at our desk:
106+
107+```
108+[user@host hello]$ ls
109+desk.docket-0 desk.ship lib mar sur sys.kelvin
110+```
111+
112+That's everything we need for now.
113+
114+## Install
115+
116+Let's spin up a fakezod in which we can install our desk:
117+
118+```
119+[user@host hello]$ cd ~/piers/fake
120+[user@host fake]$ urbit -F zod
121+```
122+
123+Once our fakezod is booted, we'll need to create a new `%hello` desk for our app and mount it. We can do this in the dojo like so:
124+
125+```
126+> |merge %hello our %base
127+>=
128+> |mount %hello
129+>=
130+```
131+
132+Now, back in the Unix terminal, we should see the new desk mounted:
133+
134+```
135+[user@host fake]$ cd zod
136+[user@host zod]$ ls
137+hello
138+```
139+
140+Currently it's just a clone of the `%base` desk, so let's delete its contents:
141+
142+```
143+[user@host zod]$ rm -r hello/*
144+```
145+
146+Next, we'll copy in the contents of the `hello` desk we created earlier. We must use `cp -LR` to resolve all the symlinks:
147+
148+```
149+[user@host zod]$ cp -LR ~/urbit-git/pkg/hello/* hello/
150+```
151+
152+Back in the dojo we can commit the changes and install the desk:
153+
154+```
155+> |commit %hello
156+> |install our %hello
157+kiln: installing %hello locally
158+docket: awaiting manual glob for %hello desk
159+```
160+
161+The `docket: awaiting manual glob for %hello desk` message is because our `desk.docket-0` file includes a [`%glob-ames`](/docs/userspace/dist/docket#glob-ames) clause which specifies our ship as the source, so it's waiting for us to upload the glob.
162+
163+If we open a browser now, navigate to `http://localhost:8080` and login with the default fakezod code `lidlut-tabwed-pillex-ridrup`, we'll see our tile's appeared but it says "installing" with a spinner due to the missing glob:
164+
165+
166+
167+## Create files for glob
168+
169+We'll now create the files for the glob. We'll use a very simple static HTML page that just displayes "Hello World!" and an image. Typically we'd have a more complex JS web app that talked to apps on our ship through Eyre's channel system, but for the sake of simplicity we'll forgo that. Let's hop back in the Unix terminal:
170+
171+```
172+[user@host zod]$ cd ~
173+[user@host ~]$ mkdir hello-glob
174+[user@host ~]$ cd hello-glob
175+[user@host hello-glob]$ mkdir img
176+[user@host hello-glob]$ wget -P img https://media.urbit.org/docs/userspace/dist/pot.svg
177+[user@host hello-glob]$ tree
178+.
179+└── img
180+ └── pot.svg
181+
182+1 directory, 1 file
183+```
184+
185+We've grabbed an image to use in our "Hello world!" page. The next thing we need to add is an `index.html` file in the root of the folder. The `index.html` file is mandatory; it's what will be loaded when the app's tile is clicked. Let's open our preferred editor and create it:
186+
187+```
188+[user@host hello-glob]$ nano index.html
189+```
190+
191+In the editor, paste in the following HTML and save it:
192+
193+```html
194+<!DOCTYPE html>
195+<html>
196+ <head>
197+ <style>
198+ div {
199+ text-align: center;
200+ }
201+ </style>
202+ </head>
203+ <title>Hello World</title>
204+ <body>
205+ <div>
206+ <h1>Hello World!</h1>
207+ <img src="img/pot.svg" alt="pot" width="219" height="196" />
208+ </div>
209+ </body>
210+</html>
211+```
212+
213+Our `hello-glob` folder should now look like this:
214+
215+```
216+[user@host hello-glob]$ tree
217+.
218+├── img
219+│ └── pot.svg
220+└── index.html
221+
222+1 directory, 2 files
223+```
224+
225+## Upload to glob
226+
227+We can now create a glob from the directory. To do so, navigate to `http://localhost:8080/docket/upload` in the browser. This will bring up the `%docket` app's [Globulator](/docs/userspace/dist/glob#globulator) tool:
228+
229+
230+
231+Simply select the `hello` desk from the drop-down, click `Choose file` and select the `hello-glob` folder in the the file browser, then hit `glob!`.
232+
233+Now if we return to our ship's homescreen, we should see the tile looks as we specified in the docket file:
234+
235+
236+
237+And if we click on the tile, it'll load the `index.html` in our glob:
238+
239+
240+
241+Our app is working!
242+
243+## Publish
244+
245+The final step is publishing our desk with the `%treaty` agent so others can install it. To do this, there's a simple command in the dojo:
246+
247+```
248+> :treaty|publish %hello
249+>=
250+```
251+
252+Note: For desks without a docket file (and therefore without a tile and glob), treaty can't be used. Instead you can make the desk public with `|public %desk-name`.
253+
254+## Remote install
255+
256+Let's spin up another fake ship so we can try install it:
257+
258+```
259+[user@host hello-glob]$ cd ~/piers/fake
260+[user@host fake]$ urbit -F bus
261+```
262+
263+At the time of writing, we must manually request the published apps on a given ship from the dojo. This will likely change in the future but for now we must run the following on `~bus` before we can search for apps on `~zod` from the homescreen:
264+
265+```
266+> :treaty|ally ~zod
267+>=
268+```
269+
270+Note: For desks without a docket files (and therefore without a tile and glob), treaty can't be used. Instead remote users can install it from the dojo with `|install ~our-ship %desk-name`.
271+
272+Now in the browser, navigate to `http://localhost:8081` and login with `~bus`'s code `riddec-bicrym-ridlev-pocsef`. Next, type `~zod/` in the search bar, and it should pop up a list of `~zod`'s published apps, which in this case is our `Hello` app:
273+
274+
275+
276+When we click on the app, it'll show some of the information from the clauses in the docket file:
277+
278+
279+
280+Click `Get App` and it'll ask as if we want to install it:
281+
282+
283+
284+Finally, click `Get "Hello"` and it'll be installed as a tile on `~bus` which can then be opened:
285+
286+