Deploy browser pre-alpha
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
extends RefCounted
|
||||
|
||||
|
||||
static func resolve(native_url: String, same_origin_path: String) -> String:
|
||||
if not OS.has_feature("web"):
|
||||
return native_url
|
||||
var browser_origin: Variant = JavaScriptBridge.eval("window.location.origin", true)
|
||||
var origin := str(browser_origin).strip_edges().rstrip("/")
|
||||
if origin.is_empty() or not origin.begins_with("http"):
|
||||
return native_url
|
||||
return "%s/%s" % [origin, same_origin_path.trim_prefix("/")]
|
||||
@@ -0,0 +1 @@
|
||||
uid://c0m4jbetdkadj
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node
|
||||
|
||||
const EndpointConfig := preload("res://scripts/autoload/api_endpoint_config.gd")
|
||||
const DEFAULT_QUESTIONS_API_URL := "https://s3q.ranaze.com/api/questions/search"
|
||||
const DEFAULT_QUESTION_ATTEMPT_API_URL := "https://s3q.ranaze.com/api/questions/attempts/first"
|
||||
const DEFAULT_QUESTION_API_BASE_URL := "https://s3q.ranaze.com/api/questions"
|
||||
@@ -44,11 +45,21 @@ var active_attempt_index := -1
|
||||
var attempt_request_active := false
|
||||
|
||||
func _ready() -> void:
|
||||
questions_api_url = str(ProjectSettings.get_setting("step3/questions_api_url", DEFAULT_QUESTIONS_API_URL))
|
||||
question_attempt_api_url = str(ProjectSettings.get_setting("step3/question_attempt_api_url", DEFAULT_QUESTION_ATTEMPT_API_URL))
|
||||
question_api_base_url = str(ProjectSettings.get_setting("step3/question_api_base_url", DEFAULT_QUESTION_API_BASE_URL))
|
||||
ratings_api_url = str(ProjectSettings.get_setting("step3/ratings_api_url", DEFAULT_RATINGS_API_URL))
|
||||
question_reports_api_url = str(ProjectSettings.get_setting("step3/question_reports_api_url", DEFAULT_QUESTION_REPORTS_API_URL))
|
||||
questions_api_url = EndpointConfig.resolve(
|
||||
str(ProjectSettings.get_setting("step3/questions_api_url", DEFAULT_QUESTIONS_API_URL)),
|
||||
"/api/questions/search")
|
||||
question_attempt_api_url = EndpointConfig.resolve(
|
||||
str(ProjectSettings.get_setting("step3/question_attempt_api_url", DEFAULT_QUESTION_ATTEMPT_API_URL)),
|
||||
"/api/questions/attempts/first")
|
||||
question_api_base_url = EndpointConfig.resolve(
|
||||
str(ProjectSettings.get_setting("step3/question_api_base_url", DEFAULT_QUESTION_API_BASE_URL)),
|
||||
"/api/questions")
|
||||
ratings_api_url = EndpointConfig.resolve(
|
||||
str(ProjectSettings.get_setting("step3/ratings_api_url", DEFAULT_RATINGS_API_URL)),
|
||||
"/api/ratings/me")
|
||||
question_reports_api_url = EndpointConfig.resolve(
|
||||
str(ProjectSettings.get_setting("step3/question_reports_api_url", DEFAULT_QUESTION_REPORTS_API_URL)),
|
||||
"/api/question-reports")
|
||||
request = HTTPRequest.new()
|
||||
request.request_completed.connect(_on_api_questions_loaded)
|
||||
add_child(request)
|
||||
|
||||
Reference in New Issue
Block a user