mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-29 23:12:08 +03:00
file-server: fix %file-server by adding SPA flag and threading is-file through request
This commit is contained in:
parent
94151b4a8f
commit
e1b011224d
@ -61,7 +61,7 @@
|
||||
:_ this
|
||||
:~ :* %pass /srv %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~chat' /app/landscape %.n])
|
||||
!>([%serve-dir /'~chat' /app/landscape %.n %.y])
|
||||
==
|
||||
[%pass / %arvo %e %connect [~ /'chat-view'] %chat-view]
|
||||
[%pass /updates %agent [our.bol %chat-store] %watch /updates]
|
||||
@ -167,7 +167,7 @@
|
||||
[%pass / %arvo %e %connect [~ /'chat-view'] %chat-view]
|
||||
:* %pass /srv %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~chat' /app/landscape %.n])
|
||||
!>([%serve-dir /'~chat' /app/landscape %.n %.y])
|
||||
==
|
||||
==
|
||||
::
|
||||
|
@ -48,7 +48,7 @@
|
||||
(contact-poke:cc [%add /~/default our.bowl *contact])
|
||||
:* %pass /srv %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~groups' /app/landscape %.n])
|
||||
!>([%serve-dir /'~groups' /app/landscape %.n %.y])
|
||||
==
|
||||
==
|
||||
::
|
||||
@ -63,7 +63,7 @@
|
||||
[%pass / %arvo %e %connect [~ /'contact-view'] %contact-view]
|
||||
:* %pass /srv %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~groups' /app/landscape %.n])
|
||||
!>([%serve-dir /'~groups' /app/landscape %.n %.y])
|
||||
==
|
||||
==
|
||||
::
|
||||
|
@ -2,25 +2,23 @@
|
||||
/+ *server, default-agent, verb, dbug
|
||||
|%
|
||||
+$ card card:agent:gall
|
||||
+$ serving (map url-base=path [=content public=?])
|
||||
+$ serving (map url-base=path [=content public=? single-page=?])
|
||||
+$ content
|
||||
$% [%clay =path]
|
||||
[%glob =glob:glob]
|
||||
==
|
||||
+$ state-base
|
||||
$: =configuration:srv
|
||||
::
|
||||
+$ state-3
|
||||
$: %3
|
||||
=configuration:srv
|
||||
=serving
|
||||
==
|
||||
+$ state-2
|
||||
$: %2
|
||||
state-base
|
||||
==
|
||||
--
|
||||
::
|
||||
%+ verb |
|
||||
%- agent:dbug
|
||||
::
|
||||
=| state-2
|
||||
=| state-3
|
||||
=* state -
|
||||
^- agent:gall
|
||||
|_ =bowl:gall
|
||||
@ -36,7 +34,7 @@
|
||||
%+ turn
|
||||
^- (list path)
|
||||
[/ /'~landscape' ~]
|
||||
|=(pax=path [pax [clay+/app/landscape %.n]])
|
||||
|=(pax=path [pax [clay+/app/landscape %.n %.y]])
|
||||
==
|
||||
:~ (connect /)
|
||||
(connect /'~landscape')
|
||||
@ -68,24 +66,35 @@
|
||||
- %2
|
||||
serving (~(del by serving.old-state) /'~landscape'/js/index)
|
||||
==
|
||||
?> ?=(%2 -.old-state)
|
||||
=? old-state ?=(%2 -.old-state)
|
||||
%= old-state
|
||||
- %3
|
||||
serving
|
||||
%- ~(run by serving.old-state)
|
||||
|= [=content public=?]
|
||||
^- [^content ? ?]
|
||||
[content public %.y]
|
||||
==
|
||||
?> ?=(%3 -.old-state)
|
||||
[~ this(state old-state)]
|
||||
::
|
||||
+$ serving-0 (map url-base=path [=clay=path public=?])
|
||||
+$ serving-1 (map url-base=path [=content public=?])
|
||||
+$ versioned-state
|
||||
$% state-0
|
||||
state-1
|
||||
state-2
|
||||
[%1 state-1]
|
||||
[%2 state-1]
|
||||
state-3
|
||||
==
|
||||
::
|
||||
+$ serving-0 (map url-base=path [=clay=path public=?])
|
||||
+$ state-0
|
||||
$: %0
|
||||
=configuration:srv
|
||||
=serving-0
|
||||
==
|
||||
+$ state-1
|
||||
$: %1
|
||||
state-base
|
||||
$: =configuration:srv
|
||||
serving=serving-1
|
||||
==
|
||||
--
|
||||
::
|
||||
@ -113,14 +122,17 @@
|
||||
?: (~(has by serving) url-base)
|
||||
~|("url already bound to {<(~(got by serving) url-base.act)>}" !!)
|
||||
:- [%pass url-base %arvo %e %connect [~ url-base] %file-server]~
|
||||
this(serving (~(put by serving) url-base clay+clay-base.act public.act))
|
||||
%_ this
|
||||
serving
|
||||
(~(put by serving) url-base clay+clay-base.act public.act spa.act)
|
||||
==
|
||||
::
|
||||
%serve-glob
|
||||
=* url-base url-base.act
|
||||
?: (~(has by serving) url-base)
|
||||
~|("url already bound to {<(~(got by serving) url-base.act)>}" !!)
|
||||
:- [%pass url-base %arvo %e %connect [~ url-base] %file-server]~
|
||||
this(serving (~(put by serving) url-base glob+glob.act public.act))
|
||||
this(serving (~(put by serving) url-base glob+glob.act public.act %.y))
|
||||
::
|
||||
%unserve-dir
|
||||
:- [%pass url-base.act %arvo %e %disconnect [~ url-base.act]]~
|
||||
@ -129,9 +141,9 @@
|
||||
%toggle-permission
|
||||
?. (~(has by serving) url-base.act)
|
||||
~|("url is not bound" !!)
|
||||
=/ [=content public=?] (~(got by serving) url-base.act)
|
||||
=/ [=content public=? spa=?] (~(got by serving) url-base.act)
|
||||
:- ~
|
||||
this(serving (~(put by serving) url-base.act [content !public]))
|
||||
this(serving (~(put by serving) url-base.act [content !public spa]))
|
||||
::
|
||||
%set-landscape-homepage-prefix
|
||||
=. landscape-homepage-prefix.configuration prefix.act
|
||||
@ -158,6 +170,7 @@
|
||||
|= =cord
|
||||
^- (unit ^cord)
|
||||
?:(=(cord '') ~ `cord)
|
||||
=/ is-file ?=(^ ext.req-line)
|
||||
=? req-line ?=(~ ext.req-line)
|
||||
[[[~ %html] (snoc site.req-line 'index')] args.req-line]
|
||||
?~ site.req-line
|
||||
@ -174,17 +187,18 @@
|
||||
%- js-response:gen
|
||||
(as-octt:mimes:html "window.ship = '{+:(scow %p our.bowl)}';")
|
||||
::
|
||||
=/ [payload=simple-payload:http public=?] (get-file req-line)
|
||||
=/ [payload=simple-payload:http public=?] (get-file req-line is-file)
|
||||
?: public payload
|
||||
(require-authorization-simple:app inbound-request payload)
|
||||
::
|
||||
++ get-file
|
||||
|= req-line=request-line
|
||||
|= [req-line=request-line is-file=?]
|
||||
^- [simple-payload:http ?]
|
||||
=/ pax=path
|
||||
?~ ext.req-line site.req-line
|
||||
(snoc site.req-line u.ext.req-line)
|
||||
=/ content=(unit [=content suffix=path public=?]) (get-content pax)
|
||||
=/ content=(unit [=content suffix=path public=?])
|
||||
(get-content pax is-file)
|
||||
?~ content [not-found:gen %.n]
|
||||
?- -.content.u.content
|
||||
%clay
|
||||
@ -234,23 +248,28 @@
|
||||
(add char ^~((sub 'a' 'A')))
|
||||
::
|
||||
++ get-content
|
||||
|= pax=path
|
||||
|= [pax=path is-file=?]
|
||||
^- (unit [content path ?])
|
||||
=/ first-try (match-content-path pax (~(del by serving) /))
|
||||
=/ first-try (match-content-path pax (~(del by serving) /) is-file)
|
||||
?^ first-try first-try
|
||||
=/ root (~(get by serving) /)
|
||||
?~ root ~
|
||||
(match-content-path pax (~(gas by *^serving) [[/ u.root] ~]))
|
||||
(match-content-path pax (~(gas by *^serving) [[/ u.root] ~]) is-file)
|
||||
::
|
||||
++ match-content-path
|
||||
|= [pax=path =^serving]
|
||||
|= [pax=path =^serving is-file=?]
|
||||
^- (unit [content path ?])
|
||||
%- ~(rep by serving)
|
||||
|= [[url-base=path =content public=?] out=(unit [content path ?])]
|
||||
|= $: [url-base=path =content public=? spa=?]
|
||||
out=(unit [content path ?])
|
||||
==
|
||||
?^ out out
|
||||
=/ suf (get-suffix url-base pax)
|
||||
?~ suf ~
|
||||
`[content u.suf public]
|
||||
=- `[content - public]
|
||||
?: ?&(spa !is-file)
|
||||
/index/html
|
||||
u.suf
|
||||
::
|
||||
++ get-suffix
|
||||
|= [a=path b=path]
|
||||
|
@ -77,7 +77,7 @@
|
||||
:~ [%pass / %arvo %e %disconnect [~ /]]
|
||||
:* %pass /srv %agent [our.bowl %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir / /app/landscape %.n])
|
||||
!>([%serve-dir / /app/landscape %.n %.y])
|
||||
==
|
||||
==
|
||||
%+ turn ~(tap by wex.bowl)
|
||||
|
@ -65,7 +65,7 @@
|
||||
[%pass - %agent [our.bowl %invite-store] %watch -]
|
||||
:* %pass /srv %agent [our.bowl %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~link' /app/landscape %.n])
|
||||
!>([%serve-dir /'~link' /app/landscape %.n %.y])
|
||||
==
|
||||
==
|
||||
::
|
||||
@ -81,7 +81,7 @@
|
||||
:- [%pass /connect %arvo %e %disconnect [~ /'~link']]
|
||||
:~ :* %pass /srv %agent [our.bowl %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~link' /app/landscape %.n])
|
||||
!>([%serve-dir /'~link' /app/landscape %.n %.y])
|
||||
== ==
|
||||
==
|
||||
::
|
||||
|
@ -96,7 +96,7 @@
|
||||
==
|
||||
:* %pass /srv %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~publish' /app/landscape %.n])
|
||||
!>([%serve-dir /'~publish' /app/landscape %.n %.y])
|
||||
==
|
||||
[%pass /groups %agent [our.bol %group-store] %watch /groups]
|
||||
==
|
||||
@ -126,7 +126,7 @@
|
||||
[%pass /view-bind %arvo %e %connect [~ /'publish-view'] %publish]
|
||||
:* %pass /srv %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~publish' /app/landscape %.n])
|
||||
!>([%serve-dir /'~publish' /app/landscape %.n %.y])
|
||||
==
|
||||
==
|
||||
=+ ^- [kick-cards=(list card) old-subs=(jug @tas @p)] kick-subs
|
||||
@ -197,7 +197,7 @@
|
||||
[%pass /view-bind %arvo %e %connect [~ /'publish-view'] %publish]
|
||||
:* %pass /srving %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~publish' /app/landscape %.n])
|
||||
!>([%serve-dir /'~publish' /app/landscape %.n %.y])
|
||||
== ==
|
||||
==
|
||||
::
|
||||
|
@ -29,7 +29,7 @@
|
||||
:_ ~
|
||||
:* %pass /srv %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~dojo' /app/landscape %.n])
|
||||
!>([%serve-dir /'~dojo' /app/landscape %.n %.y])
|
||||
==
|
||||
++ on-save !>(state)
|
||||
::
|
||||
@ -43,7 +43,7 @@
|
||||
:~ [%pass /bind/soto %arvo %e %disconnect [~ /'~dojo']]
|
||||
:* %pass /srv %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~dojo' /app/landscape %.n])
|
||||
!>([%serve-dir /'~dojo' /app/landscape %.n %.y])
|
||||
==
|
||||
==
|
||||
::
|
||||
|
@ -1,7 +1,7 @@
|
||||
/- glob
|
||||
|%
|
||||
+$ action
|
||||
$% [%serve-dir url-base=path clay-base=path public=?]
|
||||
$% [%serve-dir url-base=path clay-base=path public=? spa=?]
|
||||
[%serve-glob url-base=path =glob:glob public=?]
|
||||
[%unserve-dir url-base=path]
|
||||
[%toggle-permission url-base=path]
|
||||
|
Loading…
Reference in New Issue
Block a user