mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 21:12:56 +03:00
app-reference: correcting structure and hoon typings
This commit is contained in:
parent
77ad1fdb36
commit
2dbfbedd05
@ -2,6 +2,7 @@
|
||||
import {
|
||||
ReferenceContent, resourceFromPath
|
||||
} from '@urbit/api';
|
||||
import { isValidPatp } from 'urbit-ob';
|
||||
import _ from 'lodash';
|
||||
|
||||
export function getPermalinkForGraph(
|
||||
@ -26,6 +27,7 @@ export interface AppPermalink {
|
||||
link: string;
|
||||
ship: string;
|
||||
desk: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface GroupPermalink {
|
||||
@ -64,11 +66,11 @@ function parseGraphPermalink(
|
||||
export function permalinkToReference(link: Permalink): ReferenceContent {
|
||||
switch (link.type) {
|
||||
case 'graph':
|
||||
return { reference: { graph: _.omit(link, 'type') } };
|
||||
return { reference: { graph: _.omit(link, ['type', 'link']) } };
|
||||
case 'group':
|
||||
return { reference: { group: link.group } };
|
||||
case 'app':
|
||||
return { reference: { app: _.omit(link, 'type') } };
|
||||
return { reference: { app: _.omit(link, ['type', 'link']) } };
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,12 +84,13 @@ export function referenceToPermalink({ reference }: ReferenceContent): Permalink
|
||||
...reference.graph
|
||||
};
|
||||
} else if ('app' in reference) {
|
||||
const { ship, desk } = reference.app;
|
||||
const { ship, desk, path } = reference.app;
|
||||
return {
|
||||
type: 'app',
|
||||
link: `web+urbitgraph://app/${ship}/${desk}`,
|
||||
link: `web+urbitgraph://${ship}/${desk}/${path}`,
|
||||
ship,
|
||||
desk
|
||||
desk,
|
||||
path
|
||||
};
|
||||
} else {
|
||||
const link = `web+urbitgraph://group${reference.group.slice(5)}`;
|
||||
@ -115,13 +118,15 @@ export function parsePermalink(url: string): Permalink | null {
|
||||
};
|
||||
}
|
||||
|
||||
if (kind === 'app') {
|
||||
const [ship, desk] = rest;
|
||||
if (isValidPatp(kind)) {
|
||||
const [desk, ...parts] = rest;
|
||||
const path = parts.join('/');
|
||||
return {
|
||||
type: kind,
|
||||
type: 'app',
|
||||
link: url,
|
||||
ship,
|
||||
desk
|
||||
ship: kind,
|
||||
desk,
|
||||
path
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1200,6 +1200,10 @@
|
||||
::
|
||||
%group
|
||||
txt+"[reference to msg in {~(phat tr group.reference.content)}]"
|
||||
::
|
||||
%app
|
||||
=, reference.content
|
||||
txt+"[reference to app: {(scow %p ship)}/{(trip desk)}{(trip path)}]"
|
||||
==
|
||||
::
|
||||
%mention
|
||||
|
@ -117,10 +117,11 @@
|
||||
s+(enjs-path:res grp)
|
||||
::
|
||||
++ app
|
||||
|= [shp=res dsk=res]
|
||||
|= [=^ship =desk path=@ta]
|
||||
%- pairs
|
||||
:~ ship+s+(enjs-path:res shp)
|
||||
desk+s+(enjs-path:res dsk)
|
||||
:~ ship+s+(scot %p ship)
|
||||
desk+s+desk
|
||||
path+s+path
|
||||
==
|
||||
--
|
||||
::
|
||||
@ -385,6 +386,7 @@
|
||||
%- of
|
||||
:~ graph+graph
|
||||
group+dejs-path:res
|
||||
app+app
|
||||
==
|
||||
::
|
||||
++ graph
|
||||
@ -393,6 +395,13 @@
|
||||
graph+dejs-path:res
|
||||
index+index
|
||||
==
|
||||
::
|
||||
++ app
|
||||
%- ot
|
||||
:~ ship+(su ;~(pfix sig fed:ag))
|
||||
desk+so
|
||||
path+so
|
||||
==
|
||||
--
|
||||
::
|
||||
++ tang
|
||||
|
@ -29,6 +29,7 @@
|
||||
+$ reference
|
||||
$% [%graph group=resource =uid]
|
||||
[%group group=resource]
|
||||
[%app =ship =desk path=@ta]
|
||||
==
|
||||
::
|
||||
+$ content
|
||||
|
@ -35,6 +35,7 @@ export interface AppReference {
|
||||
app: {
|
||||
ship: string;
|
||||
desk: string;
|
||||
path: string;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user