now it checks for _PUB_ ind escription instrad of looking through topics, cleanned up logs, streaams have slugs (for rotuting and classes)
This commit is contained in:
parent
d243bfd8cd
commit
e5dbd6aaa8
5 changed files with 34 additions and 21 deletions
|
|
@ -50,11 +50,22 @@ export default {
|
||||||
if (to.path !== from.path) {
|
if (to.path !== from.path) {
|
||||||
this.$store.commit("setTopics", []);
|
this.$store.commit("setTopics", []);
|
||||||
this.$store.commit("setRules", []);
|
this.$store.commit("setRules", []);
|
||||||
this.$store.commit("setCurStream", to.path.replace("/", ""));
|
this.$store.commit("setCurStream", {
|
||||||
if (this.currentStream != ""
|
name: to.path.replace('/', '').replaceAll('_', ' '),
|
||||||
&& this.streams.find(s => s.name == this.currentStream)
|
slug: to.path.replace('/', '').replaceAll(' ', '_')
|
||||||
|
});
|
||||||
|
if (
|
||||||
|
this.currentStream.slug != ""
|
||||||
|
&&
|
||||||
|
this.streams.find(s =>
|
||||||
|
s.name == this.currentStream.name &&
|
||||||
|
s.slug == this.currentStream.slug
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
|
console.log('found stream')
|
||||||
this.setUpDoc(this.currentStream);
|
this.setUpDoc(this.currentStream);
|
||||||
|
} else {
|
||||||
|
console.log('stream does not exist')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -67,15 +78,15 @@ export default {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
api.zulip.init().then((client) => {
|
api.zulip.init().then((client) => {
|
||||||
this.zulipClient = client;
|
this.zulipClient = client;
|
||||||
api.zulip.getStreams(client).then(async (streams) => {
|
api.zulip.getStreams(client).then(streams => {
|
||||||
for (let stream of streams) {
|
for (const stream of streams) {
|
||||||
stream.topics = await api.zulip.getTopics(client, stream.stream_id)
|
stream.slug = stream.name.replaceAll(' ', '_')
|
||||||
}
|
}
|
||||||
this.$store.commit(
|
this.$store.commit(
|
||||||
"setStreams",
|
"setStreams",
|
||||||
streams.filter((s) => (
|
streams.filter((s) => (
|
||||||
s.topics.find(t => t.name == 'rules') ||
|
s.name.startsWith(this.pubStr) ||
|
||||||
s.name.startsWith(this.pubStr)
|
s.description.includes('_PUB_')
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
resolve()
|
resolve()
|
||||||
|
|
@ -88,13 +99,13 @@ export default {
|
||||||
setUpDoc(stream) {
|
setUpDoc(stream) {
|
||||||
api.zulip.getSubs(this.zulipClient).then((result) => {
|
api.zulip.getSubs(this.zulipClient).then((result) => {
|
||||||
if (
|
if (
|
||||||
!result.subscriptions.map((s) => s.name).includes(this.currentStream)
|
!result.subscriptions.map((s) => s.name).includes(this.currentStream.name)
|
||||||
) {
|
) {
|
||||||
api.zulip.addSub(this.zulipClient, this.currentStream);
|
api.zulip.addSub(this.zulipClient, this.currentStream.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
api.zulip.getAllMsgs(this.zulipClient, stream).then((result) => {
|
api.zulip.getAllMsgs(this.zulipClient, stream.name).then((result) => {
|
||||||
for (let m = 0; m < result.messages.length; m++) {
|
for (let m = 0; m < result.messages.length; m++) {
|
||||||
const message = result.messages[m];
|
const message = result.messages[m];
|
||||||
if (message.subject == "rules") {
|
if (message.subject == "rules") {
|
||||||
|
|
@ -107,7 +118,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
eventHandler(event) {
|
eventHandler(event) {
|
||||||
console.log(event);
|
console.log('event:', event);
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "message":
|
case "message":
|
||||||
switch (event.message.subject) {
|
switch (event.message.subject) {
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,10 @@ export default {
|
||||||
...mapState(["currentStream", "streams"]),
|
...mapState(["currentStream", "streams"]),
|
||||||
...mapGetters(["sortedTopics"]),
|
...mapGetters(["sortedTopics"]),
|
||||||
title() {
|
title() {
|
||||||
return this.streams.find((s) => s.name == this.currentStream)
|
return this.streams.find((s) => s.name == this.currentStream.name)
|
||||||
? this.currentStream.replace("pub-", "")
|
? this.currentStream.name
|
||||||
|
: this.$route.path == '/'
|
||||||
|
? "<= pick a stream"
|
||||||
: "Stream does not exist.";
|
: "Stream does not exist.";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="{ selected: selected }">
|
<div :class="{ selected: selected }">
|
||||||
<p class="name">
|
<p class="name">
|
||||||
<router-link :to="stream.name">
|
<router-link :to="stream.slug">
|
||||||
{{ stream.name }}
|
{{ stream.name }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@ let toCSS = (message, currentStream) => {
|
||||||
let className = "",
|
let className = "",
|
||||||
emoji_code = "",
|
emoji_code = "",
|
||||||
rules = [],
|
rules = [],
|
||||||
parentClassName = (currentStream || "").replace(" ", "-"),
|
parentClassName = (currentStream && currentStream.slug || ""),
|
||||||
id = message.id,
|
id = message.id,
|
||||||
is_codeblock = message.content.includes("<code>") || message.content.startsWith("```"),
|
is_codeblock = message.content.includes("<code>") || message.content.startsWith("```"),
|
||||||
is_font = /<p><a href=".+?\.(ttf|otf|woff)/gm.test(message.content);
|
is_font = /<p><a href=".+?\.(ttf|otf|woff)/gm.test(message.content);
|
||||||
|
|
||||||
let type = is_codeblock ? "raw" : is_font ? "font" : "rule";
|
let type = is_codeblock ? "raw" : is_font ? "font" : "rule";
|
||||||
console.log(type,message.content);
|
// console.log(type, message.content);
|
||||||
let regex = /\s?(?<selector>.+)\s*\n?{\n?(?<props>(.*;\n?)+)}/gm
|
let regex = /\s?(?<selector>.+)\s*\n?{\n?(?<props>(.*;\n?)+)}/gm
|
||||||
let results = content.matchAll(regex);
|
let results = content.matchAll(regex);
|
||||||
results = Array.from(results);
|
results = Array.from(results);
|
||||||
|
|
@ -121,7 +121,7 @@ const handleHTMLReply = message => {
|
||||||
.replace(/<\/p>\n<\/blockquote>/gm, '')
|
.replace(/<\/p>\n<\/blockquote>/gm, '')
|
||||||
// .replace(/\n/gm, '')
|
// .replace(/\n/gm, '')
|
||||||
}
|
}
|
||||||
console.table(message.responseTo)
|
// console.table(message.responseTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createStore({
|
export default createStore({
|
||||||
|
|
@ -131,7 +131,7 @@ export default createStore({
|
||||||
state: {
|
state: {
|
||||||
isMobile: false,
|
isMobile: false,
|
||||||
streams: [],
|
streams: [],
|
||||||
currentStream: '',
|
currentStream: {},
|
||||||
rules: [],
|
rules: [],
|
||||||
topics: [],
|
topics: [],
|
||||||
pubStr: 'pub-',
|
pubStr: 'pub-',
|
||||||
|
|
@ -144,7 +144,7 @@ export default createStore({
|
||||||
setCurStream: (state, stream) => state.currentStream = stream,
|
setCurStream: (state, stream) => state.currentStream = stream,
|
||||||
setTopics: (state, topics) => state.topics = topics,
|
setTopics: (state, topics) => state.topics = topics,
|
||||||
addMessage: (state, message) => {
|
addMessage: (state, message) => {
|
||||||
if (message.display_recipient == state.currentStream) {
|
if (message.display_recipient == state.currentStream.name) {
|
||||||
if (message.content.startsWith('@_**')) {
|
if (message.content.startsWith('@_**')) {
|
||||||
handleMDReply(message)
|
handleMDReply(message)
|
||||||
} else if (
|
} else if (
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ export default {
|
||||||
return this.show_ui ? "ui" : "print";
|
return this.show_ui ? "ui" : "print";
|
||||||
},
|
},
|
||||||
currentStream() {
|
currentStream() {
|
||||||
return this.$store.state.currentStream.replace(" ", "-");
|
return this.$store.state.currentStream.slug;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue