feat: add util page
This commit is contained in:
1 parent
5a892648fb
commit
39975008c8
10 files changed
+174
-12
No files matched your search
@@ -5,10 +5,13 @@
|
||||
export let source: string = ''
|
||||
export let inline: boolean = false
|
||||
|
||||
function replaceURLs(node: HTMLElement) {
|
||||
function replaceURLs(node: HTMLElement, source: string) {
|
||||
if (!div) return
|
||||
console.log('replacing source', source)
|
||||
const links = node.querySelectorAll('a')
|
||||
|
||||
links.forEach((l) => {
|
||||
console.log('replacing link', l.href)
|
||||
const photonified = photonify(l.href)
|
||||
if (photonified) l.href = photonified
|
||||
})
|
||||
@@ -16,9 +19,7 @@
|
||||
|
||||
let div: HTMLElement
|
||||
|
||||
$: if (source && div) {
|
||||
replaceURLs(div)
|
||||
}
|
||||
$: replaceURLs(div, source)
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import Logo from '$lib/components/ui/Logo.svelte'
|
||||
import { LINKED_INSTANCE_URL, instance } from '$lib/instance.js'
|
||||
import { site } from '$lib/lemmy.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { theme } from '$lib/ui/colors.js'
|
||||
import {
|
||||
Button,
|
||||
@@ -22,6 +23,7 @@
|
||||
import {
|
||||
Bars3,
|
||||
Bookmark,
|
||||
BugAnt,
|
||||
Cog6Tooth,
|
||||
CommandLine,
|
||||
ComputerDesktop,
|
||||
@@ -264,6 +266,12 @@
|
||||
</Select>
|
||||
</div>
|
||||
</MenuButton>
|
||||
{#if $userSettings.debugInfo}
|
||||
<MenuButton link href="/util">
|
||||
<Icon src={BugAnt} mini width={16} />
|
||||
Debug
|
||||
</MenuButton>
|
||||
{/if}
|
||||
<hr class="dark:opacity-10 w-[90%] my-2 mx-auto" />
|
||||
<li class="flex flex-col px-4 py-1 mx-auto my-1 text-xs w-full">
|
||||
<div class="flex flex-row gap-2 w-full">
|
||||
|
||||
+13
-7
@@ -1,13 +1,19 @@
|
||||
export const isImage = (url: string | undefined) => {
|
||||
if (!url) return false
|
||||
try {
|
||||
if (!url) return false
|
||||
|
||||
return /\.(jpeg|jpg|gif|png|svg|bmp|webp)$/i.test(new URL(url).pathname)
|
||||
return /\.(jpeg|jpg|gif|png|svg|bmp|webp)$/i.test(new URL(url).pathname)
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export const isVideo = (inputUrl: string | undefined) => {
|
||||
if (!inputUrl) return false
|
||||
export const isVideo = (url: string | undefined) => {
|
||||
try {
|
||||
if (!url) return false
|
||||
|
||||
const url = new URL(inputUrl).pathname.toLowerCase()
|
||||
|
||||
return url.endsWith('mp4') || url.endsWith('webm') || url.endsWith('mov') || url.endsWith('m4v')
|
||||
return /\.(mp4|mov|webm|mkv)$/i.test(new URL(url).pathname)
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user