logs, logs-content: Added basic view of logs and added characters to logs

This commit is contained in:
2018-09-29 13:38:18 +02:00
parent 35cee41d3a
commit ed01006b21
27 changed files with 442 additions and 13 deletions
@@ -0,0 +1,50 @@
module.exports = class {
onCreate(input) {
this.state = {
shortName: "",
name: "",
text: "",
}
this.updatePost(input)
}
onInput(input) {
if (this.state == null) {
return
}
this.updatePost(input)
}
updatePost(input) {
this.state.shortName = input.post.nick.split("_").shift()
this.state.name = input.post.nick
this.state.text = input.post.text.replace(/\x02/g, "**")
if (input.post.kind === "text" && !this.state.text.includes("\"")) {
this.state.text = '"' + this.state.text + '"'
}
if (!input.post.nick.startsWith("=")) {
const postNick = input.post.nick.replace("'s", "").replace("s'", "s")
for (const character of input.characters) {
for (const nick of character.nicks) {
if (nick === postNick) {
this.state.shortName = character.shortName
return
}
}
}
}
}
kindClass(prefix) {
if (this.input.post == null) {
return
}
return `${prefix}${this.input.post.kind.replace(".", "-")}`
}
}
@@ -0,0 +1,20 @@
<div class=["post", component.kindClass("post-type")]>
<div class="post-meta-row">
<post-meta kind="timestamp" value=input.post.time />
<post-meta kind="nick" value=input.post.nick />
</div>
<div if(input.post.kind.startsWith("annotation.")) class="post-body" >
<annotation level=(input.post.kind.substring(11))>
<markdown class="post-content" source=state.text />
</annotation>
</div>
<div if(input.post.kind === "scene") class="post-body color-text">
<markdown class="post-content post-scene" source=state.text />
</div>
<div if(input.post.kind === "action") class="post-body color-text">
<markdown class="post-content post-action" source=(state.shortName + " " + state.text) />
</div>
<div if(input.post.kind === "text") class="post-body color-text">
<markdown class="post-content post-text" source=state.text />
</div>
</div>
@@ -0,0 +1,36 @@
div.post {
margin-bottom: 1ch;
.post-meta-row {
padding: 0;
margin: 0;
}
div.post-body {
font-size: 1.25em;
div.nick-wrapper {
display: inline;
.nick-decoration {
display: inline;
}
.nick {
display: inline;
}
}
div.post-content {
display: inline;
}
div.annotation {
margin-top: 0.33em;
}
}
div.post-body p:first-of-type {
margin-top: 0;
padding-top: 0;
}
}