on main help sign in
add spawned points list to ship view and got software distro working
commit45297d9be18c0780e818d2d41e3e99ce1e2f6ccd authorJohn Hyde <johnhydefour@gmail.com> dateFri 6 May 2022, 04:47 (5 years ago) parentd831dbb
12 files changed+131−20
README.md+18−2 desk/app/astrolabe.hoon+11−2 desk/desk.docket-0+1−1 desk/lib/astrolabe.hoon+10 desk/mar/astrolabe/point-set.hoon+13 desk/mar/astrolabe/point.hoon+1−1 ui/package-lock.json+7−7 ui/package.json+1−1 ui/src/components/ShipListing.svelte+16−2 ui/src/components/ShipView.svelte+40−3 ui/src/components/Sigil.svelte+1−1 ui/src/styles/tailwind-output.css+12
README.md+18−2
@@ -25,7 +25,23 @@ To develop you'll need a running ship to point to. To do so you first need to ad
2525
2626Regardless of what you run to develop, Vite will hot-reload code changes as you work so you don't have to constantly refresh.
2727
28−### Deploying
28+### Deploying with `glob-ames` glob
29+
30+1. Spin up a comet or distribution ship.
31+2. Mount an `%astrolabe` desk. In Dojo:
32+ 1. `|merge %astrolabe our %base` to create a new desk.
33+ 2. `|mount %work` to mount it.
34+3. Install the desk
35+ 1. From the root of the project: `./install.sh path/to/pier/astrolabe`
36+ 2. From the ship's dojo: `|commit %astrolabe`
37+ 3. (if using a comet as a middleman) `|public %astrolabe`
38+ 4. (if using a comet as a middleman) from the actual distribution ship: `|install ~comet-name %astrolabe`
39+ 5. (if using a comet as a middleman) from the actual distribution ship: `|pause %astrolabe`
40+4. Build the UI with `npm run build` in the `ui` directory which will bundle all the code and assets into the `dist/` folder.
41+5. Upload the `dist/` folder as a glob to your distribution ship. Example url: https://distribution.urbit-ship.com/docket/upload
42+6. Publish the desk from dojo: `:treaty|publish %astrolabe`
43+
44+### Deploying with `glob-http` glob
2945
3046To deploy, run `npm run build` in the `ui` directory which will bundle all the code and assets into the `dist/` folder. This can then be made into a glob by doing the following:
3147
@@ -41,7 +57,7 @@ To deploy, run `npm run build` in the `ui` directory which will bundle all the c
415710. Once you've uploaded the glob, you should then update the corresponding entry in the docket file at `desk/desk.docket-0`. Both the full URL and the hash should be updated to match the glob we just created, on the line that looks like this:
4258
4359```hoon
44− glob-http+['https://bootstrap.urbit.org/glob-0v5.fdf99.nph65.qecq3.ncpjn.q13mb.glob' 0v5.fdf99.nph65.qecq3.ncpjn.q13mb]
60+ glob-http+['https://bootstrap.urbit.org/glob-0v5.fdf99.nph65.qecq3.ncpjn.q13mb.glob' 0v5.fdf99.nph65.qecq3.ncpjn.q13mb]
4561```
4662
476311. This can now be safely committed and deployed.
desk/app/astrolabe.hoon+11−2
@@ -28,8 +28,14 @@
2828 :_ this
2929 [%pass /azimuth-events %agent [our.bowl %azimuth] %watch /event]~
3030::
31−++ on-save on-save:def
32−++ on-load on-load:def
31+++ on-save !>(state)
32+++ on-load
33+ |= old-state=vase
34+ ^- (quip card _this)
35+ =/ old !<(versioned-state old-state)
36+ ?- -.old
37+ %0 `this(state old)
38+ ==
3339++ on-poke on-poke:def
3440++ on-watch on-watch:def
3541++ on-leave on-leave:def
@@ -46,6 +52,9 @@
4652 ?~ doc
4753 `~
4854 ``json+!>(s+u.doc)
55+ [%x %spawned @ ~]
56+ =/ =ship `@p`(slav %p &3.path)
57+ ``astrolabe-point-set+!>((~(get ju spa) ship))
4958 ==
5059++ on-agent
5160 |= [=wire =sign:agent:gall]
desk/desk.docket-0+1−1
@@ -2,7 +2,7 @@
22 info+'Your guide to the Urbit constellations'
33 color+0x1f.243c
44 image+'https://raw.githubusercontent.com/johnhyde/astrolabe/main/ui/src/assets/astrolabe-tile.svg'
5− glob-http+['https://bootstrap.urbit.org/glob-0v5.hurm4.ejod5.ngg9h.iub9i.n1j7o.glob' 0v5.hurm4.ejod5.ngg9h.iub9i.n1j7o]
5+ glob-ames+[~dister-midlev-mindyr 0v0]
66 base+'astrolabe'
77 version+[0 0 1]
88 website+'https://github.com/johnhyde/astrolabe'
desk/lib/astrolabe.hoon+10
@@ -10,6 +10,16 @@
1010++ enjs
1111 =, enjs:format
1212 |%
13+ ++ point-set
14+ |= points=(set ^ship)
15+ ^- json
16+ =+ point-list=~(tap in points)
17+ %+ frond %spawned
18+ :- %a
19+ %+ turn
20+ point-list
21+ |= who=^ship
22+ (ship who)
1323 ++ point
1424 |= =^point
1525 ^- json
desk/mar/astrolabe/point-set.hoonnew file+13
@@ -0,0 +1,13 @@
1+/+ *astrolabe
2+|_ points=(set ship)
3+++ grab
4+ |%
5+ ++ noun (set ship)
6+ --
7+++ grow
8+ |%
9+ ++ noun points
10+ ++ json (point-set:enjs points)
11+ --
12+++ grad %noun
13+--
desk/mar/astrolabe/point.hoon+1−1
@@ -3,7 +3,7 @@
33++ grab
44 |%
55 ++ noun point
6− ++ json point:dejs
6+ :: ++ json point:dejs
77 --
88++ grow
99 |%
ui/package-lock.json+7−7
@@ -26,7 +26,7 @@
2626 "cross-env": "^7.0.3",
2727 "postcss-cli": "^9.1.0",
2828 "sass": "^1.50.0",
29− "svelte": "^3.44.0",
29+ "svelte": "^3.48.0",
3030 "svelte-check": "^2.2.7",
3131 "svelte-preprocess": "^4.9.8",
3232 "svelte-spa-router": "^3.2.0",
@@ -2454,9 +2454,9 @@
24542454 }
24552455 },
24562456 "node_modules/svelte": {
2457− "version": "3.45.0",
2458− "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.45.0.tgz",
2459− "integrity": "sha512-6AWftH2eqqKLYH1HvKpuUWe8OfjflarhegN57P/Cqwc2Rb2F5oIdDtANU/jMscyZMzG0v6nTQox0siZR9cmRVQ==",
2457+ "version": "3.48.0",
2458+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.48.0.tgz",
2459+ "integrity": "sha512-fN2YRm/bGumvjUpu6yI3BpvZnpIm9I6A7HR4oUNYd7ggYyIwSA/BX7DJ+UXXffLp6XNcUijyLvttbPVCYa/3xQ==",
24602460 "dev": true,
24612461 "engines": {
24622462 "node": ">= 8"
@@ -4637,9 +4637,9 @@
46374637 "dev": true
46384638 },
46394639 "svelte": {
4640− "version": "3.45.0",
4641− "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.45.0.tgz",
4642− "integrity": "sha512-6AWftH2eqqKLYH1HvKpuUWe8OfjflarhegN57P/Cqwc2Rb2F5oIdDtANU/jMscyZMzG0v6nTQox0siZR9cmRVQ==",
4640+ "version": "3.48.0",
4641+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.48.0.tgz",
4642+ "integrity": "sha512-fN2YRm/bGumvjUpu6yI3BpvZnpIm9I6A7HR4oUNYd7ggYyIwSA/BX7DJ+UXXffLp6XNcUijyLvttbPVCYa/3xQ==",
46434643 "dev": true
46444644 },
46454645 "svelte-check": {
ui/package.json+1−1
@@ -22,7 +22,7 @@
2222 "cross-env": "^7.0.3",
2323 "postcss-cli": "^9.1.0",
2424 "sass": "^1.50.0",
25− "svelte": "^3.44.0",
25+ "svelte": "^3.48.0",
2626 "svelte-check": "^2.2.7",
2727 "svelte-preprocess": "^4.9.8",
2828 "svelte-spa-router": "^3.2.0",
ui/src/components/ShipListing.svelte+16−2
@@ -1,16 +1,30 @@
11<script lang="ts">
2+
23 import Sigil from "./Sigil.svelte";
4+ import { push } from 'svelte-spa-router'
5+ import { normalizeId } from '../lib/id';
6+ import { linkToShip as generateLinkToShip } from '../lib/link';
37 export let ship: any;
8+ export let linkToShip: boolean = false;
9+
10+ $: patp = normalizeId(ship.patp);
11+
12+ function handleClick() {
13+ if (linkToShip) {
14+ push(generateLinkToShip(patp));
15+ }
16+ }
417</script>
518
619<div class="flex flex-wrap p-4 border-b last:border-none items-center"
20+ on:click={handleClick}
721 on:click
822 >
9− <Sigil patp={ship.patp} size={48} />
23+ <Sigil {patp} size={48} />
1024 <!-- {#if ship.avatar}
1125 <img src={ship.avatar} class="h-12 w-12 mr-4" />
1226 {/if} -->
1327 <p class="ml-4 break-words" >
14− {ship.patp}<br/>{ship.nickname ? `(${ship.nickname})` : ''}
28+ {patp}<br/>{ship.nickname ? `(${ship.nickname})` : ''}
1529 </p>
1630</div>
ui/src/components/ShipView.svelte+40−3
@@ -11,6 +11,7 @@
1111 import ShipLink from './ShipLink.svelte';
1212 import EthAddressLink from './EthAddressLink.svelte';
1313 import CollapsibleContent from './CollapsibleContent.svelte';
14+ import ShipListing from './ShipListing.svelte';
1415
1516 export let patp: string;
1617
@@ -18,6 +19,9 @@
1819 let rawPointInfoPromise: any;
1920 let rawPointInfo: any = {};
2021 let pointInfo: any = {};
22+ let rawSpawnedPointsPromise: any;
23+ let rawSpawnedPoints: any = {};
24+ let spawnedPoints: string[] = [];
2125 const api: UrbitApi = new UrbitApi('');
2226 const spawnStatusOptions = {
2327 unspawned: {
@@ -55,6 +59,7 @@
5559 $: shipClass = clan(patp);
5660 $: azPoint = ['galaxy', 'star', 'planet'].includes(shipClass);
5761 $: canSpawnPoints = ['galaxy', 'star'].includes(shipClass);
62+ $: spawnableClassPlural = !canSpawnPoints ? '' : (shipClass === 'galaxy' ? 'Stars' : 'Planets');
5863 $: {
5964 let parents = [patp];
6065 let galaxyFound = false;
@@ -85,6 +90,23 @@
8590 });
8691 }
8792 }
93+ $: {
94+ rawSpawnedPoints = {};
95+ if (canSpawnPoints) {
96+ rawSpawnedPointsPromise = api.scry<any>({ app: 'astrolabe', path: `/spawned/${patp}` });
97+ rawSpawnedPointsPromise.then((info) => {
98+ rawSpawnedPoints = info;
99+ }).catch((error) => {
100+ rawSpawnedPoints.error = error;
101+ });
102+ }
103+ }
104+ $: {
105+ spawnedPoints = [];
106+ if (rawSpawnedPoints.spawned) {
107+ spawnedPoints = rawSpawnedPoints.spawned.map(patp => normalizeId(patp));
108+ }
109+ }
88110 $: {
89111 pointInfo = {};
90112 let spawnStatus: any,
@@ -290,9 +312,24 @@
290312 </div>
291313 </div>
292314 {#if canSpawnPoints}
293− <div>
294− <h3 class="text-lg">Spawned Points: {pointInfo.spawnedCount || ''}</h3>
295− <span class="text-green-600">// TODO</span>
315+ <div class="mt-5 p-3 border-t">
316+ {#await rawPointInfoPromise then}
317+ <h3 class="text-lg">
318+ {#if pointInfo.spawnedCount}
319+ {pointInfo.spawnedCount} Spawned {spawnableClassPlural}:
320+ {:else}
321+ No Spawned {spawnableClassPlural}
322+ {/if}
323+ </h3>
324+ {/await}
325+ {#await rawSpawnedPointsPromise}
326+ Loading {spawnableClassPlural}...
327+ {:then}
328+ <!-- TODO: pagination -->
329+ {#each spawnedPoints as patp, i}
330+ <ShipListing ship={{ patp }} linkToShip />
331+ {/each}
332+ {/await}
296333 </div>
297334 {/if}
298335</div>
ui/src/components/Sigil.svelte+1−1
@@ -28,7 +28,7 @@
2828 }
2929</script>
3030
31−<div>
31+<div class="flex-grow" style:max-width="{size}px">
3232 {#if displaySigil}
3333 {@html svgString}
3434 {:else}
ui/src/styles/tailwind-output.css+12
@@ -509,6 +509,9 @@ Ensure the default browser behavior of the `hidden` attribute.
509509.mt-4 {
510510 margin-top: 1rem;
511511}
512+.mt-5 {
513+ margin-top: 1.25rem;
514+}
512515.-mt-1 {
513516 margin-top: -0.25rem;
514517}
@@ -527,6 +530,9 @@ Ensure the default browser behavior of the `hidden` attribute.
527530.-mt-0 {
528531 margin-top: -0px;
529532}
533+.mt-3 {
534+ margin-top: 0.75rem;
535+}
530536.-mt-0\.5 {
531537 margin-top: -0.125rem;
532538}
@@ -743,6 +749,9 @@ Ensure the default browser behavior of the `hidden` attribute.
743749.border-b {
744750 border-bottom-width: 1px;
745751}
752+.border-t {
753+ border-top-width: 1px;
754+}
746755.border-white {
747756 --tw-border-opacity: 1;
748757 border-color: rgb(255 255 255 / var(--tw-border-opacity));
@@ -841,6 +850,9 @@ Ensure the default browser behavior of the `hidden` attribute.
841850.p-1 {
842851 padding: 0.25rem;
843852}
853+.p-5 {
854+ padding: 1.25rem;
855+}
844856.py-0\.5 {
845857 padding-top: 0.125rem;
846858 padding-bottom: 0.125rem;