Fix web redirects and loader rendering
This commit is contained in:
@@ -5,7 +5,6 @@ const DEFAULT_URL := "https://s3q.ranaze.com/api/donations"
|
||||
const REQUEST_TIMEOUT_SECONDS := 30.0
|
||||
const POLL_INTERVAL_SECONDS := 3.0
|
||||
const POLL_LIMIT := 200
|
||||
const CHECKOUT_STORAGE_KEY := "ranaze_donation_checkout_url"
|
||||
|
||||
signal checkout_started(donation_id: String, checkout_url: String)
|
||||
signal donation_status_changed(status: String, donation: Dictionary)
|
||||
@@ -47,7 +46,6 @@ func begin_checkout(amount_cents: int) -> void:
|
||||
if not AuthState.can_send_authenticated_request():
|
||||
donation_failed.emit("Log in before making a contribution.")
|
||||
return
|
||||
_prepare_browser_window()
|
||||
checkout_pending = true
|
||||
request_token = AuthState.access_token
|
||||
var headers := PackedStringArray([
|
||||
@@ -59,7 +57,6 @@ func begin_checkout(amount_cents: int) -> void:
|
||||
JSON.stringify({"amountCents": amount_cents}))
|
||||
if error != OK:
|
||||
checkout_pending = false
|
||||
_close_browser_window()
|
||||
donation_failed.emit("The secure checkout request could not be started.")
|
||||
|
||||
|
||||
@@ -83,18 +80,15 @@ func _on_checkout_completed(result: int, response_code: int, _headers: PackedStr
|
||||
if response_code == 401:
|
||||
AuthState.handle_unauthorized(request_token)
|
||||
if result != HTTPRequest.RESULT_SUCCESS or response_code < 200 or response_code >= 300:
|
||||
_close_browser_window()
|
||||
donation_failed.emit(_failure_message("Checkout could not be started.", result, response_code, body))
|
||||
return
|
||||
var parsed: Variant = JSON.parse_string(body.get_string_from_utf8())
|
||||
if typeof(parsed) != TYPE_DICTIONARY:
|
||||
_close_browser_window()
|
||||
donation_failed.emit("The donation service returned an invalid response.")
|
||||
return
|
||||
var donation_id := str(parsed.get("donationId", ""))
|
||||
var checkout_url := str(parsed.get("checkoutUrl", ""))
|
||||
if donation_id.is_empty() or not checkout_url.begins_with("https://"):
|
||||
_close_browser_window()
|
||||
donation_failed.emit("The donation service returned an invalid checkout link.")
|
||||
return
|
||||
active_donation_id = donation_id
|
||||
@@ -137,29 +131,13 @@ func _on_status_completed(result: int, response_code: int, _headers: PackedStrin
|
||||
stop_polling()
|
||||
|
||||
|
||||
func _prepare_browser_window() -> void:
|
||||
if OS.has_feature("web"):
|
||||
JavaScriptBridge.eval(
|
||||
"window.localStorage.removeItem('%s'); var ranazeDonationBridge = new URL('/external-redirect.html?key=%s&provider=Stripe', window.location.origin).href; window.medmindDonationWindow = window.open(ranazeDonationBridge, 'medmind_donation_checkout');" % [CHECKOUT_STORAGE_KEY, CHECKOUT_STORAGE_KEY],
|
||||
true)
|
||||
|
||||
|
||||
func _open_checkout_url(url: String) -> void:
|
||||
if OS.has_feature("web"):
|
||||
JavaScriptBridge.eval(
|
||||
"var ranazeDonationUrl = %s; window.localStorage.setItem('%s', ranazeDonationUrl); if (window.medmindDonationWindow && !window.medmindDonationWindow.closed) { try { window.medmindDonationWindow.location.replace(ranazeDonationUrl); } catch (_) {} window.medmindDonationWindow.focus(); } else { var ranazeDonationPopup = window.open(ranazeDonationUrl, 'medmind_donation_checkout'); if (ranazeDonationPopup) { window.medmindDonationWindow = ranazeDonationPopup; ranazeDonationPopup.focus(); } else { window.location.assign(ranazeDonationUrl); } }" % [JSON.stringify(url), CHECKOUT_STORAGE_KEY],
|
||||
true)
|
||||
JavaScriptBridge.eval("window.location.assign(%s);" % JSON.stringify(url), true)
|
||||
else:
|
||||
OS.shell_open(url)
|
||||
|
||||
|
||||
func _close_browser_window() -> void:
|
||||
if OS.has_feature("web"):
|
||||
JavaScriptBridge.eval(
|
||||
"window.localStorage.removeItem('%s'); if (window.medmindDonationWindow && !window.medmindDonationWindow.closed) { window.medmindDonationWindow.close(); } window.medmindDonationWindow = null;" % CHECKOUT_STORAGE_KEY,
|
||||
true)
|
||||
|
||||
|
||||
func _failure_message(prefix: String, result: int, response_code: int, body: PackedByteArray) -> String:
|
||||
if result != HTTPRequest.RESULT_SUCCESS and response_code == 0:
|
||||
return "%s Check your connection and try again." % prefix
|
||||
|
||||
@@ -651,7 +651,7 @@ func _on_reset_confirmed(result: int, code: int, _headers: PackedStringArray, bo
|
||||
func _start_steam() -> void:
|
||||
if OS.has_feature("web"):
|
||||
var popup_result: Variant = JavaScriptBridge.eval(
|
||||
"window.localStorage.removeItem('%s'); var ranazeSteamBridge = new URL('/external-redirect.html?key=%s&provider=Steam', window.location.origin).href; window.ranazeSteamWindow = window.open(ranazeSteamBridge, 'ranaze_steam'); window.ranazeSteamWindow !== null;" % [STEAM_AUTH_STORAGE_KEY, STEAM_AUTH_STORAGE_KEY],
|
||||
"window.localStorage.removeItem('%s'); var ranazeSteamBridge = new URL('/external-redirect.html?key=%s&provider=Steam', window.location.origin).href; window.ranazeSteamWindow = window.open(ranazeSteamBridge, 'ranaze_steam', 'popup=yes,width=560,height=720,resizable=yes,scrollbars=yes'); if (window.ranazeSteamWindow) { window.ranazeSteamWindow.blur(); window.focus(); } window.ranazeSteamWindow !== null;" % [STEAM_AUTH_STORAGE_KEY, STEAM_AUTH_STORAGE_KEY],
|
||||
true
|
||||
)
|
||||
steam_popup_opened = bool(popup_result)
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ RUN mkdir -p /build \
|
||||
&& sed -i "s|custom_template/release=\"\"|custom_template/release=\"/root/.local/share/godot/export_templates/${GODOT_TEMPLATE_DIR}/web_nothreads_release.zip\"|" export_presets.cfg \
|
||||
&& godot --headless --editor --path /src --quit \
|
||||
&& godot --verbose --headless --path /src --export-release Web /build/index.html \
|
||||
&& cp /src/assets/branding/ranaze-mark.png /build/ranaze-loader-icon.png \
|
||||
&& cp /src/web/ranaze-loader-icon-v1.png /build/ranaze-loader-icon-v1.png \
|
||||
&& cp /src/assets/fonts/Inter-Variable.ttf /build/medmind-inter.ttf \
|
||||
&& cp /src/web/donation-complete.html /build/donation-complete.html \
|
||||
&& cp /src/web/donation-canceled.html /build/donation-canceled.html \
|
||||
@@ -41,7 +41,7 @@ RUN mkdir -p /build \
|
||||
&& mkdir -p /build/legal \
|
||||
&& cp /src/legal/legal_documents.json /build/legal/legal_documents.json \
|
||||
&& test -s /build/index.html \
|
||||
&& test -s /build/ranaze-loader-icon.png \
|
||||
&& test -s /build/ranaze-loader-icon-v1.png \
|
||||
&& test -s /build/medmind-inter.ttf \
|
||||
&& test -s /build/donation-complete.html \
|
||||
&& test -s /build/donation-canceled.html \
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
:root[data-theme=light]{--bg:#f1f5f9;--surface:#fff;--border:#dbe3ef;--text:#0f172a;--muted:#64748b}
|
||||
*{box-sizing:border-box}body{margin:0;min-height:100vh;display:grid;place-items:center;padding:24px;background:var(--bg);color:var(--text);font-family:Inter,system-ui,sans-serif}
|
||||
main{width:min(560px,100%);padding:40px;border:1px solid var(--border);border-radius:12px;background:var(--surface);text-align:center}
|
||||
img{width:84px;height:84px;object-fit:contain}h1{margin:22px 0 12px;font-size:30px}p{margin:0;color:var(--muted);font-size:17px;line-height:1.6}
|
||||
img{width:84px;height:84px;object-fit:contain}h1{margin:22px 0 12px;font-size:30px}p{margin:0;color:var(--muted);font-size:17px;line-height:1.6}a{display:inline-block;margin-top:22px;color:var(--accent);font-weight:700}
|
||||
</style>
|
||||
</head>
|
||||
<script>try{document.documentElement.dataset.theme=localStorage.getItem('medmind-color-scheme')||''}catch(e){}</script>
|
||||
<body><main><img src="/ranaze-loader-icon.png" alt="RanaZe"><h1>Checkout canceled</h1><p>No contribution was completed. You can close this tab and return to RanaZe.</p></main></body>
|
||||
<body><main><img src="/ranaze-loader-icon-v1.png" alt="RanaZe" width="320" height="270"><h1>Checkout canceled</h1><p>No contribution was completed.</p><a href="/">Return to RanaZe</a></main></body>
|
||||
</html>
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
:root[data-theme=light]{--bg:#f1f5f9;--surface:#fff;--border:#dbe3ef;--text:#0f172a;--muted:#64748b}
|
||||
*{box-sizing:border-box}body{margin:0;min-height:100vh;display:grid;place-items:center;padding:24px;background:var(--bg);color:var(--text);font-family:Inter,system-ui,sans-serif}
|
||||
main{width:min(560px,100%);padding:40px;border:1px solid var(--border);border-radius:12px;background:var(--surface);text-align:center}
|
||||
img{width:84px;height:84px;object-fit:contain}h1{margin:22px 0 12px;font-size:30px}p{margin:0;color:var(--muted);font-size:17px;line-height:1.6}.status{color:var(--success);font-weight:700}
|
||||
img{width:84px;height:84px;object-fit:contain}h1{margin:22px 0 12px;font-size:30px}p{margin:0;color:var(--muted);font-size:17px;line-height:1.6}.status{color:var(--success);font-weight:700}a{display:inline-block;margin-top:22px;color:var(--accent);font-weight:700}
|
||||
</style>
|
||||
</head>
|
||||
<script>try{document.documentElement.dataset.theme=localStorage.getItem('medmind-color-scheme')||''}catch(e){}</script>
|
||||
<body><main><img src="/ranaze-loader-icon.png" alt="RanaZe"><h1>Thank you for supporting RanaZe</h1><p class="status">Your checkout is complete.</p><p>You can close this tab and return to RanaZe. Stripe will send your receipt by email.</p></main></body>
|
||||
<body><main><img src="/ranaze-loader-icon-v1.png" alt="RanaZe" width="320" height="270"><h1>Thank you for supporting RanaZe</h1><p class="status">Your checkout is complete.</p><p>Stripe will send your receipt by email.</p><a href="/">Return to RanaZe</a></main></body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
+7
-1
@@ -49,12 +49,18 @@ server {
|
||||
|
||||
# Godot exports reuse these filenames across releases. Revalidate them so a
|
||||
# newly deployed index never boots an older cached project package.
|
||||
location ~ ^/(index\.(js|pck|wasm)|ranaze-loader-icon\.png|medmind-inter\.ttf)$ {
|
||||
location ~ ^/(index\.(js|pck|wasm)|medmind-inter\.ttf)$ {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location = /ranaze-loader-icon-v1.png {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location / {
|
||||
add_header Cache-Control "public, max-age=3600" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c8l4x7ywr02cr"
|
||||
path="res://.godot/imported/ranaze-loader-icon-v1.png-a03a63655f2868827958b7c7a5cec183.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://web/ranaze-loader-icon-v1.png"
|
||||
dest_files=["res://.godot/imported/ranaze-loader-icon-v1.png-a03a63655f2868827958b7c7a5cec183.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
Reference in New Issue
Block a user