-
Notifications
You must be signed in to change notification settings - Fork 3
NeuGora Front End - JS #17
Description
Javascript Front End Support
Basic Pattern
Subscribe to /website to get the current state. The state will be:
{
pita: [ {type: 'g', pic: '', name: '', made: <seconds>, id: '', host: '', max: ~ || int, hodl: [ship]} ||
{type: 's', pic: '', name: '', made: <seconds>, id: '', host: '', stak: [{who: '', has: int}], nul: ~ ||[array type-g gora]}
],
owned: [<array of ids of gorae you own>],
made: [<array of ids of gorae you made>],
public: [<array of ids of gorae you have public>],
policy: [{id: <gora id>, policy: <bool - T for auto-approve, F for auto-reject>}],
tags: [{tag: '', id-list: [<array of ids of gorae with that tag>]}],
logs: { offers: [<array of gora ids you've been offered - these will be available in pita>],
requests: [{requester: '', id-list [<array of ids they've asked for>]}],
outgoing: [{when: <seconds>, id: <gora id>, who: '', act: 'give' || 'take' || 'gack', status: ~ || bool,
}
}
Each time an action is taken you will receive a {diff: {add: <state>, rem: <state>}} which you should process, rem first, by deleting from state and then adding to state (from add).
Pokes
:: interacting with gora:
:: [%ignore-give @uv] ignores a given gorae
:: [%accept-give @uv] accepts a given gorae
:: [%ignore-request @uv @p] ignore pleas for gora
:: [%accept-request @uv @p] accept pleas for gora
:: [%send-gora @uv (set ship)] give a gora to people
:: [%send-plea @uv @p] ask ship for gora @uv
:: [%kick ~] maybe gora is naughty
::
:: making & changing gorae:
:: [%rm-gora @uv] deletes a gora, local or remote
:: [%set-max @uv (unit @ud)] sets max hodlers, gora-standard
:: [%add-tag @tas (set id)] adds a tag across a set of gora
:: [%rem-tag @tas (set id)] remove a tag from a set of gora
:: [%stak-em (set id) @t @t] convert a set gorae into a stak
:: [%set-pol @uv u?(%approve %decline)] (un)set a gora's request policy
:: [%mk-gora @t @t ?([%g hodl max] [%s stak])] start a new gora with hodl/stak
::
[%ignore-give @uv]
{ ignore-give: { id: <id as string> } }
Should remove an offer from offer log, but not from Pita - you can delete it if you want tho.
[%accept-give @uv]
{ accept-give: { id: <id as string> } }
Should accept an offer, sending a gack, which will be reflected in outgoing.logs as ~ until it has been ack/nack'd and then TRUE or FALSE, respectively, thereafter.
Should result in your gora showing up as yours shortly thereafter (but not instantly - we don't inject ourselves, I don't think).
[%ignore-request @uv @p]
{ ignore-request: { id: <id as string>, ship: <ship as string> } }
Should delete a request for a gora.
[%accept-request @uv @p]
{ ignore-request: { id: <id as string>, ship: <ship as string> } }
Should accept a request for a gora. If it is a gora-standard, it will add them to hodl; if a gora-stakable it will increment their number.
Should delete the request from logs after accepting.
[%send-gora @uv (set ship)]
{ send-gora: { id: <id as string>, who: [<list of ships as strings>] }
Sends an offer to a group of people - will handle the logic of how to add them, how to offer to them.
Returns an updated outgoing.logs.
Maybe returns an updated gora.
[%send-plea @uv @p]
{ send-plea: { id: <id as string>, host: <ship as string> } }
Sends a request to someone and tries to subscribe to the gora.
Later returns a gora - but not right away there.
[%rm-gora @uv]
{ rm-gora: { id: <id as string> } }
Removes a gora. Returns a gora to delete. Maybe deletes some requests.
[%set-max @uv (unit @ud)]
{ set-max: { id: <id as string>, max: null || int } }
Sets the max possible gora on a gora - if null then unlimited. Handles the logic of whether the move is allowed, based on current holders.
Only works on %g gorae
Returns a gora to "add" (a change).
[%add-tag @tas (set @uv)]
{ add-tag: { id: <id as string>, gorae: [<id as string>] } }
Sets tag across all provided gorae.
Maybe returns an updated tag state.
[%add-tag @tas (set @uv)]
{ rem-tag: { id: <id as string>, gorae: [<id as string>] } }
Unsets tag across all provided gorae.
Maybe returns an updated tag state.
[%stak-em (set @uv) (each @uv [name=@t pic=@t])]
{ stak-em: { dez: [<ids as strings>],
which: <id of extant gora-stakable> || { name: <name as string>, pic: <name as string> }
}
}
Takes a stak of gorae (dez) and stacks them into either an existing gora-stakable (which == <id>) or a new gora-stakable (which == { name: '', pic: '' }).
Sends a bunch of deletes of the stacked old gorae.
Returns a new pita and logs.
[%set-pol @uv (unit ?(%approve %decline))]
{ set-pol: { id: <id as string> , pol: ~ | bool } }
Sets a policy - performs internal logic to determine if allowed.
Returns an updated policy.
Maybe returns updated logs.
[%mk-gora name=@t pic=@t type=?([%g hodl=(set ship) max=(unit @ud)] [%s stak=(map ship @ud)])]
{ mk-gora: {
name: string,
pic: string,
type: { g: { hodl: [<array of ships as strings>], max: null || int } } || { s: { stak: [<array of {who: ship, has: int}>] } }
}
}