Display current topic only

This commit is contained in:
Heerko 2021-10-30 22:24:08 +02:00
parent af10da0865
commit 3954f43736
12 changed files with 15649 additions and 69 deletions

View file

@ -1 +1 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>ChattyPub</title><link rel="stylesheet/css-polyfills" type="text/css" href="extra-styles.css"><script src="css-polyfills.js"></script><link href="/css/app.c01369df.css" rel="preload" as="style"><link href="/css/chunk-vendors.fa36ffc8.css" rel="preload" as="style"><link href="/js/app.185d5e35.js" rel="preload" as="script"><link href="/js/chunk-vendors.26f1d600.js" rel="preload" as="script"><link href="/css/chunk-vendors.fa36ffc8.css" rel="stylesheet"><link href="/css/app.c01369df.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but Chattypub doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.26f1d600.js"></script><script src="/js/app.185d5e35.js"></script></body></html> <!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>ChattyPub</title><link rel="stylesheet/css-polyfills" type="text/css" href="extra-styles.css"><script src="css-polyfills.js"></script><link href="/css/app.c01369df.css" rel="preload" as="style"><link href="/css/chunk-vendors.fa36ffc8.css" rel="preload" as="style"><link href="/js/app.3eda33f2.js" rel="preload" as="script"><link href="/js/chunk-vendors.e35cf9b3.js" rel="preload" as="script"><link href="/css/chunk-vendors.fa36ffc8.css" rel="stylesheet"><link href="/css/app.c01369df.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but Chattypub doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.e35cf9b3.js"></script><script src="/js/app.3eda33f2.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
front/dist/js/app.3eda33f2.js vendored Normal file

File diff suppressed because one or more lines are too long

1
front/dist/js/app.3eda33f2.js.map vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

