Skip to content

Commit

Permalink
Open external links in system browser in desktop mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Mar 28, 2023
1 parent b11d54a commit 1e4f292
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 20 deletions.
13 changes: 12 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
<div id="description">
<p>
A character sprite generator inspired by
<a class="button" href="https://stendhalgame.org/">
<a class="button extern" href="https://stendhalgame.org/">
<span class="button">Stendhal</span></a> ,
<a class="button" href="https://lpc.opengameart.org/">
<a class="button extern" href="https://lpc.opengameart.org/">
<span class="button">Liberated Pixel Cup</span></a> , &amp;
<a class="button" href="https://opengameart.org/users/cabbit">
<a class="button extern" href="https://opengameart.org/users/cabbit">
<span class="button">Cabbit</span></a>.
</p>

Expand Down Expand Up @@ -156,7 +156,7 @@
<p>background image by Kimmo Rundelin licensed under
<a href="doc/licenses/CC-BY-SA-3.0.txt">Creative Commons Attribution-ShareAlike 3.0</a></p>
<p>this software is a work-in-progress</p>
<p>source code available on <a class="button" id="git-repo"><span class="button">GitHub</span></a></p>
<p>source code available on <a class="button extern" id="git-repo"><span class="button">GitHub</span></a></p>
<p id="desktop-download"></p>
</div>
</body>
Expand Down
26 changes: 13 additions & 13 deletions info.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<p class="details">
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
<a href="https://en.wikipedia.org/wiki/Digital_rights_management">DRM restrictions</a>, chances
<a class="extern" href"https://en.wikipedia.org/wiki/Digital_rights_management">DRM restrictions</a>, 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.
</p>
Expand Down Expand Up @@ -69,39 +69,39 @@
<li>
CC BY-SA
<ul>
<li><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode">
<li><a class="extern" href"https://creativecommons.org/licenses/by-sa/4.0/legalcode">
Creative Commons Attribution-ShareAlike 4.0
</a> (<a href="https://creativecommons.org/licenses/by-sa/4.0/">summary</a>)</li>
<li><a href="https://creativecommons.org/licenses/by-sa/3.0/legalcode">
</a> (<a class="extern" href"https://creativecommons.org/licenses/by-sa/4.0/">summary</a>)</li>
<li><a class="extern" href"https://creativecommons.org/licenses/by-sa/3.0/legalcode">
Creative Commons Attribution-ShareAlike 3.0
</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">summary</a>)</li>
</a> (<a class="extern" href"https://creativecommons.org/licenses/by-sa/3.0/">summary</a>)</li>
</ul>
</li>
<li>
CC BY
<ul>
<li><a href="https://creativecommons.org/licenses/by/4.0/legalcode">
<li><a class="extern" href"https://creativecommons.org/licenses/by/4.0/legalcode">
Creative Commons Attribution 4.0
</a> (<a href="https://creativecommons.org/licenses/by/4.0/">summary</a>)</li>
<li><a href="https://creativecommons.org/licenses/by/3.0/legalcode">
</a> (<a class="extern" href"https://creativecommons.org/licenses/by/4.0/">summary</a>)</li>
<li><a class="extern" href"https://creativecommons.org/licenses/by/3.0/legalcode">
Creative Commons Attribution 3.0
</a> (<a href="https://creativecommons.org/licenses/by/3.0/">summary</a>)</li>
</a> (<a class="extern" href"https://creativecommons.org/licenses/by/3.0/">summary</a>)</li>
</ul>
</li>
<li>
OGA BY
<ul>
<li><a href="https://static.opengameart.org/OGA-BY-3.0.txt">
<li><a class="extern" href"https://static.opengameart.org/OGA-BY-3.0.txt">
OpenGameArt.org Attribution 3.0
</a> (<a href="https://opengameart.org/content/oga-by-30-faq">FAQ</a>)</li>
</a> (<a class="extern" href"https://opengameart.org/content/oga-by-30-faq">FAQ</a>)</li>
</ul>
</li>
<li>
CC0/Public Domain
<ul>
<li><a href="https://creativecommons.org/publicdomain/zero/1.0/legalcode">
<li><a class="extern" href"https://creativecommons.org/publicdomain/zero/1.0/legalcode">
Creative Commons Zero
</a> (<a href="https://creativecommons.org/publicdomain/zero/1.0/">summary</a>)</li>
</a> (<a class="extern" href"https://creativecommons.org/publicdomain/zero/1.0/">summary</a>)</li>
</ul>
</li>
</ul>
Expand Down
5 changes: 3 additions & 2 deletions script/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
7 changes: 7 additions & 0 deletions script/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}

Expand Down

0 comments on commit 1e4f292

Please sign in to comment.