mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 18:12:47 +03:00
Merge branch 'collections-api-changes' into collections
This commit is contained in:
commit
cbfd2b9aea
@ -130,7 +130,7 @@
|
||||
=/ entries=wain
|
||||
%+ turn ~(tap by a)
|
||||
|= b=[knot cord]
|
||||
=/ c=[term knot] ((hard ,[term knot]) b)
|
||||
=/ c=[term cord] ((hard ,[term cord]) b)
|
||||
(crip " [{<-.c>} {<+.c>}]")
|
||||
::
|
||||
?~ entries ~
|
||||
@ -176,126 +176,17 @@
|
||||
++ poke-collections-action
|
||||
|= act=action:collections
|
||||
^- (quip move _this)
|
||||
?. =(who.act our.bol)
|
||||
::
|
||||
:: forward poke if its not meant for us
|
||||
:_ this
|
||||
:_ ~
|
||||
:* ost.bol %poke
|
||||
/forward-collections-action
|
||||
[who.act %collections]
|
||||
%collections-action act
|
||||
==
|
||||
::
|
||||
:: resolve %collection, %post, or %comment to %write + %perms action
|
||||
=. acts.act
|
||||
%+ roll acts.act
|
||||
|= [a=sub-action out=(list sub-action)]
|
||||
^- (list sub-action)
|
||||
=/ sap (en-beam:format [byk.bol (flop (path +<.a))])
|
||||
?- -.a
|
||||
::
|
||||
%write
|
||||
=/ perms .^([dict:clay dict:clay] %cp sap)
|
||||
?: (allowed-by src.bol +.perms)
|
||||
[a out]
|
||||
out
|
||||
::
|
||||
%delete
|
||||
=/ perms .^([dict:clay dict:clay] %cp sap)
|
||||
?: (allowed-by src.bol +.perms)
|
||||
[a out]
|
||||
out
|
||||
::
|
||||
%perms
|
||||
?: =(src.bol our.bol) :: XX admin priveleges for other users?
|
||||
[a out]
|
||||
out
|
||||
::
|
||||
::
|
||||
:: XX some of this is redunant
|
||||
::
|
||||
%collection
|
||||
=/ perms .^([dict:clay dict:clay] %cp (weld sap /[name.a]/collections-config))
|
||||
?. (allowed-by src.bol +.perms)
|
||||
out
|
||||
=/ conf=config
|
||||
:* [byk.bol (flop (weld pax.a /[name.a]/collections-config))]
|
||||
name.a
|
||||
desc.a
|
||||
our.bol
|
||||
now.bol
|
||||
now.bol
|
||||
type.a
|
||||
comments.a
|
||||
~
|
||||
visible.a
|
||||
==
|
||||
=/ new=(list sub-action)
|
||||
:~ [%write (weld pax.a /[name.a]/collections-config) %collections-config conf]
|
||||
:: restrict permissions on config file
|
||||
:^ %perms (weld pax.a /[name.a]/collections-config)
|
||||
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: read XX maybe open this?
|
||||
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
|
||||
:: open permissions on collection items
|
||||
:^ %perms (weld pax.a /[name.a])
|
||||
[%black ((set whom:clay) ~)] :: read
|
||||
[%black ((set whom:clay) ~)] :: write
|
||||
==
|
||||
(weld new out)
|
||||
::
|
||||
%post
|
||||
=/ perms .^([dict:clay dict:clay] %cp (weld sap /[name.a]/umd))
|
||||
?. (allowed-by src.bol +.perms)
|
||||
out
|
||||
=. content.a (crip (weld (trip content.a) "\0a"))
|
||||
=/ 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]
|
||||
==
|
||||
=/ new=(list sub-action)
|
||||
:~ [%write (weld pax.a /[name.a]/umd) %umd `@t`(update-umd-front front content.a)]
|
||||
:: restrict write permissions on umd file
|
||||
:^ %perms (weld pax.a /[name.a]/umd)
|
||||
[%black ((set whom:clay) ~)] :: read
|
||||
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
|
||||
:: open permissions on comments
|
||||
:^ %perms (weld pax.a /[name.a])
|
||||
[%black ((set whom:clay) ~)] :: read
|
||||
[%black ((set whom:clay) ~)] :: write
|
||||
==
|
||||
(weld new out)
|
||||
::
|
||||
%comment
|
||||
=/ dat (scot %da now.bol)
|
||||
=/ perms .^([dict:clay dict:clay] %cp (weld sap /[dat]/umd))
|
||||
?. (allowed-by src.bol +.perms)
|
||||
out
|
||||
=. content.a (crip (weld (trip content.a) "\0a"))
|
||||
=/ front=(map knot cord)
|
||||
%- my
|
||||
:~ [%owner (scot %p src.bol)]
|
||||
[%date-created dat]
|
||||
[%last-modified dat]
|
||||
[%type %comments]
|
||||
==
|
||||
=/ new=(list sub-action)
|
||||
:~ [%write (weld pax.a /[dat]/umd) %umd (update-umd-front front content.a)]
|
||||
:: restrict write permissions on umd file
|
||||
:^ %perms (weld pax.a /[dat]/umd)
|
||||
[%black ((set whom:clay) ~)] :: read
|
||||
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
|
||||
==
|
||||
(weld new out)
|
||||
?: =(who.act our.bol)
|
||||
ta-done:(ta-act:ta act)
|
||||
::
|
||||
:: forward poke if its not meant for us
|
||||
:_ this
|
||||
:_ ~
|
||||
:* ost.bol %poke
|
||||
/forward-collections-action
|
||||
[who.act %collections]
|
||||
%collections-action act
|
||||
==
|
||||
::
|
||||
ta-done:(ta-act:ta act)
|
||||
::
|
||||
::::::
|
||||
::::::
|
||||
@ -326,16 +217,118 @@
|
||||
|-
|
||||
?~ acts.act ta-this
|
||||
=* a i.acts.act
|
||||
::
|
||||
=/ sap (en-beam:format [byk.bol (flop (path +<.a))])
|
||||
=/ now-id=@da (sub now.bol (div (dis now.bol ~s0..fffe) 2))
|
||||
=/ dat (scot %da now-id)
|
||||
::
|
||||
=. ta-this
|
||||
?+ -.a
|
||||
!!
|
||||
%write
|
||||
?- -.a
|
||||
%write
|
||||
=/ perms .^([dict:clay dict:clay] %cp sap)
|
||||
?: (allowed-by src.bol +.perms)
|
||||
?- -.for.a
|
||||
%umd (ta-write pax.a `cage`[-.for.a !>(+.for.a)])
|
||||
%collections-config (ta-write pax.a `cage`[-.for.a !>(+.for.a)])
|
||||
==
|
||||
%delete (ta-remove pax.a)
|
||||
%perms (ta-set-permissions pax.a r.a w.a)
|
||||
ta-this
|
||||
::
|
||||
%delete
|
||||
=/ perms .^([dict:clay dict:clay] %cp sap)
|
||||
?: (allowed-by src.bol +.perms)
|
||||
(ta-remove pax.a)
|
||||
ta-this
|
||||
::
|
||||
%perms
|
||||
?: =(src.bol our.bol) :: XX admin privileges for other users?
|
||||
(ta-set-permissions pax.a r.a w.a)
|
||||
ta-this
|
||||
::
|
||||
::
|
||||
:: XX some of this is redunant
|
||||
::
|
||||
%collection
|
||||
=/ perms .^([dict:clay dict:clay] %cp (weld sap /[dat]/collections-config))
|
||||
?. (allowed-by src.bol +.perms)
|
||||
ta-this
|
||||
=/ conf=config
|
||||
:* [byk.bol (flop (weld pax.a /[dat]/collections-config))]
|
||||
name.a
|
||||
desc.a
|
||||
our.bol
|
||||
now.bol
|
||||
now.bol
|
||||
type.a
|
||||
comments.a
|
||||
~
|
||||
visible.a
|
||||
==
|
||||
=. ta-this
|
||||
%+ ta-write (weld pax.a /[dat]/collections-config)
|
||||
[%collections-config !>(conf)]
|
||||
:: restrict permissions on config file
|
||||
=. ta-this
|
||||
%^ ta-set-permissions (weld pax.a /[dat]/collections-config)
|
||||
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: read XX maybe open this?
|
||||
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
|
||||
:: open permissions on collection items
|
||||
=. ta-this
|
||||
%^ ta-set-permissions (weld pax.a /[dat])
|
||||
[%black ((set whom:clay) ~)] :: read
|
||||
[%black ((set whom:clay) ~)] :: write
|
||||
ta-this
|
||||
::
|
||||
%post
|
||||
=/ perms .^([dict:clay dict:clay] %cp (weld sap /[dat]/umd))
|
||||
?. (allowed-by src.bol +.perms)
|
||||
ta-this
|
||||
=. content.a (crip (weld (trip content.a) "\0a"))
|
||||
=/ 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]
|
||||
==
|
||||
=. ta-this
|
||||
%+ ta-write (weld pax.a /[dat]/umd)
|
||||
[%umd !>((update-umd-front front content.a))]
|
||||
:: restrict permissions on umd file
|
||||
=. ta-this
|
||||
%^ ta-set-permissions (weld pax.a /[dat]/umd)
|
||||
[%black ((set whom:clay) ~)] :: read
|
||||
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
|
||||
:: open permissions on comments
|
||||
=. ta-this
|
||||
%^ ta-set-permissions (weld pax.a /[dat])
|
||||
[%black ((set whom:clay) ~)] :: read
|
||||
[%black ((set whom:clay) ~)] :: write
|
||||
ta-this
|
||||
::
|
||||
%comment
|
||||
=/ perms .^([dict:clay dict:clay] %cp (weld sap /[dat]/umd))
|
||||
?. (allowed-by src.bol +.perms)
|
||||
ta-this
|
||||
=. content.a (crip (weld (trip content.a) "\0a"))
|
||||
=/ front=(map knot cord)
|
||||
%- my
|
||||
:~ [%owner (scot %p src.bol)]
|
||||
[%date-created dat]
|
||||
[%last-modified dat]
|
||||
[%type %comments]
|
||||
==
|
||||
=. ta-this
|
||||
%+ ta-write (weld pax.a /[dat]/umd)
|
||||
[%umd !>((update-umd-front front content.a))]
|
||||
:: restrict permissions on umd file
|
||||
=. ta-this
|
||||
%^ ta-set-permissions (weld pax.a /[dat]/umd)
|
||||
[%black ((set whom:clay) ~)] :: read
|
||||
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
|
||||
ta-this
|
||||
::
|
||||
==
|
||||
$(acts.act t.acts.act)
|
||||
::
|
||||
|
@ -18,7 +18,7 @@
|
||||
::
|
||||
+= config
|
||||
$: full-path=beam
|
||||
name=@ta
|
||||
name=@t
|
||||
description=@t
|
||||
::
|
||||
owner=@p
|
||||
@ -43,8 +43,8 @@
|
||||
[%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]
|
||||
[%collection pax=path name=@t desc=@t comments=? visible=? type=@tas]
|
||||
[%post pax=path name=@t type=@tas comments=? content=@t]
|
||||
[%comment pax=path content=@t]
|
||||
==
|
||||
::
|
||||
|
@ -67,13 +67,16 @@
|
||||
++ 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)
|
||||
==
|
||||
;div
|
||||
;+ (config-to-elem meta.col)
|
||||
;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
|
||||
@ -86,6 +89,7 @@
|
||||
=/ owner (fall (~(get by meta.raw) %owner) 'anonymous')
|
||||
::
|
||||
;div
|
||||
;+ (front-to-elem meta.raw)
|
||||
;div.collection-date: {(trip date)}
|
||||
::
|
||||
;div#show
|
||||
@ -123,7 +127,7 @@
|
||||
^- manx
|
||||
:: XX TODO: accept types other than comments
|
||||
?> ?=(%raw -.ite)
|
||||
?> =(%comments (~(got by meta.raw.ite) %type))
|
||||
:: ?> =(%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
|
||||
@ -164,10 +168,12 @@
|
||||
++ collection-to-snip
|
||||
|= [nom=knot col=collection:collections]
|
||||
^- manx
|
||||
=/ lnk=tape
|
||||
"/~~/{(scow %p p.full-path.meta.col)}/=={(spud (flop (slag 1 s.full-path.meta.col)))}"
|
||||
;div
|
||||
;div.collection-date: {<date-created.meta.col>}
|
||||
;h3
|
||||
;a(href "{(trip -.s.bem.gas)}/{(trip nom)}"): {(trip name.meta.col)}
|
||||
;a(href lnk): {(trip name.meta.col)}
|
||||
==
|
||||
;div.who.text-mono.text-600: {<owner.meta.col>}
|
||||
;div.meta-cont
|
||||
@ -187,13 +193,15 @@
|
||||
=/ 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')
|
||||
=/ lnk=tape
|
||||
"/~~/{(scow %p p.bem.gas)}/=={(spud (flop s.bem.gas))}/{(trip nom)}"
|
||||
::
|
||||
;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}
|
||||
;a(href lnk): {(trip title)}
|
||||
;a(href lnk): *{hed.ht}
|
||||
==
|
||||
;div.who.text-mono.text-600: {(trip owner)}
|
||||
;div.snippet
|
||||
@ -209,13 +217,15 @@
|
||||
=? tal.ht ?=(~ hed.ht)
|
||||
(scag 5 c.elm)
|
||||
=/ title (fall (~(get by meta.raw) %name) nom)
|
||||
=/ lnk=tape
|
||||
"/~~/{(scow %p p.bem.gas)}/=={(spud (flop s.bem.gas))}/{(trip 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}
|
||||
;a(href lnk): {(trip title)}
|
||||
;a(href lnk): *{hed.ht}
|
||||
==
|
||||
;div.who.text-mono.text-600: {<owner.meta.col>}
|
||||
;div.snippet: *{tal.ht}
|
||||
@ -225,6 +235,28 @@
|
||||
==
|
||||
==
|
||||
==
|
||||
::
|
||||
++ front-to-elem
|
||||
|= fro=(map knot cord)
|
||||
^- manx
|
||||
:_ ~
|
||||
:- %div
|
||||
%+ turn ~(tap by (~(put by fro) %class %item-meta))
|
||||
|= [a=knot b=cord]
|
||||
^- [mane tape]
|
||||
[((hard @tas) a) (trip b)]
|
||||
::
|
||||
++ config-to-elem
|
||||
|= con=config:collections
|
||||
^- manx
|
||||
;div.collection-meta
|
||||
=urb-full-path (spud (en-beam:format full-path.con))
|
||||
=urb-name (trip name.con)
|
||||
=urb-description (trip description.con)
|
||||
=urb-owner (scow %p owner.con)
|
||||
=urb-date-created (scow %da date-created.con)
|
||||
=urb-last-modified (scow %da last-modified.con)
|
||||
=urb-type (trip type.con);
|
||||
::::
|
||||
:::: /mar/snip
|
||||
::::
|
||||
|
@ -36,7 +36,7 @@
|
||||
|= [nom=knot ite=item:collections]
|
||||
^- json
|
||||
%- pairs:enjs:format
|
||||
:~ [%name %s nom]
|
||||
:~ [%filename %s nom]
|
||||
[%item (item-to-json ite)]
|
||||
==
|
||||
==
|
||||
@ -62,13 +62,15 @@
|
||||
%+ turn (en-beam:format full-path.con)
|
||||
|= a=@ta
|
||||
[%s a]
|
||||
:- %name [%s description.con]
|
||||
:- %name [%s name.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)
|
||||
:- %type [%s type.con]
|
||||
:- %comments [%b comments.con]
|
||||
:- %sort-key ?~(sort-key.con ~ (numb:enjs:format u.sort-key.con))
|
||||
:- %visible [%b visible.con]
|
||||
==
|
||||
::
|
||||
++ meta-to-json
|
||||
|
Loading…
Reference in New Issue
Block a user