Merge remote-tracking branch 'origin/collections-redesign' into ford-turbo-eyre-sec

Note: This ignores changes to clay for expediency, these may need to
be hand merged later.
This commit is contained in:
Elliot Glaysher 2018-07-31 10:11:10 -07:00
commit 4363163319
73 changed files with 79253 additions and 400 deletions

2840
app/acme.hoon Normal file

File diff suppressed because it is too large Load Diff

638
app/collections.hoon Normal file
View File

@ -0,0 +1,638 @@
:: /app/collections/hoon
::
/? 309
/- hall
/+ collections
/= cols
/^ collection:collections
/; |= a=(map knot item:collections)
[*config:collections a]
/: /===/web/collections /_ /collection-item/
::
=, collections
=, space:userlib
::
|%
+= move [bone card]
+= card
$% [%info wire ship toro:clay]
[%poke wire dock poke]
[%perm wire ship desk path rite:clay]
==
+= poke
$% [%hall-action action:hall]
[%collection-action action:collections]
[%json json]
==
--
::
::::
::
|_ [bol=bowl:gall state=collection]
::
++ this .
::
::::
++ prep
|= old=(unit *)
^- (quip move _this)
?~ old
=< ta-done
(ta-hall-create-circle:ta /c 'collections')
=/ old-col ((soft collection) u.old)
?~ old-col
[~ this(state cols)]
=^ mow this
=< ta-done
(ta-update:ta u.old-col)
[mow this(state cols)]
::
:: mack: acknowledgement for permissions
::
++ mack
|= [wir=wire err=(unit tang)]
^- (quip move _this)
?~ err
[~ this]
(mean u.err)
::::::
:: utilities
::
++ base-spur `spur`/web/collections
++ base-beam `beam`[byk.bol (flop base-spur)]
++ base-path `path`(en-beam:format base-beam)
::
++ path-to-circle
|= pax=path
^- circle:hall
=. pax
?: ?=([%web %collections *] pax)
(weld /c (slag 2 `path`pax))
?: ?=([%collections *] pax)
(weld /c (slag 1 `path`pax))
?: ?=([%c *] pax)
`path`pax
`path`(weld /c pax)
=/ nam=term
%+ roll `(list @ta)`pax
|= [seg=@ta out=term]
%^ cat 3
?:(=(%$ out) out (cat 3 out '-'))
((hard @tas) seg)
[our.bol nam]
::
++ allowed-by
|= [who=@p dic=dict:clay]
=/ in-list=?
?| (~(has in p.who.rul.dic) who)
::
%- ~(rep by q.who.rul.dic)
|= [[@ta cru=crew:clay] out=_|]
?: out &
(~(has in cru) who)
==
?: =(%black mod.rul.dic)
!in-list
in-list
::
++ collection-notify
|= [pax=path conf=config]
^- json
%- pairs:enjs:format
:~ ['owner' [%s (crip (scow %p owner.conf))]]
['path' [%a (turn pax |=(a=@ta `json`[%s a]))]]
['name' [%s name.conf]]
['date' [%s (crip (scow %da last-modified.conf))]]
['type' [%s type.conf]]
==
::
++ item-notify
|= [pax=path raw=raw-item]
^- json
=/ owner (fall (~(get by meta.raw) %owner) ~.anon)
=/ dat (fall (~(get by meta.raw) %last-modified) (scot %da now.bol))
=/ nom (fall (~(get by meta.raw) %name) ~.no-title)
=/ typ (fall (~(get by meta.raw) %type) ~.no-type)
%- pairs:enjs:format
:~ ['owner' [%s owner]]
['path' [%a (turn pax |=(a=@ta `json`[%s a]))]]
['name' [%s nom]]
['date' [%s dat]]
['type' [%s typ]]
['content' [%s data.raw]]
==
::
::
::
++ poke-noun
|= a=*
^- (quip move _this)
:: =/ pax ((hard path) a)
=/ yo=item (~(got by data.cols) ~.yoyo)
?> ?=(%both -.yo)
=/ new-front (~(put by meta.raw.yo) %new-field ~.fuck-off)
=/ new-body (crip (weld (trip data.raw.yo) "new line\0a"))
=/ new-contents (update-umd-front new-front data.raw.yo)
=/ act=action:collections
:* our.bol %home
:~ [%write /web/collections/yoyo/umd %umd new-body]
==
==
=/ mow=move
[ost.bol %poke /poke-act [our.bol %collections] %collection-action act]
[[mow]~ this]
::
++ poke-collection-action
|= act=action:collections
^- (quip move _this)
:: ~& act
?. =(who.act our.bol)
::
:: forward poke if its not meant for us
:_ this
:_ ~
:* ost.bol %poke
/forward-collection-action
[who.act %collections]
%collection-action act
==
::
:: resolve %collection, %post, or %comment to %write action
=. acts.act
%+ turn acts.act
|= a=sub-action
^- sub-action
?: ?=(%collection -.a)
=/ conf=config
:* [byk.bol (flop (weld pax.a /[name.a]/collection-config))]
name.a
desc.a
our.bol
now.bol
now.bol
type.a
comments.a
~
visible.a
==
[%write (weld pax.a /[name.a]/collection-config) %collection-config conf]
::
?: ?=(%post -.a)
=/ front=(map knot cord)
%- my
:~ [%name name.a]
[%comments ?:(comments.a ~..y ~..n)]
[%owner (scot %p src.bol)]
[%date-created (scot %da now.bol)]
[%last-modified (scot %da now.bol)]
[%type type.a]
==
[%write (weld pax.a /[name.a]/umd) %umd (update-umd-front front content.a)]
::
?: ?=(%comment -.a)
=/ dat (scot %da now.bol)
=/ front=(map knot cord)
%- my
:~ [%owner (scot %p src.bol)]
[%date-created dat]
[%last-modified dat]
==
[%write (weld pax.a /[dat]/umd) %umd (update-umd-front front content.a)]
::
a
::
:: if its from us no need to check permissions
?: =(src.bol our.bol)
ta-done:(ta-act:ta act)
::
:: if not from us, check if every action in the list is permitted
:: if even one isn't, don't reject the whole list
=/ success=?
%+ levy acts.act
|= a=sub-action
=/ pax (path +<.a)
?+ -.a !!
%write
=/ perms .^([dict:clay dict:clay] %cp pax)
(allowed-by src.bol +.perms)
%delete
=/ perms .^([dict:clay dict:clay] %cp pax)
(allowed-by src.bol +.perms)
%perms |
==
::
?: success
ta-done:(ta-act:ta act)
[~ this] :: XX TODO: report failure
::
::::::
::::::
::
++ ta
|_ moves=(list move)
::
:: core control
::
++ ta-this .
++ ta-done [(flop moves) this]
++ ta-emit
|= mov=move
%_ ta-this
moves [mov moves]
==
++ ta-emil
|= mos=(list move)
%_ ta-this
moves (welp (flop mos) moves)
==
::
:: interface
::
++ ta-act
|= act=action:collections
^+ ta-this
|-
?~ acts.act ta-this
=* a i.acts.act
=. ta-this
?+ -.a
!!
%write (ta-write pax.a `cage`[-.for.a !>(+.for.a)])
%delete (ta-remove pax.a)
%perms (ta-set-permissions pax.a r.a w.a)
==
$(acts.act t.acts.act)
::
:: clay updates
::
++ ta-update
|= old=collection
^+ ta-this
:: ~& old+old
:: ~& new+cols
?: =(old cols)
:: ~& %no-update
ta-this
(ta-update-collection old cols /web/collections)
::
++ ta-insert-item
|= [new=item pax=path]
^+ ta-this
:: ~& insert+[-.new pax]
=/ parent-path (scag (dec (lent pax)) pax)
::
?- -.new
::
%collection
=. ta-this
(ta-hall-json parent-path 'new collection' (collection-notify pax meta.col.new))
::
=. ta-this (ta-hall-create-circle pax description.meta.col.new)
=/ items=(list [nom=@ta =item]) ~(tap by data.col.new)
|-
?~ items ta-this
=. ta-this (ta-insert-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
%both
=. ta-this
(ta-hall-json parent-path 'new collection' (collection-notify pax meta.col.new))
=. ta-this
(ta-hall-json parent-path 'new item' (item-notify pax raw.new))
=. ta-this (ta-hall-create-circle pax description.meta.col.new)
=/ items=(list [nom=@ta =item]) ~(tap by data.col.new)
=. ta-this
|-
?~ items ta-this
=. ta-this (ta-insert-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
?: ?& (~(has by meta.raw.new) %comments)
=('.y' (~(got by meta.raw.new) %comments))
==
(ta-generate-comments pax)
ta-this
::
%raw
=. ta-this
(ta-hall-json parent-path 'new item' (item-notify pax raw.new))
?: ?& (~(has by meta.raw.new) %comments)
=('.y' (~(got by meta.raw.new) %comments))
==
(ta-generate-comments pax)
ta-this
::
==
::
++ ta-remove-item
|= [old=item pax=path]
^+ ta-this
:: ~& remove+[-.old pax]
:: flush permissions
:: notify parent of deletion
=/ parent (scag (dec (lent pax)) pax)
:: recurse for children
?- -.old
::
%collection
=. ta-this
(ta-hall-json parent 'deleted collection' (collection-notify pax meta.col.old))
=. ta-this (ta-flush-permissions (weld pax /collection-config))
=/ items=(list [nom=@ta =item]) ~(tap by data.col.old)
|-
?~ items ta-this
=. ta-this (ta-remove-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
%both
=. ta-this
(ta-hall-json parent 'deleted collection' (collection-notify pax meta.col.old))
=. ta-this
(ta-hall-json parent 'deleted item' (item-notify pax raw.old))
=. ta-this (ta-flush-permissions pax)
=. ta-this (ta-flush-permissions (weld pax /collection-config))
=/ items=(list [nom=@ta =item]) ~(tap by data.col.old)
|-
?~ items ta-this
=. ta-this (ta-remove-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
%raw
=. ta-this (ta-flush-permissions pax)
(ta-hall-json parent 'deleted item' (item-notify pax raw.old))
::
==
::
::
::
++ ta-update-item
:: always make sure removals happen first and insertions happen last
:: because removals flush permissions and insertions set them
::
|= [old=item new=item pax=path]
^+ ta-this
:: ~& update-item+[-.old -.new pax]
?: =(old new)
ta-this
::
:: check for changes in item type
?: &(?=(%collection -.old) ?=(%collection -.new))
(ta-update-collection col.old col.new pax)
?: &(?=(%raw -.old) ?=(%raw -.new))
(ta-update-raw-item raw.old raw.new pax)
?: &(?=(%both -.old) ?=(%both -.new))
:: update raw item
=. ta-this (ta-update-collection col.old col.new pax)
(ta-update-raw-item raw.old raw.new pax)
::
?: &(?=(%collection -.old) ?=(%raw -.new))
:: remove collection
:: insert raw item
=. ta-this (ta-remove-item old pax)
(ta-insert-item new pax)
::
?: &(?=(%collection -.old) ?=(%both -.new))
:: insert raw item
:: update-collection
=. ta-this (ta-update-collection col.old col.new pax)
(ta-insert-item new pax)
::
?: &(?=(%raw -.old) ?=(%collection -.new))
:: remove raw item
:: insert collection
=. ta-this (ta-remove-item old pax)
(ta-insert-item new pax)
::
?: &(?=(%raw -.old) ?=(%both -.new))
:: insert collection
:: update raw item
=. ta-this (ta-update-raw-item raw.old raw.new pax)
(ta-insert-item new pax)
::
?: &(?=(%both -.old) ?=(%raw -.new))
:: remove collection
:: update raw item
=. ta-this (ta-remove-item [%collection col.old] pax)
(ta-update-raw-item raw.old raw.new pax)
::
?: &(?=(%both -.old) ?=(%collection -.new))
:: remove raw item
:: update collection
=. ta-this (ta-remove-item [%raw raw.old] pax)
(ta-update-collection col.old col.new pax)
::
ta-this
::
++ ta-update-raw-item
|= [old=raw-item new=raw-item pax=path]
^+ ta-this
:: ~& update-raw-item+[-.old -.new pax]
?: =(old new)
ta-this
::
=? ta-this !=(data.old data.new)
=/ parent-path (scag (dec (lent pax)) pax)
(ta-hall-json parent-path 'edited item' (item-notify pax new)) :: XX fil
::
=? ta-this
?& =('.y' (fall (~(get by meta.new) %comments) '.n'))
=('.n' (fall (~(get by meta.old) %comments) '.n'))
==
:: create comments
(ta-generate-comments pax)
::
=? ta-this
?& =('.n' (fall (~(get by meta.new) %comments) '.n'))
=('.y' (fall (~(get by meta.old) %comments) '.n'))
==
:: delete comments
(ta-remove (weld pax /collection-config))
::
:: check if file has been modified
:: and if so update last modified field
=/ told (trip data.old)
=/ newt (trip data.new)
=/ old-con (slag (need (find ";>" told)) told)
=/ new-con (slag (need (find ";>" newt)) newt)
=? ta-this !=(old-con new-con)
=/ contents=@t
%+ update-umd-front
(~(put by meta.new) %last-modified (scot %da now.bol))
data.new
:: ~& %update-last-modified
:: ~& contents
:: ~& (weld pax /umd)
(ta-write (weld pax /umd) %umd !>(contents))
::
ta-this
::
++ ta-update-collection
|= $: old=collection
new=collection
pax=path
==
^+ ta-this
:: ~& update-collection+pax
::
=? ta-this !=(meta.old meta.new)
=/ parent-path (scag (dec (lent pax)) pax)
(ta-hall-json parent-path 'edited collection' (collection-notify pax meta.new))
::
?: =(data.old data.new)
ta-this
::
:: new values of all changed items
=/ upd-new (~(dif in (~(int by data.old) data.new)) data.old)
:: old values of all changed items
=/ upd-old (~(dif in (~(int by data.new) data.old)) data.new)
:: all totally new entries
=/ ins-new (~(dif by data.new) data.old)
:: all deleted entries
=/ del-old (~(dif by data.old) data.new)
::
=/ upd-new=(list [nom=knot =item]) ~(tap by upd-new)
=/ upd-old=(list [nom=knot =item]) ~(tap by upd-old)
=/ ins-new=(list [nom=knot =item]) ~(tap by ins-new)
=/ del-old=(list [nom=knot =item]) ~(tap by del-old)
::
=/ lam |=([[a=knot item] out=(list path)] [(weld pax [a ~]) out])
:: ~& upd-new+(roll upd-new lam)
:: ~& upd-old+(roll upd-old lam)
:: ~& ins-new+(roll ins-new lam)
:: ~& del-old+(roll del-old lam)
::
=. ta-this |-
?~ upd-new
ta-this
?< ?=(~ upd-old)
=* new-item i.upd-new
=* old-item i.upd-old
=/ new-pax (weld pax [nom.new-item ~])
=. ta-this (ta-update-item item.old-item item.new-item new-pax)
::
%= $
upd-new t.upd-new
upd-old t.upd-old
==
::
=. ta-this |-
?~ ins-new
ta-this
=* new-item i.ins-new
=/ new-pax (weld pax [nom.new-item ~])
=. ta-this (ta-insert-item +.new-item (weld pax [-.new-item ~]))
$(ins-new t.ins-new)
::
=. ta-this |-
?~ del-old
ta-this
=* old-item i.del-old
=/ old-pax (weld pax [nom.old-item ~])
=. ta-this (ta-remove-item +.old-item (weld pax [-.old-item ~]))
$(del-old t.del-old)
::
ta-this
::
++ ta-generate-comments
|= pax=path
^+ ta-this
=/ sup=path [%collection-config (flop pax)]
=/ pat (en-beam:format [byk.bol sup])
=/ cay=config
:* [byk.bol sup]
'comments'
'comments'
our.bol
now.bol
now.bol
%comments
|
~
|
==
(ta-write (flop sup) %collection-config !>(cay))
::
:: writing files
::
++ ta-write
|= [pax=path cay=cage]
:: ~& writing+pax
^+ ta-this
=. pax (en-beam:format byk.bol (flop pax))
%+ ta-emit ost.bol
[%info (weld /ta-write pax) our.bol (foal pax cay)]
::
++ ta-remove
|= pax=path
=. pax (en-beam:format byk.bol (flop pax))
^+ ta-this
%+ ta-emit ost.bol
[%info (weld /ta-remove pax) our.bol (fray pax)]
::
:: permissions
::
++ ta-set-permissions
|= [pax=path r=rule:clay w=rule:clay]
:: =. pax (weld base-spur pax)
^+ ta-this
%+ ta-emit ost.bol
[%perm (weld /perms pax) our.bol q.byk.bol pax [%rw `r `w]]
::
++ ta-flush-permissions
|= pax=path
:: =. pax (weld base-spur pax)
^+ ta-this
%+ ta-emit ost.bol
[%perm (weld /perms pax) our.bol q.byk.bol pax [%rw ~ ~]]
::
:: hall
::
++ ta-hall-action
|= act=action:hall
^+ ta-this
%+ ta-emit ost.bol
[%poke /col-hall-action [our.bol %hall] %hall-action act]
::
++ ta-hall-actions
|= act=(list $?(~ action:hall))
^+ ta-this
?~ act ta-this
?~ i.act $(act t.act)
%= $
ta-this (ta-hall-action i.act)
act t.act
==
::
++ ta-hall-create-circle ::
|= [pax=path description=@t]
^+ ta-this
=/ circ=circle:hall (path-to-circle pax)
=/ parent=circle:hall
?: =(nom.circ %c)
[our.bol %inbox]
(path-to-circle (scag (dec (lent pax)) pax))
%- ta-hall-actions
:: XX TODO make this depend on clay perms
:~ [%create nom.circ description %journal]
[%source nom.parent & (sy `source:hall`[circ ~] ~)]
==
::
++ ta-hall-lin
|= [pax=path msg=cord]
^+ ta-this
=/ circ=circle:hall (path-to-circle pax)
%- ta-hall-action
[%phrase [circ ~ ~] [%lin | msg]~]
::
++ ta-hall-json
|= [pax=path header=@t jon=json]
^+ ta-this
=/ circ=circle:hall (path-to-circle pax)
%- ta-hall-action
:+ %phrase [circ ~ ~]
[%fat [%text ~[header]] [%lin | (crip (en-json:html jon))]]~
::
--
--

514
app/dns.hoon Normal file
View File

@ -0,0 +1,514 @@
/- dns
=, dns
!:
::
:: moves and state
::
|%
+= move (pair bone card)
+= poke
$% [%dns-bind for=ship him=ship target]
[%dns-bond for=ship him=ship turf]
[%dns-authority authority]
:: XX some other notification channel?
[%helm-send-hi ship (unit tape)]
==
+= card
$% [%tend wire ~]
[%wait wire @da]
[%poke wire dock poke]
[%rule wire %turf %put turf]
[%hiss wire [~ ~] %httr %hiss hiss:eyre]
==
:: +state: complete app state
::
+= state
$: :: dom: the set of our bindings
::
dom=(set turf)
:: per: per-dependent ips &c
::
per=(map ship relay)
:: nem: authoritative state
::
nem=(unit nameserver)
==
:: +join: dedup with :acme
::
++ join
|= [sep=@t hot=(list @t)]
^- @t
?> ?=(^ hot)
%+ rap 3
|- ^- (list @t)
?~ t.hot hot
[i.hot sep $(hot t.hot)]
:: +name: fully-qualified domain name
::
++ name
|= [him=ship dom=turf]
(cat 3 (join '.' [(crip +:(scow %p him)) (flop dom)]) '.')
:: +endpoint: append path to purl
::
++ endpoint
|= [bas=purl:eyre pat=path]
^+ bas
bas(q.q (weld q.q.bas pat))
:: +reserved: check if an ipv4 address is in a reserved range
::
++ reserved
|= a=@if
^- ?
=/ b (flop (rip 3 a))
:: 0.0.0.0/8 (software)
::
?. ?=([@ @ @ @ ~] b) &
?| :: 10.0.0.0/8 (private)
::
=(10 i.b)
:: 100.64.0.0/10 (carrier-grade NAT)
::
&(=(100 i.b) (gte i.t.b 64) (lte i.t.b 127))
:: 127.0.0.0/8 (localhost)
::
=(127 i.b)
:: 169.254.0.0/16 (link-local)
::
&(=(169 i.b) =(254 i.t.b))
:: 172.16.0.0/12 (private)
::
&(=(172 i.b) (gte i.t.b 16) (lte i.t.b 31))
:: 192.0.0.0/24 (protocol assignment)
::
&(=(192 i.b) =(0 i.t.b) =(0 i.t.t.b))
:: 192.0.2.0/24 (documentation)
::
&(=(192 i.b) =(0 i.t.b) =(2 i.t.t.b))
:: 192.18.0.0/15 (reserved, benchmark)
::
&(=(192 i.b) |(=(18 i.t.b) =(19 i.t.b)))
:: 192.51.100.0/24 (documentation)
::
&(=(192 i.b) =(51 i.t.b) =(100 i.t.t.b))
:: 192.88.99.0/24 (reserved, ex-anycast)
::
&(=(192 i.b) =(88 i.t.b) =(99 i.t.t.b))
:: 192.168.0.0/16 (private)
::
&(=(192 i.b) =(168 i.t.b))
:: 203.0.113/24 (documentation)
::
&(=(203 i.b) =(0 i.t.b) =(113 i.t.t.b))
:: 224.0.0.0/8 (multicast)
:: 240.0.0.0/4 (reserved, future)
:: 255.255.255.255/32 (broadcast)
::
(gte i.b 224)
==
:: |gcloud: provider-specific functions
::
++ gcloud
|_ aut=authority
:: +base: provider service endpoint
::
++ base
(need (de-purl:html 'https://www.googleapis.com/dns/v1/projects'))
:: +record: JSON-formatted provider-specific dns record
::
++ record
|= [him=ship tar=target]
^- json
:: ?> ?=([%gcloud *] pro.aut)
=+ ^- [typ=cord dat=cord]
?: ?=(%direct -.tar)
['A' (crip +:(scow %if p.tar))]
['CNAME' (name p.tar dom.aut)]
:- %o %- my :~
name+s+(name him dom.aut)
type+s+typ
:: XX make configureable?
ttl+n+~.300
rrdatas+a+[s+dat ~]
==
:: +request: provider-specific record-creation request
::
++ request
=, eyre
|= [him=ship tar=target pre=(unit target)]
^- hiss
:: ?> ?=([%gcloud *] pro.aut)
=/ url=purl
%+ endpoint base
/[project.pro.aut]/['managedZones']/[zone.pro.aut]/changes
=/ hed=math
(my content-type+['application/json' ~] ~)
=/ bod=octs
%- as-octt:mimes:html
%- en-json:html
:- %o %- my
:- additions+a+[(record him tar) ~]
?~ pre ~
[deletions+a+[(record him u.pre) ~] ~]
[url %post hed `bod]
--
--
::
:: the app itself
::
|_ [bow=bowl:gall state]
++ this .
:: +poke-noun: debugging
::
++ poke-noun
|= a=*
^- (quip move _this)
~& +<+:this
[~ this]
:: +sigh-httr: accept http response
::
++ sigh-httr
|= [wir=wire rep=httr:eyre]
^- (quip move _this)
?- wir
[%authority %confirm ~]
?~ nem
~& [%strange-authority wire=wir response=rep]
[~ this]
?. =(200 p.rep)
~& [%authority-confirm-fail rep]
[~ this(nem ~)]
:: XX anything to do here? parse body?
[~ this]
::
[%authority %create @ %for @ ~]
?~ nem
~& [%strange-authority wire=wir response=rep]
[~ this]
?. =(200 p.rep)
~& [%authority-create-fail wire=wir response=rep]
[~ this]
=/ him=ship (slav %p i.t.t.wir)
=/ for=ship (slav %p i.t.t.t.t.wir)
abet:(~(confirm bind u.nem) for him)
::
[%check @ ~]
=/ him=ship (slav %p i.t.wir)
?: =(200 p.rep)
abet:~(bind tell [him (~(get by per) him)])
:: cttp timeout
?: =(504 p.rep)
:: XX backoff, refactor
:_ this :_ ~
[ost.bow %wait wir (add now.bow ~m10)]
:: XX specific messages per status code
~& %direct-confirm-fail
abet:(~(fail tell [him (~(get by per) him)]) %failed-request)
::
*
~& +<
[~ this]
==
:: +sigh-tang: failed to make http request
::
++ sigh-tang
|= [wir=wire saw=tang]
^- (quip move _this)
~& [%sigh-tang wir]
?+ wir
[((slog saw) ~) this]
::
[%authority %confirm ~]
~& %authority-confirm-fail
[((slog saw) ~) this(nem ~)]
::
[%check @ ~]
~& %direct-confirm-fail
=/ him=ship (slav %p i.t.wir)
%- (slog saw)
abet:(~(fail tell [him (~(get by per) him)]) %crash)
==
:: +wake: timer callback
::
++ wake
|= [wir=wire ~]
^- (quip move _this)
?. ?=([%check @ ~] wir)
~& [%strange-wake wir]
[~ this]
=/ him=ship (slav %p i.t.wir)
abet:~(check tell [him (~(get by per) him)])
::
:: +poke-dns-authority: configure self as an authority
::
++ poke-dns-authority
|= aut=authority
^- (quip move _this)
~| %authority-reset-wat-do
?< ?=(^ nem)
abet:(init:bind aut)
:: +poke-dns-bind: create binding (if authority), forward request
::
++ poke-dns-bind
|= [for=ship him=ship tar=target]
^- (quip move _this)
~& [%bind src=src.bow +<.$]
=/ lan (clan:title him)
?: ?=(%czar lan)
~|(%bind-galazy !!)
?: =(for him)
~|(%bind-yoself !!)
?: ?& ?=(%king lan)
?=(%indirect -.tar)
==
~|(%bind-indirect-star !!)
:: always forward, there may be multiple authorities
::
=^ zom=(list move) ..this
abet:(~(forward tell [him (~(get by per) him)]) for tar)
=^ zam=(list move) ..this
?~ nem [~ this]
abet:(~(create bind u.nem) for him tar)
[(weld zom zam) this]
:: +poke-dns-bond: process established dns binding
::
++ poke-dns-bond
|= [for=ship him=ship dom=turf]
^- (quip move _this)
?: =(for him)
~|(%bond-yoself !!)
?: =(our.bow him)
~& [%bound-us dom]
:- [[ost.bow %rule /bound %turf %put dom] ~]
this(dom (~(put in ^dom) dom))
?: =(our.bow for)
~& [%bound-him him dom]
=< abet
(~(bake tell [him (~(get by per) him)]) dom)
~& [%strange-bond +<]
[~ this]
:: +coup: general poke acknowledgement or error
::
++ coup
|= [wir=wire saw=(unit tang)]
?~ saw [~ this]
~& [%coup-fallthru wir]
[((slog u.saw) ~) this]
:: +rove: hear %ames +lane change for child ships
::
++ rove
|= [wir=wire p=ship q=lane:ames]
^- (quip move _this)
:: XX move to %ames
?: =(our.bow p)
[~ this]
?. =(our.bow (sein:title p)) :: XX check will
~& [%rove-false p]
[~ this]
~& [%rove wir p q]
:: XX assert that we intend to be listening?
=< abet
(~(hear tell [p (~(get by per) p)]) q)
:: +prep: adapt state
::
:: ++ prep _[~ this]
++ prep
|= old=(unit state)
^- (quip move _this)
?^ old
[~ this(+<+ u.old)]
?: ?=(?(%czar %king) (clan:title our.bow))
abet:listen:tell
[~ this]
:: |bind: acting as zone authority
::
++ bind
=| moz=(list move)
|_ nam=nameserver
++ this .
:: +abet: finalize state changes, produce moves
::
++ abet
^- (quip move _^this)
[(flop moz) ^this(nem `nam)]
:: +emit: emit a move
::
++ emit
|= car=card
^+ this
this(moz [[ost.bow car] moz])
:: +init: establish zone authority (request confirmation)
::
++ init
|= aut=authority
:: ?> ?=(%gcloud pro.aut)
=/ wir=wire /authority/confirm
=/ url=purl:eyre
%+ endpoint base:gcloud
/[project.pro.aut]/['managedZones']/[zone.pro.aut]
~& url
%- emit(nam [aut ~ ~])
[%hiss wir [~ ~] %httr %hiss url %get ~ ~]
:: +create: bind :him, on behalf of :for
::
++ create
|= [for=ship him=ship tar=target]
:: XX defer %indirect where target isn't yet bound
?> ?| ?=(%direct -.tar)
(~(has by bon.nam) p.tar)
==
=/ wir=wire
/authority/create/(scot %p him)/for/(scot %p for)
=/ pre=(unit target)
=/ bon=(unit bound) (~(get by bon.nam) him)
?~(bon ~ `cur.u.bon)
:: ?> ?=(%gcloud pro.aut.nam)
=/ req=hiss:eyre
(~(request gcloud aut.nam) him tar pre)
%- emit(pen.nam (~(put by pen.nam) him tar)) :: XX save for
[%hiss wir [~ ~] %httr %hiss req]
:: +confirm: successfully bound
::
++ confirm
|= [for=ship him=ship]
=/ tar=target (~(got by pen.nam) him)
=/ bon=(unit bound)
(~(get by bon.nam) him)
=/ nob=bound
[now.bow tar ?~(bon ~ [[wen.u.bon cur.u.bon] hit.u.bon])]
=. pen.nam (~(del by pen.nam) him)
=. bon.nam (~(put by bon.nam) him nob)
=/ wir=wire
/bound/(scot %p him)/for/(scot %p for)
=/ dom=turf
(weld dom.aut.nam /(crip +:(scow %p him)))
%- emit
[%poke wir [for dap.bow] %dns-bond for him dom]
--
:: |tell: acting as planet parent or relay
::
++ tell
=| moz=(list move)
|_ [him=ship rel=(unit relay)]
++ this .
:: +abet: finalize state changes, produce moves
::
++ abet
^- (quip move _^this)
:- (flop moz)
?~ rel
^this
^this(per (~(put by per) him u.rel))
:: +emit: emit a move
::
++ emit
|= car=card
^+ this
this(moz [[ost.bow car] moz])
:: +listen: subscribe to %ames +lane changes for child ships
::
++ listen
^+ this
(emit [%tend /tend ~])
:: +hear: hear +lane change, maybe emit binding request
::
++ hear
|= lan=lane:ames
^+ this
=/ adr=(unit @if)
?.(?=([%if *] lan) ~ `r.lan)
=/ tar=target
?: ?| ?=(~ adr)
?=(%duke (clan:title him))
==
[%indirect our.bow]
[%direct %if u.adr]
?. ?| ?=(~ rel)
!=(tar tar.u.rel)
!bon.u.rel
==
this
=. rel `[wen=now.bow adr bon=| try=0 tar]
?:(?=(%indirect -.tar) bind check)
:: +check: confirm %direct target is accessible
::
++ check
^+ this
?> ?=(^ rel)
?> ?=(%direct -.tar.u.rel)
?: (reserved p.tar.u.rel)
(fail %reserved-ip)
?: (gth try.u.rel 2)
(fail %unreachable)
=. try.u.rel +(try.u.rel)
=/ wir=wire
/check/(scot %p him)
=/ url=purl:eyre
:- [sec=| por=~ host=[%| `@if`p.tar.u.rel]]
[[ext=`~.md path=~] query=~]
:: XX state mgmt
%- emit
[%hiss wir [~ ~] %httr %hiss url %get ~ ~]
:: +fail: %direct target is invalid or inaccessible
::
++ fail
|= err=@tas
^+ this
?> ?=(^ rel)
~& [%fail err him tar.u.rel]
=/ wir=wire
/fail/(scot %p him)
=/ msg=tape
?+ err
"dns binding failed"
::
%reserved-ip
?> ?=(%direct -.tar.u.rel)
"unable to create dns binding reserved address {(scow %if p.tar.u.rel)}"
==
:: XX state mgmt
%- emit
[%poke wir [our.bow %hood] %helm-send-hi him `msg]
:: +bind: request binding for target
::
:: Since we may be an authority, we poke ourselves.
::
++ bind
^+ this
?> ?=(^ rel)
:: XX state mgmt
=/ wir=wire
/bind/(scot %p him)/for/(scot %p our.bow)
%- emit
[%poke wir [our.bow dap.bow] %dns-bind our.bow him tar.u.rel]
:: +bake: successfully bound
::
++ bake
|= dom=turf
~& [%bake dom]
^+ this
?> ?=(^ rel)
=/ wir=wire
/forward/bound/(scot %p him)/for/(scot %p our.bow)
:: XX save domain, track bound-state per-domain
%- emit(bon.u.rel &)
[%poke wir [him dap.bow] %dns-bond our.bow him dom]
:: +forward: sending binding request up the network
::
++ forward
|= [for=ship tar=target]
~& [%forward tar]
^+ this
?: ?=(%~zod our.bow) :: ~zod don't forward
~& [%zod-no-forward him tar]
this
=/ to=ship
?- (clan:title our.bow)
%czar ~zod
* (sein:title our.bow)
==
=/ wir=wire
/forward/bind/(scot %p him)/for/(scot %p for)
%- emit :: XX for
[%poke wir [to dap.bow] %dns-bind for him tar]
--
--

View File

@ -1331,6 +1331,7 @@
?=(^ tal.u.ran.src)
::
?- -.u.tal.u.ran.src
$sd &
$da (gte now.bol +.u.tal.u.ran.src)
$ud ?& ?=(^ seq)
(gte u.seq +.u.tal.u.ran.src)
@ -1353,8 +1354,12 @@
=. ran
?~ ran `[[%ud 0] `[%ud count]]
=* hed hed.u.ran
=? hed ?=($sd -.hed)
[%ud (sub count (min count (abs:si +.hed)))]
?~ tal.u.ran `[hed `[%ud count]]
=* tal u.tal.u.ran
=? tal ?=($sd -.tal)
[%ud (sub count (min count (abs:si +.tal)))]
ran
:: never fails, but compiler needs it.
?> &(?=(^ ran) ?=(^ tal.u.ran))
@ -1363,15 +1368,17 @@
%- flop
|- ^- (list telegram)
?~ gaz zeg
?: ?- -.tal :: after the end
$ud (lth +.tal num)
$da (lth +.tal wen.i.gaz)
?: ?- -.u.tal.u.ran :: after the end
$ud (lth +.u.tal.u.ran num)
$da (lth +.u.tal.u.ran wen.i.gaz)
$sd !! :: caught above
==
:: if past the range, we're done searching.
zeg
?: ?- -.hed :: before the start
$ud (lth num +.hed)
$da (lth wen.i.gaz +.hed)
?: ?- -.hed.u.ran :: before the start
$ud (lth num +.hed.u.ran)
$da (lth wen.i.gaz +.hed.u.ran)
$sd !! :: caught above
==
:: if before the range, continue onward.
$(num +(num), gaz t.gaz)
@ -1391,18 +1398,18 @@
^- {in/? done/?}
?~ ran [& |]
=/ min
=* hed hed.u.ran
?- -.hed
$ud (gth count +.hed)
$da (gth now.bol +.hed)
?- -.hed.u.ran
$sd & :: relative is always in.
$ud (gth count +.hed.u.ran)
$da (gth now.bol +.hed.u.ran)
==
?~ tal.u.ran
[min |]
=- [&(min -) !-]
=* tal u.tal.u.ran
?- -.tal
$ud (gte +(+.tal) count)
$da (gte +.tal now.bol)
?- -.u.tal.u.ran
$sd | :: relative is always done.
$ud (gte +(+.u.tal.u.ran) count)
$da (gte +.u.tal.u.ran now.bol)
==
::
:> #
@ -2361,13 +2368,13 @@
=- (~(so-first-grams so:ta nom.qer ~ -) ran.qer)
::TODO this can be done more efficiently.
?~ wer.qer u.soy
%_ u.soy
grams
?. (~(has by sourced.u.soy) u.wer.qer) ~
%+ turn (~(got by sourced.u.soy) u.wer.qer)
|= n/@ud
(snag n grams.u.soy)
==
=- u.soy(grams -, count (lent -))
?. (~(has by sourced.u.soy) u.wer.qer) ~
%+ turn
%- flop
(~(got by sourced.u.soy) u.wer.qer)
|= n/@ud
(snag n grams.u.soy)
(cury gram-to-envelope nom.qer)
:- shape.u.soy
?. (~(has in wat.qer) %config-r) ~

View File

@ -285,8 +285,8 @@
%+ welp /circle/[inbox]/grams/config/group
?. =(0 count)
[(scot %ud last) ~]
=+ history-days=~d5
[(scot %da (sub now.bol history-days)) ~]
=+ history-msgs=200
[(cat 3 '-' (scot %ud history-msgs)) ~]
==
::
:> #

View File

@ -134,12 +134,16 @@
:- /ren/css "not meant to be called outside /web/pack"
:- /ren/js "not meant to be called outside /web/pack"
:- /ren/run "not meant to be called except on a (different) hoon file"
:- /ren/collection "temporarily disabled"
:- /ren/x-urb "temporarily disabled"
:- /ren/urb "temporarily disabled"
::
:- /app/gh "hangs for some reason"
:- /mar/gh "hangs for some reason"
:- /app/twit "slow and/or crash"
:- /gen/twit "slow and/or crash"
:- /mar/twit "slow and/or crash"
:- /web/landscape "/$ doensn't work in tests"
==
::
++ failing

30
gen/dns/authority.hoon Normal file
View File

@ -0,0 +1,30 @@
:: DNS: configure zone authority
::
:::: /hoon/authority/dns/gen
::
/- dns, sole
=, [dns sole]
:- %ask
|= $: [now=@da eny=@uvJ bec=beak]
[arg=$@(~ [dom=path ~])]
~
==
^- (sole-result [%dns-authority authority])
=- ?~ arg -
(fun.q.q [%& dom.arg])
%+ sole-lo
[%& %dns-domain "dns domain: "]
%+ sole-go thos:de-purl:html
|= hot=host:eyre
?: ?=($| -.hot)
~|(%ips-unsupported !!)
%+ sole-lo
[%& %project "gcloud project: "]
%+ sole-go urs:ab
|= project=@ta
%+ sole-lo
[%& %zone "dns zone: "]
%+ sole-go urs:ab
|= zone=@ta
%+ sole-so %dns-authority
[p.hot %gcloud project zone]

83
lib/collections.hoon Normal file
View File

@ -0,0 +1,83 @@
::
:::: /hoon/collections/lib
::
/? 309
/+ cram
::
::
|%
+= collection [meta=config data=(map nom=knot =item)]
+= item
$% [%collection col=collection]
[%raw raw=raw-item]
[%both col=collection raw=raw-item]
==
+= raw-item
$% [%umd meta=(map knot cord) data=@t]
==
::
+= config
$: full-path=beam
name=@t
description=@t
::
owner=@p
::
date-created=@da
last-modified=@da
::
type=@tas
comments=?
sort-key=(unit @)
visible=?
::
==
::
+= action
$: who=ship
dek=desk
acts=(list sub-action)
==
+= sub-action
$% [%write pax=path for=form]
[%delete pax=path]
[%perms pax=path r=rule:clay w=rule:clay]
::
[%collection pax=path name=@ta desc=@t comments=? visible=? type=@tas]
[%post pax=path name=@ta type=@tas comments=? content=@t]
[%comment pax=path content=@t]
==
::
+= form
$% [%umd @t]
[%collection-config config]
==
::
::
::
++ front-to-wain
|= a=(map knot cord)
^- wain
=/ entries=wain
%+ turn ~(tap by a)
|= b=[knot cord]
=/ c=[term knot] ((hard ,[term knot]) b)
(crip " [{<-.c>} {<+.c>}]")
::
?~ entries ~
;: weld
[':- :~' ~]
entries
[' ==' ~]
==
::
++ update-umd-front
|= [fro=(map knot cord) umd=@t]
^- @t
%- of-wain:format
=/ tum (trip umd)
=/ id (need (find ";>" tum))
%+ weld (front-to-wain fro)
(to-wain:format (crip (slag id tum)))
::
--

167
lib/colls.hoon Normal file
View File

@ -0,0 +1,167 @@
/+ old-zuse
=, old-zuse
|%
:: sort knots by date
:: TODO when we change the write path to have trailing sig, remove here before sort
++ dor
|= [a=knot b=knot]
(gth (unt:chrono:userlib (slav %da a)) (unt:chrono:userlib (slav %da b)))
:: checks if authorized
++ authed
|= gas/epic
^- ?
%+ lien
~(tap in (~(get ju aut.ced.gas) %$))
|= b/knot
=((scot %p p.bem.gas) b)
++ no-title
|= wat/wain
^- wain
?: =((scag 2 (trip -:wat)) "# ")
+:wat
wat
++ esoo
|= d/@d
^- tape
=/ t (yore d)
;: welp
(scag 1 (scow %ud y.t))
(swag [2 3] (scow %ud y.t))
"-"
(double m.t)
"-"
(double d.t.t)
"T"
(double h.t.t)
":"
(double m.t.t)
":"
(double s.t.t)
"Z"
==
:: ud to leading zero tape
++ double
|= a/@ud
^- tape
=/ x (scow %ud a)
?: (lth a 10)
(welp "0" x)
x
:: takes a map of knot * where knot is a serialized @da and returns the newest
++ latest
|* a/(map knot *)
^- (pair knot *)
=/ sa
%+ sort
~(tap by a)
|= [b=(pair knot *) c=(pair knot *)]
(dor p.b p.c)
?~ sa
*(pair knot *)
i.sa
++ latest-post
'''
/- collections
/+ colls
/= gas /$ fuel:html
/= configs /: /===/web/collections
/^ (map knot config:collections) /_ /collections-config/
:: tried to pull this func into a lib, but couldn't get the gill working correctly. grr.
/= metawcom /; |= a/(map knot topicful:collections)
^- (pair knot topicful:collections)
=/ sa
%+ sort
~(tap by a)
|= [b=(pair knot *) c=(pair knot *)]
(gth (unt:chrono:userlib (slav %da p.b)) (unt:chrono:userlib (slav %da p.c)))
?~ sa
*(pair knot topicful:collections)
i.sa
/: /%%/
/^ (map knot topicful:collections) /_ /collections-topic-full/
/= content /; |= a/(map knot manx)
^- (pair knot manx)
=/ sa
%+ sort
~(tap by a)
|= [b=(pair knot *) c=(pair knot *)]
(gth (unt:chrono:userlib (slav %da p.b)) (unt:chrono:userlib (slav %da p.c)))
?~ sa
*(pair knot manx)
i.sa
/: /%%/
/^ (map knot manx) /_
/&elem&md&/collections-topic/
=/ config (~(get by configs) +<:s.bem.gas)
~& metawcom
::
=, old-zuse
^- manx
;div.container
;div.row
;input(type "hidden", name "urb-header", value "collection-index", title "{(trip desc:(need config))}", id "{(trip +<:s.bem.gas)}", ship "{(scow %p p.bem.gas)}");
;div.col-sm-10.col-sm-offset-2
;div.post.collection-post-page
;div.row.collection-date
;span.mr-2.text-black.text-500(urb-component "Elapsed", urb-timestring "{(esoo:colls mod.info.q.metawcom)}");
;span: {(trip -:s.bem.gas)}
==
::
;div#show
;div.row.tit.mt-6.collection-title
;h3: {(trip tit.info.q.metawcom)}
==
;* ?: (authed:colls gas)
;=
;a(href ".collections-edit")
;button#edit-btn.btn.btn-primary.mb-4
; Edit →
==
==
==
;=
;div;
==
;div.row.content.mb-18.mt-6
;div: +{q.content}
==
;* ?: comm:(need config)
;=
;div
;div.mb-2
;span(urb-component "IconComment");
;span: {<~(wyt by coms.q.metawcom)>}
==
;ul
;* %+ turn
%+ sort
~(tap by coms.q.metawcom)
|= [a=[c=@da d=[mod=@da who=@p wat=wain]] b=[c=@da d=[mod=@da who=@p wat=wain]]]
(lth (unt c.a) (unt c.b))
::
|= [c=@da d=[mod=@da who=@p wat=wain]]
;li.collection-comment
;div.collection-comment-avatar
;div(urb-component "AvatarSample1");
==
;div
;div
;a.collection-comment-author.text-mono(href "/~~/pages/nutalk/profile"): {(trip (scot %p who.d))}
==
;p: {(trip (of-wain:format wat.d))}
==
;span.collection-date.text-black.mr-2(urb-component "Elapsed", urb-timestring "{(esoo:colls mod.d)}");
;span.collection-date: {(esoo:colls mod.d)}
==
==
;div(urb-component "CommentCreate", urb-coll "{(trip +<:s.bem.gas)}", urb-top "{(trip -:s.bem.gas)}");
==
==
~
==
==
==
==
==
'''
--

View File

@ -78,7 +78,8 @@
::
|= pla/place
^- knot
(scot -.pla +.pla)
?. ?=($sd -.pla) (scot -.pla +.pla)
(cat 3 '-' (scot %ud (abs:si +.pla)))
::
++ path-to-range
:> path to msg range
@ -101,10 +102,14 @@
;~ pose
(stag %ud dem:ag)
::
=- (stag %da (sear - ;~(pfix sig crub:so)))
=- (stag %da (sear - crub:so))
|= a/dime
^- (unit @da)
?:(?=($da p.a) `q.a ~)
::
%+ stag %sd
%+ cook (cury new:si |)
;~(pfix hep dem:ag)
==
::
++ change-glyphs :< ...

View File

@ -78,9 +78,17 @@
%- ~(gas in *(set well:gall))
^- (list well:gall)
=+ myr=(clan:title our)
:: TODO: Make sure all the other apps compile later.
::
:: ?: ?=($pawn myr)
:: [[%base %hall] [%base %talk] [%base %dojo] ~]
:: [[%home %hall] [%home %talk] [%home %dojo] ~]
:: [[%base %collections] [%base %hall] [%base %talk] [%base %dojo] ~]
:: :~ [%home %collections]
:: [%home %acme]
:: [%home %dns]
:: [%home %dojo]
:: [%home %hall]
:: [%home %talk]
:: ==
[[%home %dojo] ~]
::
++ deft-fish :: default connects

21
lib/nutalk.hoon Normal file
View File

@ -0,0 +1,21 @@
|= inner=manx
^- manx
;html
::
;head
;title: Nutalk
;meta(charset "utf-8");
;meta
=name "viewport"
=content "width=device-width, initial-scale=1, shrink-to-fit=no";
;link(rel "stylesheet", href "/~~/landscape/css/index.css");
==
::
;body
;div#root
;+ inner
==
;script@"/~~/landscape/js/index.js";
==
::
==

View File

@ -102,7 +102,7 @@
|= a/$@(@t purl) ^- hiss
(post-quay (parse-url a) oauth-callback+oauth-callback ~)
::
++ our-host .^(hart %e /(scot %p our)/host/fake)
++ our-host .^(hart %e /(scot %p our)/host/real)
++ oauth-callback
~& [%oauth-warning "Make sure this urbit ".
"is running on {(en-purl:html our-host `~ ~)}"]

View File

@ -101,7 +101,7 @@
%+ rap 3 :- (wack a)
(turn b |=(c/knot (cat 3 '_' (wack c))))
::
++ our-host .^(hart %e /(scot %p our)/host/fake)
++ our-host .^(hart %e /(scot %p our)/host/real)
++ redirect-uri
%- crip %- en-purl
%^ into-url:interpolate 'https://our-host/~/ac/:domain/:user/in'

16
lib/rekey.hoon Normal file
View File

@ -0,0 +1,16 @@
:: Userspace implementation of old /_ @foo behavior
:: :: ::
:::: /hoon/rekey/lib :: ::
:: :: ::
/? 310 :: version
:: :: ::
:::: :: ::
:: :: ::
=, wired
|* typ=@tas
|* inp=(map knot *) ^- (map (odo:raid typ) _(~(got by inp)))
=> .(inp `(map knot _(~(got by inp)))`inp)
%- malt
%+ murn ~(tap by inp)
|* [a=knot b=*] ^- (unit [(odo:raid typ) _b])
(both (slaw typ a) `b)

9
mar/acme/order.hoon Normal file
View File

@ -0,0 +1,9 @@
::
:::: /mar/acme/order/hoon
::
|_ a=(set (list @t))
++ grab
|%
++ noun (set (list @t))
--
--

119
mar/collection/action.hoon Normal file
View File

@ -0,0 +1,119 @@
::
:::: /hoon/actions/collection/mar
::
/? 309
/+ collections
=, collections
=, format
::
|_ act=action:collections
::
++ grow
|%
++ tank >act<
--
::
++ grab
|%
++ noun action:collections
++ json
:: |= jon=^json
:: %- (hard action:collections)
=< action
|%
++ action
%- ot:dejs
:~ ship+(su:dejs fed:ag)
desk+(su:dejs sym)
:- %acts
%- ar:dejs
%- of:dejs
:~ write+write
delete+delete
perms+perms
collection+collection
post+post
comment+comment
==
==
::
++ write
%- ot:dejs
:~ path+(su:dejs ;~(pfix fas (more fas urs:ab)))
mark+(su:dejs sym)
data+so:dejs
==
::
++ delete
%- ot:dejs
:~ path+(su:dejs ;~(pfix fas (more fas urs:ab)))
==
::
++ perms
%- ot:dejs
:~ path+(su:dejs ;~(pfix fas (more fas urs:ab)))
:- %read
%- ot:dejs
:~ mod+(su:dejs ;~(pose (jest %black) (jest %white)))
who+whoms
==
:- %write
%- ot:dejs
:~ mod+(su:dejs ;~(pose (jest %black) (jest %white)))
who+whoms
==
==
::
++ whoms
|= jon=^json
^- (set whom:clay)
=/ x ((ar:dejs (su:dejs fed:ag)) jon)
%- (hard (set whom:clay))
%- ~(run in (sy x))
|=(w=@ [& w])
--
::
++ collection
%- ot:dejs
:~ path+(su:dejs ;~(pfix fas (more fas urs:ab)))
name+sa
desc+so:dejs
comments+bo:dejs
visible+bo:dejs
==
::
++ post
%- ot:dejs
:~ path+(su:dejs ;~(pfix fas (more fas urs:ab)))
name+sa
comments+bo:dejs
content+so:dejs
==
::
++ comment
%- ot:dejs
:~ path+(su:dejs ;~(pfix fas (more fas urs:ab)))
name+sa
comments+bo:dejs
content+so:dejs
==
::
++ sa :: string as ta
|= jon=^json
?> ?=([%s *] jon)
(scot %tas p.jon)
--
::
--

View File

@ -0,0 +1,96 @@
::
:::: /hoon/config/collection/mar
::
/+ collections
|_ con=config:collections
::
::
++ grow
|%
++ mime
:- /text/x-collection-config
(as-octs:mimes:html (jam con))
:: ++ txt
:: |^
:: ^- (list @t)
:: ;: weld
:: ::
:: :~ (cat 3 'name: ' goodname.con)
:: (cat 3 'owner: ' (scot %p owner.con))
:: (cat 3 'date-created: ' (scot %da date-created.con))
:: (cat 3 'last-modified: ' (scot %da last-modified.con))
:: (cat 3 'comments: ' ?:(comments.con 'y' 'n'))
:: ==
:: ::
:: ?~ sort-key.con ~
:: [(cat 3 'sort-key: ' (scot %ud u.sortkey.con)) ~]
:: ::
:: :- 'config-permissions:'
:: (rules-to-txt r.config-permissions.con w.config-permissions.con)
:: ::
:: :- 'content-permissions:'
:: (rules-to-txt r.content-permissions.con w.content-permissions.con)
:: ::
:: ==
:: ++ rules-to-txt
:: |= [r=rule:clay w=rule:clay]
:: ^- (list @t)
:: ;: weld
:: ::
:: :* (cat 3 ' read: ' mod.r)
:: %+ turn ~(tap by who.r)
:: |= hoe=whom:clay
:: ?- -.hoe
:: %& (cat 3 ' ' (scot %p +.hoe))
:: %| (cat 3 ' ' +.hoe)
:: ==
:: ==
:: ::
:: [' ==' ~]
:: ::
:: :* (cat 3 ' write: ' mod.w)
:: %+ turn ~(tap by who.w)
:: |= hoe=whom:clay
:: ?- -.hoe
:: %& (cat 3 ' ' (scot %p +.hoe))
:: %| (cat 3 ' ' +.hoe)
:: ==
:: ==
:: ::
:: [' ==' ~]
:: ==
:: --
--
++ grab
|%
++ mime
|= [mite:eyre p=octs:eyre]
((hard config:collections) (cue q.p))
:: ++ txt
:: |= txs=(list @t)
:: ?> ?= $: name=@t
:: owner=@t
:: dc=@t
:: lm=@t
:: com=@t
:: res=(lest @t)
:: ==
:: txs
:: ::
:: =/ top
:: :* (rash name.txs ;~(pfix (jest 'name: ') (cook crip (star next))))
:: (rash owner.txs ;~(pfix (jest 'owner: ~') (fed:ag)))
:: (rash dc.txs ;~(pfix (jest 'date-created: ~') (cook |=(a=^ +.a) crub:so)))
:: (rash lm.txs ;~(pfix (jest 'last-modified: ~') (cook |=(a=^ +.a) crub:so)))
:: (rash com.txs ;~(pfix (jest 'comments: ') (flag %y %n)))
:: ==
++ noun config:collections
--
++ grad %mime
--

17
mar/collection/elem.hoon Normal file
View File

@ -0,0 +1,17 @@
::
:::: /hoon/elem/collection/mar
::
/? 310
=, mimes:html
=, html
|_ own/manx
::
++ grow :: convert to
|%
++ hymn ;html:(head body:"+{own}") :: convert to %hymn
++ html (crip (en-xml hymn)) :: convert to %html
++ mime [/text/html (as-octs html)] :: convert to %mime
--
++ grab |% :: convert from
++ noun manx :: clam from %noun
-- --

24
mar/collection/json.hoon Normal file
View File

@ -0,0 +1,24 @@
::
:::: /hoon/json/collection/mar
::
/? 309
::
:::: compute
::
=, eyre
=, format
=, html
|_ jon/json
::
++ grow :: convert to
|%
++ txt (crip (en-json jon))
++ json jon
--
++ grab
|% :: convert from
++ noun ^json :: clam from %noun
++ json ^json
--
++ grad %mime
--

11
mar/dns/bind.hoon Normal file
View File

@ -0,0 +1,11 @@
::
:::: /mar/dns/bind/hoon
::
/- dns
=, dns
|_ [for=ship him=ship target]
++ grab
|%
++ noun ,[for=ship him=ship target]
--
--

11
mar/dns/bond.hoon Normal file
View File

@ -0,0 +1,11 @@
::
:::: /mar/dns/bond/hoon
::
/- dns
=, dns
|_ [for=ship him=ship turf]
++ grab
|%
++ noun ,[for=ship him=ship turf]
--
--

13
mar/htm.hoon Normal file
View File

@ -0,0 +1,13 @@
::
:::: /hoon/htm/mar
::
/? 310
|_ own/manx
::
++ grow :: convert to
|%
++ hymn own
--
++ grab |% :: convert from
++ noun manx :: clam from %noun
-- --

12
mar/png.hoon Normal file
View File

@ -0,0 +1,12 @@
|_ dat/@t
++ grow
|%
++ mime [/image/png (as-octs:mimes:html dat)]
--
++ grab
|%
++ mime |=({p/mite q/octs} q.q)
++ noun @t
--
++ grad %mime
--

View File

@ -15,6 +15,7 @@
++ noun recoverable-error
++ httr
|= a/^httr ^- recoverable-error
~& [%recoverable-httr a]
~! a
?+ p.a ~|(non-recoverable+p.a !!)
$429 :+ p.a %rate-limit

View File

@ -1,44 +1,17 @@
::
:::: /hoon/urb/mar
:::: /hoon/elem/urb/mar
::
/? 310
/= urb-wasp-data-js /: /%/wasp-data /js/
=, format
=, mimes:html
=, html
|_ own/manx
::
|_ {{dep/@uvH hed/marl} {dep-bod/@uvH bod/marl}}
++ grow :: convert to
|%
++ mime [/text/html (as-octs html)] :: convert to %mime
++ hymn ;html:(head body:"+{own}") :: convert to %hymn
++ html (crip (en-xml hymn)) :: convert to %html
++ hymn :: inject dependencies
^- manx
;html
;head
;meta(charset "utf-8", urb_injected "");
;* hed
==
;body
;* bod
;* ?~ dep ~
:~ ;script@"/~/on/{<dep>}.js"(urb_injected "", async "", onload "setTimeout(urb.onDep,2000)");
;script(urb_injected "")
;- (trip urb-wasp-data-js)
; urb.waspWait = []
; urb.wasp = urb.wasp || [].push.bind(urb.waspWait)
; urb.onDep = function()\{
; urb.waspWait.map(urb.wasp)
; urb.onLoadUrbJS()
; urb.waspData({(en-json %s (scot %uv dep-bod))})
; }
==
==
==
==
++ mime [/text/html (as-octs html)] :: convert to %mime
--
++ grab
|% :: convert from
++ noun {@uvH manx} :: clam from %noun
--
--
++ grab |% :: convert from
++ noun manx :: clam from %noun
-- --

17
mar/x-urb-elem.hoon Normal file
View File

@ -0,0 +1,17 @@
::
:::: /hoon/elem/urb/mar
::
/? 310
=, mimes:html
=, html
|_ own/manx
::
++ grow :: convert to
|%
++ hymn ;html:(head body:"+{own}") :: convert to %hymn
++ html (crip (en-xml hymn)) :: convert to %html
++ mime [/text/html (as-octs html)] :: convert to %mime
--
++ grab |% :: convert from
++ noun manx :: clam from %noun
-- --

20
mar/x-urb.hoon Normal file
View File

@ -0,0 +1,20 @@
::
:::: /hoon/x-urb/mar
::
/? 310
=, format
=, mimes:html
=, html
::
|_ max=manx
++ grow :: convert to
|%
++ mime [/text/html (as-octs html)] :: convert to %mime
++ html (crip (en-xml hymn)) :: convert to %html
++ hymn max
--
++ grab
|% :: convert from
++ noun manx :: clam from %noun
--
--

BIN
ren/.urb.hoon.swo Executable file

Binary file not shown.

9
ren/collection.hoon Normal file
View File

@ -0,0 +1,9 @@
/+ collections
/= collection
/^ collection:collections
/; |= [a=config:collections b=(map knot item:collections) ~]
[a b]
/. /collection-config/
/_ /collection-item/
==
collection

View File

@ -0,0 +1,11 @@
/? 309
/+ collections
/= elm
/| /; |= a=collection:collections
?< ?=(~ a)
(collection-to-elem:collections a)
/collection/
::
/; item-to-elem:collections /collection-item/
==
elm

269
ren/collection/elem.hoon Normal file
View File

@ -0,0 +1,269 @@
::
::::
::
/? 309
/+ collections, cram
/= gas /$ fuel:html
/= itm /% /collection-web-item/
::
::
/= collection-post
/^ manx
/: /===/web/landscape/collection/post /% /!hymn/
/= collection-details
/^ manx
/: /===/web/landscape/collection/details /% /!hymn/
::
::
=< (item-to-elem itm)
|%
++ item-to-elem
|= itm=item:collections
^- manx
=/ sho (~(get by qix.gas) %show)
;div.container
;input
=type "hidden"
=name "urb-header"
=value "collection"
=station "{(scow %p p.bem.gas)}/{<(flop s.bem.gas)>}"
=ship "{(scow %p p.bem.gas)}";
;div.row
;div.col-sm-10.col-sm-offset-2
;div.collection-index.mt-12
;+
?- -.itm
::
%collection
?+ sho !!
~ (collection-to-elem col.itm)
[~ %post] collection-post
[~ %edit] !!
[~ %details] collection-details
==
::
%raw
?+ sho !!
~ (raw-to-elem raw.itm)
[~ %post] !!
[~ %edit] collection-post
[~ %details] collection-details
==
::
%both
?+ sho !!
~ (both-to-elem col.itm raw.itm)
[~ %post] !!
[~ %edit] collection-post
[~ %details] collection-details
==
::
==
==
==
==
==
++ collection-to-elem
|= col=collection:collections
^- manx
;ul
;* %+ turn ~(tap by data.col)
|= [nom=knot ite=item:collections]
^- manx
;li.collection-post.mt-6
;+ (item-to-snip nom ite)
==
==
::
++ raw-to-elem
|= raw=raw-item:collections
^- manx
=/ elm elm:(static:cram (ream data.raw))
=/ ht (hedtal +.elm)
=/ title (fall (~(get by meta.raw) %name) -.s.bem.gas)
=/ date (fall (~(get by meta.raw) %date-created) 'missing date')
=/ owner (fall (~(get by meta.raw) %owner) 'anonymous')
::
;div
;div.collection-date: {(trip date)}
::
;div#show
;div.row.tit.mt-6.collection-title
;+ ?~ hed.ht
;h3: {(trip title)}
;h3: *{hed.ht}
==
==
::
;div.who.text-mono.text-600: {(trip owner)}
;div.row.content.mb-18.mt-6
;+ elm
==
::
:: if comments are enabled it should be a %both not a %raw
:: XX REVIEW ^^ not robust enough?
==
::
++ both-to-elem
|= [col=collection:collections raw=raw-item:collections]
^- manx
;div
;+ (raw-to-elem raw)
::
;div
;div.mb-2
;span(urb-component "IconComment");
;span: {<~(wyt by data.col)>}
==
::
;ul
;* %+ turn ~(tap by data.col) :: XX TODO: sort
|= [nom=knot ite=item:collections]
^- manx
:: XX TODO: accept types other than comments
?> ?=(%raw -.ite)
?> =(%comments (~(got by meta.raw.ite) %type))
=/ owner (fall (~(get by meta.raw.ite) %owner) 'anonymous')
=/ date (fall (~(get by meta.raw.ite) %date-created) 'missing date')
;li.collection-comment
;div.collection-comment-avatar
;div(urb-component "AvatarSample1");
==
;div
;a.collection-comment-author.text-mono
=href "/~~/landscape/profile"
; {(trip owner)}
==
;+ elm:(static:cram (ream data.raw))
==
;span.collection-date: {(trip date)}
==
==
::
;div
=urb-component "CommentCreate"
=urb-pax "{<(flop s.bem.gas)>}"
=urb-ship "{(scow %p p.bem.gas)}";
==
==
::
::
++ item-to-snip
|= [nom=knot itm=item:collections]
^- manx
?- -.itm
%collection
(collection-to-snip nom col.itm)
%raw
(raw-to-snip nom raw.itm)
%both
(both-to-snip nom col.itm raw.itm)
==
::
++ collection-to-snip
|= [nom=knot col=collection:collections]
^- manx
;div
;div.collection-date: {<date-created.meta.col>}
;h3
;a(href "{(trip -.s.bem.gas)}/{(trip nom)}"): {(trip name.meta.col)}
==
;div.who.text-mono.text-600: {<owner.meta.col>}
;div.meta-cont
;div.com-count.ml-12
; {(trip (scot %ud ~(wyt by data.col)))} comments
==
==
==
::
++ raw-to-snip
|= [nom=knot raw=raw-item:collections]
^- manx
=/ elm=manx elm:(static:cram (ream data.raw))
=/ ht (hedtal +.elm)
=? tal.ht ?=(~ hed.ht)
(scag 5 c.elm)
=/ title (fall (~(get by meta.raw) %name) nom)
=/ date (fall (~(get by meta.raw) %date-created) 'missing date')
=/ owner (fall (~(get by meta.raw) %owner) 'anonymous')
::
;div
;div.collection-date: {(trip date)}
;h3
;+ ?~ hed.ht
;a(href "{(trip -.s.bem.gas)}/{(trip nom)}"): {(trip title)}
;a(href "{(trip -.s.bem.gas)}/{(trip nom)}"): *{hed.ht}
==
;div.who.text-mono.text-600: {(trip owner)}
;div.snippet
;* tal.ht
==
==
::
++ both-to-snip
|= [nom=knot col=collection:collections raw=raw-item:collections]
^- manx
=/ elm=manx elm:(static:cram (ream data.raw))
=/ ht (hedtal +.elm)
=? tal.ht ?=(~ hed.ht)
(scag 5 c.elm)
=/ title (fall (~(get by meta.raw) %name) nom)
::
;div
;div.collection-date: {<date-created.meta.col>}
;h3
;+ ?~ hed.ht
;a(href "{(trip -.s.bem.gas)}/{(trip nom)}"): {(trip title)}
;a(href "{(trip -.s.bem.gas)}/{(trip nom)}"): *{hed.ht}
==
;div.who.text-mono.text-600: {<owner.meta.col>}
;div.snippet: *{tal.ht}
;div.meta-cont
;div.com-count.ml-12
; {(trip (scot %ud ~(wyt by data.col)))} comments
==
==
==
::::
:::: /mar/snip
::::
++ words 1
++ hedtal
=| met/marl
|= a/marl ^- {hed/marl tal/marl}
?~ a [~ ~]
:: looks like it only terminates if it finds an h1?
?. ?=($h1 n.g.i.a)
?: ?=($meta n.g.i.a)
$(a t.a, met [i.a met])
=+ had=$(a c.i.a)
?^ -.had had
$(a t.a)
[c.i.a (weld (flop met) (limit words t.a))]
::
::
++ limit
|= {lim/@u mal/marl}
=< res
|- ^- {rem/@u res/marl}
?~ mal [lim ~]
?~ lim [0 ~]
=+ ^- {lam/@u hed/manx}
?: ?=(_;/(**) i.mal)
[lim ;/(tay)]:(deword lim v.i.a.g.i.mal)
[rem ele(c res)]:[ele=i.mal $(mal c.i.mal)]
[rem - res]:[hed $(lim lam, mal t.mal)]
::
++ deword
|= {lim/@u tay/tape} ^- {lim/@u tay/tape}
?~ tay [lim tay]
?~ lim [0 ~]
=+ wer=(dot 1^1 tay)
?~ q.wer
[lim - tay]:[i.tay $(tay t.tay)]
=+ nex=$(lim (dec lim), tay q.q.u.q.wer)
[-.nex [(wonk wer) +.nex]]
::
::
::
--

33
ren/collection/item.hoon Normal file
View File

@ -0,0 +1,33 @@
/+ collections
/= item
/^ item:collections
/; |= $: raw=?(~ raw-item:collections)
col=?(~ collection:collections)
~
==
?~ raw
?~ col
!!
[%collection col]
?~ col
[%raw raw]
[%both col raw]
::
/.
::
/| /; |= [a=(map knot cord) b=@t ~]
[%umd a b]
/. /front/
/umd/
==
::
/~ ~
==
::
/| /collection/
/~ ~
==
::
==
::
item

85
ren/collection/json.hoon Normal file
View File

@ -0,0 +1,85 @@
/? 309
/+ collections
/= gas /$ fuel:html
/= jon
/^ json
/; =< item-to-json
|%
::
++ item-to-json
|= itm=item:collections
^- json
?- -.itm
::
%collection
%+ frond:enjs:format
%collection (collection-to-json col.itm)
::
%raw
%- frond:enjs:format
[%item (raw-to-json raw.itm)]
::
%both
%- pairs:enjs:format
:~ [%item (raw-to-json raw.itm)]
[%colleciton (collection-to-json col.itm)]
==
==
::
++ collection-to-json
|= col=collection:collections
^- json
%- pairs:enjs:format
:~ [%meta (config-to-json meta.col)]
:+ %data %a
%+ turn ~(tap by data.col)
|= [nom=knot ite=item:collections]
^- json
%- pairs:enjs:format
:~ [%name %s nom]
[%item (item-to-json ite)]
==
==
::
++ raw-to-json
|= raw=raw-item:collections
^- json
%- pairs:enjs:format
:~ [%data [%s data.raw]]
[%meta (meta-to-json meta.raw)]
==
::
++ config-to-json
|= con=config:collections
^- json
?: =(con *config:collections)
~
%- pairs:enjs:format
:~ :- %full-path
:- %a
%+ turn (en-beam:format full-path.con)
|= a=@ta
[%s a]
:- %name [%s description.con]
:- %desc [%s description.con]
:- %owner (ship:enjs:format owner.con)
:- %date-created (time:enjs:format date-created.con)
:- %last-modified (time:enjs:format last-modified.con)
:- %comments [%b comments.con]
:- %sort-key ?~(sort-key.con ~ (numb:enjs:format u.sort-key.con))
==
::
++ meta-to-json
|= meta=(map knot cord)
^- json
%- pairs:enjs:format
%+ turn ~(tap by meta)
|= [key=@t val=@t]
^- [@t json]
[key [%s val]]
::
--
::
/% /collection-web-item/
::
jon

View File

@ -0,0 +1,48 @@
/+ collections
/= gas /$ fuel:html
/= raw
/^ $?(raw-item:collections ~)
/| /; |= [a=(map knot cord) b=@t ~]
^- raw-item:collections
[%umd a b]
/. /front/
/umd/
==
::
/~ ~
==
::
/= col
/^ $? [config:collections (map knot item:collections) ~]
[%no-config (map knot item:collections) ~]
~
==
/| /. /collection-config/
/_ /collection-item/
==
::
/. /~ %no-config
/_ /collection-item/
==
::
/~ ~
==
::
::
^- item:collections
?~ col
?~ raw
!!
[%raw raw]
::
?: ?=(%no-config -.col)
?: =(s.bem.gas /collections/web)
?~ raw
[%collection *config:collections +<.col]
[%both [*config:collections +<.col] raw]
?~ raw
!!
[%raw raw]
?~ raw
[%collection -.col +<.col]
[%both [-.col +<.col] raw]

17
ren/html.hoon Normal file
View File

@ -0,0 +1,17 @@
::
:::: /hoon/html/ren
::
/? 309
/+ collections
/= page /%
/^ @t
/,
/web/collections
/&html&/collection-elem/
/
:: /|
/&html&/!hymn/
:: /html/
:: ==
==
page

View File

@ -2,7 +2,7 @@
::
:::: /hoon/js/ren
::
/? 310
/? 309
/, /web/pack/js /% /!js/
/ /~ !!
==

16
ren/json.hoon Normal file
View File

@ -0,0 +1,16 @@
::
:::: /hoon/json/ren
::
/? 309
/= page /%
/^ json
/, /web/collections
/& json
/collection-json/
/
:: /|
/!json/
:: /json/
:: ==
==
page

View File

@ -1,25 +0,0 @@
::
:::: /hoon/body/tree/ren
::
/? 310
/= dat /% /tree-json/ :: default include
/= dat-sen /| /: /%%/ /% /tree-json/ :: default include
/~ ~
==
=, format
=, html
::
|%
++ script-safe
!.
|= a/tape ^- tape
?~ a a
?. ?=({$'<' $'/' *} a) [i.a $(a t.a)]
['<' '\\' '/' $(a t.t.a)]
--
::
^- marl
=/ tree (script-safe (en-json (pairs:enjs data+dat sein+dat-sen ~)))
;= ;script(type "text/javascript"): window.tree = {tree}
;div#tree;
==

View File

@ -1,28 +0,0 @@
::
:::: /hoon/combine/tree/ren
::
/? 310
/- tree-include
/+ elem-to-react-json
/= mime /mime/
/= body /tree-elem/
/= sect /&json&/tree-index/
/= snip /&snip&elem&/tree-elem/
/= meta /&json&front&/|(/front/ /~[~])
/= plan /^ json /|(/plan-json/ /~[~])
/= comt /&json&/tree-comments/
/= bump /; |=(a/(list {p/time *}) =.(a (flop a) ?~(a '' (scot %da p.i.a))))
/tree-comments/
::
^- tree-include
=* rj elem-to-react-json
:* mime
(rj body)
(rj /h1 hed.snip) :: head
(rj /div tal.snip) :: snip
meta
sect
comt
plan
bump
==

View File

@ -1,21 +0,0 @@
::
:::: /hoon/comments/tree/ren
::
/? 310
/: /%/comments
/; |= a/(map knot {ship marl})
=- (sort - dor)
%+ turn ~(tap by a)
|=({b/knot c/{ship marl}} [(slav %da b) c])
/_
/; |= a/manx ^- {ship marl}
~| a
?> ?=(_[/div ;/(~) ~[[%h2 **] ~[[%code **] ;/(who=**)]] kid=**] a)
%. a
|: a=[/div ;/(~) ~[[%h2 **] ~[[%code **] ;/(who=*tape)]] kid=*marl]
[(slav %p (crip who.a)) kid.a]
/&elem&/md/
::
::::
::
`(list (pair time {ship marl}))`-.-

View File

@ -1,9 +0,0 @@
::
:::: /hoon/elem/tree/ren
::
/? 310
/% /,
/web /|(/!elem/ /elem/)
/ /elem/
==
`manx`-.-

View File

@ -1,66 +0,0 @@
::
:::: /hoon/head/tree/ren
::
::
/? 310
/= tub /$ |=({bem/beam *} (slag (lent /web) (flop s.bem)))
/= aut
/$ %+ cork fuel:html :: after parsing params,
=, title
|= gas/epic:eyre ^- ? :: check that the fcgi
%+ lien ~(tap in (~(get ju aut.ced.gas) %$)) :: has an identity
|=(a/knot !=(%pawn (clan (slav %p a)))) :: which isn't a comet
/= dbg
/^ {nopack/? nomin/?}
/$ %+ cork fuel:html :: after parsing params,
|= gas/epic:eyre ^- {? ?} :: check if the query
:- (~(has by qix.gas) 'dbg.nopack') :: dictates separate files
(~(has by qix.gas) 'dbg.nomin') :: and/or unminified assets
/= extras /: /===/ren/tree/head/extras :: additional scripts
/^ (map knot cord) /_ /js/
::
|%
++ cdnjs
|=(a/tape "//cdnjs.cloudflare.com/ajax/libs/{a}{?:(nomin.dbg "" ".min")}.js")
++ maxcdn
|=(a/tape "//maxcdn.bootstrapcdn.com/{a}{?:(nomin.dbg "" ".min")}.js")
--
::
::::
::
^- marl
;= ;title: Urbit - A personal server
;meta(name "viewport", content "width=device-width, initial-scale=1");
;link(type "text/css", rel "stylesheet", href "//cdnjs.cloudflare.com/ajax/libs/codemirror/4.3.0/codemirror.min.css");
;* ?. nopack.dbg
:_ ~
;link(type "text/css", rel "stylesheet", href "/===/web/pack/css/codemirror-fonts-bootstrap-tree.css");
;=
;link(type "text/css", rel "stylesheet", href "/===/web/lib/css/fonts.css");
;link(type "text/css", rel "stylesheet", href "/===/web/lib/css/bootstrap.css");
;link(type "text/css", rel "stylesheet", href "/===/web/lib/css/codemirror.css");
;link(type "text/css", rel "stylesheet", href "/===/web/tree/main.css");
==
;script(type "text/javascript", src "{(cdnjs "jquery/2.1.3/jquery")}");
;script(type "text/javascript", src "{(maxcdn "bootstrap/3.3.6/js/bootstrap")}");
;script(type "text/javascript", src "{(cdnjs "lodash.js/2.4.1/lodash")}");
;script(type "text/javascript", src "{(cdnjs "react/0.14.6/react")}");
;script(type "text/javascript", src "{(cdnjs "react/0.14.6/react-dom")}");
;script(type "text/javascript", src "{(cdnjs "flux/2.1.1/Flux")}");
;* (turn ~(tap by extras) |=({@ a/@t} ;script(type "text/javascript"):"{(trip a)}"))
;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/codemirror/4.3.0/codemirror.js");
:: ;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/".
:: "codemirror/4.3.0/mode/markdown/markdown.min.js");
;* ?. nopack.dbg
:_ ~
;script(type "text/javascript", src "{?.(aut "" "/~~/~/at")}".
"/===/web/pack/js/tree-urb.js");
:: "/===/web/pack/js/tree-hoon-urb.js");
;=
:: ;script(type "text/javascript", src "/===/web/lib/js/hoon.js");
;script(type "text/javascript", src "/===/web/tree/main.js");
;script(type "text/javascript", src "{?.(aut "" "/~~/~/at")}".
"/===/web/lib/js/urb.js");
==
;link(type "application/rss+xml", rel "alternate", href "{(spud tub)}.rss-xml");
==

View File

@ -1,9 +0,0 @@
::
:::: /hoon/include/tree/ren
::
/? 310
/- tree-include
/| /tree-combine/
/:/===/web/404:/tree-combine/ :: XX merge into tree-elem?
==
`tree-include`-<

View File

@ -1,18 +0,0 @@
::
:::: /hoon/index/tree/ren
::
/? 310
/+ tree
/, /
/; (getall:tree /h1/h2/h3/h4/h5/h6) /tree-elem/
::
/pub/docs/dev/hoon/runes
/; |= {tip/marl sub/(map knot marl) $~}
(zing `(list marl)`[tip (turn ~(tap by sub) tail)])
/. /; (getall:tree %h1 ~) /tree-elem/
/_ /; (getall:tree %h1 ~) /tree-elem/
== ==
::
::::
::
`(map path marl)`[[/ -.-] ~ ~]

View File

@ -1,89 +0,0 @@
::
:::: /hoon/json/tree/ren
::
/? 310
/- tree-include
/+ tree
/= gas /$ fuel:html
/= dat /^ tree-include /tree-include/
/= kid /^ (map knot tree-include)
/_ /tree-include/
=, format
=, mimes:html
::
::::
::
|%
++ schema (dict {term $@(mark schema)})
++ dict |*(a/_* $^({a (dict a)} a))
++ plist (list {term $@(mark plist)})
++ query
$% {$kids p/(list query)}
{$name $t}
{$path $t}
{$spur $t}
::
{$bump $t}
{$beak $t}
{$comt $j}
{$plan $j}
{$head $r}
{$sect $j}
{$snip $r}
{$body $r}
{$meta $j}
{$mime $m}
==
++ schema-to-plist :: pad improper list
|= a/schema ^- plist
?@(-.a [(to-item a) ~] [(to-item -.a) $(a +.a)])
::
++ to-item
|= b/{term $@(mark schema)} ^- {term $@(mark plist)}
?@(+.b b [-.b (schema-to-plist +.b)])
::
++ from-type :: XX holding out for noun odors
|= a/$%({$t p/cord} {$r p/json} {$j p/json} {$m mime})
?- -.a
$t [%s p.a]
$m (pairs:enjs mite+[%s (en-mite p.a)] octs+(tape:enjs (en-base64 q.q.a)) ~)
$r p.a
$j p.a
==
++ from-queries
|= {bem/beam quy/(list query)}
=< (pairs:enjs (turn quy .))
|= a/query
:- -.a
?- -.a
$name (from-type +.a ?^(s.bem i.s.bem q.bem))
$beak (from-type +.a (crip (spud (en-beam bem(s /)))))
$path (from-type +.a (crip (spud (flop s.bem))))
$spur (from-type +.a (crip (spud s.bem)))
$bump (from-type +.a bump.dat)
$plan (from-type +.a plan.dat)
$comt (from-type +.a comt.dat)
$head (from-type +.a head.dat)
$snip (from-type +.a snip.dat)
$sect (from-type +.a sect.dat)
$meta (from-type +.a meta.dat)
$mime (from-type +.a mime.dat)
$body (from-type +.a body.dat)
$kids ?< (~(has by (malt p.a)) %kids) :: XX recursion?
=< o+(~(urn by kid) .)
|= {dir/knot dak/tree-include} ^- json
^^$(quy p.a, s.bem [dir s.bem], dat dak, kid ~)
==
--
::
::::
::
=, tree
^- json
=+ default='spur.t_body.r_comt.j_plan.j_beak.t_meta.j_kids_meta.j_head.r_bump.t'
=+ ^= schem
=+ seh=(fall (~(get by qix.gas) 'q') default)
~|(bad-noun+seh ;;(schema (rash seh read-schem)))
%+ from-queries bem.gas
~| invalid-query+schem
;;((list query) (schema-to-plist schem))

View File

@ -1,26 +1,15 @@
::
:::: /hoon/urb/ren
:::: /hoon/elem/urb/ren
::
/? 310
/+ urb-split :: for single-page apps
/% /^ {hed/{@uvH marl} bod/{@uvH marl}}
/, /web/pages
/; urb-split /# /!hymn/
/web/static
::
:: TODO: remove once we no longer need static site generator
::
/; |= urb=manx
^- [hed=[@uvH marl] bod=[@uvH marl]]
?: ?=({{$html $~} {{$head $~} *} {{$body $~} *} $~} urb)
=+ `{{$html $~} {{$head $~} hed/marl} {{$body $~} bod/marl} $~}`urb
:- [0v0 hed]
[0v0 bod]
:- [0v0 ~]
[0v0 [urb ~]]
/&hymn&/html/
::
/
/urb-tree/
/? 309
:: nutalk ::FIXME write ren/urb/nutalk
/= inner
/% /^ manx
/, :: /web/pages/nutalk /# /!htm/
/web/pages /!hymn/
:: put collections through the same .htm
:: routing structure as nutalk
:: /web/collections /# /htm/ ::a lot of stuff in here isn't .hoon files
/ /!hymn/ :: /tree-elem/
==
-.-
inner

View File

@ -1,9 +0,0 @@
:: Combine /tree-head/ and /tree-body/
::
:::: /hoon/tree/urb/ren
::
/? 310
/= hed /# /% /tree-head/
/= bod /# /% /tree-body/
^- {hed/{@uvH marl} bod/{@uvH marl}}
[hed bod]

14
ren/x-urb/elem.hoon Normal file
View File

@ -0,0 +1,14 @@
::
:::: /hoon/elem/x-urb/ren
::
/? 309
/= inner
/% /^ manx
/, /web/landscape /!hymn/
/web/collections /collection-elem/
/
/| /!hymn/
:: /&hymn&/elem/
==
==
inner

22
ren/x-urb/wrap.hoon Normal file
View File

@ -0,0 +1,22 @@
:: Add tree chrome
::
:::: /hoon/wrap/urb/ren
::
/? 309
/+ nutalk
/= wrapped
/% /^ $-(inr=manx out=manx)
/~ nutalk
:: /, /web/pages/nutalk /~ nutalk
:: /web/pages /~ urb-split
:: :: put collections through the same .htm
:: :: routing structure as nutalk
:: /web/collections /~ nutalk
:: ::
:: /
:: :: /urb-tree/
:: /~
:: |= [@ manx] ^- urb
:: ~|(%tree-unimplemented !!)
:: ==
wrapped

View File

@ -29,6 +29,8 @@
:~ 'https://mail.google.com'
'https://www.googleapis.com/auth/plus.me'
'https://www.googleapis.com/auth/userinfo.email'
'https://www.googleapis.com/auth/ndev.clouddns.readwrite'
'https://www.googleapis.com/auth/cloud-platform.read-only'
==
::
++ exchange-url 'https://www.googleapis.com/oauth2/v4/token'

59
sur/dns.hoon Normal file
View File

@ -0,0 +1,59 @@
|%
:: +turf: a domain, TLD first
::
+= turf (list @t)
:: +provider: DNS service provider (gcloud only for now)
::
+= provider
$% [%gcloud project=@ta zone=@ta]
==
:: +authority: responsibility for a DNS zone
::
+= authority
$: :: dom: authority over a fully-qualified domain
::
dom=turf
:: pro: DNS service provider
::
pro=provider
==
:: +target: a ship is bound to a ...
::
+= target
$% :: %direct: an A record
::
[%direct %if p=@if]
:: %indirect: a CNAME record
::
[%indirect p=ship]
==
:: +bound: an established binding, plus history
::
+= bound
$: :: wen: established
::
wen=@da
:: cur: current target
::
cur=target
:: hit: historical targets
::
hit=(list (pair @da target))
==
:: +nameserver: a b s o l u t e p o w e r
::
+= nameserver
$: aut=authority
pen=(map ship target)
bon=(map ship bound)
==
:: +relay: a good parent keeps track
::
+= relay
$: wen=@da
wer=(unit @if)
bon=?
try=@ud
tar=target
==
--

View File

@ -55,6 +55,7 @@
++ place :> range indicators
$% {$da @da} :< date
{$ud @ud} :< message number
{$sd @sd} :< previous messages
== ::
++ prize :> query result
$% {$client prize-client} :< /client

5
sur/urb.hoon Normal file
View File

@ -0,0 +1,5 @@
:: Disassembled page <head>/<body>
::
:::: /hoon/urb/sur
::
{hed/{dep/@uvH ele/marl} bod/{dep/@uvH ele/marl}}

View File

@ -4,7 +4,8 @@
=> =~
:: structures
=, ames
=+ protocol-version=2
:: this number needs to be below 8
=+ protocol-version=0
|%
+= move [p=duct q=(wind note:able gift:able)] :: local move
--
@ -445,6 +446,7 @@
+>.$(hoc.saf (~(put by hoc.saf) her [[~31337.1.1 ~ wil] ~ *clot]))
::
++ lax :: lax:as:go
=| rov=(unit lane) :: maybe lane change
|_ [her=ship dur=dore] :: per client
++ cluy :: cluy:lax:as:go
^- [p=life q=gens r=acru] :: client crypto
@ -518,6 +520,25 @@
[~ ryn]
lun.wod.dur
[~ ryn]
::
rov
|- ^- (unit lane)
:: XX check will
?: ?| !=(our (sein:title her))
?=(?(%earl %pawn) (clan:title her))
==
~
?- ryn
[%if *] ?. ?=([~ %if *] lun.wod.dur)
`ryn
?:(=(r.u.lun.wod.dur r.ryn) ~ `ryn)
::
[%ix *] ?. ?=([~ %ix *] lun.wod.dur)
`ryn
?:(=(r.u.lun.wod.dur r.ryn) ~ `ryn)
::
[%is *] ?~(q.ryn ~ $(ryn u.q.ryn))
==
==
::
++ wist :: wist:lax:as:go
@ -1471,8 +1492,10 @@
==
::
++ zank :: zank:ho:um:am
=? bin ?=(^ rov.diz)
[[%maze her u.rov.diz] bin]
%= +>.$ :: resolve
gus (nux:gus diz)
gus (nux:gus diz(rov ~))
wab.weg (~(put by wab.weg) her bah(sop abet:puz))
==
-- :: --ho:um:am
@ -1553,9 +1576,14 @@
(hunt lth doz rtn.sop.bah)
::
++ load
|= old=fort
~& %ames-reload
..^$(fox old)
=/ old-fort
(cork fort |=(fort [%0 gad=gad hop=hop bad=bad ton=ton zac=zac]))
|= old=?(fort old-fort)
?- old
[%0 *] $(old [%1 gad hop bad ton zac ~]:old)
[%1 *] ~& %ames-reload
..^$(fox old)
==
::
++ scry
|= [fur=(unit (set monk)) ren=@tas why=shop syd=desk lot=coin tyl=path]
@ -1604,6 +1632,11 @@
:_ fox
:~ [s.bon %give %woot q.p.bon r.bon]
==
::
%maze
:_ fox
%+ turn ~(tap in ten.fox)
|=(hen=duct [hen %give %rove p.bon q.bon])
::
%mead :_(fox [[hen [%give %hear p.bon q.bon]] ~])
%milk
@ -1713,6 +1746,14 @@
::
%sith
(~(czar am [now fox]) p.kyz q.kyz r.kyz)
::
%tend
:: XX exclude comets and moons? and planets?
:: ?> &(?=(^ hen) ?=([@ @ *] i.hen))
:: =/ who=@p (slav %p i.t.i.hen)
:: ?: ?=((%earl %pawn) (clan:title who))
:: [~ fox]
[~ fox(ten (~(put in ten.fox) hen))]
::
%nuke
:- ~

View File

@ -1,3 +1,4 @@
!:
:: clay (4c), revision control
::
:: This is split in three top-level sections: structure definitions, main
@ -44,9 +45,9 @@
:: Type of request.
::
:: %d produces a set of desks, %p gets file permissions, %u checks for
:: existence, %v produces a ++dome of all desk data, %w gets @ud and @da
:: variants for the given case, %x gets file contents, %y gets a directory
:: listing, and %z gets a recursive hash of the file contents and children.
:: existence, %v produces a ++dome of all desk data, %w gets a revision
:: number/date, %x gets file contents, %y gets a directory listing, and %z gets
:: a recursive hash of the file contents and children.
::
:: ++ care ?($d $p $u $v $w $x $y $z)
::
@ -2391,6 +2392,7 @@
$delta (~(put in $(lob q.q.gar)) lob)
==
::
::
:: Gets the permissions that apply to a particular node.
::
:: If the node has no permissions of its own, we use its parent's.
@ -2398,7 +2400,7 @@
:: we default to fully private (empty whitelist).
::
++ read-p
|= pax/path
|= {aeon pax/path}
^- (unit (unit (each cage lobe)))
=- [~ ~ %& %noun !>(-)]
:- (read-p-in pax per.red)

View File

@ -92,7 +92,11 @@
-- ::
|% :: models
++ bolo :: eyre state
$: $0 :: version
$: $1 :: version
dom/(set (list @t)) :: domain names
fig/http-config :: config
por/{clr/@ud sek/(unit @ud)} :: live ports
wel/wank :: .well-known
gub/@t :: random identity
hov/(unit ship) :: master for remote
top/beam :: ford serve prefix
@ -157,6 +161,7 @@
{$spur p/spur}
{$subs p/?($put $delt) q/{dock $json wire path}}
{$view p/ixor q/{$~ u/@ud}}
::{$view p/ixor q/{$~ u/@ud} r/(unit @dr)}
==
::
++ perk-auth :: parsed auth
@ -179,6 +184,9 @@
{$html p/manx} :: successful page
{$htme p/manx} :: authentication fail
==
::
++ wank :: .well-known ankh
{p/(unit mime) q/(map @ta wank)}
-- ::
|%
++ eat-headers
@ -228,6 +236,25 @@
^- wall
(zing (turn tan |=(a/tank (wash 0^wid a))))
::
++ yank :: get .well-known
|= [wel=wank pat=path]
^- (unit mime)
?~ pat p.wel
=/ wan (~(get by q.wel) i.pat)
?~ wan ~
$(wel u.wan, pat t.pat)
::
++ dank :: put/del .well-known
|= [wel=wank pat=path mim=(unit mime)]
^- wank
?~ pat wel(p mim)
=/ wan (~(get by q.wel) i.pat)
?: &(?=(~ wan) ?=(~ mim))
wel
:- p.wel
%+ ~(put by q.wel)
i.pat
$(wel ?~(wan *wank u.wan), pat t.pat)
::
++ add-cookies
|= {cug/(list @t) hit/httr} ^- httr
@ -642,7 +669,46 @@
=. our ?~(hov our u.hov) :: XX
=. p.top our :: XX necessary?
?- -.kyz
$born +>.$(ged hen) :: register external
$born
:: XX capture IPs too
=/ mod/(set (list @t))
%- ~(gas in *(set (list @t)))
%+ turn
(skim p.kyz |=(a=host ?=(%& -.a)))
|=(a=host ?>(?=(%& -.a) p.a))
=/ dif/(set (list @t)) (~(dif in mod) dom)
=? dom ?=(^ dif) (~(uni in dom) mod)
=? mow ?=(^ dif)
=/ cmd [%acme %poke `cage`[%acme-order !>(dom)]]
:_(mow [hen %pass /acme/order %g %deal [our our] cmd])
%= +>.$
ged hen :: register external
mow :_(mow [hen [%give %form fig]])
==
::
$live
+>.$(clr.por p.kyz, sek.por q.kyz)
::
$rule
?- -.p.kyz
$cert
?: =(secure.fig p.p.kyz) +>.$
=. secure.fig p.p.kyz
+>.$(mow :_(mow [ged [%give %form fig]]))
::
$turf
=/ mod/(set (list @t))
?: ?=(%put p.p.kyz)
(~(put in dom) q.p.kyz)
(~(del in dom) q.p.kyz)
?: =(dom mod) +>.$
=/ cmd [%acme %poke `cage`[%acme-order !>(mod)]]
%= +>.$
dom mod
mow :_(mow [hen %pass /acme/order %g %deal [our our] cmd])
==
==
::
$serv
=< ~&([%serving (en-beam top)] .)
?^(p.kyz +>.$(top p.kyz) +>.$(q.top p.kyz))
@ -652,6 +718,7 @@
::
$init :: register ownership
=. our ?~(hov p.kyz (min u.hov p.kyz))
=. fig [~ ?=(%king (clan:title our)) & &]
+>.$(hov [~ our], top [[our %home ud+0] /web])
::
?($chis $this) :: inbound request
@ -738,6 +805,9 @@
?~ p.lid +>.^$
(del-deps:$(p.lid t.p.lid) i.p.lid %& hen)
==
::
$well
+>.$(wel (dank wel p.kyz q.kyz))
::
$went
:: this won't happen until we send responses.
@ -769,9 +839,44 @@
(ames-gram q.p.kyz aut+~ p.u.mez)
=. sop (~(put by sop) p.u.mez q.p.kyz |)
(ames-gram q.p.kyz hat+~ p.u.mez our-host)
::
$get-inner
%^ exec-live ay+(dray p+uv+~ q.p.kyz p.u.mez) -.s.u.mez
::
:: =/ ext/mark q.u.mez
:: =/ fig/coin r.u.mez ::(fcgi ~ *cred) ::STUB fcgi params for /$
[%bake q.u.mez r.u.mez s.u.mez]
::
$got-inner
?. (~(has by pox) p.u.mez)
~& lost-gram-inner+p.kyz^p.u.mez
+>.$
=: hen (~(got by pox) p.u.mez)
pox (~(del by pox) p.u.mez)
==
?- -.q.u.mez
%|
=/ dep 0v0 ::XX remote dependency?
(fail 500 dep p.q.u.mez)
::
%&
=/ res/(cask) p.q.u.mez
=/ dep 0v0 ::XX remote dependency?
=/ bek -.top ::XX where is wrapper-renderer beak stored exactly
:: XX store request mark
=/ ext (end 3 (sub (met 3 p.res) (met 3 '-elem')) p.res) :: %x-urb-elem -> %x-urb
%^ exec-live ha+(en-beam bek ~) (norm-beak bek)
:+ %cast ext
:+ %call [%core (norm-beak bek) /wrap/[ext]/ren]
[%vale res]
==
::
$not +>.$(mow :_(mow [ged [%give %that q.p.kyz p.u.mez]]))
==
::
$wegh !! :: handled elsewhere
::
$wise (ames-gram p.kyz [%not ~] q.kyz) :: proxy notification
==
::
::++ axom :: old response
@ -860,10 +965,18 @@
=| ses/(unit hole)
|- ^+ ..axon
?- tee
$@($~ {?($on $ay $ow) *}) ~|(e+ford+lost+tee !!)
$@($~ {?($on $ow) *}) ~|(e+ford+lost+tee !!)
{$of @ $~} ~|(e+ford+lost+tee !!)
{$si $~} (give-sigh q.sih)
{$se ^} !! ::(get-made:(dom-vi q.tee) p.tee [p q]:sih)
{$ay ^}
=/ res/(each (cask) tang)
?- -.q.sih
%| [%| p.q.sih]
%& [%& [p q.q]:p.q.sih] :: strip type
==
(ames-gram (slav %p p.tee) got-inner+~ (slav %uv q.tee) res)
::
{$hi ^}
?: ?=($| -.q.sih)
(give-sigh q.sih) :: XX crash?
@ -1083,6 +1196,7 @@
++ teba |*(a/$-(* _..handle) |*(b/* %_(done ..handle (a b))))
++ del-deps (teba ^del-deps)
++ new-deps (teba ^new-deps)
++ ames-gram (teba ^ames-gram)
++ exec-live (teba ^exec-live)
++ give-html (teba ^give-html)
++ give-thou (teba ^give-thou)
@ -1199,6 +1313,11 @@
:~ 'User-agent: *'
'Disallow: '
==
::
{@tas $'.well-known' ^} :: XX file extension?
=/ mim (yank wel (tail q.pok))
?~ mim ~
`(resp 200 p.u.mim q.q.u.mim)
==
::
++ is-spur |(?~(q.pok & ((sane %ta) i.q.pok)))
@ -1267,8 +1386,16 @@
::
$of
:+ %view ?>(?=({@ $~} but) i.but)
?> ?=({{$poll @} $~} quy) :: XX eventsource
?> ?=({{$poll @} $~} quy)
:: :^ %view
:: ?> ?=({@ $~} but)
:: i.but
:: ?> ?=({{$poll @} *} quy) :: XX eventsource
[~ (rash q.i.quy dem)]
:: ?: ?=({{$t @} $~} +.quy)
:: =/ s (rash q.i.t.quy dem)
:: `(yule [0 0 0 s ~])
:: ~
::
$to
=+ ^- dir/{p/ship q/term r/mark}
@ -1355,11 +1482,18 @@
$away [%& %html logout-page:xml]
?($beam $spur)
=^ payload mef process-payload
=+ ext=(fall p.pok %urb)
=+ ext=(fall p.pok %x-urb)
=+ bem=?-(-.hem $beam p.hem, $spur [-.top (weld p.hem s.top)])
~| bad-beam+q.bem
?< =- ?~(- | =(-.u.- 0))
(sky [151 %noun] %cw (en-beam bem(+ ~, r [%da now])))
?< =([~ 0] (sky [151 %noun] %cw (en-beam bem(+ ~, r [%da now]))))
?: ::!=(our p.bem) ::TODO also if it is?
=('x-' (end 3 2 ext))
=. ext (cat 3 ext '-elem')
=. -.bem (norm-beak -.bem)
=/ han (sham hen)
=. pox (~(put by pox) han hen)
=+ arg=(fcgi payload fcgi-cred)
[%| (ames-gram p.bem [%get-inner ~] han ext arg bem)]
=+ wir=`whir`[%ha (en-beam -.bem ~)]
=. wir ?+(mef !! $get wir, $head [%he wir])
=. r.bem ?+(r.bem r.bem {$ud $0} da+now)
@ -1411,6 +1545,7 @@
::
$view
~| lost-ixor+p.hem
:: [%| ((teba poll:(ire-ix p.hem)) u.q.hem r.hem)]
[%| ((teba poll:(ire-ix p.hem)) u.q.hem)]
==
::
@ -1766,11 +1901,15 @@
++ pop-duct =^(ned med ~(get to med) abet(hen ned))
++ poll
|= a/@u ^+ ..ix
:: |= [a/@u t=(unit @dr)]
:: ^+ ..ix
=< abet
=. ..poll refresh
?: =(a p.eve)
=. ..poll poll-rest
=. era (add ~s30 now)
=. era (add ~s8 now)
:: ?~ t (add ~s30 now)
:: (add u.t now)
=. lyv (~(put by lyv) hen [%poll ire])
pass-wait(ude [~ hen &])
?: (gth a p.eve) ~|(seq-high+cur=p.eve !!)
@ -2070,10 +2209,20 @@
~
::
++ load :: take previous state
::|= * %. (bolo +<)
|= old/?(bolo) ^+ ..^$
=> |%
++ bolo-old (cork bolo |=(bolo [%0 |5.+<]))
--
|= old/?(bolo-old bolo)
^+ ..^$
?- -.old
$0 ..^$(+>- old)
$0 $(old [%1 ~ *http-config [8.080 ~] [~ ~] +.old])
::
$1 :: XX temporary fix for bad proxy config
::
=/ rox=? ?~ hov.old
proxy.fig.old
?=(%king (clan:title u.hov.old))
..^$(+>- old(proxy.fig rox))
==
::
++ scry
@ -2101,7 +2250,14 @@
?+ p.lot [~ ~]
{$tas $fake} ``[& [~ 8.443] %& /localhost] :: XX from unix
{$tas $real}
``~(our-host ye [`duct`~[/] [now eny our sky] ~] bol)
=/ hot=host [%& ?^(dom n.dom /localhost)]
=/ sek=? &(?=(^ sek.por) !?=(hoke hot))
=/ por=(unit @ud)
?. sek
?:(=(80 clr.por) ~ `clr.por)
?> ?=(^ sek.por)
?:(=(443 u.sek.por) ~ sek.por)
``[sek por hot]
==
==
::

View File

@ -829,6 +829,7 @@
(stag %fsbc ;~(pfix buc hoon:read)) :: /$ extra arguments
(stag %fsbr ;~(pfix bar alts:read)) :: /| or (options)
(stag %fshx ;~(pfix hax horn:read)) :: /# insert dephash
(stag %fspt ;~(pfix pat horn:read)) :: /@ insert dephash
(stag %fsts ;~(pfix tis name:read)) :: /= apply face
(stag %fsdt ;~(pfix dot list:read)) :: /. list
(stag %fscm ;~(pfix com case:read)) :: /, switch by path
@ -1151,6 +1152,21 @@
(flaw cof leaf+"file not found" (smyt (en-beam bem)) ~)
(fine cof u.u.von)
::
++ load-time
~/ %load-time
|= {cof/cafe bem/beam}
^- (bolt time)
?: =([%ud 0] r.bem)
(flaw cof [leaf+"ford: no data: {<(en-beam bem(s ~))>}"]~)
?. =(%ud -.r.bem)
~|(%beam-not-normalized !!) ::XX flaw?
=+ von=(syve [151 %noun] ~ %cw bem)
?~ von
[p=cof q=[%1 [[%c %w bem ~] ~ ~]]]
?. ?=([~ %time * @da] u.von)
(flaw cof leaf+"ford: bad-revision: {<(bind u.von head)>}" ~)
(fine cof q.q.u.u.von)
::
++ load-to-mark
~/ %load-to-mark
|= {cof/cafe for/mark bem/beam}
@ -1620,6 +1636,30 @@
%- flux
|= {mark vax/vase}
[%noun (slop [atom+['uvH' ~] dep] vax)]
::
$fspt
?. ?=([$fszy @] p.hon)
(flaw cof leaf+"ford: STUB /@ only implemented for /mark/" ~)
%+ cope $(cof cof, hon p.hon)
|= {cof/cafe mark vax/vase}
%+ cope (normalize-beak cof how(s [q.p.hon s.how]))
|= {cof/cafe bem/beam}
?> ?=(%ud -.r.bem)
%+ cope (load-arch cof bem)
|= {cof/cafe ark/arch}
?~ fil.ark (flaw cof leaf+"ford: no file {<(tope bem)>}" ~)
=; res
=. q.res ::XX prevent infinite dependency loop
?-(-.q.res $1 [!!], ?($0 $2) q.res(p ~))
res
::
|- ^- (bolt cage) ::TODO do this in clay
=/ bom bem(p.r (dec p.r.bem))
%+ cope (load-arch cof bom)
|= {cof/cafe ork/arch}
?: =(fil.ork fil.ark) ^$(cof cof, bem bom)
%+ cope (load-time cof bem(s ~))
(flux |=(wen/time [%noun (slop !>(wen) vax)]))
::
$fsts
%+ cope $(hon q.hon)

View File

@ -1224,11 +1224,14 @@
$nuke `%a
$ogre `%c
$perm `%c
$rule `%e
$serv `%e
$tend `%a
$them `%e
$wait `%b
$want `%a
$warp `%c
$well `%e
$wipe `%f :: XX cache clear
==
--

View File

@ -135,6 +135,7 @@
{$init p/@p} :: report install
{$mack p/(unit tang)} ::
{$mass p/mass} :: memory usage
{$rove p/ship q/lane} :: lane change
{$send p/lane q/@} :: transmit packet
{$woot p/ship q/coop} :: reaction message
== ::
@ -161,6 +162,7 @@
{$nuke p/@p} :: toggle auto-block
{$make p/(unit @t) q/@ud r/@ s/?} :: wild license
{$sith p/@p q/@uw r/?} :: imperial generator
{$tend $~} :: watch lane changes
{$wake $~} :: timer activate
{$wegh $~} :: report memory
{$west p/sack q/path r/*} :: network request
@ -203,6 +205,7 @@
++ boon :: fort output
$% {$beer p/ship q/@uvG} :: gained ownership
{$cake p/sock q/soap r/coop s/duct} :: e2e message result
{$maze p/ship q/lane} :: lane change
{$mead p/lane q/rock} :: accept packet
{$milk p/sock q/soap r/*} :: e2e pass message
{$ouzo p/lane q/rock} :: transmit packet
@ -240,12 +243,13 @@
wid/@ud :: logical wdow msgs
== ::
++ fort :: formal state
$: $0 :: version
$: $1 :: version
gad/duct :: client interface
hop/@da :: network boot date
bad/(set @p) :: bad ships
ton/town :: security
zac/(map ship corn) :: flows by server
ten/(set duct) :: watch lanes
== ::
++ gcos :: id description
$% {$czar $~} :: 8-bit ship
@ -502,6 +506,10 @@
q/path :: spur
r/cage :: data
== ::
++ real :: resolved permissions
$: mod/?($black $white) ::
who/(pair (set ship) (map @ta crew)) ::
== ::
++ rave :: general request
$% {$sing p/mood} :: single request
{$next p/mood} :: await next version
@ -666,9 +674,11 @@
++ able ^?
|%
+= gift :: out result <-$
$% [%mass p=mass] :: memory usage
$% [%form p=http-config] :: configuration
[%mass p=mass] :: memory usage
[%mack p=(unit tang)] :: message ack
[%sigh p=cage] :: marked http response
[%that p=@p q=prox] :: get proxied request
[%thou p=httr] :: raw http response
[%thus p=@ud q=(unit hiss)] :: http request+cancel
[%veer p=@ta q=path r=@t] :: drop-through
@ -676,10 +686,12 @@
[%velo p=@t q=@t] :: drop-through
== ::
+= task :: in request ->$
$% [%born ~] :: new unix process
$% [%born p=(list host)] :: new unix process
[%crud p=@tas q=(list tank)] :: XX rethink
[%hiss p=(unit user) q=mark r=cage] :: outbound user req
[%init p=@p] :: report install
[%live p=@ud q=(unit @ud)] :: http/s ports
[%rule p=http-rule] :: update config
[%serv p=$@(desk beam)] :: set serving root
[%them p=(unit hiss)] :: outbound request
[%they p=@ud q=httr] :: inbound response
@ -687,8 +699,10 @@
[%this p=? q=clip r=httq] :: inbound request
[%thud ~] :: inbound cancel
[%wegh ~] :: report memory
[%well p=path q=(unit mime)] :: put/del .well-known
[%went p=sack q=path r=@ud s=coop] :: response confirm
[%west p=sack q=[path *]] :: network request
[%wise p=ship q=prox] :: proxy notification
== ::
-- ::able
::
@ -722,6 +736,11 @@
[[%get ~] p=@uvH q=[? clip httq]] :: remote request
[[%got ~] p=@uvH q=httr] :: remote response
[[%gib ~] p=@uvH] :: remote cancel
::
[[%get-inner ~] p=@uvH q=mark r=coin s=beam] ::TODO details?
[[%got-inner ~] p=@uvH q=(each (cask) tang)] ::TODO details?
::
[[%not ~] p=prox] :: proxy notification
== ::
++ hart {p/? q/(unit @ud) r/host} :: http sec+port+host
++ hate {p/purl q/@p r/moth} :: semi-cooked request
@ -732,6 +751,34 @@
++ host (each (list @t) @if) :: http host
++ hoke %+ each {$localhost $~} :: local host
?($.0.0.0.0 $.127.0.0.1) ::
:: +http-config: full http-server configuration
::
+= http-config
$: :: secure: PEM-encoded RSA private key and cert or cert chain
::
secure=(unit [key=wain cert=wain])
:: proxy: reverse TCP proxy HTTP(s)
::
proxy=?
:: log: keep HTTP(s) access logs
::
log=?
:: redirect: send 301 redirects to upgrade HTTP to HTTPS
::
:: Note: requires certificate.
::
redirect=?
==
:: +http-rule: update configuration
::
+= http-rule
$% :: %cert: set or clear certificate and keypair
::
[%cert p=(unit [key=wain cert=wain])]
:: %turf: add or remove established dns binding
::
[%turf p=?(%put %del) q=(list @t)]
==
++ httq :: raw http request
$: p/meth :: method
q/@t :: unparsed url
@ -769,6 +816,22 @@
++ octs {p/@ud q/@t} :: octet-stream
++ oryx @t :: CSRF secret
++ pork {p/(unit @ta) q/(list @t)} :: fully parsed url
:: +prox: proxy notification
::
:: Used on both the proxy (ward) and upstream sides for
:: sending/receiving proxied-request notifications.
::
+= prox
$: :: por: tcp port
::
por=@ud
:: sek: secure?
::
sek=?
:: non: authentication nonce
::
non=@uvJ
==
++ purf (pair purl (unit @t)) :: url with fragment
++ purl {p/hart q/pork r/quay} :: parsed url
++ quay (list {p/@t q/@t}) :: parsed url query
@ -834,6 +897,7 @@
{$fsbc p/hoon} :: /$ argument
{$fsbr p/(list horn)} :: /| options
{$fshx p/horn} :: /# insert dephash
{$fspt p/horn} :: /@ insert mod-time
{$fsts p/term q/horn} :: /= apply face
{$fsdt p/(list horn)} :: /. list
{$fscm p/(list (pair spur horn))} :: /, switch by path
@ -2638,11 +2702,14 @@
%+ mix txt
%^ rsh 3 (sub (mul 16 blocks) len)
%+ rep 7
%- flop
|- ^- (list @ux)
?: =(blocks 0) ~
:- (encrypt ctr)
$(ctr (inc mod ctr), blocks (dec blocks))
=| seed=(list @ux)
|- ^+ seed
?: =(blocks 0) seed
%= $
seed [(encrypt ctr) seed]
ctr (inc mod ctr)
blocks (dec blocks)
==
:: :: ++de:ctra:aes:crypto
++ de :: decrypt
en
@ -2662,11 +2729,14 @@
%+ mix txt
%^ rsh 3 (sub (mul 16 blocks) len)
%+ rep 7
%- flop
|- ^- (list @ux)
?: =(blocks 0) ~
:- (encrypt ctr)
$(ctr (inc mod ctr), blocks (dec blocks))
=| seed=(list @ux)
|- ^+ seed
?: =(blocks 0) seed
%= $
seed [(encrypt ctr) seed]
ctr (inc mod ctr)
blocks (dec blocks)
==
:: :: ++de:ctrb:aes:crypto
++ de :: decrypt
en
@ -2686,11 +2756,14 @@
%+ mix txt
%^ rsh 3 (sub (mul 16 blocks) len)
%+ rep 7
%- flop
|- ^- (list @ux)
?: =(blocks 0) ~
:- (encrypt ctr)
$(ctr (inc mod ctr), blocks (dec blocks))
=| seed=(list @ux)
|- ^+ seed
?: =(blocks 0) seed
%= $
seed [(encrypt ctr) seed]
ctr (inc mod ctr)
blocks (dec blocks)
==
:: :: ++de:ctrc:aes:crypto
++ de :: decrypt
en

3
web.hoon Normal file
View File

@ -0,0 +1,3 @@
^- manx
;div(data-component "InboxPage");

View File

@ -0,0 +1,5 @@
# Collections
A thin layer for managing file-system-based content, like blogs, forums and notes. Sends notifications using `hall`.
Very much in development. Not even functional yet.

View File

@ -0,0 +1,18 @@
:: /- collections
:: /+ colls
:: /= gas /$ fuel:html
:: /= configs /: /===/web/collections
:: /^ (map knot config:collections) /_ /collections-config/
:: =/ id %+ fall
:: %- %~ get
:: by
:: qix.gas
:: ==
:: %coll
:: ''
/= gas /$ fuel:html
^- manx
;div
;div(urb-component "TopicCreatePage", urb-ship "{(scow %p p.bem.gas)}");
;input(type "hidden", name "urb-header", value "collection-write", station "query");
==

View File

@ -0,0 +1,18 @@
:: /- collections
:: /+ colls
:: /= gas /$ fuel:html
:: /= configs /: /===/web/collections
:: /^ (map knot config:collections) /_ /collections-config/
:: =/ id %+ fall
:: %- %~ get
:: by
:: qix.gas
:: ==
:: %coll
:: ''
/= gas /$ fuel:html
^- manx
;div
;div(urb-component "TopicCreatePage", urb-ship "{(scow %p p.bem.gas)}");
;input(type "hidden", name "urb-header", value "collection-write", station "query");
==

File diff suppressed because one or more lines are too long

73306
web/landscape/js/index.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,63 @@
/+ collections, colls
/= gas /$ fuel:html
::/= all-colls /: /===/web/collections
:: /collection-web-item/
|%
:: is this collection on the profile?
++ is-pro
|= col=collection:collections
visible.meta.col
--
^- manx
;div.profile-page
;input(type "hidden", name "urb-header", value "profile", ship "{(scow %p p.bem.gas)}");
;div.container
;div.row
;div.col-sm-offset-2.col-sm-10
;div.profile-avatar
;div(urb-component "AvatarLg", urb-ship "{(scow %p p.bem.gas)}");
;div.profile-shipname: {(scow %p p.bem.gas)}
;div(urb-component "ProfileMsgBtn", urb-ship "{(scow %p p.bem.gas)}");
==
==
==
;div.row
;div.col-sm-offset-2.col-sm-10
::;div.text-700.mt-8: Blogs, Forum and Notes
::;ul.vanilla
:: ;div;
:: ;* %+ turn
:: %+ sort
:: %+ skim
:: ~(tap by all-colls)
:: is-pro
:: |= [a=(pair knot *) b=(pair knot *)]
:: (gth (unt:chrono:userlib (slav %da p.a)) (unt:chrono:userlib (slav %da p.b)))
:: |= [t=knot col=collection:collections]
:: ;div.mt-2.text-500
:: ;a(href "/~~/{(scow %p p.bem.gas)}/==/web/collections/{(trip t)}")
:: ; {(trip desc.conf.col)}
:: ==
:: ==
::==
::;div.text-700.mt-8: Chats
;div(urb-component "ChatList", urb-hostship "{(scow %p p.bem.gas)}");
;div.text-700.mt-8: Meta
;div.mt-2.text-500.row
;span.col-sm-2: Started:
;span.col-sm-10.text-mono: ~2018.4.12..6.45.12
==
;div.mt-2.text-500.row
;span.col-sm-2: Issued:
;span.col-sm-10.text-mono
;a(href "/~~/{(scow %p (sein:title p.bem.gas))}/==/web/pages/nutalk/profile"): {(scow %p (sein:title p.bem.gas))}
==
==
;div.mt-2.text-500.row
;span.col-sm-2: Events:
;span.col-sm-10.text-mono: 852.129.320
==
==
==
==
==

View File

@ -0,0 +1,6 @@
^- manx
;div
;div(urb-component "ChatPage");
;input(type "hidden", name "urb-header", value "stream", station "query");
==

View File

@ -0,0 +1,3 @@
^- manx
;div(urb-component "StreamCreatePage");

View File

@ -0,0 +1,14 @@
input.red {
background: hsl(0, 100%, 60%);
}
form.inline {
display: inline;
}
.edit-toggle:checked ~ .edit-off {
display: none;
}
.edit-toggle:not(:checked) ~ .edit-on {
display: none;
}

47
web/lib/js/easy-form.js Normal file
View File

@ -0,0 +1,47 @@
//REVIEW this feels too complicated
let match_url_end = (pattern,out={})=> {
if(!pattern) return out
let here = document.location.pathname.split("/").reverse()
while(!here[0]) here.shift()
for(let segment of pattern.split("/").reverse()){
let val = here.shift()
if(segment[0] != ":") continue //REVIEW check for match?
out[segment.slice(1)] = val
}
return out
}
//
window.easy_form = {
submit: (form)=> {
const param = (key)=> {
var x = form.elements[`easy_form:${key}`]
return x && x.value
}
let mark = param("mark")
if(!mark) throw new TypeError("Need a mark")
let appl = param("appl") || mark.match(/^[^-]*/)[0]
let tag = param("tag")
//
if(param("confirm") != null && !confirm("Are you sure?"))
return false
//
let req = {}
req = match_url_end(param("url_end"),req)
//
for (let [k,v] of new FormData(form)){
if(!/^easy_form:/.test(k)) {
req[k] = v
}
}
if(tag) req = {[tag]:req}
fetch("/~/auth.json", {credentials: "same-origin"})
.then((res)=>res.json())
.then(({oryx})=> fetch(`/~/to/${appl}/${mark}`,{
method: "POST",
body:JSON.stringify({oryx,wire:"/",xyro:req}),
credentials: "same-origin"
}))
return false
}
}

73
web/pages/elapsed.js Normal file
View File

@ -0,0 +1,73 @@
var secToString = function(secs) {
if (secs <= 0) {
return 'Completed';
}
secs = Math.floor(secs)
var min = 60;
var hour = 60 * min;
var day = 24 * hour;
var week = 7 * day;
var year = 52 * week;
var fy = function(s) {
if (s < year) {
return ['', s];
} else {
return [Math.floor(s / year) + 'y', s % year];
}
}
var fw = function(tup) {
var str = tup[0];
var sec = tup[1];
if (sec < week) {
return [str, sec];
} else {
return [str + ' ' + Math.floor(sec / week) + 'w', sec % week];
}
}
var fd = function(tup) {
var str = tup[0];
var sec = tup[1];
if (sec < day) {
return [str, sec];
} else {
return [str + ' ' + Math.floor(sec / day) + 'd', sec % day];
}
}
var fh = function(tup) {
var str = tup[0];
var sec = tup[1];
if (sec < hour) {
return [str, sec];
} else {
return [str + ' ' + Math.floor(sec / hour) + 'h', sec % hour];
}
}
var fm = function(tup) {
var str = tup[0];
var sec = tup[1];
if (sec < min) {
return [str, sec];
} else {
return [str + ' ' + Math.floor(sec / min) + 'm', sec % min];
}
}
var fs = function(tup) {
var str = tup[0];
var sec = tup[1];
return str + ' ' + sec + 's';
}
return fs(fm(fh(fd(fw(fy(secs)))))).trim();
}
window.onload = function() {
var das = document.querySelectorAll('[data-urb-elapsed]');
for (var i=0; i < das.length; i ++) {
var urbD = das[i].dataset.urbElapsed; // UTC
var serverTime = new Date(urbD);
var clientTime = new Date(); // local
var interval = secToString((clientTime - serverTime) / 1000).split(' ')[0];
document.querySelector("[data-urb-elapsed='" + urbD + "']").innerHTML = '-' + interval;
}
}

18
web/pages/toggle.js Normal file
View File

@ -0,0 +1,18 @@
document.toggleDisplay = function(id1, id2) {
var id1 = 'show';
var id2 = 'edit';
var isDisplayed = function(id) {
return document.getElementById(id).style.display != 'none';
}
console.log(document.getElementById(id1));
console.log(document.getElementById(id2));
if (isDisplayed(id1)) {
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'inherit';
} else {
document.getElementById(id1).style.display = 'inherit';
document.getElementById(id2).style.display = 'none';
}
};
document.getElementById('edit-btn').onclick = document.toggleDisplay;