From 1e4f2929d0f38c9b84e95e60ed3c5ca2fdd686be Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Mon, 27 Mar 2023 18:35:20 -0700 Subject: [PATCH] Open external links in system browser in desktop mode --- build.py | 13 ++++++++++++- index.html | 8 ++++---- info.html | 26 +++++++++++++------------- script/config.js | 5 +++-- script/nav.js | 7 +++++++ 5 files changed, 39 insertions(+), 20 deletions(-) diff --git a/build.py b/build.py index c7953d2..0f371cb 100755 --- a/build.py +++ b/build.py @@ -530,7 +530,7 @@ def stageWeb(_dir, verbose=False): if options["web-dist"]: contents = changes changes = re.sub( - r"^config\[\"web-dist\"\] = false$", + r"^config\[\"web-dist\"\] = false", "config[\"web-dist\"] = true", contents, 1, re.M ) @@ -615,6 +615,17 @@ def stageDesktop(_dir, verbose=False): break if lines != lines_orig: writeFile(file_index, lines) + file_config_js = os.path.join(dir_res, "script", "config.js") + content = readFile(file_config_js) + changes = re.sub( + r"^config\[\"desktop\"\] = false", + "config[\"desktop\"] = true", + content, 1, re.M + ) + if changes != content: + writeFile(file_config_js, changes) + if verbose: + print("updated file '{}'".format(file_config_js)) def runDesktop(_dir, verbose=False): targets.run("stage-desktop", _dir, verbose) diff --git a/index.html b/index.html index 976f03a..989d6cb 100644 --- a/index.html +++ b/index.html @@ -20,11 +20,11 @@

A character sprite generator inspired by - + Stendhal , - + Liberated Pixel Cup , & - + Cabbit.

@@ -156,7 +156,7 @@

background image by Kimmo Rundelin licensed under Creative Commons Attribution-ShareAlike 3.0

this software is a work-in-progress

-

source code available on GitHub

+

source code available on GitHub

diff --git a/info.html b/info.html index 62b288b..8ccbca2 100644 --- a/info.html +++ b/info.html @@ -31,7 +31,7 @@

That being said, these assets are free and under very permissive licenses. If you plan to use what is provided here in a product, project, or distribution center that is not encumbered by - DRM restrictions, chances + DRM restrictions, chances are you can use it. Just abide by the terms of the license and follow any additional specifications required by the author(s) where necessary.

@@ -69,39 +69,39 @@
  • CC BY-SA
  • CC BY
  • OGA BY
  • CC0/Public Domain
  • diff --git a/script/config.js b/script/config.js index 128c332..069136d 100644 --- a/script/config.js +++ b/script/config.js @@ -12,5 +12,6 @@ export const config = {}; config["version"] = "0.2"; config["git-repo"] = "https://github.com/AntumDeluge/chargen"; -config["asset-info"] = config["git-repo"] + "/blob/master/assets/README.md" -config["web-dist"] = false +config["asset-info"] = config["git-repo"] + "/blob/master/assets/README.md"; +config["web-dist"] = false; +config["desktop"] = false; diff --git a/script/nav.js b/script/nav.js index 2ad7dd6..425a4b2 100644 --- a/script/nav.js +++ b/script/nav.js @@ -30,6 +30,13 @@ const formatLinks = function() { if (anchor.id && typeof(config[anchor.id]) !== "undefined") { anchor.href = config[anchor.id]; } + if (config["desktop"] && anchor.classList.contains("extern")) { + anchor.onclick = function(evt) { + evt.preventDefault(); + // open external links in system browser + Neutralino.os.open(anchor.href); + } + } } }