Skip to content

Commit

Permalink
refactor: handle launchurl elements;
Browse files Browse the repository at this point in the history
  • Loading branch information
ondreian committed Aug 12, 2020
1 parent aedde00 commit 742e26e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"electron-store": "^4.0.0",
"electron-window-state": "^5.0.3",
"keyboardjs": "^2.5.1",
"mark.js": "^8.11.1",
"mithril": "^1.1.6",
"ps-list": "^6.3.0",
"sass": "^1.26.10"
Expand Down
19 changes: 17 additions & 2 deletions src/session/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Bus = require("../bus")
const Parser = require("../parser")
const Pipe = require("../util/pipe")
const Lens = require("../util/lens")
const Url = require("../util/url")
const SessionState = require("./state")
/**
* a TCP Game feed -> DOM renderer
Expand Down Expand Up @@ -233,7 +234,6 @@ module.exports = class Feed {

static TOP_LEVEL_STATUS_TAGS = [
"progressbar",
"indicator",
"container",
"compass",
"dialogdata",
Expand Down Expand Up @@ -261,6 +261,7 @@ module.exports = class Feed {
"stream#inv",
"clearstream",
"streamwindow",
"indicator",
]

ingestDocument(parsed, cb) {
Expand All @@ -280,13 +281,27 @@ module.exports = class Feed {
this.ingestDocumentTextNodes(parsed.head)
if (prompt) this.append(prompt)
this.pruneIgnorableTags(parsed)
// make sure we handled all state tags that might
// also contain renderable text
this.ingestState(parsed, Feed.LOOSELY_NESTED_TAGS)

const launch = parsed.querySelector("launchurl")
// handles goals, bbs commands
if (launch) {
console.log(launch)
launch.remove()
Url.open_external_link(
"https://www.play.net" +
launch.attributes.src.value
)
}

if (parsed.body.hasChildNodes()) {
// this is for debugging
console.log(
"parsed:unhandled(children: %s, %o)",
parsed.body.hasChildNodes(),
parsed.body.childNodes
(window._temp = parsed)
)
}
return ok()
Expand Down
5 changes: 5 additions & 0 deletions src/util/url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exports.open_external_link = (url) => {
// console.log("opening:url(%s)", url)
require("electron").shell.openExternal(url)
return false
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3353,6 +3353,11 @@ map-visit@^1.0.0:
dependencies:
object-visit "^1.0.0"

mark.js@^8.11.1:
version "8.11.1"
resolved "https://registry.yarnpkg.com/mark.js/-/mark.js-8.11.1.tgz#180f1f9ebef8b0e638e4166ad52db879beb2ffc5"
integrity sha1-GA8fnr74sOY45BZq1S24eb6y/8U=

md5.js@^1.3.4:
version "1.3.5"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
Expand Down

0 comments on commit 742e26e

Please sign in to comment.