mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 02:17:27 -04:00
handle query strings, pass gate url to child process
This commit is contained in:
parent
55718913c4
commit
12eb00bccc
5 changed files with 44 additions and 26 deletions
|
@ -33,7 +33,7 @@ func app_exit(time_spent: float) -> Dictionary:
|
|||
return event
|
||||
|
||||
|
||||
# GATE
|
||||
# SEARCH
|
||||
|
||||
func search(query: String) -> Dictionary:
|
||||
var event = base("search")
|
||||
|
@ -41,29 +41,37 @@ func search(query: String) -> Dictionary:
|
|||
return event
|
||||
|
||||
|
||||
func gate_open(url: String) -> Dictionary:
|
||||
var event = base("gate_open")
|
||||
event.gate_url = url
|
||||
# GATE
|
||||
|
||||
func base_gate(event_name: String, url: String) -> Dictionary:
|
||||
var event = base(event_name)
|
||||
if url.contains("?"):
|
||||
var split = url.split("?", true, 1)
|
||||
event.gate_url = split[0]
|
||||
event.query_string = split[1]
|
||||
else:
|
||||
event.gate_url = url
|
||||
return event
|
||||
|
||||
|
||||
func gate_open(url: String) -> Dictionary:
|
||||
return base_gate("gate_open", url)
|
||||
|
||||
|
||||
func gate_load(url: String, download_time: float) -> Dictionary:
|
||||
var event = base("gate_load")
|
||||
event.gate_url = url
|
||||
var event = base_gate("gate_load", url)
|
||||
event.download_time = download_time
|
||||
return event
|
||||
|
||||
|
||||
func gate_start(url: String, bootup_time: float) -> Dictionary:
|
||||
var event = base("gate_start")
|
||||
event.gate_url = url
|
||||
var event = base_gate("gate_start", url)
|
||||
event.bootup_time = bootup_time
|
||||
return event
|
||||
|
||||
|
||||
func gate_exit(url: String, time_spent: float) -> Dictionary:
|
||||
var event = base("gate_exit")
|
||||
event.gate_url = url
|
||||
var event = base_gate("gate_exit", url)
|
||||
event.time_spent = time_spent
|
||||
return event
|
||||
|
||||
|
@ -71,15 +79,11 @@ func gate_exit(url: String, time_spent: float) -> Dictionary:
|
|||
# BOOKMARK
|
||||
|
||||
func bookmark(url: String) -> Dictionary:
|
||||
var event = base("bookmark")
|
||||
event.gate_url = url
|
||||
return event
|
||||
return base_gate("bookmark", url)
|
||||
|
||||
|
||||
func unbookmark(url: String) -> Dictionary:
|
||||
var event = base("unbookmark")
|
||||
event.gate_url = url
|
||||
return event
|
||||
return base_gate("unbookmark", url)
|
||||
|
||||
|
||||
# ERROR
|
||||
|
|
|
@ -21,8 +21,9 @@ func _ready() -> void:
|
|||
load_gate(gate_events.current_gate_url)
|
||||
|
||||
|
||||
func load_gate(config_url: String) -> void:
|
||||
Debug.logclr("======== " + config_url + " ========", Color.GREEN)
|
||||
func load_gate(gate_url: String) -> void:
|
||||
Debug.logclr("======== " + gate_url + " ========", Color.GREEN)
|
||||
var config_url = gate_url.split("?")[0]
|
||||
var config_path = await FileDownloader.download(config_url, connect_timeout)
|
||||
if config_path.is_empty(): return error(GateEvents.GateError.NOT_FOUND)
|
||||
|
||||
|
@ -30,7 +31,7 @@ func load_gate(config_url: String) -> void:
|
|||
if c_gate.load_result != OK: return error(GateEvents.GateError.INVALID_CONFIG)
|
||||
gate_events.gate_config_loaded_emit(config_url, c_gate)
|
||||
|
||||
gate = Gate.create(config_url, c_gate.title, c_gate.description, c_gate.icon_url, c_gate.image_url)
|
||||
gate = Gate.create(gate_url, c_gate.title, c_gate.description, c_gate.icon_url, c_gate.image_url)
|
||||
gate_events.gate_info_loaded_emit(gate)
|
||||
|
||||
# Download all in parallel
|
||||
|
|
|
@ -38,7 +38,7 @@ func start(_pipe: Dictionary, _gate: Gate) -> void:
|
|||
|
||||
|
||||
func create_log_file() -> void:
|
||||
var folder = gate.url.replace("http://", "").replace("https://", "").replace(".gate", "")
|
||||
var folder = gate.url.split("?")[0].replace("http://", "").replace("https://", "").replace(".gate", "")
|
||||
folder = folder.replace(":", "_") # remove ':' before port
|
||||
|
||||
var path = LOG_FOLDER + "/" + folder + "/" + LOG_FILE
|
||||
|
|
|
@ -43,6 +43,7 @@ func start_sandbox_linux(gate: Gate) -> Dictionary:
|
|||
var args = [
|
||||
"--main-pack", pack_file,
|
||||
"--resolution", "%dx%d" % [render_result.width, render_result.height],
|
||||
"--url", gate.url,
|
||||
"--verbose"
|
||||
]
|
||||
if not shared_libs.is_empty(): args += ["--gdext-libs-dir", shared_libs]
|
||||
|
@ -62,6 +63,7 @@ func start_sandbox_windows(gate: Gate) -> Dictionary:
|
|||
var args = [
|
||||
"--main-pack", pack_file,
|
||||
"--resolution", "%dx%d" % [render_result.width, render_result.height],
|
||||
"--url", gate.url,
|
||||
"--verbose"
|
||||
]
|
||||
if not shared_libs.is_empty(): args += ["--gdext-libs-dir", shared_libs]
|
||||
|
@ -79,6 +81,7 @@ func start_sandbox_macos(gate: Gate) -> Dictionary:
|
|||
var args = [
|
||||
"--main-pack", pack_file,
|
||||
"--resolution", "%dx%d" % [render_result.width, render_result.height],
|
||||
"--url", gate.url,
|
||||
"--verbose"
|
||||
]
|
||||
if not shared_libs.is_empty(): args += ["--gdext-libs-dir", shared_libs]
|
||||
|
|
|
@ -31,14 +31,24 @@ func join(base_url: String, path: String) -> String:
|
|||
|
||||
|
||||
func fix_gate_url(url: String) -> String:
|
||||
if not url.begins_with("http://") and not url.begins_with("https://"):
|
||||
url = "https://" + url
|
||||
var base_url = url
|
||||
var query_string = ""
|
||||
var has_query = url.contains("?")
|
||||
|
||||
if url.get_extension() != "gate":
|
||||
var slash = "" if url.ends_with("/") else "/"
|
||||
url += slash + "world.gate"
|
||||
if has_query:
|
||||
var split = url.split("?", true, 1)
|
||||
base_url = split[0]
|
||||
query_string = split[1]
|
||||
|
||||
url = lower_domain(url)
|
||||
if not base_url.begins_with("http://") and not base_url.begins_with("https://"):
|
||||
base_url = "https://" + base_url
|
||||
|
||||
if base_url.get_extension() != "gate":
|
||||
var slash = "" if base_url.ends_with("/") else "/"
|
||||
base_url += slash + "world.gate"
|
||||
|
||||
base_url = lower_domain(base_url)
|
||||
url = base_url + "?" + query_string if query_string != "" else base_url
|
||||
return url
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue