diff --git a/pkg/arvo/app/neo.hoon b/pkg/arvo/app/neo.hoon index f88345867a..2e7edf05cb 100644 --- a/pkg/arvo/app/neo.hoon +++ b/pkg/arvo/app/neo.hoon @@ -1564,14 +1564,16 @@ =. run (emit do-std-warp) =. run (emit (do-card #/[p/our.bowl] %make %root ~ ~)) + =. run + (emit (do-card #/[p/our.bowl]/cod/std/src/imp %make %sig `sig/!>(~) ~)) =. run (emit (do-card #/[p/our.bowl]/sky %make %sky ~ ~)) =. run (emit (do-card #/[p/our.bowl]/srv/hawk %make %hawk-eyre ~ ~)) =. run - (emit (do-card #/[p/our.bowl]/blue %make %blue ~ ~)) + (emit (do-card #/[p/our.bowl]/blue %make %blue ~ (~(gas by *crew:neo) src/#/[p/our.bowl]/cod/std/src/imp ~))) =. run - (emit (do-card #/[p/our.bowl]/mast %make %mast ~ ~)) + (emit (do-card #/[p/our.bowl]/mast %make %mast ~ (~(gas by *crew:neo) src/#/[p/our.bowl]/cod/std/src/imp ~))) =. run (emit (do-card #/[p/our.bowl]/self %make %self ~ ~)) =. run diff --git a/pkg/arvo/neo/cod/std/src/fil/wi-nd.js b/pkg/arvo/neo/cod/std/src/fil/wi-nd.js index 9848f7c886..032efd3f81 100644 --- a/pkg/arvo/neo/cod/std/src/fil/wi-nd.js +++ b/pkg/arvo/neo/cod/std/src/fil/wi-nd.js @@ -126,6 +126,27 @@ customElements.define( ` this.intervalId = null } + connectedCallback() { + $(this.gid('searchbar')).off() + $(this.gid('searchbar')).on('submit', (e) => { + e.preventDefault() + this.setAttribute('here', $(this.gid('input-here')).val()) + this.setAttribute('renderer', this.strategies[0]) + this.rebuildIframe() + }) + $(this.gid('input-here')).off() + $(this.gid('input-here')).on('focusout', (e) => { + $(this).removeAttr('searching') + }) + $(this.gid('input-here')).on('blur', (e) => { + $(this).removeAttr('searching') + }) + $(this.gid('menu-toggle')).off() + $(this.gid('menu-toggle')).on('click', (e) => { + this.toggleAttribute('menu') + }) + this.intervalId = null + } connectedCallback() { $(this.gid('searchbar')).off() $(this.gid('searchbar')).on('submit', (e) => { @@ -146,6 +167,19 @@ customElements.define( this.toggleAttribute('menu') }) + $(this.gid('dragger')).off() + $(this.gid('dragger')).on('dragstart', (e) => { + e.originalEvent.dataTransfer.setData( + 'text/plain', + this.getAttribute('wid') + ) + }) + $(this.gid('dragger')).on('dragenter', (e) => { + $(this).emit('drag-start') + }) + $(this.gid('dragger')).on('dragend', (e) => { + $(this).emit('drag-end') + }) $(this.gid('dragger')).off() $(this.gid('dragger')).on('dragstart', (e) => { e.originalEvent.dataTransfer.setData( @@ -202,6 +236,22 @@ customElements.define( this.setAttribute('wid', `${Date.now()}`) this.buildMenu() + // poll iframes for changes every 350ms + this.intervalId = setInterval(() => { + let here = this.getAttribute('here') + let favicon = this.getAttribute('favicon') + let tabTitle = this.getAttribute('tab-title') + $(this.gid('tabs')) + .children() + .each(function () { + this.contentWindow.postMessage({ + messagetype: 'sky-poll', + here, + favicon, + tabTitle + }) + }) + }, 350) // poll iframes for changes every 350ms this.intervalId = setInterval(() => { let here = this.getAttribute('here') @@ -402,6 +452,7 @@ customElements.define( if (words.length != 2) { words = ['b', 'b-error'] } + return words[1].split('-').slice(1).join(' ') } } } @@ -419,6 +470,23 @@ customElements.define( } return r } + async checkUrl(url) { + try { + let response = await fetch(url, { method: 'GET' }) + if (response.ok) { + if (response.redirected) { + return false + } else { + return true + } + } else { + return false + } + } catch (error) { + console.error('Fetch error:', error) + return false + } + } createIframe(prefix, here, open) { let el = document.createElement('iframe') el.setAttribute('prefix', prefix) @@ -436,10 +504,22 @@ customElements.define( }) return el } - rebuildIframe() { - $(this.gid('tabs')).children().remove() - let frame = this.createIframe(this.renderer, this.here, true) - $(this.gid('tabs')).append(frame) + async rebuildIframe() { + let url = + this.renderer === '/self' + ? window.location.origin + this.here + : window.location.origin + this.renderer + this.here + let isLoading = await this.checkUrl(url) + if (isLoading) { + $(this.gid('tabs')).children().remove() + let frame = this.createIframe(this.renderer, this.here, true) + $(this.gid('tabs')).append(frame) + } else { + $(this.gid('tabs')).children().remove() + let frame = this.createIframe(`/tree`, this.here, true) + $(this.gid('menu-toggle')).text(`tree`) + $(this.gid('tabs')).append(frame) + } } registerServiceWorker(iframe, prefix) { // for convenience, this part is inject by wi-nd. @@ -540,6 +620,43 @@ customElements.define( }) breadcrumbs.append(spacer) } + buildMenu() { + let menu = this.gid('menu') + $(menu).children().remove() + // + /*let top = $(` + ` + iframeDoc.body.appendChild(inlineScript) + } + buildBreadcrumbs() { + let breadcrumbs = $(this.gid('breadcrumbs')) + breadcrumbs.children().remove() + // + this.path.forEach((p, i) => { + let chevron = $(document.createElement('span')) + chevron.addClass('s-2 f4 o6 fc ac jc no-select') + if (i > 0) { + chevron.text('›') + } + breadcrumbs.append(chevron) + // + let crumb = $(document.createElement('button')) + crumb.addClass((i === 0 ? 'p-1' : 'p1') + ' b2 hover br1 s-1 f2') + crumb.text(i === 0 && this.path[0].startsWith('~') ? '/' : this.path[i]) + crumb.on('click', () => { + $(this).attr('here', '/' + this.path.slice(0, i + 1).join('/')) + $(this).attr('renderer', this.strategies[0]) + this.rebuildIframe() + }) + breadcrumbs.append(crumb) + }) + let spacer = $(document.createElement('button')) + spacer.addClass('grow b2 br1 hover') + spacer.on('click', () => { + $(this).attr('searching', '') + }) + breadcrumbs.append(spacer) + } buildMenu() { let menu = this.gid('menu') $(menu).children().remove() @@ -573,6 +690,7 @@ customElements.define( `);*/ + let top = $(` let top = $(`
@@ -589,6 +707,8 @@ customElements.define(
`) /*$(top).find('h4').text(this.renderer); + `) + /*$(top).find('h4').text(this.renderer); if (this.strategies.includes(this.renderer)) { $(top).find('#bm-save-btn').addClass('hidden') } @@ -601,6 +721,9 @@ customElements.define( $(top).find('#bm-del-btn').on('click', (e) => { $(this).emit('unbookmark-renderer', this.renderer) });*/ + //menu.appendChild(top.get(0)); + // + let bookmarks = $(` //menu.appendChild(top.get(0)); // let bookmarks = $(` @@ -609,6 +732,22 @@ customElements.define(
+ `) + // + this.strategies.forEach((s) => { + let bookmark = $(``) + bookmark.text(this.labelLookup(s) || s) + $(bookmark).on('click', (e) => { + $(this).attr('renderer', s) + }) + if (s === this.renderer) { + $(bookmark).addClass('toggled') + } + bookmarks.find('.frw').append(bookmark) + }) + menu.appendChild(bookmarks.get(0)) + // + let any = $(` `) // this.strategies.forEach((s) => { @@ -636,5 +775,12 @@ customElements.define( }) menu.appendChild(any.get(0)) } + `) + any.on('submit', (e) => { + e.preventDefault() + $(this).attr('renderer', any.find('input').val()) + }) + menu.appendChild(any.get(0)) + } } ) diff --git a/pkg/arvo/neo/cod/std/src/imp/blue.hoon b/pkg/arvo/neo/cod/std/src/imp/blue.hoon index 0231c60aea..1adbab404b 100644 --- a/pkg/arvo/neo/cod/std/src/imp/blue.hoon +++ b/pkg/arvo/neo/cod/std/src/imp/blue.hoon @@ -1,6 +1,7 @@ /@ eyre-reqs /- serv=sky-server /- srv=server +/- su=shrub-utils ^- kook:neo |% ++ state pro/%sig @@ -11,7 +12,20 @@ :~ :- [|/%ta |] [pro/%eyre-task (sy %rely ~)] == -++ deps *deps:neo +++ deps + %- ~(gas by *band:neo) + :~ :- %src + ^- fief:neo + :- req=& + ^- quay:neo + :- [only/%sig ~] + ^- (unit port:neo) + :+ ~ %y + %- ~(gas by *lads:neo) + :~ :- [|/%tas |] + `lash:neo`[only/%hoon ~] + == + == ++ form |_ [=bowl:neo =aeon:neo =pail:neo] ++ init @@ -44,8 +58,21 @@ :: :: handle everything under /blue =/ renderer (snag 1 inner) + =/ lore q:(~(got by deps.bowl) %src) + =/ has-renderer + !=(~ (get-pail-saga-by-pith:su lore /[renderer])) ?^ renderer ~|('Second iota in URL must be a @tas.' !!) + ?. has-renderer + :_ sig/!>(~) + =/ =pith:neo #/[p/our.bowl]/$/eyre + =/ loc + (en-cord:pith:neo (welp /tree (tail (tail inner)))) + :~ + [pith %poke eyre-sign/!>([eyre-id %head 307 ['Location' loc]~])] + [pith %poke eyre-sign/!>([eyre-id %data ~])] + [pith %poke eyre-sign/!>([eyre-id %done ~])] + == :_ sig/!>(~) :~ :* (welp here.bowl [[%ta eyre-id] ~]) %make diff --git a/pkg/arvo/neo/cod/std/src/imp/mast.hoon b/pkg/arvo/neo/cod/std/src/imp/mast.hoon index 91edc14af7..bac501aa36 100644 --- a/pkg/arvo/neo/cod/std/src/imp/mast.hoon +++ b/pkg/arvo/neo/cod/std/src/imp/mast.hoon @@ -1,12 +1,26 @@ /@ ui-event /@ mast-bind +/- su=shrub-utils /* mast-js =< ^- kook:neo |% ++ state [%pro %sig] ++ poke (sy %mast-bind %eyre-task %eyre-chan-task %gift ~) -++ deps *deps:neo +++ deps + %- ~(gas by *band:neo) + :~ :- %src + ^- fief:neo + :- req=& + ^- quay:neo + :- [only/%sig ~] + ^- (unit port:neo) + :+ ~ %y + %- ~(gas by *lads:neo) + :~ :- [|/%tas |] + `lash:neo`[only/%hoon ~] + == + == ++ kids :+ ~ %y %- my @@ -72,10 +86,14 @@ (~(got by endpoints.rig) url) =/ =rope (mug bind) =/ =boat ship.src.bowl + =/ lore q:(~(got by deps.bowl) %src) + =/ renderer=(unit pail:neo) (get-pail-saga-by-pith:su lore /[view.bind]) ?. ?| =(our.bowl boat) (~(has in public.rig) rope) == [(~(make-403 res bowl) rid) pail] + =/ has-renderer !=(~ renderer) + ?. has-renderer [(~(make-tree-redirect res bowl) rid src.bind) pail] =/ at=pith:neo (~(session moor our.bowl) rope boat) =/ =made:neo [view.bind ~ (my [%src src.bind] ~)] =/ wat (~(get by waiting.rig) [rope boat]) @@ -291,6 +309,14 @@ [307 ['Location' '/~/login?redirect='] ~] ~ :: + ++ make-tree-redirect + |= [rid=@ta loc=pith] + ^- (list card:neo) + %^ make-direct-http-cards + rid + [307 ['Location' (en-cord:pith:neo (welp /tree loc))] ~] + ~ + :: ++ make-direct-http-cards |= [rid=@ta hed=response-header:http dat=(unit octs)] ^- (list card:neo) diff --git a/pkg/arvo/neo/cod/std/src/imp/sky.hoon b/pkg/arvo/neo/cod/std/src/imp/sky.hoon index 73c877367c..516e460748 100644 --- a/pkg/arvo/neo/cod/std/src/imp/sky.hoon +++ b/pkg/arvo/neo/cod/std/src/imp/sky.hoon @@ -35,7 +35,7 @@ :_ sig/!>(~) :~ [#/[p/our.bowl]/sky/strategy/[p/our.bowl] %make %order `order/!>(~) ~] - [#/[p/our.bowl]/sky/strategy/[p/our.bowl]/home %make %order `order/!>([#/hawk ~]) ~] + [#/[p/our.bowl]/sky/strategy/[p/our.bowl]/home %make %order `order/!>([#/self ~]) ~] [#/[p/our.bowl]/profiles [%make %profiles `[%sig !>(~)] ~]] [#/[p/our.bowl]/profiles/default [%make %sig `[%sig !>(~)] ~]] [#/[p/our.bowl]/homepage [%make %homepage `[%homepage !>([#/default ~])] (malt ~[[%profiles #/[p/our.bowl]/profiles]])]]