Add required features for UserVM

- Add ability to override site name, welcome modal
- Add ability to load a JSON file to get nodes from
- Make NSFW vms configurable
This commit is contained in:
Elijah R 2024-04-10 16:48:59 -04:00
parent c78298345c
commit 21825fbdee
4 changed files with 20 additions and 5 deletions

View File

@ -1,4 +1,7 @@
{
"SiteNameOverride": null,
"WelcomeModalTitleOverride": null,
"WelcomeModalBodyOverride": null,
"ChatSound": "//computernewb.com/collab-vm/notify.ogg",
"ServerAddresses": [
"wss://computernewb.com/collab-vm/vm0",
@ -11,6 +14,8 @@
"wss://computernewb.com/collab-vm/vm7",
"wss://computernewb.com/collab-vm/vm8"
],
"ServerAddressesListURI": null,
"NSFWVMs": ["vm0b0t"],
"Auth": {
"Enabled": false,
"APIEndpoint": "http://127.0.0.1:5858"

View File

@ -314,11 +314,15 @@ Theme: cvmDisabled
display: none;
}
/* VM0 Blur */
div[data-cvm-node=vm0b0t] {
img {
/* NSFW Blur */
.cvm-nsfw {
img {
filter:blur(40px)!important;
}
}
h5::before {
content: "[NSFW] ";
color: #ff0000;
}
}
#accountDropdownMenuLink, #accountModalError, #accountModalSuccess {

View File

@ -1,6 +1,7 @@
import { StringLike } from './StringLike';
import { Format } from './format';
import { Emitter, Unsubscribe, createNanoEvents } from 'nanoevents';
import Config from '../../config.json';
/// All string keys.
export enum I18nStringKey {
@ -411,6 +412,9 @@ export class I18n {
// Returns a (raw, unformatted) string. Currently only used if we don't need formatting.
GetStringRaw(key: I18nStringKey): string {
if (key === I18nStringKey.kGeneric_CollabVM && Config.SiteNameOverride) return Config.SiteNameOverride;
if (key === I18nStringKey.kWelcomeModal_Header && Config.WelcomeModalTitleOverride) return Config.WelcomeModalTitleOverride;
if (key === I18nStringKey.kWelcomeModal_Body && Config.WelcomeModalBodyOverride) return Config.WelcomeModalBodyOverride;
let val = this.lang.stringKeys[key];
// Look up the fallback language by default if the language doesn't

View File

@ -350,6 +350,7 @@ async function multicollab(url: string) {
div.classList.add('col-sm-5', 'col-md-3');
let card = document.createElement('div');
card.classList.add('card');
if (Config.NSFWVMs.indexOf(vm.id) !== -1) card.classList.add('cvm-nsfw');
card.setAttribute('data-cvm-node', vm.id);
card.addEventListener('click', async () => {
try {
@ -501,8 +502,9 @@ function closeVM() {
}
async function loadList() {
var jsonVMs = Config.ServerAddressesListURI === null ? [] : await (await fetch(Config.ServerAddressesListURI)).json();
await Promise.all(
Config.ServerAddresses.map((url) => {
[Config.ServerAddresses, jsonVMs].flat().map((url) => {
return multicollab(url);
})
);