This commit is contained in:
Marcel Hellkamp 2024-06-06 14:21:53 +02:00
parent 98fd76dd35
commit 1d13a935ab
6 changed files with 14 additions and 14 deletions

View File

@ -99,7 +99,7 @@ This project was inspired by [Mastowall](https://github.com/rstockm/mastowall),
## License
Copyright (C) 2023 Marcel Hellkamp
Copyright (C) 2024 Marcel Hellkamp
Copyright (C) 2023 Gesellschaft für wissenschaftliche Datenverarbeitung mbH Göttingen
This program is free software: you can redistribute it and/or modify

View File

@ -65,11 +65,11 @@ onUpdated(fixLayout)
watch([useWindowSize().width, config, allPosts], fixLayout, { deep: true })
// Watch for a theme changes
const isDarkPrefered = usePreferredDark()
const isDarkPreferred = usePreferredDark()
const actualTheme = computed(() => {
var theme = config.value?.theme
if (!theme || theme === "auto")
theme = isDarkPrefered.value ? "dark" : "light"
theme = isDarkPreferred.value ? "dark" : "light"
return theme
})
watch(actualTheme, () => {

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import { sanatizeConfig, isServer, isLanguage, toQuery } from '@/config';
import { sanitizeConfig, isServer, isLanguage, toQuery } from '@/config';
import { computed, ref } from 'vue';
import { arrayUnique } from '@/utils';
import { type Config } from '@/types';
@ -14,7 +14,7 @@ const props = defineProps<{
const config = computed({
get: () => props.modelValue,
set: (value) => emit('update:modelValue', sanatizeConfig(value)),
set: (value) => emit('update:modelValue', sanitizeConfig(value)),
});
const formServers = computed({
@ -251,7 +251,7 @@ const onSubmit = () => {
<input type="text" class="form-control" id="edit-server" placeholder="all languages"
v-model.lazy="formLang">
<div class="form-text">List of <a href="https://en.wikipedia.org/wiki/ISO_639-1"
tyrget="_blanlk">two-letter language codes</a> to allow. Leave blank to allow all languages.</div>
target="_blank">two-letter language codes</a> to allow. Leave blank to allow all languages.</div>
</div>
</div>

View File

@ -180,7 +180,7 @@ export function fromQuery(query: string): Config {
}
// Clean, fix and return a valid config
return sanatizeConfig(config);
return sanitizeConfig(config);
}
export function toQuery(config: Config, userConfig?: string): string {
@ -223,7 +223,7 @@ export function isLanguage(lang: string) {
return isString(lang) && lang.match(/^[a-z]{2}$/i)
}
export function sanatizeConfig(config: any): Config {
export function sanitizeConfig(config: any): Config {
const boolOr = (value: any, fallback: boolean) => {
if (typeof value == "boolean") return value;
@ -284,7 +284,7 @@ export async function loadConfig() {
try {
const rs = await fetch(url, { cache: "reload", })
if (!rs.ok) throw new Error(`HTTP error! Status: ${rs.status}`);
siteConfig = sanatizeConfig(await rs.json() || {});
siteConfig = sanitizeConfig(await rs.json() || {});
siteConfigSource = url
} catch (e) {
console.warn(`Failed to load (or parse) [${url}], falling back to defaults.`)
@ -297,7 +297,7 @@ export async function loadConfig() {
if (!siteConfig && siteConfigUrl)
await loadJson(siteConfigUrl)
if (!siteConfig)
siteConfig = sanatizeConfig(deepClone(fallbackConfig))
siteConfig = sanitizeConfig(deepClone(fallbackConfig))
return fromQuery(window.location.search)
}

View File

@ -82,7 +82,7 @@ export async function fetchPosts(cfg: Config, onProgress: (progress: Progress) =
// Collect results
const posts: Post[] = []
const addOrRepacePost = (post: Post) => {
const addOrReplacePost = (post: Post) => {
const i = posts.findIndex(p => p.id === post.id)
if (i >= 0)
posts[i] = post
@ -108,7 +108,7 @@ export async function fetchPosts(cfg: Config, onProgress: (progress: Progress) =
.map(status => fixLocalAcct(domain, status))
.filter(status => filterStatus(cfg, status))
.map(status => statusToWallPost(cfg, status))
.forEach(addOrRepacePost)
.forEach(addOrReplacePost)
} catch (err: any) {
let error = err instanceof Error ? err : new Error(err?.toString())
progress.errors.push(error)

View File

@ -29,11 +29,11 @@ export function deepClone(obj: any) {
/**
* Find all text nodes and replace each occuences of a pattern with either
* Find all text nodes and replace each occurrences of a pattern with either
* a string or a new DOM node. Can be used to replace emojis with images or
* URLs with links.
*
* The root node is modifed in-place and also returned.
* The root node is modified in-place and also returned.
*/
export function replaceInText(root: Node, pattern: RegExp, replace: (m: RegExpMatchArray) => string | Node) {
const walk = (node: Node) => {