15589
front/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,20 +1,16 @@
<template> <template>
<section> <section>
<h1 class="title">{{ title }}</h1> <h1 class="title">{{ title }}</h1>
<vue3-markdown-it <vue3-markdown-it
class="description" class="description"
:source="description" :source="description"
v-bind="$mdOpts" v-bind="$mdOpts"
> >
</vue3-markdown-it> </vue3-markdown-it>
<Toc <Toc :sortedTopics="sortedTopics" />
:sortedTopics="sortedTopics" <Authors :authors="authors" />
/>
<Authors
:authors="authors"
/>
<Chapter <Chapter
v-for="topic in sortedTopics" v-for="topic in filteredTopics"
:key="topic.title" :key="topic.title"
:id="toValidID(topic.title)" :id="toValidID(topic.title)"
:topic="topic" :topic="topic"
@ -26,9 +22,9 @@
<script> <script>
import { mapGetters, mapState } from "vuex"; import { mapGetters, mapState } from "vuex";
import Authors from './Authors'; import Authors from "./Authors";
import Chapter from "./Chapter"; import Chapter from "./Chapter";
import Toc from './Toc'; import Toc from "./Toc";
export default { export default {
name: "Content", name: "Content",
@ -37,38 +33,48 @@ export default {
Toc, Toc,
Authors, Authors,
}, },
props: ["print", "show_message_data"], props: ["print", "show_message_data", "only_current_topic"],
computed: { computed: {
...mapState(["currentStream", "streams"]), ...mapState(["currentStream", "streams"]),
...mapGetters(["sortedTopics"]), ...mapGetters(["sortedTopics"]),
filteredTopics() {
const hash = this.$route.hash.substr(1);
if (!hash) return this.sortedTopics;
const found = this.sortedTopics.find((el) => {
return this.toValidID(el.title) === hash;
});
return [found];
},
foundStream() { foundStream() {
return this.streams.find(s => s.name == this.currentStream.name) return this.streams.find((s) => s.name == this.currentStream.name);
}, },
title() { title() {
return this.foundStream return this.foundStream
? this.currentStream.name ? this.currentStream.name
: this.$route.path == '/' : this.$route.path == "/"
? "<= pick a stream" ? "<= pick a stream"
: "Stream does not exist."; : "Stream does not exist.";
}, },
description() { description() {
return this.title && return (
this.foundStream && this.title &&
this.foundStream.description.replace('_PUB_', '') this.foundStream &&
this.foundStream.description.replace("_PUB_", "")
);
}, },
authors() { authors() {
return [ return [
...new Set( ...new Set(
this.title && this.title &&
this.foundStream && this.foundStream &&
this.sortedTopics this.sortedTopics
.map(t => t.messages) .map((t) => t.messages)
.flat() .flat()
.map(m => m.sender_full_name) .map((m) => m.sender_full_name)
), ),
...[ 'Pub Bot' ] ...["Pub Bot"],
] ];
} },
}, },
methods: { methods: {
toValidID(string) { toValidID(string) {
@ -82,5 +88,4 @@ export default {
</script> </script>
<style scoped> <style scoped>
</style> </style>

View file

@ -25,3 +25,6 @@ app
.use(router) .use(router)
.use(store) .use(store)
.mount('#app') .mount('#app')
app.config.devtools = true

View file

@ -14,6 +14,12 @@
<div class="controls"> <div class="controls">
<button @click="toggle_ui">{{ show_ui ? "Hide" : "Show" }} UI</button> <button @click="toggle_ui">{{ show_ui ? "Hide" : "Show" }} UI</button>
<button @click="print">Print</button> <button @click="print">Print</button>
<label for="checkbox">
<input type="checkbox" id="checkbox" v-model="only_current_topic" />
Display only current topic
</label>
<!-- <button @click="print_preview">Preview</button> --> <!-- <button @click="print_preview">Preview</button> -->
<label for="msg-data" <label for="msg-data"
><input ><input
@ -38,6 +44,7 @@
:print="!show_ui || expand_content" :print="!show_ui || expand_content"
:show_message_data="show_message_data" :show_message_data="show_message_data"
ref="content" ref="content"
:only_current_topic="only_current_topic"
/> />
</pane> </pane>
<pane v-if="show_ui" :size="panel_sizes[2]" min-size="15"> <pane v-if="show_ui" :size="panel_sizes[2]" min-size="15">
@ -58,8 +65,7 @@ import Content from "../components/Content";
import Rules from "../components/Rules"; import Rules from "../components/Rules";
import { Splitpanes, Pane } from "splitpanes"; import { Splitpanes, Pane } from "splitpanes";
import "splitpanes/dist/splitpanes.css"; import "splitpanes/dist/splitpanes.css";
import { Previewer } from "pagedjs"; // import { Previewer } from "pagedjs";
import { ref, onMounted } from "vue"; import { ref, onMounted } from "vue";
export default { export default {
@ -83,6 +89,7 @@ export default {
show_message_data: false, show_message_data: false,
panel_sizes: { 0: 10, 1: 55, 2: 35 }, panel_sizes: { 0: 10, 1: 55, 2: 35 },
expand_content: false, expand_content: false,
only_current_topic: false,
}; };
}, },
computed: { computed: {
@ -107,16 +114,16 @@ export default {
if (prev) this.toggle_ui(null, true); if (prev) this.toggle_ui(null, true);
}, 1000); }, 1000);
}, },
print_preview() { // print_preview() {
this.expand_content = true; // this.expand_content = true;
let content = document.getElementById("content"); // let content = document.getElementById("content");
let paged = new Previewer(); // let paged = new Previewer();
paged // paged
.preview(content, ["path/to/css/file.css"], this.preview) // .preview(content, ["path/to/css/file.css"], this.preview)
.then((flow) => { // .then((flow) => {
console.log("Rendered", flow.total, "pages."); // console.log("Rendered", flow.total, "pages.");
}); // });
}, // },
toggle_ui(evt, state) { toggle_ui(evt, state) {
if (state !== undefined) this.show_ui = state; if (state !== undefined) this.show_ui = state;
else this.show_ui = !this.show_ui; else this.show_ui = !this.show_ui;