urbit/pkg/base-dev/mar/story.hoon

71 lines
2.1 KiB
Plaintext
Raw Normal View History

/- *story
2022-01-31 00:01:45 +03:00
/+ *story
2022-01-16 07:37:51 +03:00
!:
|_ tale=story
2022-01-31 00:02:47 +03:00
+$ story-diff [additions=story deletions=story]
::
2022-01-16 07:37:51 +03:00
++ grad
|%
++ form %story-diff
++ diff
|= tory=story
^- story-diff
2022-01-31 00:03:10 +03:00
:: Given new story (tory), old story (tale), compute the diff
:: additions = new - old
:: deletions = old - new
[(dif-ju tory tale) (dif-ju tale tory)]
2022-01-16 07:37:51 +03:00
++ pact
|= dif=story-diff
2022-01-31 00:03:10 +03:00
:: compute the new story after applying dif to tale
2022-01-16 07:37:51 +03:00
^- story
2022-01-31 00:03:10 +03:00
=. tale (uni-ju tale additions.dif)
=. tale (dif-ju tale deletions.dif)
tale
2022-01-16 07:37:51 +03:00
++ join
|= [ali=story-diff bob=story-diff]
^- (unit story-diff)
2022-01-31 00:03:10 +03:00
=/ joined-additions (uni-ju additions.ali additions.bob)
=/ joined-deletions (uni-ju deletions.ali deletions.bob)
::
2022-01-16 07:37:51 +03:00
:: in a true join, we'd do an intersection and see if the vals are not exactly the same
:: which means we have a conflict, then we'd produce null, kick the flow to mash
%- some
2022-01-31 00:03:10 +03:00
[joined-additions joined-deletions]
2022-01-16 07:37:51 +03:00
++ mash
:: called by meld, force merge, annotating conflicts
|= $: [als=ship ald=desk ali=story-diff]
[bos=ship bod=desk bob=story-diff]
==
^- story-diff
(need (join ali bob)) :: XX temporary, only because join doesn't fail
--
::
++ grow :: convert to
|% ::
++ mime :: to %mime
[/text/x-urb-story (as-octs:mimes:html (of-wain:format txt))]
++ txt
^- wain
2022-02-04 20:53:13 +03:00
%- snoc :_ '' :: ensures terminating newline is present
%+ murn ~(tap by tale)
2022-01-30 23:59:58 +03:00
|= [[=tako:clay =proses]]
2022-01-26 19:41:08 +03:00
^- (unit cord)
?~ proses ~
%- some
2022-01-26 19:41:08 +03:00
%- crip
;: welp
2022-01-30 23:59:58 +03:00
(tako-to-text tako)
(proses-to-text proses)
2022-01-26 19:41:08 +03:00
"---"
==
--
++ grab
|% :: convert from
++ noun story :: clam from %noun
++ mime :: retrieve form %mime
|= [p=mite q=octs]
=/ story-text `@t`q.q
2022-02-05 14:16:59 +03:00
`story`(rash story-text parse-story)
--
--