diff --git a/pkg/arvo/neo/cod/std/src/imp/hawk-eyre-handler.hoon b/pkg/arvo/neo/cod/std/src/imp/hawk-eyre-handler.hoon index 0750da3681..03d41b9e50 100644 --- a/pkg/arvo/neo/cod/std/src/imp/hawk-eyre-handler.hoon +++ b/pkg/arvo/neo/cod/std/src/imp/hawk-eyre-handler.hoon @@ -6,216 +6,203 @@ /> htmx /< node => - |% - ++ main - ^- curb:neo - ::[%or rol/[%ui-main pro/%htmx] pro/%htmx ~] - :: rol/[%ui-main pro/%htmx] - pro/%htmx - ++ kids-curb - ^- curb:neo - ::[%or rol/[%ui-cell pro/%htmx] pro/%htmx ~] - pro/%htmx - :: rol/[%ui-list pro/%htmx] - ++ manx-to-octs - |= man=manx - (as-octt:mimes:html (en-xml:html man)) - :: - ++ render - |= [main=manx kids=marl] - ;div - ;+ main +|% +++ manx-to-octs + |= man=manx + (as-octt:mimes:html (en-xml:html man)) +++ parse-url + |= =request:http + ^- [pax=path pam=(map @t @t)] + =/ parsed + %+ rash url.request + ;~ plug + ;~(pfix fas (more fas smeg:de-purl:html)) + yque:de-purl:html + == + :: strip first 2 segments (/neo/hawk) + :- (slag 2 -.parsed) + (malt +.parsed) +++ parse-body + |= =request:http + ^- manx + %+ fall + (de-xml:html q:(fall body.request [p=0 q=''])) + *manx +++ eyre-cards + |= [eyre-id=@ta =bowl:neo status=@ud =manx] + ^- (list card:neo) + =/ =pith:neo #/[p/our.bowl]/$/eyre + =/ head=sign:eyre:neo [eyre-id %head [status [['content-type' 'text/html'] ~]]] + =/ data=sign:eyre:neo [eyre-id %data `(manx-to-octs manx)] + =/ done=sign:eyre:neo [eyre-id %done ~] + :~ [pith %poke eyre-sign/!>(head)] + [pith %poke eyre-sign/!>(data)] + [pith %poke eyre-sign/!>(done)] + [here.bowl %cull ~] + == +++ default-refresher + |= =pith + =/ tath (en-tape:pith:neo pith) + ;div + =hx-get "/neo/hawk{tath}" + =hx-target "closest .hawk" + =hx-select ".hawk" + =hx-trigger "load once" + =hx-swap "outerHTML" + ; + == +++ hawk + |_ [here=pith main=manx raw=manx has-app=?] + ++ id *@da + ++ our-tape + =/ f (snag 0 here) + ?@(f (trip f) (scow f)) + ++ idt `tape`(zing (scan +:(scow %da id) (most dot (star ;~(less dot prn))))) + ++ slot 0 :: XX fix sky positional saving + ++ lift + ;div.hawk.fc.wf.hf + =id "hawk-{idt}" + =hx-params "id,slot" + =hx-vals "\{\"id\": \"{}\", \"slot\": \"{}\"}" + ;+ header ;div - ;* kids + =class "raw p-page wf hf b0 scroll-y scroll-x {(trip ?:(has-app 'hidden' ''))}" + ;+ raw + == + ;div + =class "rendered wf hf b0 scroll-y scroll-x {(trip ?:(has-app '' 'hidden'))}" + =id "hawk-rendered-{idt}" + =morph-retain "class" + ;+ main == == - ++ parse-url - |= =request:http - ^- [pax=path pam=(map @t @t)] - =/ parsed - %+ rash url.request - ;~ plug - ;~(pfix fas (more fas smeg:de-purl:html)) - yque:de-purl:html + ++ header + ;header.b2.p1.frw.g1.ac + =id "hawk-header-{idt}" + =style "border: 2px solid var(--b2);" + ;button + =class "p1 hover b2 br1 bd0 {(trip ?:(has-app '' 'toggled'))}" + =onclick + """ + $(this).toggleClass('toggled'); + $(this).closest('.hawk').find('.raw').toggleClass('hidden'); + $(this).closest('.hawk').find('.rendered').toggleClass('hidden'); + $(this).closest('header').children('.hawk-tog').toggleClass('hidden'); + """ + ;+ outline:feather-icons == - :- (slag 2 -.parsed) :: strip first 2 segments (/neo/hawk) - (malt +.parsed) - ++ parse-body - |= =request:http - ^- manx - %+ fall - (de-xml:html q:(fall body.request [p=0 q=''])) - *manx - ++ eyre-cards - |= [eyre-id=@ta =bowl:neo status=@ud =manx] - ^- (list card:neo) - =/ =pith:neo #/[p/our.bowl]/$/eyre - =/ head=sign:eyre:neo [eyre-id %head [status [['content-type' 'text/html'] ~]]] - =/ data=sign:eyre:neo [eyre-id %data `(manx-to-octs manx)] - =/ done=sign:eyre:neo [eyre-id %done ~] - :~ [pith %poke eyre-sign/!>(head)] - [pith %poke eyre-sign/!>(data)] - [pith %poke eyre-sign/!>(done)] - [here.bowl %cull ~] - == - ++ default-refresher - |= =pith - =/ tath (en-tape:pith:neo pith) - ;div - =hx-get "/neo/hawk{tath}" - =hx-target "closest .hawk" - =hx-select ".hawk" - =hx-trigger "load once" - =hx-swap "outerHTML" - ; - == - ++ hawk - |_ [here=pith main=manx raw=manx] - ++ id *@da - ++ idt `tape`(zing (scan +:(scow %da id) (most dot (star ;~(less dot prn))))) - ++ has-app %.y :: XX : switch on it. make it real. etc - ++ slot 0 :: XX fix sky positional saving - ++ lift - ;div.hawk.fc.wf.hf - =id "hawk-{idt}" - =hx-params "id,slot" - =hx-vals "\{\"id\": \"{}\", \"slot\": \"{}\"}" - ;+ header - ::;+ raw - ;div - =class "rendered wf hf b0 scroll-y scroll-x {(trip ?:(has-app '' 'hidden'))}" - =id "hawk-rendered-{idt}" - =morph-retain "class" - ;+ main - == - == - ++ header - ;header.b2.p1.frw.g1.ac - =id "hawk-header-{idt}" - =style "border: 2px solid var(--b2);" - ;button - =class "p1 hover b2 br1 bd0 {(trip ?:(has-app '' 'toggled'))}" - =onclick - """ - $(this).toggleClass('toggled'); - $(this).closest('.hawk').find('.raw').toggleClass('hidden'); - $(this).closest('.hawk').find('.rendered').toggleClass('hidden'); - $(this).closest('header').children('.hawk-tog').toggleClass('hidden'); - """ - ;+ outline:feather-icons - == - ;div - =class "hawk-tog frw g1 ac grow {(trip ?:(has-app '' 'hidden'))}" - ;* - =< p - %^ spin here - 0 - |= [=iota a=@] - :_ +(a) - ;div.fr.ac.g1 + ;div + =class "hawk-tog frw g1 ac grow {(trip ?:(has-app '' 'hidden'))}" + ;* + =< p + %^ spin here + 0 + |= [=iota a=@] + :_ +(a) + ;div.fr.ac.g1 + =style "height: 2rem;" + ;div.f4.s-1: > + ;a.hover.b2.br1.p-1.s0.loader.fc.ac.jc =style "height: 2rem;" - ;div.f4.s-1: > - ;a.hover.b2.br1.p-1.s0.loader.fc.ac.jc - =style "height: 2rem;" - =hx-vals "\{\"id\": \"{}\", \"slot\": \"{}\"}" - =href "/neo/hawk{(en-tape:pith:neo (scag +(a) here))}" - ;span.loaded - ;+ ;/ - ?: =(a 0) "/" - (trip ?@(iota iota (scot iota))) - == - ;span.loading - ;+ loading.feather-icons - == + =hx-vals "\{\"id\": \"{}\", \"slot\": \"{}\"}" + =href "/neo/hawk{(en-tape:pith:neo (scag +(a) here))}" + ;span.loaded + ;+ ;/ + ?: =(a 0) "/" + (trip ?@(iota iota (scot iota))) == - == - ;div.grow; - == - ;form - =class "hawk-tog grow fr m0 relative {(trip ?:(has-app 'hidden' ''))}" - =style "height: 2rem;" - =hx-get "/neo/hawk" - =hx-target "closest .hawk" - ;div.absolute - =style "top: 0.5rem; right: 0.5rem;" - ;div.loader - ;div.loaded(style "opacity: 0"): --- - ;div.loading - ;+ loading:feather-icons + ;span.loading + ;+ loading.feather-icons == == == - ;input.p-1.br1.b1.wf.s0.loaded.grow.bd0 - =style "margin-left: 5px;" - =type "text" - =value (en-tape:pith:neo here) - =oninput - """ - $(this).attr('value', this.value); - $(this).parent().attr('hx-get', '/neo/hawk'+this.value); - htmx.process(document.body); - """ - ; + ;div.grow; + == + ;form + =class "hawk-tog grow fr m0 relative {(trip ?:(has-app 'hidden' ''))}" + =style "height: 2rem;" + =hx-get "/neo/hawk" + =hx-target "closest .hawk" + ;div.absolute + =style "top: 0.5rem; right: 0.5rem;" + ;div.loader + ;div.loaded(style "opacity: 0"): --- + ;div.loading + ;+ loading:feather-icons + == == == - ;div.fr.ac.jc.g1.hawk-actions - =id "hawk-actions-{idt}" - ;button.p1.hover.b2.br1.loader.s-1 - =id "hawk-slide-up-{idt}" - =hx-post "/neo/hawk/sky?stud=sky-diff" - =hx-target "find .loading" - =hx-swap "outerHTML" - =head "slide-up" - =hawk-slot "{}" - ;span.loaded - ;+ chevron-left:feather-icons - == - ;span.loading - ;+ loading.feather-icons - == - == - ;button.p1.hover.b2.br1.loader.s-1 - =id "hawk-slide-down-{idt}" - =hx-post "/neo/hawk/sky?stud=sky-diff" - =hx-target "find .loading" - =hx-swap "outerHTML" - =head "slide-down" - =hawk-slot "{}" - ;span.loaded - ;+ chevron-right:feather-icons - == - ;span.loading - ;+ loading.feather-icons - == - == - ;button.p1.hover.b2.br1.loader.s-1 - =id "hawk-close-{idt}" - =hx-post "/neo/hawk/sky?stud=sky-diff" - =hx-target "find .loading" - =hx-swap "outerHTML" - =head "minimize" - =hawk-slot "{}" - ;span.loaded - ;+ minimize:feather-icons - == - ;span.loading - ;+ loading.feather-icons - == - == - ;style - ;+ ;/ %- trip - ''' - @media(max-width: 900px) { - .hawk-actions { - display: none !important; - } - } - ''' - == + ;input.p-1.br1.b1.wf.s0.loaded.grow.bd0 + =style "margin-left: 5px;" + =type "text" + =value (en-tape:pith:neo here) + =oninput + """ + $(this).attr('value', this.value); + $(this).parent().attr('hx-get', '/neo/hawk'+this.value); + htmx.process(document.body); + """ + ; == == - -- + ;div.fr.ac.jc.g1.hawk-actions + =id "hawk-actions-{idt}" + ;button.p1.hover.b2.br1.loader.s-1 + =id "hawk-slide-up-{idt}" + =hx-post "/neo/hawk/{our-tape}/sky?stud=sky-diff" + =hx-target "find .loading" + =hx-swap "outerHTML" + =head "slide-up" + =hawk-slot "{}" + ;span.loaded + ;+ chevron-left:feather-icons + == + ;span.loading + ;+ loading.feather-icons + == + == + ;button.p1.hover.b2.br1.loader.s-1 + =id "hawk-slide-down-{idt}" + =hx-post "/neo/hawk/{our-tape}/sky?stud=sky-diff" + =hx-target "find .loading" + =hx-swap "outerHTML" + =head "slide-down" + =hawk-slot "{}" + ;span.loaded + ;+ chevron-right:feather-icons + == + ;span.loading + ;+ loading.feather-icons + == + == + ;button.p1.hover.b2.br1.loader.s-1 + =id "hawk-close-{idt}" + =hx-post "/neo/hawk/{our-tape}/sky?stud=sky-diff" + =hx-target "find .loading" + =hx-swap "outerHTML" + =head "minimize" + =hawk-slot "{}" + ;span.loaded + ;+ minimize:feather-icons + == + ;span.loading + ;+ loading.feather-icons + == + == + ;style + ;+ ;/ %- trip + ''' + @media(max-width: 900px) { + .hawk-actions { + display: none !important; + } + } + ''' + == + == + == -- +-- ^- kook:neo |% ++ state pro/%eyre-task @@ -231,6 +218,7 @@ :- req=| ^- quay:neo :- [[%or rol/[%ui-main pro/%htmx] pro/%htmx ~] ~] + :- [[%or rol/[%ui-main pro/%htmx] pro/%htmx ~] ~] ^- (unit port:neo) :+ ~ %z %- ~(gas by *lads:neo) @@ -256,7 +244,7 @@ eyre-id bowl 403 - ;div: 40 + ;div: 403 == ?~ src=(~(get by deps.bowl) %src) %: eyre-cards @@ -294,23 +282,46 @@ ^- stud:neo ~| %no-stud-specified (~(got by pam.purl) 'stud') - =/ =pail:neo [poke-stud (node [poke-stud body])] - =/ bol *bowl:neo - =. here.bol here - =. our.bol our.bowl - =. now.bol now.bowl - =. eny.bol eny.bowl - =/ =manx - ?~ converter=(mole |.((htmx pail))) - (default-refresher here) - :: XX virtualize - (u.converter bol) - :- [here %poke pail] - %: eyre-cards - eyre-id - bowl - 200 - manx + ::=/ mul `(each ^vase tang)`[%.y p=!>(~)] :: stub for build system bug + =/ mul (mule |.((node [poke-stud body]))) + ?- -.mul + %.n + %: eyre-cards + eyre-id + bowl + 400 + ;div + ;* + %+ turn (tang p.mul) + |= =tank + ;div: {(of-wall:format (~(win re tank) 0 55))} + == + == + :: + %.y + =/ =pail:neo [poke-stud p.mul] + =/ bol *bowl:neo + =. here.bol here + =. our.bol our.bowl + =. now.bol now.bowl + =. eny.bol eny.bowl + =/ =manx + ?~ converter=(mole |.((htmx pail))) + (default-refresher here) + =/ mul + %- mule + |.((u.converter bol)) + ?- -.mul + %.y p.mul + %.n ;div: error + == + :- [here %poke pail] + %: eyre-cards + eyre-id + bowl + 200 + manx + == == == -- diff --git a/pkg/arvo/neo/cod/std/src/imp/hawk-eyre.hoon b/pkg/arvo/neo/cod/std/src/imp/hawk-eyre.hoon index eef1cd9780..b4004689b4 100644 --- a/pkg/arvo/neo/cod/std/src/imp/hawk-eyre.hoon +++ b/pkg/arvo/neo/cod/std/src/imp/hawk-eyre.hoon @@ -22,8 +22,8 @@ %eyre-task =+ !<(=task:eyre:neo vax) =/ [eyre-id=@ta req=inbound-request:eyre] task - =/ purl (parse-url:serv request.req) - =/ inner=pith:neo (pave:neo pax.purl) + =/ lin (parse-request-line:serv url.request.req) + =/ inner=pith:neo (pave:neo (slag 2 site.lin)) =/ =crew:neo (~(gas by *crew:neo) src/inner ~) =/ =made:neo [%hawk-eyre-handler `[stud vax] crew] =/ =made:neo [%hawk-eyre-handler `[stud vax] crew] diff --git a/pkg/arvo/neo/cod/std/src/imp/sky-eyre-handler.hoon b/pkg/arvo/neo/cod/std/src/imp/sky-eyre-handler.hoon index 8be83bb4d2..10a44e812d 100644 --- a/pkg/arvo/neo/cod/std/src/imp/sky-eyre-handler.hoon +++ b/pkg/arvo/neo/cod/std/src/imp/sky-eyre-handler.hoon @@ -12,241 +12,242 @@ =< ^- kook:neo |% - ++ main - ^- curb:neo - pro/%htmx - :: [%or rol/[%ui-main pro/%htmx] pro/%htmx ~] - :: rol/[%ui-main pro/%htmx] - ++ kids-curb - ^- curb:neo - pro/%htmx - :: rol/[%ui-list pro/%htmx] - ++ manx-to-octs - |= man=manx - %- as-octt:mimes:html - %+ welp "" - (en-xml:html man) + ++ state pro/%eyre-task + ++ poke *(set stud:neo) + ++ kids + :+ ~ %y + %- ~(gas by *lads:neo) + ~ + ++ deps + %- ~(gas by *band:neo) + :~ :- %src + ^- fief:neo + :- req=| + ^- quay:neo + :- [pro/%htmx ~] + ^- (unit port:neo) + :+ ~ %y + %- ~(gas by *lads:neo) + :~ :- & + `lash:neo`[any/~ ~] + == + == :: - ++ render - |= [main=manx kids=marl] - ;div - ;+ main - ;div - ;* kids - == - == - ++ icon-url - ^~ - %- trip - %^ cat - 3 - 'data:image/png;base64,' - %- ~(en base64:mimes:html & |) - (as-octs:mimes:html hawk-icon) - ++ favicon - ^~ - =; m m(a.g [[%href icon-url] a.g.m]) - ^- manx - ;link - =rel "icon" - =type "image/png" - ; - == - ++ manifest-url - ^~ - %- trip - %^ cat - 3 - 'data:application/json;utf-8,' - %- en:json:html - %- pairs:enjs:format - :~ - ['name' s+'sky'] - ['description' s+'an urbit namespace viewer'] - ['start_url' s+'http://localhost/neo/sky'] :: XX - ['display' s+'standalone'] - ['background_color' s+'black'] - :+ 'icons' %a - :~ - %- pairs:enjs:format - :~ - ['src' s+(crip icon-url)] - ['sizes' s+'196x196'] - ['type' s+'image/png'] + ++ form + |_ [=bowl:neo =aeon:neo =pail:neo] + ++ poke + |= [=stud:neo vax=vase] + ^- (quip card:neo pail:neo) + `pail + ++ init + |= pal=(unit pail:neo) + =/ [=stud:neo =vase] (need pal) + =+ !<([eyre-id=@ta req=inbound-request:eyre] vase) + :_ [stud vase] + =/ =pith:neo #/[p/our.bowl]/$/eyre + =; =manx + =/ head=sign:eyre:neo [eyre-id %head [200 [['content-type' 'text/html'] ~]]] + =/ data=sign:eyre:neo [eyre-id %data `(manx-to-octs manx)] + =/ done=sign:eyre:neo [eyre-id %done ~] + :~ [pith %poke eyre-sign/!>(head)] + [pith %poke eyre-sign/!>(data)] + [pith %poke eyre-sign/!>(done)] + [here.bowl %cull ~] == - == - == - ++ manifest - ^~ - =; m m(a.g [[%href manifest-url] a.g.m]) - ^- manx - ;link - =rel "manifest" - ; - == - ++ htmx-extensions - :: htmx extension which encodes the request - :: as the serialized HTML of the calling element - %- trip - ''' - htmx.defineExtension('html-enc', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - evt.detail.headers['Content-Type'] = "text/html"; - } - }, - encodeParameters : function(xhr, parameters, elt) { - xhr.overrideMimeType('text/html'); - let xmls = new XMLSerializer(); - return (xmls.serializeToString(elt)); - } - }); - Idiomorph.defaults.ignoreActive = true; - Idiomorph.defaults.callbacks.beforeAttributeUpdated = (name, node, type) => { - if (node.hasAttribute('morph-retain')) { - let ribs = node.getAttribute('morph-retain').split(',').map(t => t.trim()); - if (ribs.includes(name)) { - return false; - } - } - } - Idiomorph.defaults.callbacks.beforeNodeMorphed = (oldNode, newNode) => { - if (oldNode?.nodeName !== "#text") { - if (oldNode.hasAttribute('morph-no-swap') && oldNode.id === newNode.id) { - return false; - } - else if ( - newNode.hasAttribute('morph-if-class') && - !oldNode.classList.contains(newNode.getAttribute('morph-if-class')) - ) { - return false; - } - } - } - ''' - :: - ++ lift - |= in=manx - ^- manx - ;html - ;head - ;meta(charset "UTF-8"); - ;title: s k y - ;script: {(trip jquery)} - ;script: {(trip htmx-js)} - ;script: {(trip htmx-response-targets)} - ;script: {(trip htmx-idiomorph)} - ;script: {htmx-extensions} - ;meta - =name "viewport" - =content - """ - width=device-width, - initial-scale=1.0, - maximum-scale=1.0 - """ - ; - == - ;meta - =name "htmx-config" - =content (trip '{"ignoreTitle":"true"}') - ; - == - ::;style - :: ;+ ;/ %- trip - :: ''' - :: @font-face { - :: font-family: 'Urbit Sans'; - :: src: url("https://media.urbit.org/fonts/UrbitSans/UrbitSansVFWeb-Regular.woff2") format("woff2"); - :: font-style: normal; - :: font-weight: 100 700; - :: } - :: ''' - ::== - ;style: {(trip reset)} - ;style: {(trip feather)} - ;script - ;+ ;/ - """ - window.log=function()\{if(this.console)\{console.log(Array.prototype.slice.call(arguments));}}; - jQuery.fn.log=function (msg)\{console.log(msg, this); return this;}; - jQuery.fn.emit=function (name)\{(this[0]).dispatchEvent(new Event(name, \{ bubbles: true, cancelable: true, composed: true })); return this;}; - """ - == - ;script: {(trip a-i-r)} - ;script: {(trip date-now)} - ;+ favicon - ;+ manifest - == - ;body - =hx-ext "html-enc,response-targets,morph" - =hx-swap "innerHTML" - =hx-boost "true" - =hx-history "false" - =hx-replace-url "/neo/sky" - =hx-target "closest .hawk" - =style - """ - background-color: var(--b1); - background-image: var(--sky-bg-url); - background-size: var(--sky-bg-size); - background-repeat: var(--sky-bg-repeat); - """ - ;+ in - == - == + ?~ src=(~(get by deps.bowl) %src) + ;div: 404 + =/ root=idea:neo (~(got of:neo q.u.src) /) + ?> =(%htmx p.pail.root) + =/ bol *bowl:neo + =. here.bol p.u.src + =. our.bol our.bowl + =. now.bol now.bowl + =. eny.bol eny.bowl + =. kids.bol q.u.src + :: XX src.bowl + (lift (!<(htmx q.pail.root) bol)) + -- -- -^- kook:neo |% -++ state pro/%eyre-task -++ poke *(set stud:neo) -++ kids - :+ ~ %y - %- ~(gas by *lads:neo) - ~ -++ deps - %- ~(gas by *band:neo) - :~ :- %src - ^- fief:neo - :- req=| - ^- quay:neo - :- [main ~] - ^- (unit port:neo) - :+ ~ %z - %- ~(gas by *lads:neo) - :~ :- & - `lash:neo`[kids-curb ~] - == - == +++ manx-to-octs + |= man=manx + %- as-octt:mimes:html + %+ welp "" + (en-xml:html man) :: -++ form - |_ [=bowl:neo =aeon:neo =pail:neo] - ++ poke - |= [=stud:neo vax=vase] - ^- (quip card:neo pail:neo) - `pail - ++ init - |= pal=(unit pail:neo) - =/ [=stud:neo =vase] (need pal) - =+ !<([eyre-id=@ta req=inbound-request:eyre] vase) - :_ [stud vase] - =/ =pith:neo #/[p/our.bowl]/$/eyre - =; =manx - %+ snoc - (~(respond neo:serv pith) [eyre-id (manx-response:gen:serv manx)]) - [here.bowl %cull ~] - ?~ src=(~(get by deps.bowl) %src) - ;div: 404 - =/ root=idea:neo (~(got of:neo q.u.src) /) - ?> =(%htmx p.pail.root) - =/ bol *bowl:neo - =. here.bol p.u.src - =. our.bol our.bowl - =. now.bol now.bowl - =. eny.bol eny.bowl - =. kids.bol q.u.src - ~& kids/~(key by ~(tar of:neo kids.bol)) - :: XX src.bowl - (lift (!<(htmx q.pail.root) bol)) - -- +++ icon-url + ^~ + %- trip + %^ cat + 3 + 'data:image/png;base64,' + %- ~(en base64:mimes:html & |) + (as-octs:mimes:html hawk-icon) +++ favicon + ^~ + =; m m(a.g [[%href icon-url] a.g.m]) + ^- manx + ;link + =rel "icon" + =type "image/png" + ; + == +++ manifest-url + ^~ + %- trip + %^ cat + 3 + 'data:application/json;utf-8,' + %- en:json:html + %- pairs:enjs:format + :~ + ['name' s+'sky'] + ['description' s+'an urbit namespace viewer'] + ['start_url' s+'http://localhost/neo/sky'] :: XX + ['display' s+'standalone'] + ['background_color' s+'black'] + :+ 'icons' %a + :~ + %- pairs:enjs:format + :~ + ['src' s+(crip icon-url)] + ['sizes' s+'196x196'] + ['type' s+'image/png'] + == + == + == +++ manifest + ^~ + =; m m(a.g [[%href manifest-url] a.g.m]) + ^- manx + ;link + =rel "manifest" + ; + == +++ htmx-extensions + :: htmx extension which encodes the request + :: as the serialized HTML of the calling element + %- trip + ''' + htmx.defineExtension('html-enc', { + onEvent: function (name, evt) { + if (name === "htmx:configRequest") { + evt.detail.headers['Content-Type'] = "text/html"; + } + }, + encodeParameters : function(xhr, parameters, elt) { + xhr.overrideMimeType('text/html'); + let xmls = new XMLSerializer(); + return (xmls.serializeToString(elt)); + } + }); + Idiomorph.defaults.ignoreActive = true; + Idiomorph.defaults.callbacks.beforeAttributeUpdated = (name, node, type) => { + if (node.hasAttribute('morph-retain')) { + let ribs = node.getAttribute('morph-retain').split(',').map(t => t.trim()); + if (ribs.includes(name)) { + return false; + } + } + } + Idiomorph.defaults.callbacks.beforeNodeMorphed = (oldNode, newNode) => { + if (oldNode?.nodeName !== "#text") { + if (oldNode.hasAttribute('morph-no-swap') && oldNode.id === newNode.id) { + return false; + } + else if ( + newNode.hasAttribute('morph-if-class') && + !oldNode.classList.contains(newNode.getAttribute('morph-if-class')) + ) { + return false; + } + } + } + ''' +:: +++ lift + |= in=manx + ^- manx + ;html + ;head + ;meta(charset "UTF-8"); + ;title: s k y + ;script: {(trip jquery)} + ;script: {(trip htmx-js)} + ;script: {(trip htmx-response-targets)} + ;script: {(trip htmx-idiomorph)} + ;script: {htmx-extensions} + ;meta + =name "viewport" + =content + """ + width=device-width, + initial-scale=1.0, + maximum-scale=1.0 + """ + ; + == + ;meta + =name "htmx-config" + =content (trip '{"ignoreTitle":"true"}') + ; + == + ::;style + :: ;+ ;/ %- trip + :: ''' + :: @font-face { + :: font-family: 'Urbit Sans'; + :: src: url("https://media.urbit.org/fonts/UrbitSans/UrbitSansVFWeb-Regular.woff2") format("woff2"); + :: font-style: normal; + :: font-weight: 100 700; + :: } + :: ''' + ::== + ;style: {(trip reset)} + ;style: {(trip feather)} + ;script + ;+ ;/ %- trip + ''' + window.log = function() { + if (this.console) { + console.log(Array.prototype.slice.call(arguments)); + } + }; + jQuery.fn.log = function (msg) { + console.log(msg, this); + return this; + }; + jQuery.fn.emit = function (name) { + (this[0]).dispatchEvent( + new Event( + name, + { bubbles: true, cancelable: true, composed: true } + ) + ); + return this; + }; + ''' + == + ;script: {(trip a-i-r)} + ;script: {(trip date-now)} + ;+ favicon + ;+ manifest + == + ;body + =hx-ext "html-enc,response-targets,morph" + =hx-swap "innerHTML" + =hx-boost "true" + =hx-history "false" + =hx-replace-url "/neo/sky" + =hx-target "closest .hawk" + =style + """ + background-color: var(--b1); + background-image: var(--sky-bg-url); + background-size: var(--sky-bg-size); + background-repeat: var(--sky-bg-repeat); + """ + ;+ in + == + == --