Merge branch 'data-dep' into tree-comments

handle chrome/data separation in an official manner
This commit is contained in:
Anton Dyudin 2016-02-09 19:43:19 -08:00
commit bd143385c5
10 changed files with 136 additions and 93 deletions

View File

@ -197,15 +197,6 @@
=+ cuh=(turn `(list ,@t)`cug |=(a=@t set-cookie/a)) =+ cuh=(turn `(list ,@t)`cug |=(a=@t set-cookie/a))
hit(q (weld cuh q.hit)) hit(q (weld cuh q.hit))
:: ::
++ inject :: inject dependency
|= [dep=@uvH max=[[%html ~] [[%head ~] hed=marl] [[%body ~] tal=marl] ~]]
^- manx
=: hed.max :_(hed.max ;meta(charset "utf-8", urb_injected "");)
tal.max (welp tal.max ;script(urb_injected ""):"{(trip etag:js)}" ~)
==
?~ dep max
max(hed :_(hed.max ;script@"/~/on/{<dep>}.js"(urb_injected "");))
::
++ add-json :: inject window.urb ++ add-json :: inject window.urb
|= [urb=json jaz=cord] ^- cord |= [urb=json jaz=cord] ^- cord
=- (cat 3 (crip -) jaz) =- (cat 3 (crip -) jaz)
@ -228,13 +219,14 @@
[sas ~[content-type/(moon mit)] [~ (taco rez)]] [sas ~[content-type/(moon mit)] [~ (taco rez)]]
:: ::
++ render-tang :: tanks to manx ++ render-tang :: tanks to manx
|= tan=tang |= [dep=@uvH tan=tang]
;html ;html
;head ;head
;link(rel "stylesheet", href "/lib/base.css"); ;link(rel "stylesheet", href "/lib/base.css");
;title: server error ;title: server error
== ==
;body:div#c.err:pre:code:"{(wush 80 tan)}" ;body:div#c.err:pre:code:"{(wush 80 tan)}"
;script@"/~/on/{<dep>}.js";
== ==
:: ::
++ favi :: XX favicon ++ favi :: XX favicon
@ -390,23 +382,6 @@
urb.wreq.abort() // trigger keep urb.wreq.abort() // trigger keep
} }
} }
urb.waspElem = function(ele){
url = ele.src || ele.href
if(!url || (new URL(url)).host != document.location.host)
return;
urb.waspUrl(url)
}
urb.waspUrl = function(url){
var xhr = new XMLHttpRequest()
xhr.open("HEAD", url)
xhr.send()
xhr.onload = urb.waspLoadedXHR
}
urb.waspLoadedXHR = function(){urb.wasp(urb.getXHRWasp(this))}
urb.getXHRWasp = function(xhr){
var dep = xhr.getResponseHeader("etag")
if(dep) return JSON.parse(dep.substr(2))
}
''' '''
:: ::
@ -461,14 +436,6 @@
function(){document.getElementById("c").innerHTML = "" } function(){document.getElementById("c").innerHTML = "" }
)} )}
''' '''
++ etag
'''
if(!window.urb) window.urb = {}
urb.waspAll = function(sel){
Array.prototype.map.call(document.querySelectorAll(sel), urb.waspElem)
}
if(urb.wasp){urb.waspAll('script'); urb.waspAll('link')}
'''
-- --
++ xml ++ xml
|% |%
@ -847,16 +814,7 @@
?. ?=(%mime p.cay) ?. ?=(%mime p.cay)
=+ bek=-:(need (tome p.tee)) =+ bek=-:(need (tome p.tee))
=+ bik=?+(r.bek bek [%ud %0] bek(r da/now)) =+ bik=?+(r.bek bek [%ud %0] bek(r da/now))
=- (execute tee bik [%flag [p.sih `~] -]) (execute tee bik [%flag [p.sih `~] %cast %mime q.sih])
=- `silk`[%cast %mime `[p.cay -]]
?. ?=([%ud 0] r.bek) q.cay
?+ p.cay q.cay :: inject dependency long-poll
%urb =< (slam !>(.) q.cay)
|= urb=manx
~| [%malformed-urb urb]
?> ?=([[%html ~] [[%head ~] *] [[%body ~] *] ~] urb)
(inject p.sih urb)
==
~| q.q.cay ~| q.q.cay
=+ ((hard ,[mit=mite rez=octs]) q.q.cay) =+ ((hard ,[mit=mite rez=octs]) q.q.cay)
=+ dep=(crip "W/{(pojo %s (scot %uv p.sih))}") =+ dep=(crip "W/{(pojo %s (scot %uv p.sih))}")
@ -920,7 +878,7 @@
|= [sas=@ud dep=@uvH mez=tang] |= [sas=@ud dep=@uvH mez=tang]
^+ +> ^+ +>
:: (back ha/~ dep %tang !>(mez)) ::tang->urb chain may be source of failure :: (back ha/~ dep %tang !>(mez)) ::tang->urb chain may be source of failure
(give-html sas ~ (inject dep (render-tang mez))) (give-html sas ~ (render-tang dep mez))
:: ::
++ give-html ++ give-html
|= [sas=@ud cug=(list ,@t) max=manx] |= [sas=@ud cug=(list ,@t) max=manx]

View File

@ -48,6 +48,7 @@
++ cafe :: live cache ++ cafe :: live cache
$: p=(set calx) :: used $: p=(set calx) :: used
q=(map ,* calx) :: cache q=(map ,* calx) :: cache
r=(map ,@uvH deps) :: dependss
== :: == ::
:: :: :: ::
++ calm :: cache metadata ++ calm :: cache metadata
@ -101,11 +102,6 @@
^- cafe :: ^- cafe ::
a(q (~(put by q.a) [-.b q.b] b)) :: a(q (~(put by q.a) [-.b q.b] b)) ::
:: :: :: ::
++ chub :: cache merge
|= [a=cafe b=cafe] ::
^- cafe ::
[(~(uni in p.a) p.b) (~(uni by q.a) q.b)] ::
:: ::
++ faun (flux |=(a=vase [%& %noun a])) :: vase to gage ++ faun (flux |=(a=vase [%& %noun a])) :: vase to gage
++ feel (flux |=(a=cage q.a)) :: cage to vase ++ feel (flux |=(a=cage q.a)) :: cage to vase
++ furl :: unwrap gage to cage ++ furl :: unwrap gage to cage
@ -316,6 +312,12 @@
[%warp [our p.bem] q.bem [~ %sing ren r.bem (flop s.bem)]] [%warp [our p.bem] q.bem [~ %sing ren r.bem (flop s.bem)]]
== ==
:: ::
++ clad :: hash dependencies
|* hoc=(bolt) ^+ [*@uvH hoc]
?: ?=(%1 -.q.hoc) [*@uvH hoc]
=^ dep r.p.hoc (daze [p.q r.p]:hoc)
[dep hoc]
::
++ clef :: cache a result ++ clef :: cache a result
|* sem=* |* sem=*
|* [hoc=(bolt) fun=(burg)] |* [hoc=(bolt) fun=(burg)]
@ -485,7 +487,7 @@
++ dash :: process cache ++ dash :: process cache
|= cof=cafe |= cof=cafe
^+ +> ^+ +>
%_(+> jav.bay q.cof) %_(+> jav.bay q.cof, deh.bay r.cof)
:: ::
++ diff :: diff ++ diff :: diff
|= [cof=cafe kas=silk kos=silk] |= [cof=cafe kas=silk kos=silk]
@ -532,29 +534,28 @@
== ==
:: ::
++ daze :: remember depends ++ daze :: remember depends
|= dep=(set beam) |= [dep=(set beam) deh=(map ,@uvH deps)]
^+ [*@uvH deh.bay] ^+ [*@uvH deh]
=. dep =. dep
=< (sa (skip (~(tap in dep)) .)) =< (sa (skip (~(tap in dep)) .))
|= dap=beam ^- ? |= dap=beam ^- ?
?~ s.dap | ?~ s.dap |
=>(.(s.dap t.s.dap) |((~(has in dep) dap) $)) =>(.(s.dap t.s.dap) |((~(has in dep) dap) $))
?~ dep [0v0 deh.bay] ?~ dep [0v0 deh]
=+ hap=(sham dep) =+ hap=(sham dep)
?: (~(has by deh.bay) hap) ?: (~(has by deh) hap)
[hap deh.bay] [hap deh]
[hap (~(put by deh.bay) hap [%init dep])] [hap (~(put by deh) hap [%init dep])]
:: ::
++ exec :: execute app ++ exec :: execute app
^+ ..zo ^+ ..zo
?: !=(~ q.kig) ..zo ?: !=(~ q.kig) ..zo
=+ bot=(make [~ jav.bay] kas) =+ bot=(make [~ jav.bay deh.bay] kas)
=^ dep bot (clad bot)
=. ..exec (dash p.bot) =. ..exec (dash p.bot)
?- -.q.bot ?- -.q.bot
%0 =^ dep deh.bay (daze p.q.bot) %0 amok:(expo [%made dep q.q.bot])
amok:(expo [%made dep q.q.bot]) %2 amok:(expo [%made dep %| q.q.bot])
%2 =^ dep deh.bay (daze p.q.bot)
amok:(expo [%made dep %| q.q.bot])
%1 =+ zuk=(~(tap by p.q.bot) ~) %1 =+ zuk=(~(tap by p.q.bot) ~)
=< abet =< abet
|- ^+ ..exec |- ^+ ..exec
@ -678,6 +679,7 @@
(stag %ape ;~(pfix sig ape:read)) (stag %ape ;~(pfix sig ape:read))
(stag %arg ;~(pfix buc ape:read)) (stag %arg ;~(pfix buc ape:read))
(stag %alt ;~(pfix bar alt:read)) (stag %alt ;~(pfix bar alt:read))
(stag %dep ;~(pfix hax day:read))
(stag %dub ;~(pfix tis dub:read)) (stag %dub ;~(pfix tis dub:read))
(stag %fan ;~(pfix dot fan:read)) (stag %fan ;~(pfix dot fan:read))
(stag %for ;~(pfix com for:read)) (stag %for ;~(pfix com for:read))
@ -1431,10 +1433,19 @@
|= cof=cafe ^- (bolt cage) |= cof=cafe ^- (bolt cage)
?~ p.hon (flaw cof leaf/"ford: out of options" ~) ?~ p.hon (flaw cof leaf/"ford: out of options" ~)
(coop ^$(cof cof, hon i.p.hon) ..$(p.hon t.p.hon)) (coop ^$(cof cof, hon i.p.hon) ..$(p.hon t.p.hon))
::
%dep
=+ [dep bot]=(clad $(hon p.hon)) :: XX review
%+ cope bot
%- flux
|= [mark vax=vase]
[%noun (slop [atom/'uvH' dep] vax)]
:: ::
%dub %dub
%+ cope $(hon q.hon) %+ cope $(hon q.hon)
(flux |=([mar=mark vax=vase] [mar [%face p.hon p.vax] q.vax])) %- flux
|= [mar=mark vax=vase]
[mar [%face p.hon p.vax] q.vax]
:: ::
%fan %fan
%- cope :_ (flux |=(a=vase noun/a)) %- cope :_ (flux |=(a=vase noun/a))
@ -1675,7 +1686,7 @@
?> (~(has by q.kig) tik) ?> (~(has by q.kig) tik)
=+ `[ren=care bem=beam]`(~(got by q.kig) tik) =+ `[ren=care bem=beam]`(~(got by q.kig) tik)
?~ rot ?~ rot
=^ dep deh.bay (daze ~) :: dependencies? =^ dep deh.bay (daze ~ deh.bay) :: dependencies?
amok:(expo [%made dep %| (smyt ren (tope bem)) ~]) amok:(expo [%made dep %| (smyt ren (tope bem)) ~])
=+ (cat 3 'c' ren) =+ (cat 3 'c' ren)
exec(q.kig (~(del by q.kig) tik), keg (~(put by keg) [- bem] r.u.rot)) exec(q.kig (~(del by q.kig) tik), keg (~(put by keg) [- bem] r.u.rot))

View File

@ -2493,6 +2493,7 @@
$% [%ape p=twig] :: /~ twig by hand $% [%ape p=twig] :: /~ twig by hand
[%arg p=twig] :: /$ argument [%arg p=twig] :: /$ argument
[%alt p=(list horn)] :: /| options [%alt p=(list horn)] :: /| options
[%dep p=horn] :: /# insert dephash
[%dub p=term q=horn] :: /= apply face [%dub p=term q=horn] :: /= apply face
[%fan p=(list horn)] :: /. list [%fan p=(list horn)] :: /. list
[%for p=(list (pair path:spur horn))] :: /, switch by path [%for p=(list (pair path:spur horn))] :: /, switch by path

9
lib/urb-split.hoon Normal file
View File

@ -0,0 +1,9 @@
::
:::: /hoon/urb-split/lib
::
|= [dep=@uvH urb=manx] ^- [hed=[@uvh marl] bod=[@uvH marl]]
~| [%malformed-urb urb] :: XX types
?> ?=([[%html ~] [[%head ~] *] [[%body ~] *] ~] urb)
=+ `[[%html ~] [[%head ~] hed=marl] [[%body ~] bod=marl] ~]`urb
:- [dep hed] :: Assume all dependencies are hard
[0v0 bod]

View File

@ -2,19 +2,42 @@
:::: /hoon/urb/mar :::: /hoon/urb/mar
:: ::
/? 314 /? 314
/= urb-wasp-data-js /: /%/wasp-data /js/
!: !:
|_ own=manx |_ [[dep=@uvH hed=marl] [dep-bod=@uvH bod=marl]]
:: ++ linked-deps-js
'''
urb.waspAll = function(sel){
[].map.call(document.querySelectorAll(sel), urb.waspElem)
}
if(urb.wasp){urb.waspAll('script'); urb.waspAll('link')}
'''
++ grow :: convert to ++ grow :: convert to
|% |%
++ html (crip (poxo own)) :: convert to %html
++ mime [/text/html (taco html)] :: convert to %mime ++ mime [/text/html (taco html)] :: convert to %mime
++ html (crip (poxo hymn)) :: convert to %html
++ hymn :: inject dependencies
^- manx
;html
;head
;meta(charset "utf-8", urb_injected "");
;* ?~ dep ~
:~ ;script@"/~/on/{<dep>}.js"(urb_injected "");
;script(urb_injected "")
;- (trip urb-wasp-data-js)
;- "urb.waspData({(pojo %s (scot %uv dep-bod))})"
==
==
;* hed
==
;body
;* bod
;script(urb_injected ""):"{(trip linked-deps-js)}"
==
==
-- --
++ grab ++ grab
|% :: convert from |% :: convert from
++ noun manx :: clam from %noun ++ noun ,[@uvH manx] :: clam from %noun
:: conversion from hymn is handled specially by %eyre,
:: which injects dependency information
:: ++ hymn !! :: inject into %hymn
-- --
-- --

30
mar/urb/wasp-data.js Normal file
View File

@ -0,0 +1,30 @@
urb.waspElem = function(ele){
url = ele.src || ele.href
if(!url || (new URL(url)).host != document.location.host)
return;
urb.waspUrl(url)
}
urb.waspUrl = function(url){
var xhr = new XMLHttpRequest()
xhr.open("HEAD", url)
xhr.send()
xhr.onload = urb.waspLoadedXHR
}
urb.waspLoadedXHR = function(){urb.wasp(urb.getXHRWasp(this))}
urb.getXHRWasp = function(xhr){
var dep = xhr.getResponseHeader("etag")
if(dep) return JSON.parse(dep.substr(2))
}
urb.datadeps = {}
urb.waspData = function(dep){
urb.datadeps[dep] = true
urb.wasp(dep)
}
urb.ondataupdate = urb.onupdate // overridable
var _onupdate = urb.onupdate
urb.onupdate = function(dep){
if(urb.datadeps[dep]) urb.ondataupdate(dep)
else _onupdate(dep)
}

14
ren/tree/body.hoon Normal file
View File

@ -0,0 +1,14 @@
::
:::: /hoon/body/tree/ren
::
/? 314
/= dat /% /tree-json/ :: default include
^- marl
;= ;script(type "text/javascript"): window.tree = {(pojo (joba %data dat))}
;div.container
;div.row#main
;div#head;
;div#body;
==
==
==

View File

@ -1,10 +1,8 @@
:: ::
:::: /hoon/hymn/tree/ren :::: /hoon/head/tree/ren
:: ::
:: ::
/? 314 /? 314
/- tree-include
/= dat /% /tree-json/ :: default include
/= tub /$ |=([bem=beam *] (flop s.bem)) /= tub /$ |=([bem=beam *] (flop s.bem))
/= aut /= aut
/$ %+ cork fuel :: after parsing params, /$ %+ cork fuel :: after parsing params,
@ -15,9 +13,8 @@
!: !:
:::: ::::
:: ::
;html ^- marl
;head ;= ;title: Tree
;title: Tree
;meta(name "viewport", content "width=device-width, initial-scale=1"); ;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"); ;link(type "text/css", rel "stylesheet", href "//cdnjs.cloudflare.com/ajax/libs/codemirror/4.3.0/codemirror.min.css");
;link(type "text/css", rel "stylesheet", href "/lib/css/fonts.css"); ;link(type "text/css", rel "stylesheet", href "/lib/css/fonts.css");
@ -39,14 +36,4 @@
"codemirror/4.3.0/mode/markdown/markdown.min.js"); "codemirror/4.3.0/mode/markdown/markdown.min.js");
;script(type "text/javascript", src "{?.(aut "" "/~~")}". ;script(type "text/javascript", src "{?.(aut "" "/~~")}".
"/~/at/lib/js/urb.js"); "/~/at/lib/js/urb.js");
==
;body
;script(type "text/javascript"): window.tree = {(pojo (joba %data dat))}
;div.container
;div.row#main
;div#head;
;div#body;
==
==
==
== ==

View File

@ -1,9 +1,11 @@
:: ::
:::: /hoon/urb/ren :::: /hoon/urb/ren
:: ::
/% /, /+ urb-split :: for single-page apps
/talk/log /talklog-hymn/ /% /^ [hed=[@uvH marl] bod=[@uvH marl]]
/web/app /|(/!hymn/ /tree-hymn/) /, /web/app
/ /tree-hymn/ /|(/;urb-split;/#/!hymn/ /urb-tree/)
/
/urb-tree/
== ==
`manx`-.- -.-

8
ren/urb/tree.hoon Normal file
View File

@ -0,0 +1,8 @@
:: Combine /tree-head/ and /tree-body/
::
:::: /hoon/urb/ren
::
/= hed /# /% /: /===/ren /tree-head/ :: XX static
/= bod /# /% /tree-body/
^- [hed=[@uvH marl] bod=[@uvH marl]]
[hed bod]