on master help sign in
fixed web-apps to reflect click code from examples repo; updated instructions to match
commit021ce99c612a33d1ec892003bd438963a796e61e authorHenry Ault <henry@tlon.io> dateTue 26 Jul 2016, 15:55 (10 years ago) parentfd3b22b
1 file changed+23−23
docs/arvo/web-apps.md+23−23
docs/arvo/web-apps.md+23−23
@@ -19,7 +19,7 @@ poke it. There'll be a button to poke the app, and line of text
1919below it saying how many times the app has been poked. We can
2020update this by subscribing our page to the relevant path on its app.
2121
22−Let's first write the app, `/app/click.hoon`:
22+Let's first checkout the app `/app/examples/click.hoon`:
2323
2424```
2525/? 314
@@ -29,15 +29,15 @@ Let's first write the app, `/app/click.hoon`:
2929--
3030!:
3131|_ {hid/bowl clicks/@}
32−++ poke-click
32+++ poke-examples-click-click
3333 |= click/$click
3434 ~& [%poked +(clicks)]
3535 :_ +>.$(clicks +(clicks))
3636 %+ turn (prey /the-path hid)
37− |=({o/bone *} [o %diff %clicks +(clicks)])
37+ |=({o/bone *} [o %diff %examples-click-clicks +(clicks)])
3838++ peer-the-path
3939 |= pax/path
40− [[[ost.hid %diff %clicks clicks] ~] +>.$]
40+ [[[ost.hid %diff %examples-click-clicks clicks] ~] +>.$]
4141--
4242```
4343
@@ -48,7 +48,7 @@ all our subcribers the new value. When someone subscribes to us
4848on the path `/the-path`, we immediately give them the current
4949number of clicks.
5050
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`:
5252
5353```
5454|_ click/$click
@@ -63,7 +63,7 @@ Let's take a look at the new marks. Here's `/mar/click.hoon`:
6363--
6464```
6565
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
6767valid value is `%click`. We can convert from `noun` by just
6868producing `%click`.
6969
@@ -83,22 +83,22 @@ is true.
8383> the core `jo`. Our case is actually simple enough that the
8484> `?>` line could have been `?> =([%s 'click'] jon)`.
8585
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`)
8787
8888```
89−~fintud-macrep:dojo> &click %click
89+~fintud-macrep:dojo> &examples-click-click %click
9090%click
91−~fintud-macrep:dojo> &click &json [%s 'click']
91+~fintud-macrep:dojo> &examples-click-click &json [%s 'click']
9292%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"')]
9494%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"')]
9696/~fintud-macrep/home/0/mar/click:<[7 5].[8 11]>
9797ford: casting %json to %click
9898ford: cast %click
9999```
100100
101−And `/mar/clicks.hoon`:
101+And `/mar/examples/click/clicks.hoon`:
102102
103103```
104104|_ clicks/@
@@ -110,7 +110,7 @@ And `/mar/clicks.hoon`:
110110--
111111```
112112
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
114114object with a single field "clicks" with our value.
115115
116116> 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.
118118> produces a JSON object with one element.
119119
120120```
121−~fintud-macrep:dojo> &json &clicks 6
121+~fintud-macrep:dojo> &json &examples-click-clicks 6
122122[%o p={[p='clicks' q=[%n p=~.6]]}]
123−~fintud-macrep:dojo> &mime &json &clicks 6
124−[[%text %json ~] p=12 q='{"clicks":6}']
125123```
126124
127125Now 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
129127the app from the command line.
130128
131129```
132−~fintud-macrep:dojo> |start %click
130+~fintud-macrep:dojo> |start %examples-click
133131>=
134−~fintud-macrep:dojo> :click &click %click
132+~fintud-macrep:dojo> :examples-click &examples-click-click %click
135133[%poked 1]
136134>=
137−~fintud-macrep:dojo> :click &click %click
135+~fintud-macrep:dojo> :examples-click &examples-click-click %click
138136[%poked 2]
139137>=
140138```
141139
140+Please pardon the awkwardness of the name 'examples-click-click', but we used it to stay true to our examples naming convention.
141+
142142**Exercise**:
143143
144144- 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
177177We have a button labeled "Poke!" and a div with id `clicks` where
178178we'll put the number of clicks. We also include a small
179179javascript 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`:
181181
182182```
183+
183184$(function() {
184185 var clicks, $go, $clicks, $err
185186
186187 $go = $('#go')
187188 $clicks = $('#clicks')
188189 $err = $('#err')
189−
190− window.urb.appl = "click"
191190
192191 $go.on("click",
193192 function() {
194193 window.urb.send(
195− "click", {mark: "click"}
194+ "click", {mark: "examples-click-click"}
196195 ,function(err,res) {
197196 if(err)
198197 return $err.text("There was an error. Sorry!")
@@ -205,6 +204,7 @@ $(function() {
205204 })
206205 })
207206
207+ window.urb.appl = "examples-click"
208208 window.urb.bind('/the-path',
209209 function(err,dat) {
210210 clicks = dat.data.clicks