From b6d5f4135aec4eff04ea31f221cdd5d9ba1d6288 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Sun, 5 Feb 2023 17:59:37 -0600 Subject: [PATCH] Pruned gem usage, replaced Launchy since it will cause a command prompt to momentarily appear. --- Gemfile | 11 ++++------- Gemfile.lock | 9 --------- lib/common.rb | 12 ++++++++++++ lib/pages/community.rb | 18 +++++++++--------- lib/pages/games.rb | 8 ++++---- lib/pages/games_redesign.rb | 6 +++--- lib/pages/login.rb | 4 ++-- lib/states/interface.rb | 2 +- lib/states/interface_redesign.rb | 2 +- w3d_hub_linux_launcher.rb | 1 - 10 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Gemfile b/Gemfile index a11012f..a44c375 100644 --- a/Gemfile +++ b/Gemfile @@ -1,17 +1,14 @@ source "https://rubygems.org" gem "cyberarm_engine" -gem "launchy" -gem "i18n" -gem "rexml" gem "digest-crc" -gem "ffi" -gem "websocket-client-simple" -gem "thread-local" +gem "i18n" gem "ircparser" +gem "rexml" gem "rubyzip" -gem "win32-security", platforms: [:x64_mingw, :mingw] +gem "websocket-client-simple" gem "win32-process", platforms: [:x64_mingw, :mingw] +gem "win32-security", platforms: [:x64_mingw, :mingw] # group :windows_packaging do # gem "rake" diff --git a/Gemfile.lock b/Gemfile.lock index 1291e6d..67dddf9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,6 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.8.1) - public_suffix (>= 2.0.2, < 6.0) concurrent-ruby (1.2.0) cyberarm_engine (0.23.0) excon (~> 0.88) @@ -20,13 +18,9 @@ GEM i18n (1.12.0) concurrent-ruby (~> 1.0) ircparser (1.0.0) - launchy (2.5.2) - addressable (~> 2.8) - public_suffix (5.0.1) rake (13.0.6) rexml (3.2.5) rubyzip (2.3.2) - thread-local (1.1.0) websocket (1.2.9) websocket-client-simple (0.6.0) event_emitter @@ -45,13 +39,10 @@ PLATFORMS DEPENDENCIES cyberarm_engine digest-crc - ffi i18n ircparser - launchy rexml rubyzip - thread-local websocket-client-simple win32-process win32-security diff --git a/lib/common.rb b/lib/common.rb index 2885475..d2993ba 100644 --- a/lib/common.rb +++ b/lib/common.rb @@ -32,6 +32,18 @@ class W3DHub linux? || mac? end + def self.url(path) + raise "Hazardous input: #{path}" if path.include?("&&") || path.include?(";") + + if windows? + system("start #{path}") + elsif linux? + system("xdg-open #{path}") + elsif mac? + system("open #{path}") + end + end + def self.prompt_for_nickname(accept_callback: nil, cancel_callback: nil) CyberarmEngine::Window.instance.push_state( W3DHub::States::PromptDialog, diff --git a/lib/pages/community.rb b/lib/pages/community.rb index db1a732..0ee0d54 100644 --- a/lib/pages/community.rb +++ b/lib/pages/community.rb @@ -16,16 +16,16 @@ class W3DHub flow(width: 64 * 4 + (3 * 32), height: 1.0) do image "#{GAME_ROOT_PATH}/media/icons/app.png", hover: { color: 0xaa_ffffff }, height: 1.0, tip: "#{I18n.t(:app_name)} Github Repository" do - Launchy.open("https://github.com/cyberarm/w3d_hub_linux_launcher") + W3DHub.url("https://github.com/cyberarm/w3d_hub_linux_launcher") end image "#{GAME_ROOT_PATH}/media/icons/w3dhub.png", hover: { color: 0xaa_ffffff }, height: 1.0, margin_left: 32, tip: "W3D Hub Forums" do - Launchy.open("https://w3dhub.com/forum/") + W3DHub.url("https://w3dhub.com/forum/") end image "#{GAME_ROOT_PATH}/media/social_media_icons/discord.png", hover: { color: 0xaa_ffffff }, height: 1.0, margin_left: 32, tip: "W3D Hub Discord Server" do - Launchy.open("https://discord.com/invite/GYhW7eV") + W3DHub.url("https://discord.com/invite/GYhW7eV") end image "#{GAME_ROOT_PATH}/media/social_media_icons/facebook.png", hover: { color: 0xaa_ffffff }, height: 1.0, margin_left: 32, tip: "W3D Hub Facebook Page" do - Launchy.open("https://www.facebook.com/w3dhub") + W3DHub.url("https://www.facebook.com/w3dhub") end end @@ -43,10 +43,10 @@ class W3DHub tagline "Help & Support" flow(width: 1.0) do para "For help and support using this launcher or playing any W3D Hub game visit the" - link("W3D Hub forums", text_size: 16, tip: "https://w3dhub.com/forum/") { Launchy.open("https://w3dhub.com/forum/") } + link("W3D Hub forums", text_size: 16, tip: "https://w3dhub.com/forum/") { W3DHub.url("https://w3dhub.com/forum/") } para "or join us in" image "#{GAME_ROOT_PATH}/media/social_media_icons/discord.png", height: 16, padding_top: 4 - link("#tech-support", text_size: 16, tip: "https://discord.com/invite/GYhW7eV") { Launchy.open("https://discord.com/invite/GYhW7eV") } + link("#tech-support", text_size: 16, tip: "https://discord.com/invite/GYhW7eV") { W3DHub.url("https://discord.com/invite/GYhW7eV") } para "on the W3D Hub Discord server" end end @@ -112,7 +112,7 @@ class W3DHub # stack(width: 0.6, height: 1.0) do # stack(width: 1.0, height: 112) do # link "#{item.title}", text_size: 18 do - # Launchy.open(item.uri) + # W3DHub.url(item.uri) # end # inscription item.blurb.gsub(/\n+/, "\n").strip[0..180] # end @@ -120,7 +120,7 @@ class W3DHub # flow(width: 1.0) do # inscription item.timestamp.strftime("%Y-%m-%d"), width: 0.499 # link I18n.t(:"games.read_more"), width: 0.5, text_align: :right, text_size: 14 do - # Launchy.open(item.uri) + # W3DHub.url(item.uri) # end # end # end @@ -142,7 +142,7 @@ class W3DHub inscription item.blurb.gsub(/\n+/, "\n").strip[0..1024], fill: true button I18n.t(:"games.read_more"), width: 1.0, margin_top: 8, margin_bottom: 0, padding_top: 4, padding_bottom: 4 do - Launchy.open(item.uri) + W3DHub.url(item.uri) end end diff --git a/lib/pages/games.rb b/lib/pages/games.rb index 2fcbf50..ef97011 100644 --- a/lib/pages/games.rb +++ b/lib/pages/games.rb @@ -116,7 +116,7 @@ class W3DHub flow(width: 1.0, height: 22, margin_bottom: 8) do image "#{GAME_ROOT_PATH}/media/ui_icons/share1.png", width: 0.11 link item.name, text_size: 18 do - Launchy.open(item.uri) + W3DHub.url(item.uri) end end end @@ -223,7 +223,7 @@ class W3DHub stack(width: 0.6, height: 1.0) do stack(width: 1.0, height: 112) do link "#{item.title}", text_size: 18 do - Launchy.open(item.uri) + W3DHub.url(item.uri) end inscription item.blurb.gsub(/\n+/, "\n").strip[0..180] end @@ -231,7 +231,7 @@ class W3DHub flow(width: 1.0) do inscription item.timestamp.strftime("%Y-%m-%d"), width: 0.5 link I18n.t(:"games.read_more"), width: 0.5, text_align: :right, text_size: 14 do - Launchy.open(item.uri) + W3DHub.url(item.uri) end end end @@ -265,7 +265,7 @@ class W3DHub stack(width: 0.75, height: 1.0) do stack(width: 1.0, height: 128 - 28) do - link(mod[:name]) { Launchy.open(mod[:url]) } + link(mod[:name]) { W3DHub.url(mod[:url]) } inscription "Author: #{mod[:author]} | #{mod[:type]} | #{mod[:subtype]}" para mod[:description][0..180] end diff --git a/lib/pages/games_redesign.rb b/lib/pages/games_redesign.rb index aaa7683..1ac0672 100644 --- a/lib/pages/games_redesign.rb +++ b/lib/pages/games_redesign.rb @@ -136,7 +136,7 @@ class W3DHub flow(width: 1.0, height: 22, margin_bottom: 8) do image "#{GAME_ROOT_PATH}/media/ui_icons/share1.png", width: 24 link item.name, text_size: 18 do - Launchy.open(item.uri) + W3DHub.url(item.uri) end end end @@ -426,7 +426,7 @@ class W3DHub inscription item.blurb.gsub(/\n+/, "\n").strip[0..1024], fill: true button I18n.t(:"games.read_more"), width: 1.0, margin_top: 8, margin_bottom: 0, padding_top: 4, padding_bottom: 4 do - Launchy.open(item.uri) + W3DHub.url(item.uri) end end @@ -525,7 +525,7 @@ class W3DHub stack(width: 0.75, height: 1.0) do stack(width: 1.0, height: 128 - 28) do - link(mod[:name]) { Launchy.open(mod[:url]) } + link(mod[:name]) { W3DHub.url(mod[:url]) } inscription "Author: #{mod[:author]} | #{mod[:type]} | #{mod[:subtype]}" para mod[:description][0..180] end diff --git a/lib/pages/login.rb b/lib/pages/login.rb index 51001b2..be93145 100644 --- a/lib/pages/login.rb +++ b/lib/pages/login.rb @@ -98,7 +98,7 @@ class W3DHub flow(width: 1.0) do link(I18n.t(:"interface.log_out"), text_size: 16, width: 0.5) { depopulate_account_info } link I18n.t(:"interface.profile"), text_size: 16, width: 0.49 do - Launchy.open("https://secure.w3dhub.com/forum/index.php?showuser=#{Store.account.id}") + W3DHub.url("https://secure.w3dhub.com/forum/index.php?showuser=#{Store.account.id}") end end end @@ -131,7 +131,7 @@ class W3DHub flow(width: 1.0) do link(I18n.t(:"interface.log_in"), text_size: 16, width: 0.5) { page(W3DHub::Pages::Login) } link I18n.t(:"interface.register"), text_size: 16, width: 0.49 do - Launchy.open("https://secure.w3dhub.com/forum/index.php?app=core&module=global§ion=register") + W3DHub.url("https://secure.w3dhub.com/forum/index.php?app=core&module=global§ion=register") end end end diff --git a/lib/states/interface.rb b/lib/states/interface.rb index c9ac5de..f25028c 100644 --- a/lib/states/interface.rb +++ b/lib/states/interface.rb @@ -67,7 +67,7 @@ class W3DHub flow(width: 1.0) do link(I18n.t(:"interface.log_in"), text_size: 16, width: 0.5) { page(W3DHub::Pages::Login) } link I18n.t(:"interface.register"), text_size: 16, width: 0.49 do - Launchy.open("https://secure.w3dhub.com/forum/index.php?app=core&module=global§ion=register") + W3DHub.url("https://secure.w3dhub.com/forum/index.php?app=core&module=global§ion=register") end end end diff --git a/lib/states/interface_redesign.rb b/lib/states/interface_redesign.rb index 925854e..5e84bac 100644 --- a/lib/states/interface_redesign.rb +++ b/lib/states/interface_redesign.rb @@ -91,7 +91,7 @@ class W3DHub flow(width: 1.0) do link(I18n.t(:"interface.log_in"), text_size: 16, width: 0.5) { page(W3DHub::Pages::Login) } link I18n.t(:"interface.register"), text_size: 16, width: 0.49 do - Launchy.open("https://secure.w3dhub.com/forum/index.php?app=core&module=global§ion=register") + W3DHub.url("https://secure.w3dhub.com/forum/index.php?app=core&module=global§ion=register") end end end diff --git a/w3d_hub_linux_launcher.rb b/w3d_hub_linux_launcher.rb index ece78fa..2575959 100644 --- a/w3d_hub_linux_launcher.rb +++ b/w3d_hub_linux_launcher.rb @@ -68,7 +68,6 @@ class W3DHub end require "i18n" -require "launchy" require "websocket-client-simple" require "English"