diff --git a/marko/components/irc-caret-notation/component.js b/marko/components/irc-caret-notation/component.js new file mode 100644 index 0000000..d687361 --- /dev/null +++ b/marko/components/irc-caret-notation/component.js @@ -0,0 +1,23 @@ +const {parse, BOLD} = require("irc-caret-notation") + +module.exports = class { + onCreate() { + this.state = { + paragraphs: [], + prev: "", + } + } + + onInput(input) { + if (this.state == null) { + return + } + + if (input.source != this.state.prev) { + this.state.prev = input.source + this.state.paragraphs = input.source.split("\n").filter(l => l.length > 0).map(l => parse(l, { + "*": (!(input.source.startsWith("(")) ? BOLD : null), + })) + } + } +} \ No newline at end of file diff --git a/marko/components/irc-caret-notation/index.marko b/marko/components/irc-caret-notation/index.marko new file mode 100644 index 0000000..46a7cab --- /dev/null +++ b/marko/components/irc-caret-notation/index.marko @@ -0,0 +1,5 @@ +
+

+ ${chunk.text} +

+
\ No newline at end of file diff --git a/marko/components/menu-link/index.marko b/marko/components/menu-link/index.marko index 59f84af..7b18f33 100644 --- a/marko/components/menu-link/index.marko +++ b/marko/components/menu-link/index.marko @@ -1,6 +1,6 @@ -
-
${input.icon}
+
+
${input.icon}
diff --git a/marko/page/logs-content/components/logs-content-menu/component.js b/marko/page/logs-content/components/logs-content-menu/component.js index ae6c37b..5e4fdea 100644 --- a/marko/page/logs-content/components/logs-content-menu/component.js +++ b/marko/page/logs-content/components/logs-content-menu/component.js @@ -1,5 +1,21 @@ module.exports = class { + onCreate() { + this.state = { + highlights: [], + } + } + select(value) { this.emit("select", value) } + + toggleHighlight(id) { + if (this.state.highlights.includes(id)) { + this.state.highlights = this.state.highlights.filter(id2 => id2 !== id) + } else { + this.state.highlights = this.state.highlights.concat(id) + } + + this.emit("hightlights", this.state.highlights); + } } \ No newline at end of file diff --git a/marko/page/logs-content/components/logs-content-menu/index.marko b/marko/page/logs-content/components/logs-content-menu/index.marko index 88e4ec1..e0674d4 100644 --- a/marko/page/logs-content/components/logs-content-menu/index.marko +++ b/marko/page/logs-content/components/logs-content-menu/index.marko @@ -4,10 +4,23 @@ Add Post - Links + Channel ${input.log.channel.name} - ${input.log.channel.eventName} - - ${character.name} (${character.author}) - + + + Event + ${input.log.eventName} + + + 0)> + Characters + + 0 && !state.highlights.includes(character.id)) + icon="C" + on-click("toggleHighlight", character.id)> + ${character.name} (${character.author}) + + + + \ No newline at end of file diff --git a/marko/page/logs-content/components/page/component.js b/marko/page/logs-content/components/page/component.js index f86be86..0be23e9 100644 --- a/marko/page/logs-content/components/page/component.js +++ b/marko/page/logs-content/components/page/component.js @@ -9,6 +9,7 @@ module.exports = class { log: input.log, modal: null, removed: false, + highlights: [], } } @@ -166,6 +167,10 @@ module.exports = class { this.state.removed = true } + highlightsChanged(highlights) { + this.state.highlights = highlights.slice(); + } + get title() { if (this.state.log.title) { return this.state.log.title diff --git a/marko/page/logs-content/components/page/index.marko b/marko/page/logs-content/components/page/index.marko index d039f0d..5dadbe9 100644 --- a/marko/page/logs-content/components/page/index.marko +++ b/marko/page/logs-content/components/page/index.marko @@ -1,4 +1,4 @@ - +
@@ -25,6 +25,7 @@ prev=(state.log.posts[loop.getIndex() - 1] || {}) post=post characters=state.log.characters + highlights=state.highlights last=(post.position === state.log.posts.length) />
diff --git a/marko/page/logs-content/components/post/component.js b/marko/page/logs-content/components/post/component.js index 342eb64..57edf1f 100644 --- a/marko/page/logs-content/components/post/component.js +++ b/marko/page/logs-content/components/post/component.js @@ -14,6 +14,7 @@ module.exports = class { multipart: false, anchored: false, prevWasText: false, + dark: false, } this.mounted = false; @@ -80,39 +81,13 @@ module.exports = class { this.state.shortName = input.post.nick.split("_").shift() this.state.name = input.post.nick this.state.nameSuffix = "" - - this.state.text = input.post.text.replace(/\x02/g, "**").replace(/\x1D/g, "*").replace(/\`/g, "\\`").trim(); - - // Fix Ctrl-Bs - let left = false - this.state.text = this.state.text.replace(/\s*\*\*\s*/g, str => { - left = !left - - if (left) { - return " **" - } else if (!left) { - return "** " - } - - return str - }) - - if (this.state.text.startsWith("|")) { - this.state.name = "" - this.state.text = this.state.text.slice(1).trim(); - } - if (input.post.kind === "text" && !this.state.text.includes("\"") && !this.state.text.includes("\''") && !this.state.text.includes("|")) { - const colonIndex = this.state.text.indexOf(": "); - if (colonIndex != -1 && colonIndex < this.state.text.indexOf(" ")) { - this.state.text = this.state.text.replace(": ", ": \"") + "\""; - } else { - this.state.text = '"' + this.state.text + '"' - } - } + this.state.text = input.post.text - if (this.state.text.charAt(0) == this.state.text.charAt(0).toUpperCase()) { - this.state.name = "" + if (input.highlights.length > 0 && (input.post.kind === "action" || input.post.kind === "text")) { + this.state.dark = true + } else { + this.state.dark = false } if (!input.post.nick.startsWith("=")) { @@ -120,13 +95,19 @@ module.exports = class { for (const character of input.characters) { for (const nick of character.nicks) { if (nick === postNick) { - this.state.name = character.name + this.state.name = character.name + character.id this.state.shortName = character.shortName if (input.post.nick.endsWith("'s") || input.post.nick.endsWith("'")) { this.state.nameSuffix = (character.shortName.endsWith("s") || character.shortName.endsWith("z")) ? "'" : "'s" } + if (input.highlights.length > 0) { + this.state.dark = !(input.highlights.includes(character.id)) + } else { + this.state.dark = false + } + return } } diff --git a/marko/page/logs-content/components/post/index.marko b/marko/page/logs-content/components/post/index.marko index e70cce1..d2b0620 100644 --- a/marko/page/logs-content/components/post/index.marko +++ b/marko/page/logs-content/components/post/index.marko @@ -1,4 +1,4 @@ -
+
diff --git a/package-lock.json b/package-lock.json index 585af88..c31d19c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2308,13 +2308,13 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fsevents": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.4.tgz", - "integrity": "sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg==", + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.8.tgz", + "integrity": "sha512-tPvHgPGB7m40CZ68xqFGkKuzN+RnpGmSV+hgeKxhRpbxdqKXUFJGC3yonBOLzQBcJyGpdZFDfCsdOC2KFsXzeA==", "optional": true, "requires": { - "nan": "^2.9.2", - "node-pre-gyp": "^0.10.0" + "nan": "^2.12.1", + "node-pre-gyp": "^0.12.0" }, "dependencies": { "abbrev": { @@ -2324,7 +2324,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -2332,7 +2333,7 @@ "optional": true }, "are-we-there-yet": { - "version": "1.1.4", + "version": "1.1.5", "bundled": true, "optional": true, "requires": { @@ -2342,32 +2343,37 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "chownr": { - "version": "1.0.1", + "version": "1.1.1", "bundled": true, "optional": true }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2375,15 +2381,15 @@ "optional": true }, "debug": { - "version": "2.6.9", + "version": "4.1.1", "bundled": true, "optional": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, "deep-extend": { - "version": "0.5.1", + "version": "0.6.0", "bundled": true, "optional": true }, @@ -2426,7 +2432,7 @@ } }, "glob": { - "version": "7.1.2", + "version": "7.1.3", "bundled": true, "optional": true, "requires": { @@ -2444,11 +2450,11 @@ "optional": true }, "iconv-lite": { - "version": "0.4.21", + "version": "0.4.24", "bundled": true, "optional": true, "requires": { - "safer-buffer": "^2.1.0" + "safer-buffer": ">= 2.1.2 < 3" } }, "ignore-walk": { @@ -2470,7 +2476,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2480,6 +2487,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2492,24 +2500,27 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { - "version": "2.2.4", + "version": "2.3.5", "bundled": true, + "optional": true, "requires": { - "safe-buffer": "^5.1.1", + "safe-buffer": "^5.1.2", "yallist": "^3.0.0" } }, "minizlib": { - "version": "1.1.0", + "version": "1.2.1", "bundled": true, "optional": true, "requires": { @@ -2519,37 +2530,38 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } }, "ms": { - "version": "2.0.0", + "version": "2.1.1", "bundled": true, "optional": true }, "needle": { - "version": "2.2.0", + "version": "2.3.0", "bundled": true, "optional": true, "requires": { - "debug": "^2.1.2", + "debug": "^4.1.0", "iconv-lite": "^0.4.4", "sax": "^1.2.4" } }, "node-pre-gyp": { - "version": "0.10.0", + "version": "0.12.0", "bundled": true, "optional": true, "requires": { "detect-libc": "^1.0.2", "mkdirp": "^0.5.1", - "needle": "^2.2.0", + "needle": "^2.2.1", "nopt": "^4.0.1", "npm-packlist": "^1.1.6", "npmlog": "^4.0.2", - "rc": "^1.1.7", + "rc": "^1.2.7", "rimraf": "^2.6.1", "semver": "^5.3.0", "tar": "^4" @@ -2565,12 +2577,12 @@ } }, "npm-bundled": { - "version": "1.0.3", + "version": "1.0.6", "bundled": true, "optional": true }, "npm-packlist": { - "version": "1.1.10", + "version": "1.4.1", "bundled": true, "optional": true, "requires": { @@ -2591,7 +2603,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2601,6 +2614,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2635,11 +2649,11 @@ "optional": true }, "rc": { - "version": "1.2.7", + "version": "1.2.8", "bundled": true, "optional": true, "requires": { - "deep-extend": "^0.5.1", + "deep-extend": "^0.6.0", "ini": "~1.3.0", "minimist": "^1.2.0", "strip-json-comments": "~2.0.1" @@ -2667,16 +2681,17 @@ } }, "rimraf": { - "version": "2.6.2", + "version": "2.6.3", "bundled": true, "optional": true, "requires": { - "glob": "^7.0.5" + "glob": "^7.1.3" } }, "safe-buffer": { - "version": "5.1.1", - "bundled": true + "version": "5.1.2", + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2689,7 +2704,7 @@ "optional": true }, "semver": { - "version": "5.5.0", + "version": "5.7.0", "bundled": true, "optional": true }, @@ -2706,6 +2721,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2723,6 +2739,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2733,16 +2750,16 @@ "optional": true }, "tar": { - "version": "4.4.1", + "version": "4.4.8", "bundled": true, "optional": true, "requires": { - "chownr": "^1.0.1", + "chownr": "^1.1.1", "fs-minipass": "^1.2.5", - "minipass": "^2.2.4", - "minizlib": "^1.1.0", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.1", + "safe-buffer": "^5.1.2", "yallist": "^3.0.2" } }, @@ -2752,20 +2769,22 @@ "optional": true }, "wide-align": { - "version": "1.1.2", + "version": "1.1.3", "bundled": true, "optional": true, "requires": { - "string-width": "^1.0.2" + "string-width": "^1.0.2 || 2" } }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { - "version": "3.0.2", - "bundled": true + "version": "3.0.3", + "bundled": true, + "optional": true } } }, @@ -3415,6 +3434,11 @@ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" }, + "irc-caret-notation": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/irc-caret-notation/-/irc-caret-notation-1.0.0.tgz", + "integrity": "sha512-V/Dhqb/wentrfxH5U2pUTK1ye53mIEmpWCpT81Qa+/YfEDY7XuFjpCD/J0WRzjDqaecwn4mj0Mz+6T6bAz/BSA==" + }, "is-absolute": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz", @@ -3977,9 +4001,9 @@ "integrity": "sha1-OWCLQ1wJAfpVECF8FFJyjWvBm18=" }, "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" }, "lodash.includes": { "version": "4.3.0", @@ -4289,9 +4313,9 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", + "version": "2.13.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", + "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==", "optional": true }, "nanomatch": { diff --git a/package.json b/package.json index 4171f9d..1853bdb 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "graphql-query-compress": "^1.1.0", "http-proxy-middleware": "^0.19.1", "ip": "^1.1.5", + "irc-caret-notation": "^1.0.0", "isomorphic-fetch": "^2.2.1", "jsonwebtoken": "^8.3.0", "lasso": "^3.2.6",