show "Redirecting..." page for cross-ship redirects

This commit is contained in:
Anton Dyudin 2016-09-06 13:05:36 -07:00
parent 2433a3f101
commit 2113b4d6e1

View File

@ -423,15 +423,25 @@
}
urb.foreign = /^\/~\/am/.test(window.location.pathname)
urb.redir = function(ship){
if(ship) document.location.pathname =
document.location.pathname.replace(/^\/~~|\/~\/as\/any/,'/~/as/~'+ship)
else document.location =
urb.redirTo = function(url){
document.title = "Redirecting"
var mount = document.getElementById("pass") || document.body
mount.outerHTML = "Redirecting to <a href=\""+url+"\">"+url+"</a>"
document.location = url
}
urb.redir = function(ship){
if(ship){
var location = new URL(document.location)
location.pathname = location.pathname.replace(/^\/~~|\/~\/as\/any/,'/~/as/~'+ship)
urb.redirTo(location)
}
else urb.redirTo(
document.location.hash.match(/#[^?]+/)[0].slice(1) +
document.location.pathname.replace(
/^\/~\/am\/[^/]+/,
'/~/as/~' + urb.ship) +
document.location.search
)
}
if(urb.foreign && urb.auth.indexOf(urb.ship) !== -1){
req("/~/auth.json?PUT",
@ -465,6 +475,16 @@
;body:"You may now close this window."
==
::
++ redir
|= url/tape
;html
;head:title:"Redirecting..."
;body
;p: Redirecting to ;{a/"{url}" "{url}"}
;script: setTimeout(function()\{document.location = {(pojo (jape url))}}, 3000)
==
==
::
++ login-page
%+ titl 'Sign in - Urbit'
;= ;div.container.top
@ -853,8 +873,9 @@
(fail 404 p.sih p.q.sih)
=* cay p.q.sih
?: ?=($red-quri p.cay)
=+ url=((hard quri) q.q.cay)
(give-thou 307 [location+(crip (apex:earn url))]~ ~)
=+ url=(apex:earn ((hard quri) q.q.cay))
(give-thou 307 [location+(crip url)]~ ~)
:: (give-html:abet 200 ~ (redir:xml url))
?. ?=($mime p.cay)
=+ bek=(norm-beak -:(need (tome p.tee)))
=+ tee-ses=?~(ses tee [%ac u.ses tee])
@ -1475,8 +1496,7 @@
q.q.pul ['~' %am ses q.q.pul]
==
=+ url=(welp (earn pul(p hat)) '#' (head:earn p.pul))
%- give-thou:abet
(add-cookies cug [307 [location+(crip url)]~ ~])
(give-html:abet 200 cug (redir:xml url))
::
++ logon
|= her/ship