From e54a3a2896adedc79039ebeeba7534525740a902 Mon Sep 17 00:00:00 2001 From: Fang Date: Sat, 2 Dec 2017 19:45:47 +0100 Subject: [PATCH 1/8] Initial commit. --- app/collections.hoon | 311 +++++++++++++++++++++++++++++++++++ mar/collections/comment.hoon | 38 +++++ mar/collections/config.hoon | 41 +++++ readme.md | 5 + 4 files changed, 395 insertions(+) create mode 100644 app/collections.hoon create mode 100644 mar/collections/comment.hoon create mode 100644 mar/collections/config.hoon create mode 100644 readme.md diff --git a/app/collections.hoon b/app/collections.hoon new file mode 100644 index 000000000..f3831da4f --- /dev/null +++ b/app/collections.hoon @@ -0,0 +1,311 @@ +:: /app/collection/hoon +:: +/- hall +/+ hall +:: +::TODO nom/term too ambiguous, use col/term where applicable. +:: +=> |% + ++ state :: + $: cols/(map term collection) :: collections by name + == :: + ++ collection :: + $: conf/config :: configuration + coms/(set term) :: comment circles + == :: + ++ comment :: + $: who/ship :: author + wen/@da :: created + wed/@da :: editted + wat/wain :: content + == :: + ++ config :: + $: desc/cord :: description + publ/? :: public or private + visi/? :: visible or hidden + mems/(set ship) :: ships on list + == :: + ++ action :: + $% $: $create :: create a collection + wat/kind :: collection kind + des/cord :: name + pub/? :: public or private + ses/(set ship) :: black/whitelist + vis/? :: visible or hidden + == :: + {$delete nom/term} :: delete a collection + == + ++ kind ?($blog $fora $note) + ++ command + $% {$write wer/term wat/wain} ::TODO parent? title? etc. + == + :: + ++ move (pair bone card) ::< all actions + ++ lime ::> diff fruit + $% {$hall-prize prize:hall} :: + {$hall-rumor rumor:hall} :: + == :: + ++ poke :: + $% {$hall-action action:hall} :: + == :: + ++ card :: + $% {$diff lime} :: + {$info wire ship term nori:clay} :: + {$peer wire dock path} :: + {$poke wire dock poke} :: + {$pull wire dock $~} :: + {$quit $~} :: + == :: + -- +:: +|_ {bol/bowl:gall state} +:: +::TODO ++prep watch %desk +:: +++ poke-noun + |= a/@ + ^- (quip move _+>) + ~& %poked + [~ +>] +:: +++ poke-collections-action + |= act/action + ^- (quip move _+>) + ?. (team:title our.bol src.bol) [~ +>] + ?- -.act + $create + =+ nom=(sane-cord des.act) + =^ mos +>.$ + =< ta-done + =- (ta-change-config:ta nom - %coll) + [des.act pub.act vis.act ses.act] + =- [[- mos] +>.$] + :* 0 + %peer + /hall/[nom] + [our.bol %hall] + /circle/(make-circle nom ~)/config-l + == + :: + $delete + [~ +>] + ::TODO - delete files + :: - unsubscribe from the thing + :: - send delete action to hall + :: - remove from state + == +:: +++ diff-hall-prize + |= {wir/wire piz/prize:hall} + ^- (quip move _+>) + [~ +>] +:: +++ diff-hall-rumor + |= {wir/wire rum/rumor:hall} + ^- (quip move _+>) + ?> ?=({$hall @tas $~} wir) + =+ nom=i.t.wir + ?> ?=({$circle $config *} rum) + ta-done:(ta-apply-config-diff:ta nom dif.rum.rum) +:: +++ diff-filesystem ::TODO ? + |= {wir/wire *} + ^- (quip move _+>) + [~ +>] + ::TODO - extract nom from path + :: - determine if config file or content + :: - if config: determine changes, then send to hall for nom and comms + :: - if content: determine if comment or op, then + :: post notification, noting whether new or changed. + :: if op, also create comments channel (and add to state) + :: + :: /web/collections/ + :: /web/collections/my-blog.config + :: /web/collections/my-blog/post-title.txt + :: /web/collections/my-blog/post-title/1.txt or: + :: /web/collections/my-blog/post-title/~2017.12.01..12.34.56..abcd.txt + :: + :: %collections--my-blog + :: %collections--my-blog--post-title +:: +++ ta + |_ moves/(list move) + :: + ++ ta-done + [(flop moves) +>] + :: + ++ ta-emit + |= mov/move + %_(+> moves [mov moves]) + :: + ++ ta-emil + |= mos/(list move) + %_(+> moves (welp (flop mos) moves)) + :: + ++ ta-hall-action + |= act/action:hall + %- ta-emit + :^ ost.bol %poke / ::TODO and handle returns correctly. + :+ [our.bol %hall] %hall-action + act + :: + ++ ta-change-comment + |= {nom/term top/term num/@ud wat/wain} + ^+ +> + =+ old=(some *comment) ::TODO get existing comment + %- ta-write-comment + :^ nom top num + ::?~ old + :: [src.bol now.bol now.bol wat] + u.old(wat wat, wed now.bol) + :: + ++ ta-write-comment + |= {nom/term top/term num/@ud com/comment} + ^+ +> + %- ta-emit + =+ mun=(scot %ud num) + =/ paf/path + %+ en-beam:format [our.bol %home da+now.bol] + (flop /web/collections/[nom]/[top]/[mun]/collections-comment) + :* ost.bol + %info + /comment/[nom]/[top]/[mun] + our.bol + (foal:space:userlib paf [%collections-comment !>(com)]) + == + :: + ++ ta-apply-config-diff + |= {nom/term dif/diff-config:hall} + ^+ +> + +> + ::TODO find error? + ::=- (ta-change-config nom - %hall) + ::=+ cof=conf:(~(got by cols) nom) + ::?+ -.dif ta + :: $caption + :: cof(desc cap.dif) + :::: + :: $permit + :: cof ::TODO + :::: + :: $remove + :: cof ::TODO/REVIEW ignore/recreate? *don't* remove files. + ::== + :: + ++ ta-change-config + |= {nom/term new/config src/?($file $hall $coll)} + ^+ +> + :: if not changed on disk, update the file. + =? +> !?=($file src) + (ta-write-config nom new) + =+ ole=(~(get by cols) nom) + :: if we don't have it yet, add to state and hall. + ?~ ole + =. cols (~(put by cols) nom new ~) + (ta-hall-create nom new) + :: update config in state. + =. cols (~(put by cols) nom u.ole(conf new)) + :: if we got it from file, update config in hall. + =+ dif=(ta-config-diff conf.u.ole new) + =? +>.$ ?=(^ des.dif) + (ta-hall-set-description nom u.des.dif) + =? +>.$ ?=(^ vis.dif) + (ta-hall-set-visible nom u.vis.dif) + ::TODO do below for all coms as well. + =? +>.$ ?=(^ rem.dif) + (ta-hall-set-permissions nom | rem.dif) + =? +>.$ ?=(^ add.dif) + (ta-hall-set-permissions nom & add.dif) + +>.$ + :: + ++ ta-write-config + |= {nom/term cof/config} + ^+ +> + %- ta-emit + =/ paf/path + %+ en-beam:format [our.bol %home da+now.bol] + (flop /web/collections/[nom]/collections-config) + :* ost.bol + %info + /config/[nom] + our.bol + (foal:space:userlib paf [%collections-config !>(cof)]) + == + :: + ++ ta-config-diff + |= {old/config new/config} + ^- $: des/(unit cord) + vis/(unit ?) + rem/(set ship) + add/(set ship) + == + :+ ?: =(desc.old desc.new) ~ + `desc.new + ?: =(visi.old visi.new) ~ + `visi.new + :- (~(dif in mems.old) mems.new) + (~(dif in mems.new) mems.old) + :: + ++ ta-hall-create + |= {nom/term cof/config} + ^+ +> + =+ nam=(make-circle nom ~) + =. +>.$ + %- ta-hall-action + [%create nam desc.cof ?:(publ.cof %journal %village)] + =? +>.$ visi.cof + (ta-hall-set-visible nam &) + ?~ mems.cof +>.$ + (ta-hall-set-permissions nam & mems.cof) + :: + ++ ta-hall-set-description + |= {nom/term des/cord} + ^+ +> + %- ta-hall-action + [%depict (make-circle nom ~) des] + :: + ++ ta-hall-set-visible + |= {nom/term vis/?} + ^+ +> + %- ta-hall-action + [%public vis our.bol (make-circle nom ~)] + :: + ++ ta-hall-set-permissions + |= {nom/term inv/? sis/(set ship)} + ^+ +> + %- ta-hall-action + [%permit (make-circle nom ~) inv sis] + -- +:: +++ sane-cord + |= c/cord + ^- term + %- crip + %- zing + %+ scan (cass (trip c)) + =+ val=;~(pose low nud) + =+ inv=(plus ;~(less ;~(pose low nud) next)) + %+ ifix [(star inv) (star inv)] + %- star ;~ pose + ;~(plug val (easy ~)) + ;~(plug (cold '-' inv) val (easy ~)) + == +:: +++ make-circle + |= {n/term t/(unit term)} + ^- term + ;: (cury cat 3) + %collection-- + n + ?~(t %$ '--') + ?~(t %$ u.t) + == +:: +++ read-config + |= nom/term + .^ config + %cx + ::TODO current desk, not always %home! + /(scot %p our.bol)/home/(scot %da now.bol)/web/collections/[nom]/collections-config + == +-- diff --git a/mar/collections/comment.hoon b/mar/collections/comment.hoon new file mode 100644 index 000000000..fe3f8b9a8 --- /dev/null +++ b/mar/collections/comment.hoon @@ -0,0 +1,38 @@ +:: /mar/collections/comment/hoon +:: +|_ $= com + $: who/ship :: author + wen/@da :: created + wed/@da :: editted + wat/wain :: content + == :: +:: +++ grow + |% + ++ mime + :- /text/x-collections-comment + %- as-octs:mimes:html + (of-wain:format txt) + ++ txt + ^- (list @t) + :^ (scot %p who.com) + (scot %da wen.com) + (scot %da wed.com) + wat + -- +:: +++ grab + |% + ++ mime + |= {p/mite:eyre q/octs:eyre} + (txt (to-wain:format q.q)) + ++ txt + |= txs/(list @t) + ?> (gte (lent txs) 3) + :^ (slav %p (snag 0 txs)) + (slav %da (snag 1 txs)) + (slav %da (snag 2 txs)) + (slag 3 txs) + -- +++ grad %txt +-- diff --git a/mar/collections/config.hoon b/mar/collections/config.hoon new file mode 100644 index 000000000..9735d8bdc --- /dev/null +++ b/mar/collections/config.hoon @@ -0,0 +1,41 @@ +:: /mar/collections/config/hoon +:: +|_ $= con + $: desc/cord :: description + publ/? :: public or private + visi/? :: visioverable + mems/(set ship) :: ships on list + == :: +:: +++ grow + |% + ++ mime + :- /text/x-collections-config + %- as-octs:mimes:html + (of-wain:format txt) + ++ txt + ^- (list @t) + :^ desc.con + ?:(publ.con 'public' 'private') + ?:(visi.con 'visible' 'hidden') + %+ turn ~(tap in mems.con) + (cury scot %p) + -- +:: +++ grab + |% + ++ mime + |= {p/mite:eyre q/octs:eyre} + (txt (to-wain:format q.q)) + ++ txt + |= txs/(list @t) + ?> (gte (lent txs) 3) + :^ (snag 0 txs) + =((snag 1 txs) 'public') + =((snag 2 txs) 'visible') + %- ~(gas in *(set ship)) + %+ turn (slag 3 txs) + (cury slav %p) + -- +++ grad %txt +-- diff --git a/readme.md b/readme.md new file mode 100644 index 000000000..1f3c0b656 --- /dev/null +++ b/readme.md @@ -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. From 764b3ec3282f52de944ecca794de85ee13e462b4 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 4 Dec 2017 22:34:44 +0100 Subject: [PATCH 2/8] Additions for working with topics/posts/notes. Added in hall notifications. Compiles, but untested and doesn't do much. --- app/collections.hoon | 289 ++++++++++++++++++++++++++++--------- mar/collections/topic.hoon | 43 ++++++ 2 files changed, 262 insertions(+), 70 deletions(-) create mode 100644 mar/collections/topic.hoon diff --git a/app/collections.hoon b/app/collections.hoon index f3831da4f..743f1133e 100644 --- a/app/collections.hoon +++ b/app/collections.hoon @@ -3,6 +3,14 @@ /- hall /+ hall :: +:: collections: state, files, hall +:: topics: state, files, hall, notify +:: comments: s a e, files, notify +:: +:: /web/collections/my-coll.config +:: /web/collections/my-coll/some.topic +:: /web/collections/my-coll/some/1.comment +:: ::TODO nom/term too ambiguous, use col/term where applicable. :: => |% @@ -11,7 +19,11 @@ == :: ++ collection :: $: conf/config :: configuration - coms/(set term) :: comment circles + tops/(map @da topic) :: parent-level content + == :: + ++ topic :: + $: tit/cord :: title + comment :: == :: ++ comment :: $: who/ship :: author @@ -30,9 +42,11 @@ wat/kind :: collection kind des/cord :: name pub/? :: public or private - ses/(set ship) :: black/whitelist vis/? :: visible or hidden - == :: + ses/(set ship) :: black/whitelist + == :: + {$submit nom/term tit/cord wat/wain} :: submit a post/note + {$comment nom/term top/@da com/@da wat/wain} :: submit a comment {$delete nom/term} :: delete a collection == ++ kind ?($blog $fora $note) @@ -66,33 +80,18 @@ |= a/@ ^- (quip move _+>) ~& %poked - [~ +>] + ta-done:(ta-write-config:ta %test ['a description' & & [~palzod ~ ~]]) :: ++ poke-collections-action |= act/action ^- (quip move _+>) ?. (team:title our.bol src.bol) [~ +>] + =< ta-done ?- -.act - $create - =+ nom=(sane-cord des.act) - =^ mos +>.$ - =< ta-done - =- (ta-change-config:ta nom - %coll) - [des.act pub.act vis.act ses.act] - =- [[- mos] +>.$] - :* 0 - %peer - /hall/[nom] - [our.bol %hall] - /circle/(make-circle nom ~)/config-l - == - :: - $delete - [~ +>] - ::TODO - delete files - :: - unsubscribe from the thing - :: - send delete action to hall - :: - remove from state + $create (ta-create:ta +.act) + $submit (ta-submit:ta +.act) + $comment (ta-comment:ta +.act) + $delete (ta-delete:ta +.act) == :: ++ diff-hall-prize @@ -149,31 +148,55 @@ :+ [our.bol %hall] %hall-action act :: - ++ ta-change-comment - |= {nom/term top/term num/@ud wat/wain} - ^+ +> - =+ old=(some *comment) ::TODO get existing comment - %- ta-write-comment - :^ nom top num - ::?~ old - :: [src.bol now.bol now.bol wat] - u.old(wat wat, wed now.bol) + :: %performing-actions :: - ++ ta-write-comment - |= {nom/term top/term num/@ud com/comment} + ++ ta-create + |= {wat/kind des/cord pub/? vis/? ses/(set ship)} ^+ +> + =+ nom=(sane-cord des) + =. +>.$ + =- (ta-change-config nom - %coll) + [des pub vis ses] %- ta-emit - =+ mun=(scot %ud num) - =/ paf/path - %+ en-beam:format [our.bol %home da+now.bol] - (flop /web/collections/[nom]/[top]/[mun]/collections-comment) - :* ost.bol - %info - /comment/[nom]/[top]/[mun] - our.bol - (foal:space:userlib paf [%collections-comment !>(com)]) + :* 0 + %peer + /hall/[nom] + [our.bol %hall] + /circle/(make-circle nom ~)/config-l == :: + ++ ta-submit + |= {nom/term tit/cord wat/wain} + %+ ta-change-topic nom + [[tit src.bol now.bol now.bol wat] %coll] + :: + ++ ta-comment + |= {nom/term top/@da com/@da wat/wain} + ^+ +> + =+ col=(~(get by cols) nom) + ?~ col +>.$ + =+ tob=(~(get by tops.u.col) top) + ?~ tob +>.$ + =+ old=(get-comment nom top com) + ?~ old + %^ ta-write-comment nom top + [src.bol now.bol now.bol wat] + ?. =(who.u.old src.bol) +>.$ + %^ ta-write-comment nom top + u.old(wat wat, wed now.bol) + + :: + ++ ta-delete + |= nom/term + ^+ +> + +> + ::TODO - delete files + :: - unsubscribe from the thing + :: - send delete action to hall + :: - remove from state + :: + :: %applying-changes + :: ++ ta-apply-config-diff |= {nom/term dif/diff-config:hall} ^+ +> @@ -202,10 +225,15 @@ :: if we don't have it yet, add to state and hall. ?~ ole =. cols (~(put by cols) nom new ~) - (ta-hall-create nom new) + (ta-hall-create nom ~ new) + :: make sure publ stays unchanged. + =. +>.$ + ?: =(publ.conf.u.ole publ.new) +>.$ + =. new new(publ publ.conf.u.ole) + (ta-write-config nom new) :: update config in state. =. cols (~(put by cols) nom u.ole(conf new)) - :: if we got it from file, update config in hall. + :: update config in hall. =+ dif=(ta-config-diff conf.u.ole new) =? +>.$ ?=(^ des.dif) (ta-hall-set-description nom u.des.dif) @@ -218,20 +246,6 @@ (ta-hall-set-permissions nom & add.dif) +>.$ :: - ++ ta-write-config - |= {nom/term cof/config} - ^+ +> - %- ta-emit - =/ paf/path - %+ en-beam:format [our.bol %home da+now.bol] - (flop /web/collections/[nom]/collections-config) - :* ost.bol - %info - /config/[nom] - our.bol - (foal:space:userlib paf [%collections-config !>(cof)]) - == - :: ++ ta-config-diff |= {old/config new/config} ^- $: des/(unit cord) @@ -246,15 +260,108 @@ :- (~(dif in mems.old) mems.new) (~(dif in mems.new) mems.old) :: - ++ ta-hall-create + ++ ta-change-topic + |= {nom/term top/topic src/?($file $coll)} + ^+ +> + =+ old=(get-topic nom wen.top) + :: only original poster and host can edit. + ?. |(?=($~ old) =(who.u.old src.bol) ?=($file src)) +>.$ + :: ensure legit author. + =? top ?=($coll src) + top(who src.bol) + :: change last edit date. + =. top top(wed now.bol) + :: store in state. + =. cols + %+ ~(put by cols) nom + =+ col=(~(got by cols) nom) + col(tops (~(put by tops.col) wen.top top)) + =+ new=?=($~ old) + =? +>.$ new + (ta-hall-create nom `wen.top conf:(~(got by cols) nom)) + =. +>.$ + (ta-write-topic nom top) + (ta-hall-notify nom wen.top ~ new wat.top) + :: + ++ ta-change-comment + |= {nom/term top/@da com/comment src/?($file $coll)} + ^+ +> + =+ old=(get-comment nom top wen.com) + :: only original poster and host can edit. + ?. |(?=($~ old) =(who.u.old src.bol) ?=($file src)) + +>.$ + :: ensure legit author. + =? com ?=($coll src) + com(who src.bol) + :: change last edit date. + =. com com(wed now.bol) + =. +>.$ + (ta-write-comment nom top com) + (ta-hall-notify nom top `wen.com ?=($~ old) wat.com) + :: + :: %writing-files + :: + ++ ta-write-config |= {nom/term cof/config} ^+ +> - =+ nam=(make-circle nom ~) + %- ta-emit + =/ paf/path + %- make-path + /[nom]/collections-config + :* ost.bol + %info + /config/[nom] + our.bol + (foal:space:userlib paf [%collections-config !>(cof)]) + == + :: + ++ ta-write-topic + |= {nom/term top/topic} + ^+ +> + =+ wan=(scot %da wen.top) + =+ pax=(make-path /[nom]/[wan]/collections-topic) + %- ta-emit + :* ost.bol + %info + /topic/[nom]/[wan] + our.bol + (foal:space:userlib pax [%collections-topic !>(top)]) + == + :: + ++ ta-write-comment + |= {nom/term top/@da com/comment} + ^+ +> + =+ tap=(scot %da top) + =+ wan=(scot %da wen.com) + =/ pax/path + %- make-path + /[nom]/[tap]/[wan]/collections-comment + %- ta-emit + :* ost.bol + %info + /comment/[nom]/[tap]/[wan] + our.bol + (foal:space:userlib pax [%collections-comment !>(com)]) + == + :: + :: %hall-changes + :: + ++ ta-hall-create + |= {nom/term top/(unit @da) cof/config} + ^+ +> + =+ nam=(make-circle nom top) =. +>.$ %- ta-hall-action [%create nam desc.cof ?:(publ.cof %journal %village)] + ::TODO if ?~ top, sub to config changes =? +>.$ visi.cof (ta-hall-set-visible nam &) + =? +>.$ ?=(^ top) + %- ta-hall-action + ::NOTE %source also subs to local config & presence, but + :: that generally won't result in visible notifications. + :^ %source (make-circle nom ~) & + [`source:hall`[[our.bol nam] ~] ~ ~] ?~ mems.cof +>.$ (ta-hall-set-permissions nam & mems.cof) :: @@ -275,6 +382,16 @@ ^+ +> %- ta-hall-action [%permit (make-circle nom ~) inv sis] + :: + ++ ta-hall-notify + |= {nom/term top/@da com/(unit @da) new/? wat/wain} + ^+ +> + %- ta-hall-action + =- :+ %phrase [[our.bol tar] ~ ~] + [%fat [%text wat] [%lin | msg]]~ + ^- {tar/naem:hall msg/cord} + ::TODO + [(make-circle nom ~) 'TODO'] -- :: ++ sane-cord @@ -292,20 +409,52 @@ == :: ++ make-circle - |= {n/term t/(unit term)} + |= {n/term t/(unit @da)} ^- term ;: (cury cat 3) %collection-- n ?~(t %$ '--') - ?~(t %$ u.t) + ?~(t %$ (sane-cord (scot %da u.t))) == :: -++ read-config +++ beak-now + byk.bol(r [%da now.bol]) +:: +++ make-path + |= pax/path + :(welp (en-beam:format beak-now ~) /web/collections pax) +:: +++ has-file + |= pax/path + ::NOTE %cu not implemented, so we use %cy instead. + =- ?=(^ fil.-) + .^(arch %cy pax) +:: +++ get-config |= nom/term - .^ config - %cx - ::TODO current desk, not always %home! - /(scot %p our.bol)/home/(scot %da now.bol)/web/collections/[nom]/collections-config - == + ^- (unit config) + =/ pax + %- make-path + /[nom]/collections-config + ?. (has-file pax) ~ + `.^(config %cx pax) +:: +++ get-topic + |= {nom/term top/@da} + ^- (unit topic) + =/ pax + %- make-path + /[nom]/(scot %da top)/collections-topic + ?. (has-file pax) ~ + `.^(topic %cx pax) +:: +++ get-comment + |= {nom/term top/@da wen/@da} + ^- (unit comment) + =/ pax + %- make-path + /[nom]/(scot %da top)/(scot %da wen)/collections-comment + ?. (has-file pax) ~ + `.^(comment %cx pax) -- diff --git a/mar/collections/topic.hoon b/mar/collections/topic.hoon new file mode 100644 index 000000000..abffda9d8 --- /dev/null +++ b/mar/collections/topic.hoon @@ -0,0 +1,43 @@ +:: /mar/collections/comment/hoon +:: +|_ $= top + $: tit/cord :: title + who/ship :: author + wen/@da :: created + wed/@da :: editted + wat/wain :: content + == :: +:: +++ grow + |% + ++ mime + :- /text/x-collections-comment + %- as-octs:mimes:html + (of-wain:format txt) + ++ txt + ^- (list @t) + :* tit.top + (scot %p who.top) + (scot %da wen.top) + (scot %da wed.top) + wat + == + -- +:: +++ grab + |% + ++ mime + |= {p/mite:eyre q/octs:eyre} + (txt (to-wain:format q.q)) + ++ txt + |= txs/(list @t) + ?> (gte (lent txs) 4) + :* (snag 0 txs) + (slav %p (snag 1 txs)) + (slav %da (snag 2 txs)) + (slav %da (snag 3 txs)) + (slag 4 txs) + == + -- +++ grad %txt +-- From fb5594001dd8ef07d99400c9de6cd93a54d683ed Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 4 Dec 2017 22:47:41 +0100 Subject: [PATCH 3/8] Proper permissions for actions. --- app/collections.hoon | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/collections.hoon b/app/collections.hoon index 743f1133e..e7a6f7414 100644 --- a/app/collections.hoon +++ b/app/collections.hoon @@ -85,7 +85,17 @@ ++ poke-collections-action |= act/action ^- (quip move _+>) - ?. (team:title our.bol src.bol) [~ +>] + ?. ?- -.act + ?($create $delete) + (team:title src.bol our.bol) + :: + ?($submit $comment) + =+ col=(~(get by cols) nom.act) + ?~ col | + ?! .= publ.conf.u.col + (~(has in mems.conf.u.col) src.bol) + == + [~ +>] =< ta-done ?- -.act $create (ta-create:ta +.act) From 3509a5c590c5cdaa808d013b77c398a059c8792c Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 4 Dec 2017 22:51:01 +0100 Subject: [PATCH 4/8] Commands obsoleted by actions. --- app/collections.hoon | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/collections.hoon b/app/collections.hoon index e7a6f7414..00df8c094 100644 --- a/app/collections.hoon +++ b/app/collections.hoon @@ -50,10 +50,6 @@ {$delete nom/term} :: delete a collection == ++ kind ?($blog $fora $note) - ++ command - $% {$write wer/term wat/wain} ::TODO parent? title? etc. - == - :: ++ move (pair bone card) ::< all actions ++ lime ::> diff fruit $% {$hall-prize prize:hall} :: From d243de9f961993eef497f6c744d42f2034455711 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 4 Dec 2017 22:59:53 +0100 Subject: [PATCH 5/8] Properly apply hall config diffs. --- app/collections.hoon | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/app/collections.hoon b/app/collections.hoon index 00df8c094..d51145304 100644 --- a/app/collections.hoon +++ b/app/collections.hoon @@ -206,20 +206,27 @@ ++ ta-apply-config-diff |= {nom/term dif/diff-config:hall} ^+ +> - +> - ::TODO find error? - ::=- (ta-change-config nom - %hall) - ::=+ cof=conf:(~(got by cols) nom) - ::?+ -.dif ta - :: $caption - :: cof(desc cap.dif) - :::: - :: $permit - :: cof ::TODO - :::: - :: $remove - :: cof ::TODO/REVIEW ignore/recreate? *don't* remove files. - ::== + =+ cof=conf:(~(got by cols) nom) + =; new/(unit config) + ?~ new +>.$ + (ta-change-config nom u.new %hall) + ?+ -.dif ~ + $caption + `cof(desc cap.dif) + :: + $permit + %- some + %_ cof + mems + %. mems.cof + ?: add.dif + ~(dif in sis.dif) + ~(int in sis.dif) + == + :: + $remove + `cof ::TODO/REVIEW ignore/recreate? *don't* remove files. + == :: ++ ta-change-config |= {nom/term new/config src/?($file $hall $coll)} From 9a855b4c7e90dbfe27a1fac663221373ad4254a6 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 4 Dec 2017 23:09:44 +0100 Subject: [PATCH 6/8] Don't sub to configs of comment notification channels. --- app/collections.hoon | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/collections.hoon b/app/collections.hoon index d51145304..97d9a9501 100644 --- a/app/collections.hoon +++ b/app/collections.hoon @@ -160,16 +160,8 @@ |= {wat/kind des/cord pub/? vis/? ses/(set ship)} ^+ +> =+ nom=(sane-cord des) - =. +>.$ - =- (ta-change-config nom - %coll) - [des pub vis ses] - %- ta-emit - :* 0 - %peer - /hall/[nom] - [our.bol %hall] - /circle/(make-circle nom ~)/config-l - == + =- (ta-change-config nom - %coll) + [des pub vis ses] :: ++ ta-submit |= {nom/term tit/cord wat/wain} @@ -366,7 +358,14 @@ =. +>.$ %- ta-hall-action [%create nam desc.cof ?:(publ.cof %journal %village)] - ::TODO if ?~ top, sub to config changes + =? +>.$ ?=($~ top) + %- ta-emit + :* 0 + %peer + /hall/[nom] + [our.bol %hall] + /circle/[nam]/config-l + == =? +>.$ visi.cof (ta-hall-set-visible nam &) =? +>.$ ?=(^ top) From cbf1307000bb116b02306bdd8948f97f088a468e Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 5 Dec 2017 16:04:52 +0100 Subject: [PATCH 7/8] Config file parsing more forgiving, just ignores invalid ship names. --- mar/collections/config.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mar/collections/config.hoon b/mar/collections/config.hoon index 9735d8bdc..2ac0e81f9 100644 --- a/mar/collections/config.hoon +++ b/mar/collections/config.hoon @@ -34,8 +34,8 @@ =((snag 1 txs) 'public') =((snag 2 txs) 'visible') %- ~(gas in *(set ship)) - %+ turn (slag 3 txs) - (cury slav %p) + %+ murn (slag 3 txs) + (cury slaw %p) -- ++ grad %txt -- From 73588e959421e19a981bdef6d39972339fb9b90a Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 11 Dec 2017 20:59:44 +0100 Subject: [PATCH 8/8] Minor changes, renaming, comment notes. --- app/collections.hoon | 196 ++++++++++++++++++++++--------------------- 1 file changed, 99 insertions(+), 97 deletions(-) diff --git a/app/collections.hoon b/app/collections.hoon index 97d9a9501..fb828bb45 100644 --- a/app/collections.hoon +++ b/app/collections.hoon @@ -3,15 +3,19 @@ /- hall /+ hall :: -:: collections: state, files, hall -:: topics: state, files, hall, notify -:: comments: s a e, files, notify +:: things to keep in sync: +:: collections: state, files, hall unique by name +:: topics: state, files, hall, notify unique by date +:: comments: s a e, files, notify unique by date/number? :: +:: filepaths: :: /web/collections/my-coll.config :: /web/collections/my-coll/some.topic :: /web/collections/my-coll/some/1.comment :: -::TODO nom/term too ambiguous, use col/term where applicable. +:: notification circles: +:: %collections--my-blog new/changed post notifications +:: %collections--my-blog--post-title new/changed comments notifications :: => |% ++ state :: @@ -45,13 +49,14 @@ vis/? :: visible or hidden ses/(set ship) :: black/whitelist == :: - {$submit nom/term tit/cord wat/wain} :: submit a post/note - {$comment nom/term top/@da com/@da wat/wain} :: submit a comment - {$delete nom/term} :: delete a collection - == - ++ kind ?($blog $fora $note) - ++ move (pair bone card) ::< all actions - ++ lime ::> diff fruit + ::TODO probably want to specify @da here too. + {$submit col/term tit/cord wat/wain} :: submit a post/note + {$comment col/term top/@da com/@da wat/wain} :: submit a comment + {$delete col/term} :: delete a collection + == :: + ++ kind ?($blog $fora $note) :: + ++ move (pair bone card) :: all actions + ++ lime :: diff fruit $% {$hall-prize prize:hall} :: {$hall-rumor rumor:hall} :: == :: @@ -64,13 +69,21 @@ {$peer wire dock path} :: {$poke wire dock poke} :: {$pull wire dock $~} :: + {$warp wire sock riff:clay} :: {$quit $~} :: == :: -- :: |_ {bol/bowl:gall state} :: -::TODO ++prep watch %desk +++ prep ::< prepare state + ::> adapts state. + :: + |= old/(unit *) + ^- (quip move _..prep) + ::?~ old + [~ ..prep] ::TODO init, start clay subs + ::[~ ..prep(+<+ u.old)] :: ++ poke-noun |= a/@ @@ -78,12 +91,21 @@ ~& %poked ta-done:(ta-write-config:ta %test ['a description' & & [~palzod ~ ~]]) :: +++ writ + |= {wir/wire rit/riot:clay} + ^- (quip move _+>) + [~ +>] + ::TODO watch for file changes. create on new files, update on change, delete + :: on remove. we want to watch /web/collections recursively if possible, + :: or /web/collections/[col] for each collection and then + :: /web/collections/[col]/[top] for each topic as they get created. +:: ++ poke-collections-action |= act/action ^- (quip move _+>) ?. ?- -.act ?($create $delete) - (team:title src.bol our.bol) + (team:title our.bol src.bol) :: ?($submit $comment) =+ col=(~(get by cols) nom.act) @@ -113,26 +135,6 @@ ?> ?=({$circle $config *} rum) ta-done:(ta-apply-config-diff:ta nom dif.rum.rum) :: -++ diff-filesystem ::TODO ? - |= {wir/wire *} - ^- (quip move _+>) - [~ +>] - ::TODO - extract nom from path - :: - determine if config file or content - :: - if config: determine changes, then send to hall for nom and comms - :: - if content: determine if comment or op, then - :: post notification, noting whether new or changed. - :: if op, also create comments channel (and add to state) - :: - :: /web/collections/ - :: /web/collections/my-blog.config - :: /web/collections/my-blog/post-title.txt - :: /web/collections/my-blog/post-title/1.txt or: - :: /web/collections/my-blog/post-title/~2017.12.01..12.34.56..abcd.txt - :: - :: %collections--my-blog - :: %collections--my-blog--post-title -:: ++ ta |_ moves/(list move) :: @@ -150,7 +152,7 @@ ++ ta-hall-action |= act/action:hall %- ta-emit - :^ ost.bol %poke / ::TODO and handle returns correctly. + :^ ost.bol %poke / ::TODO wire, handle ++coup. :+ [our.bol %hall] %hall-action act :: @@ -164,44 +166,44 @@ [des pub vis ses] :: ++ ta-submit - |= {nom/term tit/cord wat/wain} - %+ ta-change-topic nom + |= {col/term tit/cord wat/wain} + %+ ta-change-topic col [[tit src.bol now.bol now.bol wat] %coll] :: ++ ta-comment - |= {nom/term top/@da com/@da wat/wain} + |= {col/term top/@da com/@da wat/wain} ^+ +> - =+ col=(~(get by cols) nom) + =+ col=(~(get by cols) col) ?~ col +>.$ =+ tob=(~(get by tops.u.col) top) ?~ tob +>.$ - =+ old=(get-comment nom top com) + =+ old=(get-comment col top com) ?~ old - %^ ta-write-comment nom top + %^ ta-write-comment col top [src.bol now.bol now.bol wat] ?. =(who.u.old src.bol) +>.$ - %^ ta-write-comment nom top + %^ ta-write-comment col top u.old(wat wat, wed now.bol) - :: ++ ta-delete - |= nom/term + |= col/term ^+ +> +> ::TODO - delete files - :: - unsubscribe from the thing + :: - unsubscribe from clay + :: - unsubscribe from hall :: - send delete action to hall :: - remove from state :: :: %applying-changes :: ++ ta-apply-config-diff - |= {nom/term dif/diff-config:hall} + |= {col/term dif/diff-config:hall} ^+ +> - =+ cof=conf:(~(got by cols) nom) + =+ cof=conf:(~(got by cols) col) =; new/(unit config) ?~ new +>.$ - (ta-change-config nom u.new %hall) + (ta-change-config col u.new %hall) ?+ -.dif ~ $caption `cof(desc cap.dif) @@ -221,34 +223,34 @@ == :: ++ ta-change-config - |= {nom/term new/config src/?($file $hall $coll)} + |= {col/term new/config src/?($file $hall $coll)} ^+ +> :: if not changed on disk, update the file. =? +> !?=($file src) - (ta-write-config nom new) - =+ ole=(~(get by cols) nom) + (ta-write-config col new) + =+ ole=(~(get by cols) col) :: if we don't have it yet, add to state and hall. ?~ ole - =. cols (~(put by cols) nom new ~) - (ta-hall-create nom ~ new) + =. cols (~(put by cols) col new ~) + (ta-hall-create col ~ new) :: make sure publ stays unchanged. =. +>.$ ?: =(publ.conf.u.ole publ.new) +>.$ =. new new(publ publ.conf.u.ole) - (ta-write-config nom new) + (ta-write-config col new) :: update config in state. - =. cols (~(put by cols) nom u.ole(conf new)) + =. cols (~(put by cols) col u.ole(conf new)) :: update config in hall. =+ dif=(ta-config-diff conf.u.ole new) =? +>.$ ?=(^ des.dif) - (ta-hall-set-description nom u.des.dif) + (ta-hall-set-description col u.des.dif) =? +>.$ ?=(^ vis.dif) - (ta-hall-set-visible nom u.vis.dif) - ::TODO do below for all coms as well. + (ta-hall-set-visible col u.vis.dif) + ::TODO do below for all topic circles as well. =? +>.$ ?=(^ rem.dif) - (ta-hall-set-permissions nom | rem.dif) + (ta-hall-set-permissions col | rem.dif) =? +>.$ ?=(^ add.dif) - (ta-hall-set-permissions nom & add.dif) + (ta-hall-set-permissions col & add.dif) +>.$ :: ++ ta-config-diff @@ -266,9 +268,9 @@ (~(dif in mems.new) mems.old) :: ++ ta-change-topic - |= {nom/term top/topic src/?($file $coll)} + |= {col/term top/topic src/?($file $coll)} ^+ +> - =+ old=(get-topic nom wen.top) + =+ old=(get-topic col wen.top) :: only original poster and host can edit. ?. |(?=($~ old) =(who.u.old src.bol) ?=($file src)) +>.$ :: ensure legit author. @@ -278,20 +280,20 @@ =. top top(wed now.bol) :: store in state. =. cols - %+ ~(put by cols) nom - =+ col=(~(got by cols) nom) + %+ ~(put by cols) col + =+ col=(~(got by cols) col) col(tops (~(put by tops.col) wen.top top)) =+ new=?=($~ old) =? +>.$ new - (ta-hall-create nom `wen.top conf:(~(got by cols) nom)) + (ta-hall-create col `wen.top conf:(~(got by cols) col)) =. +>.$ - (ta-write-topic nom top) - (ta-hall-notify nom wen.top ~ new wat.top) + (ta-write-topic col top) + (ta-hall-notify col wen.top ~ new wat.top) :: ++ ta-change-comment - |= {nom/term top/@da com/comment src/?($file $coll)} + |= {col/term top/@da com/comment src/?($file $coll)} ^+ +> - =+ old=(get-comment nom top wen.com) + =+ old=(get-comment col top wen.com) :: only original poster and host can edit. ?. |(?=($~ old) =(who.u.old src.bol) ?=($file src)) +>.$ @@ -301,50 +303,50 @@ :: change last edit date. =. com com(wed now.bol) =. +>.$ - (ta-write-comment nom top com) - (ta-hall-notify nom top `wen.com ?=($~ old) wat.com) + (ta-write-comment col top com) + (ta-hall-notify col top `wen.com ?=($~ old) wat.com) :: :: %writing-files :: ++ ta-write-config - |= {nom/term cof/config} + |= {col/term cof/config} ^+ +> %- ta-emit =/ paf/path %- make-path - /[nom]/collections-config + /[col]/collections-config :* ost.bol %info - /config/[nom] + /config/[col] our.bol (foal:space:userlib paf [%collections-config !>(cof)]) == :: ++ ta-write-topic - |= {nom/term top/topic} + |= {col/term top/topic} ^+ +> =+ wan=(scot %da wen.top) - =+ pax=(make-path /[nom]/[wan]/collections-topic) + =+ pax=(make-path /[col]/[wan]/collections-topic) %- ta-emit :* ost.bol %info - /topic/[nom]/[wan] + /topic/[col]/[wan] our.bol (foal:space:userlib pax [%collections-topic !>(top)]) == :: ++ ta-write-comment - |= {nom/term top/@da com/comment} + |= {col/term top/@da com/comment} ^+ +> =+ tap=(scot %da top) =+ wan=(scot %da wen.com) =/ pax/path %- make-path - /[nom]/[tap]/[wan]/collections-comment + /[col]/[tap]/[wan]/collections-comment %- ta-emit :* ost.bol %info - /comment/[nom]/[tap]/[wan] + /comment/[col]/[tap]/[wan] our.bol (foal:space:userlib pax [%collections-comment !>(com)]) == @@ -352,9 +354,9 @@ :: %hall-changes :: ++ ta-hall-create - |= {nom/term top/(unit @da) cof/config} + |= {col/term top/(unit @da) cof/config} ^+ +> - =+ nam=(make-circle nom top) + =+ nam=(make-circle col top) =. +>.$ %- ta-hall-action [%create nam desc.cof ?:(publ.cof %journal %village)] @@ -362,7 +364,7 @@ %- ta-emit :* 0 %peer - /hall/[nom] + /hall/[col] [our.bol %hall] /circle/[nam]/config-l == @@ -372,38 +374,38 @@ %- ta-hall-action ::NOTE %source also subs to local config & presence, but :: that generally won't result in visible notifications. - :^ %source (make-circle nom ~) & + :^ %source (make-circle col ~) & [`source:hall`[[our.bol nam] ~] ~ ~] ?~ mems.cof +>.$ (ta-hall-set-permissions nam & mems.cof) :: ++ ta-hall-set-description - |= {nom/term des/cord} + |= {col/term des/cord} ^+ +> %- ta-hall-action - [%depict (make-circle nom ~) des] + [%depict (make-circle col ~) des] :: ++ ta-hall-set-visible - |= {nom/term vis/?} + |= {col/term vis/?} ^+ +> %- ta-hall-action - [%public vis our.bol (make-circle nom ~)] + [%public vis our.bol (make-circle col ~)] :: ++ ta-hall-set-permissions - |= {nom/term inv/? sis/(set ship)} + |= {col/term inv/? sis/(set ship)} ^+ +> %- ta-hall-action - [%permit (make-circle nom ~) inv sis] + [%permit (make-circle col ~) inv sis] :: ++ ta-hall-notify - |= {nom/term top/@da com/(unit @da) new/? wat/wain} + |= {col/term top/@da com/(unit @da) new/? wat/wain} ^+ +> %- ta-hall-action =- :+ %phrase [[our.bol tar] ~ ~] [%fat [%text wat] [%lin | msg]]~ ^- {tar/naem:hall msg/cord} ::TODO - [(make-circle nom ~) 'TODO'] + [(make-circle col ~) 'TODO'] -- :: ++ sane-cord @@ -444,29 +446,29 @@ .^(arch %cy pax) :: ++ get-config - |= nom/term + |= col/term ^- (unit config) =/ pax %- make-path - /[nom]/collections-config + /[col]/collections-config ?. (has-file pax) ~ `.^(config %cx pax) :: ++ get-topic - |= {nom/term top/@da} + |= {col/term top/@da} ^- (unit topic) =/ pax %- make-path - /[nom]/(scot %da top)/collections-topic + /[col]/(scot %da top)/collections-topic ?. (has-file pax) ~ `.^(topic %cx pax) :: ++ get-comment - |= {nom/term top/@da wen/@da} + |= {col/term top/@da wen/@da} ^- (unit comment) =/ pax %- make-path - /[nom]/(scot %da top)/(scot %da wen)/collections-comment + /[col]/(scot %da top)/(scot %da wen)/collections-comment ?. (has-file pax) ~ `.^(comment %cx pax) --