Rename helpers folder, move some vue filters
This commit is contained in:
parent
b164e95290
commit
fc1c9568e2
@ -9,8 +9,8 @@
|
||||
# Ignore client folder as it's being built into public/ folder
|
||||
# except for the specified files which are used by the server
|
||||
client/**
|
||||
!client/js/libs/handlebars/ircmessageparser/findLinks.js
|
||||
!client/js/libs/handlebars/ircmessageparser/cleanIrcMessage.js
|
||||
!client/js/helpers/ircmessageparser/findLinks.js
|
||||
!client/js/helpers/ircmessageparser/cleanIrcMessage.js
|
||||
!client/index.html.tpl
|
||||
|
||||
public/js/bundle.vendor.js.map
|
||||
|
@ -2,7 +2,7 @@
|
||||
<ChannelWrapper ref="wrapper" :network="network" :channel="channel">
|
||||
<span class="name">{{ channel.name }}</span>
|
||||
<span v-if="channel.unread" :class="{highlight: channel.highlight}" class="badge">{{
|
||||
channel.unread | roundBadgeNumber
|
||||
unreadCount
|
||||
}}</span>
|
||||
<template v-if="channel.type === 'channel'">
|
||||
<span
|
||||
@ -25,6 +25,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const roundBadgeNumber = require("../js/helpers/roundBadgeNumber");
|
||||
import ChannelWrapper from "./ChannelWrapper.vue";
|
||||
|
||||
export default {
|
||||
@ -36,6 +37,11 @@ export default {
|
||||
network: Object,
|
||||
channel: Object,
|
||||
},
|
||||
computed: {
|
||||
unreadCount() {
|
||||
return roundBadgeNumber(this.channel.unread);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
this.$refs.wrapper.close();
|
||||
|
@ -77,8 +77,7 @@
|
||||
</template>
|
||||
<template v-else-if="link.type === 'error'">
|
||||
<em v-if="link.error === 'image-too-big'">
|
||||
This image is larger than {{ link.maxSize | friendlysize }} and cannot be
|
||||
previewed.
|
||||
This image is larger than {{ imageMaxSize }} and cannot be previewed.
|
||||
<a :href="link.link" target="_blank" rel="noopener">Click here</a>
|
||||
to open it in a new window.
|
||||
</em>
|
||||
@ -108,6 +107,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const friendlysize = require("../js/helpers/friendlysize");
|
||||
|
||||
export default {
|
||||
name: "LinkPreview",
|
||||
props: {
|
||||
@ -124,6 +125,9 @@ export default {
|
||||
moreButtonLabel() {
|
||||
return this.isContentShown ? "Less" : "More";
|
||||
},
|
||||
imageMaxSize() {
|
||||
return friendlysize(this.link.maxSize);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
"link.type"() {
|
||||
|
@ -28,7 +28,7 @@
|
||||
<span class="not-connected-icon" />
|
||||
</span>
|
||||
<span v-if="channel.unread" :class="{highlight: channel.highlight}" class="badge">{{
|
||||
channel.unread | roundBadgeNumber
|
||||
unreadCount
|
||||
}}</span>
|
||||
</div>
|
||||
<span
|
||||
@ -47,6 +47,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const roundBadgeNumber = require("../js/helpers/roundBadgeNumber");
|
||||
import ChannelWrapper from "./ChannelWrapper.vue";
|
||||
import socket from "../js/socket";
|
||||
const storage = require("../js/localStorage");
|
||||
@ -67,6 +68,9 @@ export default {
|
||||
joinChannelLabel() {
|
||||
return this.isJoinChannelShown ? "Cancel" : "Join a channel…";
|
||||
},
|
||||
unreadCount() {
|
||||
return roundBadgeNumber(this.channel.unread);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script>
|
||||
const parse = require("../js/libs/handlebars/parse");
|
||||
const parse = require("../js/helpers/parse");
|
||||
|
||||
export default {
|
||||
name: "ParsedMessage",
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<span
|
||||
:class="['user', $options.filters.colorClass(user.nick), {active: active}]"
|
||||
:class="['user', nickColor, {active: active}]"
|
||||
:data-name="user.nick"
|
||||
role="button"
|
||||
v-on="onHover ? {mouseover: hover} : {}"
|
||||
@ -9,6 +9,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const colorClass = require("../js/helpers/colorClass");
|
||||
|
||||
export default {
|
||||
name: "Username",
|
||||
props: {
|
||||
@ -16,6 +18,11 @@ export default {
|
||||
active: Boolean,
|
||||
onHover: Function,
|
||||
},
|
||||
computed: {
|
||||
nickColor() {
|
||||
return colorClass(this.user.nick);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
hover() {
|
||||
return this.onHover(this.user);
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<span
|
||||
:class="['user', $options.filters.colorClass(user.original.nick), {active: active}]"
|
||||
:class="['user', nickColor, {active: active}]"
|
||||
:data-name="user.original.nick"
|
||||
role="button"
|
||||
@mouseover="hover"
|
||||
@ -9,6 +9,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const colorClass = require("../js/helpers/colorClass");
|
||||
|
||||
export default {
|
||||
name: "UsernameFiltered",
|
||||
props: {
|
||||
@ -16,6 +18,11 @@ export default {
|
||||
active: Boolean,
|
||||
onHover: Function,
|
||||
},
|
||||
computed: {
|
||||
nickColor() {
|
||||
return colorClass(this.user.original.nick);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
hover() {
|
||||
this.onHover ? this.onHover(this.user.original) : null;
|
||||
|
@ -4,7 +4,7 @@ const $ = require("jquery");
|
||||
const fuzzy = require("fuzzy");
|
||||
const Mousetrap = require("mousetrap");
|
||||
const {Textcomplete, Textarea} = require("textcomplete");
|
||||
const emojiMap = require("./libs/simplemap.json");
|
||||
const emojiMap = require("./helpers/simplemap.json");
|
||||
const constants = require("./constants");
|
||||
const store = require("./store").default;
|
||||
|
||||
|
@ -7,10 +7,10 @@ const findEmoji = require("./ircmessageparser/findEmoji");
|
||||
const findNames = require("./ircmessageparser/findNames");
|
||||
const merge = require("./ircmessageparser/merge");
|
||||
const colorClass = require("./colorClass");
|
||||
const emojiMap = require("../fullnamemap.json");
|
||||
const LinkPreviewToggle = require("../../../components/LinkPreviewToggle.vue").default;
|
||||
const LinkPreviewFileSize = require("../../../components/LinkPreviewFileSize.vue").default;
|
||||
const InlineChannel = require("../../../components/InlineChannel.vue").default;
|
||||
const emojiMap = require("./fullnamemap.json");
|
||||
const LinkPreviewToggle = require("../../components/LinkPreviewToggle.vue").default;
|
||||
const LinkPreviewFileSize = require("../../components/LinkPreviewFileSize.vue").default;
|
||||
const InlineChannel = require("../../components/InlineChannel.vue").default;
|
||||
const emojiModifiersRegex = /[\u{1f3fb}-\u{1f3ff}]/gu;
|
||||
|
||||
// Create an HTML `span` with styling information for a given fragment
|
@ -1,16 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = function(a, b, opt) {
|
||||
if (arguments.length !== 3) {
|
||||
throw new Error("Handlebars helper `equal` expects 3 arguments");
|
||||
}
|
||||
|
||||
a = a.toString();
|
||||
b = b.toString();
|
||||
|
||||
if (a === b) {
|
||||
return opt.fn(this);
|
||||
}
|
||||
|
||||
return opt.inverse(this);
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const socket = require("../socket");
|
||||
const cleanIrcMessage = require("../libs/handlebars/ircmessageparser/cleanIrcMessage");
|
||||
const cleanIrcMessage = require("../helpers/ircmessageparser/cleanIrcMessage");
|
||||
const webpush = require("../webpush");
|
||||
const {vueApp} = require("../vue");
|
||||
const store = require("../store").default;
|
||||
|
@ -4,18 +4,12 @@ const Vue = require("vue").default;
|
||||
|
||||
const store = require("./store").default;
|
||||
const App = require("../components/App.vue").default;
|
||||
const roundBadgeNumber = require("./libs/handlebars/roundBadgeNumber");
|
||||
const localetime = require("./libs/handlebars/localetime");
|
||||
const friendlysize = require("./libs/handlebars/friendlysize");
|
||||
const colorClass = require("./libs/handlebars/colorClass");
|
||||
const localetime = require("./helpers/localetime");
|
||||
const storage = require("./localStorage");
|
||||
const {router} = require("./router");
|
||||
const constants = require("./constants");
|
||||
|
||||
Vue.filter("localetime", localetime);
|
||||
Vue.filter("friendlysize", friendlysize);
|
||||
Vue.filter("colorClass", colorClass);
|
||||
Vue.filter("roundBadgeNumber", roundBadgeNumber);
|
||||
|
||||
const appName = document.title;
|
||||
|
||||
|
@ -24,12 +24,12 @@ const fs = require("fs");
|
||||
const fullNameEmojiMapOutput = JSON.stringify(fullNameEmojiMap, null, 2) + "\n";
|
||||
|
||||
fs.writeFileSync(
|
||||
path.resolve(path.join(__dirname, "..", "client", "js", "libs", "simplemap.json")),
|
||||
path.resolve(path.join(__dirname, "..", "client", "js", "helpers", "simplemap.json")),
|
||||
emojiMapOutput
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
path.resolve(path.join(__dirname, "..", "client", "js", "libs", "fullnamemap.json")),
|
||||
path.resolve(path.join(__dirname, "..", "client", "js", "helpers", "fullnamemap.json")),
|
||||
fullNameEmojiMapOutput
|
||||
);
|
||||
})();
|
||||
|
@ -5,8 +5,8 @@ const got = require("got");
|
||||
const URL = require("url").URL;
|
||||
const mime = require("mime-types");
|
||||
const Helper = require("../../helper");
|
||||
const cleanIrcMessage = require("../../../client/js/libs/handlebars/ircmessageparser/cleanIrcMessage");
|
||||
const findLinks = require("../../../client/js/libs/handlebars/ircmessageparser/findLinks");
|
||||
const cleanIrcMessage = require("../../../client/js/helpers/ircmessageparser/cleanIrcMessage");
|
||||
const findLinks = require("../../../client/js/helpers/ircmessageparser/findLinks");
|
||||
const storage = require("../storage");
|
||||
const currentFetchPromises = new Map();
|
||||
const imageTypeRegex = /^image\/.+/;
|
||||
|
@ -3,7 +3,7 @@
|
||||
const Chan = require("../../models/chan");
|
||||
const Msg = require("../../models/msg");
|
||||
const LinkPrefetch = require("./link");
|
||||
const cleanIrcMessage = require("../../../client/js/libs/handlebars/ircmessageparser/cleanIrcMessage");
|
||||
const cleanIrcMessage = require("../../../client/js/helpers/ircmessageparser/cleanIrcMessage");
|
||||
const Helper = require("../../helper");
|
||||
const nickRegExp = /(?:\x03[0-9]{1,2}(?:,[0-9]{1,2})?)?([\w[\]\\`^{|}-]+)/g;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const friendlysize = require("../../../../../client/js/libs/handlebars/friendlysize");
|
||||
const friendlysize = require("../../../../client/js/helpers/friendlysize");
|
||||
|
||||
describe("friendlysize Handlebars helper", function() {
|
||||
describe("friendlysize helper", function() {
|
||||
it("should render big values in human-readable version", function() {
|
||||
expect(friendlysize(51200)).to.equal("50 KB");
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const anyIntersection = require("../../../../../../client/js/libs/handlebars/ircmessageparser/anyIntersection");
|
||||
const anyIntersection = require("../../../../../client/js/helpers/ircmessageparser/anyIntersection");
|
||||
|
||||
describe("anyIntersection", () => {
|
||||
it("should not intersect on edges", () => {
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const cleanIrcMessage = require("../../../../../../client/js/libs/handlebars/ircmessageparser/cleanIrcMessage");
|
||||
const cleanIrcMessage = require("../../../../../client/js/helpers/ircmessageparser/cleanIrcMessage");
|
||||
|
||||
describe("cleanIrcMessage", function() {
|
||||
it("should remove all formatting", function() {
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const fill = require("../../../../../../client/js/libs/handlebars/ircmessageparser/fill");
|
||||
const fill = require("../../../../../client/js/helpers/ircmessageparser/fill");
|
||||
|
||||
describe("fill", () => {
|
||||
const text = "01234567890123456789";
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const findChannels = require("../../../../../../client/js/libs/handlebars/ircmessageparser/findChannels");
|
||||
const findChannels = require("../../../../../client/js/helpers/ircmessageparser/findChannels");
|
||||
|
||||
describe("findChannels", () => {
|
||||
it("should find single letter channel", () => {
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const findEmoji = require("../../../../../../client/js/libs/handlebars/ircmessageparser/findEmoji");
|
||||
const findEmoji = require("../../../../../client/js/helpers/ircmessageparser/findEmoji");
|
||||
|
||||
describe("findEmoji", () => {
|
||||
it("should find default emoji presentation character", () => {
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const findLinks = require("../../../../../../client/js/libs/handlebars/ircmessageparser/findLinks");
|
||||
const findLinks = require("../../../../../client/js/helpers/ircmessageparser/findLinks");
|
||||
|
||||
describe("findLinks", () => {
|
||||
it("should find url", () => {
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const findNames = require("../../../../../../client/js/libs/handlebars/ircmessageparser/findNames");
|
||||
const findNames = require("../../../../../client/js/helpers/ircmessageparser/findNames");
|
||||
|
||||
describe("findNames", () => {
|
||||
it("should find nicks in text", () => {
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const merge = require("../../../../../../client/js/libs/handlebars/ircmessageparser/merge");
|
||||
const merge = require("../../../../../client/js/helpers/ircmessageparser/merge");
|
||||
|
||||
describe("merge", () => {
|
||||
it("should split style information", () => {
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const parseStyle = require("../../../../../../client/js/libs/handlebars/ircmessageparser/parseStyle");
|
||||
const parseStyle = require("../../../../../client/js/helpers/ircmessageparser/parseStyle");
|
||||
|
||||
describe("parseStyle", () => {
|
||||
it("should skip control codes", () => {
|
@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const localetime = require("../../../../../client/js/libs/handlebars/localetime");
|
||||
const localetime = require("../../../../client/js/helpers/localetime");
|
||||
|
||||
describe("localetime Handlebars helper", () => {
|
||||
describe("localetime helper", () => {
|
||||
it("should render a human-readable date", () => {
|
||||
// 12PM in UTC time
|
||||
const date = new Date("2014-05-22T12:00:00Z");
|
@ -3,7 +3,7 @@
|
||||
const expect = require("chai").expect;
|
||||
|
||||
import {renderToString} from "@vue/server-test-utils";
|
||||
import ParsedMessageTestWrapper from "../../../components/ParsedMessageTestWrapper.vue";
|
||||
import ParsedMessageTestWrapper from "../../components/ParsedMessageTestWrapper.vue";
|
||||
|
||||
function getParsedMessageContents(text, message) {
|
||||
let contents = renderToString(ParsedMessageTestWrapper, {
|
||||
@ -19,7 +19,7 @@ function getParsedMessageContents(text, message) {
|
||||
return contents;
|
||||
}
|
||||
|
||||
describe("parse Handlebars helper", () => {
|
||||
describe("IRC formatted message parser", () => {
|
||||
it("should not introduce xss", () => {
|
||||
const testCases = [
|
||||
{
|
@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const roundBadgeNumber = require("../../../../../client/js/libs/handlebars/roundBadgeNumber");
|
||||
const roundBadgeNumber = require("../../../../client/js/helpers/roundBadgeNumber");
|
||||
|
||||
describe("roundBadgeNumber Handlebars helper", function() {
|
||||
describe("roundBadgeNumber helper", function() {
|
||||
it("should return any number under 1000 as a string", function() {
|
||||
expect(roundBadgeNumber(123)).to.equal("123");
|
||||
});
|
@ -1,25 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const equal = require("../../../../../client/js/libs/handlebars/equal");
|
||||
|
||||
describe("equal Handlebars helper", function() {
|
||||
const block = {
|
||||
fn: () => "fn",
|
||||
inverse: () => "inverse",
|
||||
};
|
||||
|
||||
it("should render the first block if both values are equal", function() {
|
||||
expect(equal("foo", "foo", block)).to.equal("fn");
|
||||
});
|
||||
|
||||
it("should render the inverse block if values are not equal", function() {
|
||||
expect(equal("foo", "bar", block)).to.equal("inverse");
|
||||
});
|
||||
|
||||
it("should throw if too few or too many arguments are given", function() {
|
||||
expect(() => equal("foo", block)).to.throw(Error, /expects 3 arguments/);
|
||||
|
||||
expect(() => equal("foo", "bar", "baz", block)).to.throw(Error, /expects 3 arguments/);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user