@@ -19,7 +19,7 @@ poke it. There'll be a button to poke the app, and line of text
19below it saying how many times the app has been poked. We can
19below it saying how many times the app has been poked. We can
20update this by subscribing our page to the relevant path on its app.
20update this by subscribing our page to the relevant path on its app.
22−Let's first write the app, `/app/click.hoon`:
22+Let's first checkout the app `/app/examples/click.hoon`:
@@ -29,15 +29,15 @@ Let's first write the app, `/app/click.hoon`:
31|_ {hid/bowl clicks/@}
31|_ {hid/bowl clicks/@}
32−++ poke-click
32+++ poke-examples-click-click
33 |= click/$click
33 |= click/$click
34 ~& [%poked +(clicks)]
34 ~& [%poked +(clicks)]
35 :_ +>.$(clicks +(clicks))
35 :_ +>.$(clicks +(clicks))
36 %+ turn (prey /the-path hid)
36 %+ turn (prey /the-path hid)
37− |=({o/bone *} [o %diff %clicks +(clicks)])
37+ |=({o/bone *} [o %diff %examples-click-clicks +(clicks)])
38++ peer-the-path
38++ peer-the-path
39 |= pax/path
39 |= pax/path
40− [[[ost.hid %diff %clicks clicks] ~] +>.$]
40+ [[[ost.hid %diff %examples-click-clicks clicks] ~] +>.$]
@@ -48,7 +48,7 @@ all our subcribers the new value. When someone subscribes to us
48on the path `/the-path`, we immediately give them the current
48on the path `/the-path`, we immediately give them the current
49number of clicks.
49number of clicks.
51−Let's take a look at the new marks. Here's `/mar/click.hoon`:
51+Let's take a look at the new marks. Here's `/mar/examples/click/click.hoon`:
54|_ click/$click
54|_ click/$click
@@ -63,7 +63,7 @@ Let's take a look at the new marks. Here's `/mar/click.hoon`:
66−The mark `click` has hoon type `%click`, which means the only
66+The mark `examples-click-click` has hoon type `%click`, which means the only
67valid value is `%click`. We can convert from `noun` by just
67valid value is `%click`. We can convert from `noun` by just
68producing `%click`.
68producing `%click`.
@@ -83,22 +83,22 @@ is true.
83> the core `jo`. Our case is actually simple enough that the
83> the core `jo`. Our case is actually simple enough that the
84> `?>` line could have been `?> =([%s 'click'] jon)`.
84> `?>` line could have been `?> =([%s 'click'] jon)`.
86−We can test this mark from the command line (don't forget to start your app with `|start %click`)
86+We can test this mark from the command line (don't forget to start your app with `|start %examples-click`)
89−~fintud-macrep:dojo> &click %click
89+~fintud-macrep:dojo> &examples-click-click %click
91−~fintud-macrep:dojo> &click &json [%s 'click']
91+~fintud-macrep:dojo> &examples-click-click &json [%s 'click']
93−~fintud-macrep:dojo> &click &json &mime [/text/json (taco '"click"')]
93+~fintud-macrep:dojo> &examples-click-click &json &mime [/text/json (taco '"click"')]
95−~fintud-macrep:dojo> &click &json &mime [/text/json (taco '"clickety"')]
95+~fintud-macrep:dojo> &examples-click-click &json &mime [/text/json (taco '"clickety"')]
96/~fintud-macrep/home/0/mar/click:<[7 5].[8 11]>
96/~fintud-macrep/home/0/mar/click:<[7 5].[8 11]>
97ford: casting %json to %click
97ford: casting %json to %click
98ford: cast %click
98ford: cast %click
101−And `/mar/clicks.hoon`:
101+And `/mar/examples/click/clicks.hoon`:
104|_ clicks/@
104|_ clicks/@
@@ -110,7 +110,7 @@ And `/mar/clicks.hoon`:
113−`clicks` is just an atom. We convert to json by creating an
113+`examples-clicks-clicks` is just an atom. We convert to json by creating an
114object with a single field "clicks" with our value.
114object with a single field "clicks" with our value.
116> Be sure to checkout section 3bD, JSON and XML, in zuse.hoon
116> Be sure to checkout section 3bD, JSON and XML, in zuse.hoon
@@ -118,10 +118,8 @@ object with a single field "clicks" with our value.
118> produces a JSON object with one element.
118> produces a JSON object with one element.
121−~fintud-macrep:dojo> &json &clicks 6
121+~fintud-macrep:dojo> &json &examples-click-clicks 6
122[%o p={[p='clicks' q=[%n p=~.6]]}]
122[%o p={[p='clicks' q=[%n p=~.6]]}]
123−~fintud-macrep:dojo> &mime &json &clicks 6
124−[[%text %json ~] p=12 q='{"clicks":6}']
127Now that we know the marks involved, take another look at the app
125Now that we know the marks involved, take another look at the app
@@ -129,16 +127,18 @@ above. Everything should be pretty straightforward. Let's poke
129the app from the command line.
127the app from the command line.
132−~fintud-macrep:dojo> |start %click
130+~fintud-macrep:dojo> |start %examples-click
134−~fintud-macrep:dojo> :click &click %click
132+~fintud-macrep:dojo> :examples-click &examples-click-click %click
135[%poked 1]
133[%poked 1]
137−~fintud-macrep:dojo> :click &click %click
135+~fintud-macrep:dojo> :examples-click &examples-click-click %click
138[%poked 2]
136[%poked 2]
140+Please pardon the awkwardness of the name 'examples-click-click', but we used it to stay true to our examples naming convention.
142**Exercise**:
142**Exercise**:
144- Modify `:sink` from the subcriptions chapter to listen to
144- Modify `:sink` from the subcriptions chapter to listen to
@@ -177,22 +177,21 @@ To view the frontend, point your browser at `ship-name.urbit.org/~~/click` if yo
177We have a button labeled "Poke!" and a div with id `clicks` where
177We have a button labeled "Poke!" and a div with id `clicks` where
178we'll put the number of clicks. We also include a small
178we'll put the number of clicks. We also include a small
179javascript file where the client-side application logic can be
179javascript file where the client-side application logic can be
180−found. It's in `/web/click/main.js`:
180+found. It's in `/web/pages/examples/click.js`:
183$(function() {
184$(function() {
184 var clicks, $go, $clicks, $err
185 var clicks, $go, $clicks, $err
186 $go = $('#go')
187 $go = $('#go')
187 $clicks = $('#clicks')
188 $clicks = $('#clicks')
188 $err = $('#err')
189 $err = $('#err')
190− window.urb.appl = "click"
192 $go.on("click",
191 $go.on("click",
193 function() {
192 function() {
194 window.urb.send(
193 window.urb.send(
195− "click", {mark: "click"}
194+ "click", {mark: "examples-click-click"}
196 ,function(err,res) {
195 ,function(err,res) {
198 return $err.text("There was an error. Sorry!")
197 return $err.text("There was an error. Sorry!")
@@ -205,6 +204,7 @@ $(function() {
207+ window.urb.appl = "examples-click"
208 window.urb.bind('/the-path',
208 window.urb.bind('/the-path',
209 function(err,dat) {
209 function(err,dat) {
210 clicks = dat.data.clicks
210 clicks = dat.data.clicks