Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4657ae2aec | ||
|
|
f134d57b79 | ||
|
|
9b4da98ac4 | ||
|
|
599ca83f0f | ||
|
|
b952007f3b | ||
|
|
c0e74f4756 | ||
|
|
68a8e7ef97 |
@@ -1,7 +1,7 @@
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
|
||||||
<div class="change">
|
<div class="change">
|
||||||
<span class="change-id color-menu">[${moment(input.data.date).format("MMM D HH:mm:SS")}] * </span>
|
<span class="change-id color-menu">[${moment(input.data.date).format("MMM D HH:mm:ss")}] * </span>
|
||||||
<span class="author color-text">${input.data.author} </span>
|
<span class="author color-text">${input.data.author} </span>
|
||||||
<span class="text color-text">${state.operation} </span>
|
<span class="text color-text">${state.operation} </span>
|
||||||
<span for(link in state.links | status-var=loop) key=link.href class="link">
|
<span for(link in state.links | status-var=loop) key=link.href class="link">
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ module.exports = class {
|
|||||||
removed: false,
|
removed: false,
|
||||||
multipart: false,
|
multipart: false,
|
||||||
anchored: false,
|
anchored: false,
|
||||||
|
prevWasText: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mounted = false;
|
this.mounted = false;
|
||||||
@@ -48,6 +49,7 @@ module.exports = class {
|
|||||||
|
|
||||||
const timediff = Date.parse(input.post.time) - Date.parse(input.prev.time)
|
const timediff = Date.parse(input.post.time) - Date.parse(input.prev.time)
|
||||||
this.state.multipart = (input.post.nick == input.prev.nick && input.prev.multipart !== false) && (Math.abs(timediff) < 60000);
|
this.state.multipart = (input.post.nick == input.prev.nick && input.prev.multipart !== false) && (Math.abs(timediff) < 60000);
|
||||||
|
this.state.prevWasText = (input.prev.kind === "text");
|
||||||
|
|
||||||
this.updatePost(input)
|
this.updatePost(input)
|
||||||
}
|
}
|
||||||
@@ -79,14 +81,14 @@ module.exports = class {
|
|||||||
this.state.name = input.post.nick
|
this.state.name = input.post.nick
|
||||||
this.state.nameSuffix = ""
|
this.state.nameSuffix = ""
|
||||||
|
|
||||||
this.state.text = input.post.text.replace(/\x02/g, "**").replace(/\x1D/g, "_").trim();
|
this.state.text = input.post.text.replace(/\x02/g, "**").replace(/\x1D/g, "*").replace(/\`/g, "\\`").trim();
|
||||||
|
|
||||||
if (this.state.text.startsWith("|")) {
|
if (this.state.text.startsWith("|")) {
|
||||||
this.state.name = ""
|
this.state.name = ""
|
||||||
this.state.text = this.state.text.slice(1).trim();
|
this.state.text = this.state.text.slice(1).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.post.kind === "text" && !this.state.text.includes("\"") && !this.state.text.includes("|")) {
|
if (input.post.kind === "text" && !this.state.text.includes("\"") && !this.state.text.includes("\''") && !this.state.text.includes("|")) {
|
||||||
const colonIndex = this.state.text.indexOf(": ");
|
const colonIndex = this.state.text.indexOf(": ");
|
||||||
if (colonIndex != -1 && colonIndex < this.state.text.indexOf(" ")) {
|
if (colonIndex != -1 && colonIndex < this.state.text.indexOf(" ")) {
|
||||||
this.state.text = this.state.text.replace(": ", ": \"") + "\"";
|
this.state.text = this.state.text.replace(": ", ": \"") + "\"";
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<markdown class="post-content post-scene" source=state.text />
|
<markdown class="post-content post-scene" source=state.text />
|
||||||
</div>
|
</div>
|
||||||
<div if(input.post.kind === "action") class="post-body color-text">
|
<div if(input.post.kind === "action") class="post-body color-text">
|
||||||
$ const prefix = (!state.multipart ? state.shortName + state.nameSuffix + " " : "");
|
$ const prefix = ((!state.multipart || state.prevWasText) ? state.shortName + state.nameSuffix + " " : "");
|
||||||
<markdown class="post-content post-action" source=(prefix + state.text) />
|
<markdown class="post-content post-action" source=(prefix + state.text) />
|
||||||
</div>
|
</div>
|
||||||
<div if(input.post.kind === "text") class="post-body color-text">
|
<div if(input.post.kind === "text") class="post-body color-text">
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ module.exports = class {
|
|||||||
|
|
||||||
const search = this.state.search.toLocaleLowerCase()
|
const search = this.state.search.toLocaleLowerCase()
|
||||||
|
|
||||||
this.state.characters = input.characters.filter(c => !this.state.activeMap.characters[c.id]).filter(c => this.matches(c.name, search)).sort((a,b) => a.name.localeCompare(b.name))
|
this.state.characters = input.characters.filter(c => !this.state.activeMap.characters[c.id]).filter(c => this.matches(c.name, search)).sort((a,b) => compareFilters(a.name, b.name, search))
|
||||||
this.state.channels = input.channels.filter(c => !this.state.activeMap.channels[c.name]).filter(c => this.matches(c.name, search)).sort((a,b) => a.name.localeCompare(b.name))
|
this.state.channels = input.channels.filter(c => !this.state.activeMap.channels[c.name]).filter(c => this.matches(c.name, search)).sort((a,b) => compareFilters(a.name, b.name, search))
|
||||||
this.state.eventNames = input.eventNames.filter(e => !this.state.activeMap.events[e]).filter(e => this.matches(e, search)).sort((a,b) => a.localeCompare(b))
|
this.state.eventNames = input.eventNames.filter(e => !this.state.activeMap.events[e]).filter(e => this.matches(e, search)).sort((a,b) => compareFilters(a, b, search))
|
||||||
}
|
}
|
||||||
|
|
||||||
updateActive({filter, characters, channels, eventNames}) {
|
updateActive({filter, characters, channels, eventNames}) {
|
||||||
@@ -126,4 +126,29 @@ module.exports = class {
|
|||||||
|
|
||||||
return str.toLowerCase().indexOf(search) !== -1
|
return str.toLowerCase().indexOf(search) !== -1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {string} a
|
||||||
|
* @param {string} b
|
||||||
|
* @param {string} search
|
||||||
|
*/
|
||||||
|
function compareFilters(a, b, search) {
|
||||||
|
if (search != "") {
|
||||||
|
if (search.charAt(0) != "#" && a.charAt(0) == "#" && b.charAt(0) == "#") {
|
||||||
|
search = '#' + search
|
||||||
|
}
|
||||||
|
|
||||||
|
const aStarts = a.toLocaleLowerCase().startsWith(search)
|
||||||
|
const bStarts = b.toLocaleLowerCase().startsWith(search)
|
||||||
|
|
||||||
|
if (aStarts && !bStarts) {
|
||||||
|
return -1
|
||||||
|
} else if (bStarts && !aStarts) {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return a.localeCompare(b)
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<div class="story-chapter">
|
<div class="story-chapter">
|
||||||
<a class="anchor" id=input.chapter.id />
|
<a class="anchor" id=input.chapter.id />
|
||||||
<h1 if(input.chapter.title) class="title color-primary">${input.chapter.title}</h1>
|
<h1 if(input.chapter.title && !input.hideTitle) class="title color-primary">${input.chapter.title}</h1>
|
||||||
<div class="metadata">
|
<div class="metadata">
|
||||||
<div class="options color-menu">
|
<div class="options color-menu">
|
||||||
<if-permitted user=input.user author=input.chapter.author permission="chapter.edit">
|
<if-permitted user=input.user author=input.chapter.author permission="chapter.edit">
|
||||||
|
|||||||
@@ -19,7 +19,11 @@
|
|||||||
so you can still read it (or back it up) before leaving the page.
|
so you can still read it (or back it up) before leaving the page.
|
||||||
</p>
|
</p>
|
||||||
</annotation>
|
</annotation>
|
||||||
<chapter for(chapter in state.story.chapters) key=chapter.id chapter=chapter user=(!state.removed ? input.user : null) on-edit("updateChapter", chapter.id) on-remove("removeChapter", chapter.id) on-move("moveChapter", chapter) />
|
<chapter for(chapter in state.story.chapters) key=chapter.id
|
||||||
|
chapter=chapter
|
||||||
|
user=(!state.removed ? input.user : null)
|
||||||
|
hideTitle=(state.story.chapters[0] === chapter && chapter.title === state.story.name)
|
||||||
|
on-edit("updateChapter", chapter.id) on-remove("removeChapter", chapter.id) on-move("moveChapter", chapter) />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<create-chapter-modal storyId=state.story.id enabled=(state.modal === "chapter.add") chapter=input.chapter on-close("close") on-add("addChapter") />
|
<create-chapter-modal storyId=state.story.id enabled=(state.modal === "chapter.add") chapter=input.chapter on-close("close") on-add("addChapter") />
|
||||||
|
|||||||
Generated
+5
@@ -3405,6 +3405,11 @@
|
|||||||
"loose-envify": "^1.0.0"
|
"loose-envify": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ip": {
|
||||||
|
"version": "1.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
|
||||||
|
"integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo="
|
||||||
|
},
|
||||||
"ipaddr.js": {
|
"ipaddr.js": {
|
||||||
"version": "1.8.0",
|
"version": "1.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz",
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
"express-session": "^1.15.6",
|
"express-session": "^1.15.6",
|
||||||
"graphql-query-compress": "^1.1.0",
|
"graphql-query-compress": "^1.1.0",
|
||||||
"http-proxy-middleware": "^0.19.1",
|
"http-proxy-middleware": "^0.19.1",
|
||||||
|
"ip": "^1.1.5",
|
||||||
"isomorphic-fetch": "^2.2.1",
|
"isomorphic-fetch": "^2.2.1",
|
||||||
"jsonwebtoken": "^8.3.0",
|
"jsonwebtoken": "^8.3.0",
|
||||||
"lasso": "^3.2.6",
|
"lasso": "^3.2.6",
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ const config = require("./config")
|
|||||||
const express = require("express")
|
const express = require("express")
|
||||||
const proxy = require("express-http-proxy")
|
const proxy = require("express-http-proxy")
|
||||||
const proxy2 = require("http-proxy-middleware")
|
const proxy2 = require("http-proxy-middleware")
|
||||||
|
const ip = require("ip")
|
||||||
|
const dns = require("dns")
|
||||||
const lasso = require("lasso")
|
const lasso = require("lasso")
|
||||||
const lassoMiddleware = require("lasso/middleware")
|
const lassoMiddleware = require("lasso/middleware")
|
||||||
const markoExpress = require("marko/express")
|
const markoExpress = require("marko/express")
|
||||||
@@ -26,7 +28,26 @@ lasso.configure(require("./marko-config"))
|
|||||||
|
|
||||||
// Set trusted proxy
|
// Set trusted proxy
|
||||||
if (config.trustedProxy != null) {
|
if (config.trustedProxy != null) {
|
||||||
app.set('trust proxy', config.trustedProxy)
|
if (ip.isV4Format(config.trustedProxy) || ip.isV6Format(config.trustedProxy)) {
|
||||||
|
app.set('trust proxy', config.trustedProxy)
|
||||||
|
|
||||||
|
console.log("Trusting proxy", config.trustedProxy);
|
||||||
|
} else {
|
||||||
|
dns.resolve4(config.trustedProxy, (err, res) => {
|
||||||
|
if (err != null) {
|
||||||
|
console.error("Failed to resolve trustedProxy hostname")
|
||||||
|
console.error(err)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
if (res.length === 0) {
|
||||||
|
console.error("No results for trustedProxy hostname")
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Trusting proxy", res[0], `(${config.trustedProxy})`);
|
||||||
|
app.set('trust proxy', res[0])
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply middleware
|
// Apply middleware
|
||||||
|
|||||||
Reference in New Issue
Block a user