Merge branch 'ford-master-state-machine' into ford-turbo

This commit is contained in:
Elliot Glaysher 2018-07-23 15:20:29 -07:00
commit bf696a049d
11 changed files with 2537 additions and 2226 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/sec/**/*.atom
*.swp

282
app/static.hoon Normal file
View File

@ -0,0 +1,282 @@
::
:::: /hoon/static/app
::
::
:: XX REVIEW: should this be a generator?
:: - it makes sense, since it doesnt need to store state between calls, its just producing a result
:: - but we can't pass arbitrary run-time arguments to ford runes.... yet
:: and we need that to specify the input file
:: - but we could have a special fixed directory to place our input files, so that we don't
:: have to pass the location as an argument at runtime
:: - but then could you have multiple separate static builds?
:: - let it take all files in a directory, build them as html
:: spider the links, then keep a map from all top-level files a set of their connected files
:: - then let the generator args specify which top-level file to write out and where to write it
:: - how do we know what a top-level file is? or can we treat all files as top levels files
:: mapped to their corresponding subset of linked files?
::
::
/? 309
/- static
|%
::::
:::: structures
::::
+= move [bone card]
+= card
$% [%poke wire dock poke]
[%exec wire ship (unit bilk:ford)]
[%info wire ship toro:clay]
==
+= poke
$% [%static-action action:static]
==
::::
:::: utilities
::::
::
:: +find-links: takes a manx and returns a list of all href and src links in it
::
++ find-links
|= max=manx
^- (list tape)
%+ weld
::
%+ roll a.g.max
|= [[n=mane v=tape] out=(list tape)]
?: ?=(?(%href %src) n)
[v out]
out
::
%+ roll c.max
|= [m=manx out=(list tape)]
(weld out (find-links m))
::
+= relative
$% [%root wir=wire ext=mark]
[%here wir=wire ext=mark]
[%up n=@ wir=wire ext=mark]
==
::
++ parse-relative
|= pax=tape
^- (unit relative)
%+ rust pax
%+ cook
|= a=^
?: ?=([%up @] -.a)
((hard relative) [%up ->.a +.a])
((hard relative) a)
;~ plug
::
;~ pose
(cold %root fas)
::
(cold [%up 1] ;~(plug dot fas))
::
%+ cook
|= a=(list %up)
[%up +((lent a))]
(plus (cold %up ;~(plug dot dot fas)))
::
(cold [%up 1] (easy ~))
==
::
%+ cook
|= a=(list coin)
%+ turn a
|= b=coin
~(rent co b)
(more fas nuck:so)
::
;~ pose
(cold %html (jest '.html'))
(cold %md (jest '.md'))
(cold %umd (jest '.umd'))
(cold %hoon (jest '.hoon'))
(cold %js (jest '.js'))
(cold %css (jest '.css'))
(easy %$)
==
==
::
++ process-relative
|= [loc=beam rel=relative]
^- [loc=beam ext=mark]
|-
?- -.rel
%root
[loc(s (flop wir.rel)) ext.rel]
::
%here
[loc(s (flop (weld (flop s.loc) wir.rel))) ext.rel]
::
%up
%= $
s.loc (slag n.rel s.loc)
rel [%here wir.rel ext.rel]
==
==
::
+= state
$: waiting=(map wire [in=beam out=beam])
finished=(set beam)
==
--
::::
:::: app proper
::::
|_ [bol=bowl:gall sta=state]
::
++ this .
::
:: +prep: we don't need no state
::
++ prep
|= old=(unit)
:- ~
this(sta *state)
::
:: +poke-static-action: send build request to ford and wait for result
::
++ poke-static-action
|= act=action:static
^- (quip move _this)
?- -.act
%build
?> !?=(~ s.in.act)
=. s.out.act [-.s.in.act s.out.act]
=/ sil (find-file in.act ext.act)
=/ wir=wire /build/(scot %p (sham [in.act out.act]))
=/ car [%exec wir our.bol `[-.in.act sil]]
:- [ost.bol car]~
%= this
waiting.sta (~(put by waiting.sta) wir [in.act out.act])
==
==
::
:: +find-file: checks for file at %umd, %md, %html, %js, %css, and %hoon extensions
:: returns a silk to send to ford
::
++ find-file
|= [loc=beam ext=mark]
^- silk:ford
?> !?=(~ s.loc)
::
=/ try-exts=(list @tas)
:~ %hoon
%md
%umd
%html
==
:: if ext is unspecified then try the extensions defined in try-exts
::
=/ normed-ext=@tas
?: =(%$ ext)
|-
?~ try-exts
~_ leaf+"Error: Non-existent file: {<(en-beam:format loc)>}" !!
=/ pax (weld (en-beam:format loc) [i.try-exts ~])
=/ ark .^(arch %cy pax)
?~ fil.ark
$(try-exts t.try-exts)
i.try-exts
:: otherwise just try the extension given
::
=/ pax (weld (en-beam:format loc) [ext ~])
=/ ark .^(arch %cy pax)
?~ fil.ark
~_ leaf+"Error: Non-existent file: {<pax>}" !!
ext
:: form silk for the given mark
::
?: ?=(%hoon normed-ext)
:: [%cast %hymn [%bake %noun *coin loc]]
[%cast %hymn [%ride [%cnts p=~[[%.y p=1]] q=~] [%core loc]]]
?: ?=(%md normed-ext)
[%cast %elem [%cast %down [%file loc(s [normed-ext s.loc])]]]
?: ?=(%umd normed-ext)
[%cast %elem [%file loc(s [normed-ext s.loc])]]
?: ?=(%html normed-ext)
[%cast %hymn [%file loc(s [normed-ext s.loc])]]
?: ?=(?(%js %css) normed-ext)
[%file loc(s [normed-ext s.loc])]
~_ leaf+"Error: Unsupported filetype: {<normed-ext>}" !!
::
:: +coup: handle errors
::
++ coup
|= [wir=wire err=(unit tang)]
^- (quip move _this)
?~ err
[~ this]
(mean u.err)
::
:: +made: process ford result
::
++ made
|= [wir=path hash=@uvJ gag=gage:ford]
^- (quip move _this)
:: if ford build failed, print out error and crash
:: otherwise, assert we got single result, not a table
::
?: ?=(%| -.gag)
~_ p.gag !!
?> ?=(%& -.gag)
:: retrieve the build in/out beams
::
=/ bem=[in=beam out=beam] (need (~(get by waiting.sta) wir))
?> &(!?=(~ s.in.bem) !?=(~ s.out.bem))
::
=/ file-contents q.q.p.gag
=/ file-type=mark p.p.gag
:: finish by removing build from waiting list
:: and adding it to our finished list, to prevent infinite build loops
::
:_ %= this
waiting.sta (~(del by waiting.sta) wir)
finished.sta (~(put in finished.sta) in.bem)
==
::
^- (list move)
:: if js or css, pass it through without processing it
::
?. ?=(?(%hymn %elem) file-type)
?> ?=(?(%js %css) file-type)
=. s.out.bem [file-type s.out.bem]
=/ pax (en-beam:format out.bem)
?> ?=(@t file-contents)
=/ fol (foal:space:userlib pax [file-type !>(file-contents)])
:_ ~
[ost.bol %info /write our.bol fol]
:: get all links from manx
::
=/ file-contents=manx ((hard manx) q.q.p.gag)
=/ links=(list tape) (find-links file-contents)
:: process list of links into list of static-action
::
=/ new-actions=(list move)
%+ roll links
|= [link=tape output=(list move)]
=/ parsed (parse-relative link)
?~ parsed
output
=/ new-in (process-relative in.bem u.parsed)
=/ new-out (process-relative out.bem u.parsed)
=. s.loc.new-out (slag 1 s.loc.new-out)
?: (~(has in finished.sta) loc.new-in)
output
:_ output
[ost.bol %poke /act [our.bol dap.bol] %static-action [%build loc.new-in loc.new-out ext.new-in]]
:: write html output file to clay
::
=. s.out.bem [%html s.out.bem]
~& (flop s.out.bem)
=/ pax (en-beam:format out.bem)
=/ fol (foal:space:userlib pax [%html !>((crip (en-xml:html file-contents)))])
:_ new-actions
[ost.bol %info /write our.bol fol]
--

File diff suppressed because it is too large Load Diff

16
gen/static/build.hoon Normal file
View File

@ -0,0 +1,16 @@
::
:::: /hoon/build/static/gen
::
/? 309
:- %say
|= $: [now=@da eny=@uvJ bec=beak]
[input=path output=path ~]
~
==
~_ leaf+"Error: Invalid beam. Try prefixing your path with % or /===/"
:* %static-action
%build
(need (de-beam:format input))
(need (de-beam:format output))
%$
==

11
mar/static/action.hoon Normal file
View File

@ -0,0 +1,11 @@
::
:::: /hoon/action/static/mar
::
/? 309
/- static
|_ act=action:static
++ grab
|%
++ noun action:static
--
--

View File

@ -6,6 +6,20 @@
/% /^ {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/
==

12
sur/static.hoon Normal file
View File

@ -0,0 +1,12 @@
::
:::: /hoon/static/sur
::
/? 309
|%
::
:: +action: kickoff generation of site tree
::
+= action
$% [%build in=beam out=beam ext=mark]
==
--

View File

@ -4,7 +4,7 @@
=> =~
:: structures
=, ames
=+ protocol-version=1
=+ protocol-version=2
|%
+= move [p=duct q=(wind note:able gift:able)] :: local move
--
@ -170,8 +170,8 @@
0w0 :: 52, ~rut, Curtis Yarvin
0w2L.M6-o5.DDTFL.R4sFL.7Zuay :: 53, ~tyl, Tlon Investor 11 (oldkey)
0w0 :: 54, ~wyd, Curtis Yarvin
0w0 :: 55, ~tep, Curtis Yarvin
0w0 :: 56, ~bes, Curtis Yarvin
0w0 :: 55, ~tep, Rivendell
0w0 :: 56, ~bes, NSPV
0w0 :: 57, ~dex, Jared Hance
0w0 :: 58, ~sef, Owen Rescher
0w0 :: 59, ~wyc, Galen Wolfe-Pauly

View File

@ -2410,9 +2410,17 @@
++ read-p-in
|= {pax/path pes/regs}
^- dict
=+ rul=(~(get by pes) pax)
?^ rul [pax u.rul]
?~ pax [/ %white ~]
=/ rul/(unit rule) (~(get by pes) pax)
?^ rul
:+ pax mod.u.rul
%- ~(rep in who.u.rul)
|= {w/whom out/(pair (set ship) (map @ta crew))}
?: ?=({$& @p} w)
[(~(put in p.out) +.w) q.out]
=/ cru/(unit crew) (~(get by cez.ruf) +.w)
?~ cru out
[p.out (~(put by q.out) +.w u.cru)]
?~ pax [/ %white ~ ~]
$(pax (scag (dec (lent pax)) `path`pax))
::
++ may-read
@ -2445,13 +2453,18 @@
++ allowed-by
|= {who/ship pax/path pes/regs}
^- ?
=+ rul=rul:(read-p-in pax pes)
=- ?:(?=($black mod.rul) !- -)
%- ~(rep in who.rul)
|= {w/whom h/_|}
?: h &
?: ?=($& -.w) =(p.w who)
(~(has in (fall (~(get by cez) p.w) ~)) who)
=/ rul/real rul:(read-p-in pax pes)
=/ in-list/?
?| (~(has in p.who.rul) who)
::
%- ~(rep by q.who.rul)
|= {{@ta cru/crew} out/_|}
?: out &
(~(has in cru) who)
==
?: =(%black mod.rul)
!in-list
in-list
::
:: Checks for existence of a node at an aeon.
::

File diff suppressed because it is too large Load Diff

View File

@ -444,7 +444,7 @@
++ cass {ud/@ud da/@da} :: cases for revision
++ coop (unit ares) :: e2e ack
++ crew (set ship) :: permissions group
++ dict {src/path rul/rule} :: effective permission
++ dict {src/path rul/real} :: effective permission
++ dome :: project state
$: ank/ankh :: state
let/@ud :: top id
@ -508,6 +508,10 @@
{$mult p/mool} :: next version of any
{$many p/? q/moat} :: track range
== ::
++ real :: resolved permissions
$: mod/?($black $white) ::
who/(pair (set ship) (map @ta crew)) ::
== ::
++ regs (map path rule) :: rules for paths
++ riff {p/desk q/(unit rave)} :: request+desist
++ rite :: new permissions
@ -885,6 +889,12 @@
:: our: who our ship is (remove after cc-release)
::
our=@p
:: live: whether we run this build live
::
:: A live build will subscribe to further updates and keep the
:: build around.
::
live=?
:: plan: the schematic to build
::
=schematic
@ -970,7 +980,6 @@
$: %success
$^ [head=build-result tail=build-result]
$% [%$ =cage]
[%pin date=@da =build-result]
[%alts =build-result]
[%bake =cage]
[%bunt =cage]
@ -978,7 +987,6 @@
[%cast =cage]
[%core =vase]
[%diff =cage]
[%dude =build-result]
[%hood =scaffold]
[%join =cage]
[%list results=(list build-result)]
@ -989,7 +997,6 @@
[%plan =vase]
[%reef =vase]
[%ride =vase]
[%same =build-result]
[%scry =cage]
[%slim [=type =nock]]
[%slit =type]
@ -1360,7 +1367,7 @@
cranes=(list crane)
:: sources: hoon sources, either parsed or on the filesystem
::
sources=(list brick)
sources=(list hoon)
==
:: +cable: a reference to something on the filesystem
::
@ -1372,19 +1379,6 @@
::
file-path=term
==
:: +brick: hoon code, either directly specified or referencing clay
::
+= brick
$% $: :: %direct: inline parsed hoon
::
%direct
source=hoon
==
$: :: %indirect: reference to a hoon file in clay
::
%indirect
location=beam
== ==
:: +truss: late-bound path
::
:: TODO: the +tyke data structure should be rethought, possibly as part
@ -1541,7 +1535,6 @@
?- -.+.result
^ [%noun (slop q:$(result head.result) q:$(result tail.result))]
%$ cage.result
%pin $(result build-result.result)
%alts $(result build-result.result)
%bake cage.result
%bunt cage.result
@ -1549,7 +1542,6 @@
%cast cage.result
%core [%noun vase.result]
%diff cage.result
%dude $(result build-result.result)
%hood [%noun !>(scaffold.result)]
%join cage.result
%list [%noun -:!>(*(list cage)) (turn results.result result-to-cage)]
@ -1560,7 +1552,6 @@
%plan [%noun vase.result]
%reef [%noun vase.result]
%ride [%noun vase.result]
%same $(result build-result.result)
%scry cage.result
%slim [%noun !>([type nock]:result)]
%slit [%noun !>(type.result)]