fix: resolve all typescript errors in sv check (#715)
This commit is contained in:
1 parent
2a5fb886ae
commit
7bddf16559
38 files changed
+195
-249
No files matched your search
@@ -18,9 +18,10 @@
|
|||||||
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
||||||
"@tailwindcss/container-queries": "^0.1.1",
|
"@tailwindcss/container-queries": "^0.1.1",
|
||||||
"@tailwindcss/vite": "^4.1.18",
|
"@tailwindcss/vite": "^4.1.18",
|
||||||
|
"@types/node": "^25.2.2",
|
||||||
"@types/nprogress": "^0.2.3",
|
"@types/nprogress": "^0.2.3",
|
||||||
"@types/ua-parser-js": "^0.7.39",
|
"@types/ua-parser-js": "^0.7.39",
|
||||||
"@xylightdev/svelte-hero-icons": "^2.2.7",
|
"@xylightdev/svelte-hero-icons": "^2.2.9",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^9.39.2",
|
||||||
"eslint-plugin-svelte": "^3.14.0",
|
"eslint-plugin-svelte": "^3.14.0",
|
||||||
"jsdom": "^22.1.0",
|
"jsdom": "^22.1.0",
|
||||||
@@ -357,6 +358,8 @@
|
|||||||
|
|
||||||
"@types/linkify-it": ["@types/linkify-it@5.0.0", "", {}, "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q=="],
|
"@types/linkify-it": ["@types/linkify-it@5.0.0", "", {}, "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q=="],
|
||||||
|
|
||||||
|
"@types/node": ["@types/node@25.2.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-BkmoP5/FhRYek5izySdkOneRyXYN35I860MFAGupTdebyE66uZaR+bXLHq8k4DirE5DwQi3NuhvRU1jqTVwUrQ=="],
|
||||||
|
|
||||||
"@types/nprogress": ["@types/nprogress@0.2.3", "", {}, "sha512-k7kRA033QNtC+gLc4VPlfnue58CM1iQLgn1IMAU8VPHGOj7oIHPp9UlhedEnD/Gl8evoCjwkZjlBORtZ3JByUA=="],
|
"@types/nprogress": ["@types/nprogress@0.2.3", "", {}, "sha512-k7kRA033QNtC+gLc4VPlfnue58CM1iQLgn1IMAU8VPHGOj7oIHPp9UlhedEnD/Gl8evoCjwkZjlBORtZ3JByUA=="],
|
||||||
|
|
||||||
"@types/resolve": ["@types/resolve@1.20.2", "", {}, "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q=="],
|
"@types/resolve": ["@types/resolve@1.20.2", "", {}, "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q=="],
|
||||||
@@ -383,7 +386,7 @@
|
|||||||
|
|
||||||
"@typescript-eslint/visitor-keys": ["@typescript-eslint/visitor-keys@8.54.0", "", { "dependencies": { "@typescript-eslint/types": "8.54.0", "eslint-visitor-keys": "^4.2.1" } }, "sha512-VFlhGSl4opC0bprJiItPQ1RfUhGDIBokcPwaFH4yiBCaNPeld/9VeXbiPO1cLyorQi1G1vL+ecBk1x8o1axORA=="],
|
"@typescript-eslint/visitor-keys": ["@typescript-eslint/visitor-keys@8.54.0", "", { "dependencies": { "@typescript-eslint/types": "8.54.0", "eslint-visitor-keys": "^4.2.1" } }, "sha512-VFlhGSl4opC0bprJiItPQ1RfUhGDIBokcPwaFH4yiBCaNPeld/9VeXbiPO1cLyorQi1G1vL+ecBk1x8o1axORA=="],
|
||||||
|
|
||||||
"@xylightdev/svelte-hero-icons": ["@xylightdev/svelte-hero-icons@2.2.7", "", { "peerDependencies": { "svelte": "^5.0.0" } }, "sha512-txlrlCf68r6DE43hITVN/ep8dYP2ops0AVtW+HAxIdWgAkae/L7fFJtbhb9iZIDSgHB7HV/5eV+UCVGdEXz3xw=="],
|
"@xylightdev/svelte-hero-icons": ["@xylightdev/svelte-hero-icons@2.2.9", "", { "peerDependencies": { "svelte": "^5.0.0" } }, "sha512-P3cQPL8e3LNGLq1F4Pltg6/iMMf68wHmO89ovBmNl35WPu3KT3Ne4cv4OWLsQK2W0RgbSpzHbCr5ksBSnXISHA=="],
|
||||||
|
|
||||||
"abab": ["abab@2.0.6", "", {}, "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA=="],
|
"abab": ["abab@2.0.6", "", {}, "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA=="],
|
||||||
|
|
||||||
@@ -805,6 +808,8 @@
|
|||||||
|
|
||||||
"undici": ["undici@7.18.2", "", {}, "sha512-y+8YjDFzWdQlSE9N5nzKMT3g4a5UBX1HKowfdXh0uvAnTaqqwqB92Jt4UXBAeKekDs5IaDKyJFR4X1gYVCgXcw=="],
|
"undici": ["undici@7.18.2", "", {}, "sha512-y+8YjDFzWdQlSE9N5nzKMT3g4a5UBX1HKowfdXh0uvAnTaqqwqB92Jt4UXBAeKekDs5IaDKyJFR4X1gYVCgXcw=="],
|
||||||
|
|
||||||
|
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
|
||||||
|
|
||||||
"unenv": ["unenv@2.0.0-rc.24", "", { "dependencies": { "pathe": "^2.0.3" } }, "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw=="],
|
"unenv": ["unenv@2.0.0-rc.24", "", { "dependencies": { "pathe": "^2.0.3" } }, "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw=="],
|
||||||
|
|
||||||
"universalify": ["universalify@0.2.0", "", {}, "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg=="],
|
"universalify": ["universalify@0.2.0", "", {}, "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg=="],
|
||||||
|
|||||||
+2
-1
@@ -16,9 +16,10 @@
|
|||||||
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
||||||
"@tailwindcss/container-queries": "^0.1.1",
|
"@tailwindcss/container-queries": "^0.1.1",
|
||||||
"@tailwindcss/vite": "^4.1.18",
|
"@tailwindcss/vite": "^4.1.18",
|
||||||
|
"@types/node": "^25.2.2",
|
||||||
"@types/nprogress": "^0.2.3",
|
"@types/nprogress": "^0.2.3",
|
||||||
"@types/ua-parser-js": "^0.7.39",
|
"@types/ua-parser-js": "^0.7.39",
|
||||||
"@xylightdev/svelte-hero-icons": "^2.2.7",
|
"@xylightdev/svelte-hero-icons": "^2.2.10",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^9.39.2",
|
||||||
"eslint-plugin-svelte": "^3.14.0",
|
"eslint-plugin-svelte": "^3.14.0",
|
||||||
"jsdom": "^22.1.0",
|
"jsdom": "^22.1.0",
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export function getClient(
|
|||||||
|
|
||||||
export async function validateInstance(
|
export async function validateInstance(
|
||||||
instance: string,
|
instance: string,
|
||||||
type: ClientType,
|
type: ClientType = DEFAULT_CLIENT_TYPE,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (instance == '') return false
|
if (instance == '') return false
|
||||||
|
|
||||||
|
|||||||
+31
-24
@@ -1,14 +1,13 @@
|
|||||||
import { marked } from 'marked'
|
import { marked, type TokenizerAndRendererExtension, type Tokens } from 'marked'
|
||||||
import markedLinkifyIt from 'marked-linkify-it'
|
import markedLinkifyIt from 'marked-linkify-it'
|
||||||
|
|
||||||
export const spoilerPlugin = {
|
export const spoilerPlugin: TokenizerAndRendererExtension = {
|
||||||
name: 'spoiler',
|
name: 'spoiler',
|
||||||
level: 'block',
|
level: 'block',
|
||||||
start(src) {
|
start(src: string) {
|
||||||
return src.match(/:::/)?.index
|
return src.match(/:::/)?.index
|
||||||
},
|
},
|
||||||
// eslint-disable-next-line
|
tokenizer(src: string) {
|
||||||
tokenizer(src, tokens) {
|
|
||||||
const rule = /::: ?spoiler(?: ?(.*))\n([\s\S]*?)\n:::/
|
const rule = /::: ?spoiler(?: ?(.*))\n([\s\S]*?)\n:::/
|
||||||
const match = rule.exec(src)
|
const match = rule.exec(src)
|
||||||
if (match) {
|
if (match) {
|
||||||
@@ -17,10 +16,11 @@ export const spoilerPlugin = {
|
|||||||
raw: match[0],
|
raw: match[0],
|
||||||
title: match[1].trim(),
|
title: match[1].trim(),
|
||||||
text: match[2].trim(),
|
text: match[2].trim(),
|
||||||
|
tokens: [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
renderer(token) {
|
renderer(token: Tokens.Generic) {
|
||||||
return `
|
return `
|
||||||
<details>
|
<details>
|
||||||
<summary>${marked.parseInline(token.title)}</summary>
|
<summary>${marked.parseInline(token.title)}</summary>
|
||||||
@@ -30,11 +30,11 @@ export const spoilerPlugin = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const linkify = markedLinkifyIt(
|
export const linkify = (markedLinkifyIt as any)(
|
||||||
{
|
{
|
||||||
'!': {
|
'!': {
|
||||||
validate: function (text, pos, self) {
|
validate: function (text: string, pos: number, self: any) {
|
||||||
var tail = text.slice(pos)
|
const tail = text.slice(pos)
|
||||||
|
|
||||||
if (!self.re.community) {
|
if (!self.re.community) {
|
||||||
self.re.community = new RegExp(
|
self.re.community = new RegExp(
|
||||||
@@ -47,11 +47,12 @@ export const linkify = markedLinkifyIt(
|
|||||||
if (pos >= 2 && tail[pos - 2] === '!') {
|
if (pos >= 2 && tail[pos - 2] === '!') {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return tail.match(self.re.community)[0].length
|
const match = tail.match(self.re.community)
|
||||||
|
return match ? match[0].length : 0
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
},
|
},
|
||||||
normalize: function (match) {
|
normalize: function (match: any) {
|
||||||
let prefix = match.url
|
let prefix = match.url
|
||||||
prefix = prefix.startsWith('c/') ? prefix.slice(2) : prefix.slice(1)
|
prefix = prefix.startsWith('c/') ? prefix.slice(2) : prefix.slice(1)
|
||||||
|
|
||||||
@@ -59,8 +60,8 @@ export const linkify = markedLinkifyIt(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'@': {
|
'@': {
|
||||||
validate: function (text, pos, self) {
|
validate: function (text: string, pos: number, self: any) {
|
||||||
var tail = text.slice(pos)
|
const tail = text.slice(pos)
|
||||||
|
|
||||||
if (!self.re.user) {
|
if (!self.re.user) {
|
||||||
self.re.user = new RegExp(
|
self.re.user = new RegExp(
|
||||||
@@ -73,11 +74,12 @@ export const linkify = markedLinkifyIt(
|
|||||||
if (pos >= 2 && tail[pos - 2] === '!') {
|
if (pos >= 2 && tail[pos - 2] === '!') {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return tail.match(self.re.user)[0].length
|
const match = tail.match(self.re.user)
|
||||||
|
return match ? match[0].length : 0
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
},
|
},
|
||||||
normalize: function (match) {
|
normalize: function (match: any) {
|
||||||
let prefix = match.url
|
let prefix = match.url
|
||||||
prefix = prefix.startsWith('u/') ? prefix.slice(2) : prefix.slice(1)
|
prefix = prefix.startsWith('u/') ? prefix.slice(2) : prefix.slice(1)
|
||||||
|
|
||||||
@@ -103,7 +105,7 @@ export { regexes as CONTENT_REGEXES }
|
|||||||
/**
|
/**
|
||||||
* Convert links to photon links
|
* Convert links to photon links
|
||||||
*/
|
*/
|
||||||
export const photonify = (link) => {
|
export const photonify = (link: string) => {
|
||||||
if (regexes.community.test(link)) {
|
if (regexes.community.test(link)) {
|
||||||
const match = link.match(regexes.community)
|
const match = link.match(regexes.community)
|
||||||
if (!match) return
|
if (!match) return
|
||||||
@@ -139,36 +141,41 @@ export const photonify = (link) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function subSupscriptExtension(tokensExtractor) {
|
export function subSupscriptExtension(
|
||||||
|
tokensExtractor: (params: any) => Tokens.Generic | null,
|
||||||
|
): TokenizerAndRendererExtension {
|
||||||
return {
|
return {
|
||||||
name: 'subscriptSuperscript',
|
name: 'subscriptSuperscript',
|
||||||
level: 'inline',
|
level: 'inline',
|
||||||
start(src) {
|
start(src: string) {
|
||||||
return src.match(/[~^]/)?.index
|
return src.match(/[~^]/)?.index
|
||||||
},
|
},
|
||||||
// eslint-disable-next-line
|
tokenizer(this: any, src: string) {
|
||||||
tokenizer(src, tokens) {
|
|
||||||
const subscriptRule = /^~([^~\s](?:[^~]*[^~\s])?)~/
|
const subscriptRule = /^~([^~\s](?:[^~]*[^~\s])?)~/
|
||||||
const superscriptRule = /^\^([^^\s](?:[^^]*[^^\s])?)\^/
|
const superscriptRule = /^\^([^^\s](?:[^^]*[^^\s])?)\^/
|
||||||
|
|
||||||
let match
|
let match
|
||||||
|
|
||||||
if ((match = subscriptRule.exec(src))) {
|
if ((match = subscriptRule.exec(src))) {
|
||||||
return tokensExtractor({
|
return (
|
||||||
|
tokensExtractor({
|
||||||
type: 'subscript',
|
type: 'subscript',
|
||||||
content: match[1],
|
content: match[1],
|
||||||
raw: match[0],
|
raw: match[0],
|
||||||
lexer: this.lexer,
|
lexer: this.lexer,
|
||||||
})
|
}) ?? undefined
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((match = superscriptRule.exec(src))) {
|
if ((match = superscriptRule.exec(src))) {
|
||||||
return tokensExtractor({
|
return (
|
||||||
|
tokensExtractor({
|
||||||
type: 'superscript',
|
type: 'superscript',
|
||||||
content: match[1],
|
content: match[1],
|
||||||
raw: match[0],
|
raw: match[0],
|
||||||
lexer: this.lexer,
|
lexer: this.lexer,
|
||||||
})
|
}) ?? undefined
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
/**
|
|
||||||
* Container extension is a marked extension that parses a block of text surrounded by :::
|
|
||||||
*
|
|
||||||
* @param tokensExtractor Converts the container input into a custom token that svelte components will receive.
|
|
||||||
* If this function returns a value that contains an array of `tokens`,
|
|
||||||
* this array will be populated with the tokens that are found inside the container,
|
|
||||||
* allowing to nest markdown inside the container.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* Given the following markdown:
|
|
||||||
*
|
|
||||||
* :::container option="option-1" option-2="option-2" boolean-option
|
|
||||||
* Something inside the container
|
|
||||||
* :::
|
|
||||||
*
|
|
||||||
* The token extractor would receive the following parameters:
|
|
||||||
* **type**: `container`
|
|
||||||
* **content**: `Something inside the container`
|
|
||||||
* **options**: { 'option': 'option-1', 'option-2': 'option-2', 'boolean-option': true }
|
|
||||||
*/
|
|
||||||
export default function (tokensExtractor) {
|
|
||||||
return {
|
|
||||||
name: 'container',
|
|
||||||
level: 'block',
|
|
||||||
start(src) {
|
|
||||||
return src.match(/:::[^:\n]/)?.index
|
|
||||||
},
|
|
||||||
tokenizer(src) {
|
|
||||||
const rule =
|
|
||||||
/:::[\s]?(?<type>[a-z0-9-]+)(?<options>.*)?\n(?<content>(?:.|\n)*)\n:::(?:\n)*/i
|
|
||||||
|
|
||||||
const match = rule.exec(findRawContainer(src))
|
|
||||||
if (!match || !match.groups) return null
|
|
||||||
|
|
||||||
const type = match.groups.type.toLocaleLowerCase()
|
|
||||||
const options = parseOptions(match.groups.options || '')
|
|
||||||
const content = match.groups.content || ''
|
|
||||||
|
|
||||||
const result = tokensExtractor({
|
|
||||||
type: type,
|
|
||||||
content: content,
|
|
||||||
raw: match[0],
|
|
||||||
options: options,
|
|
||||||
lexer: this.lexer,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (result?.tokens) {
|
|
||||||
this.lexer.blockTokens(content, result.tokens)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function findRawContainer(src) {
|
|
||||||
if (!src.startsWith(':::')) return undefined
|
|
||||||
const lines = src.split('\n')
|
|
||||||
let open = 1
|
|
||||||
let lineNumber = 1
|
|
||||||
|
|
||||||
for (lineNumber = 1; lineNumber < lines.length; lineNumber++) {
|
|
||||||
const line = lines[lineNumber]
|
|
||||||
if (line.startsWith(':::')) {
|
|
||||||
if (/:::[^:\n\s]/.test(line)) {
|
|
||||||
open++
|
|
||||||
} else if (/^:::(\n|$)/.test(line)) {
|
|
||||||
open -= 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (open === 0) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lines.slice(0, lineNumber + 1).join('\n')
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseOptions(options) {
|
|
||||||
const output = {}
|
|
||||||
let remaining = options
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
const regex = /(?<name>[a-z0-9]+)(?:="(?<value>(?:.*?))")?/i
|
|
||||||
const match = regex.exec(remaining)
|
|
||||||
if (!match) break
|
|
||||||
|
|
||||||
const name = match?.groups?.name
|
|
||||||
|
|
||||||
if (name) {
|
|
||||||
output[name] = match?.groups?.value ?? true
|
|
||||||
}
|
|
||||||
|
|
||||||
remaining = remaining.slice(match.index + match[0].length)
|
|
||||||
}
|
|
||||||
|
|
||||||
return output
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import type { TokenizerAndRendererExtension, Tokens } from 'marked'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* spoiler extension for marked
|
||||||
|
*/
|
||||||
|
export default function (
|
||||||
|
tokensExtractor: (params: any) => Tokens.Generic | null,
|
||||||
|
): TokenizerAndRendererExtension {
|
||||||
|
return {
|
||||||
|
name: 'spoiler',
|
||||||
|
level: 'block',
|
||||||
|
start(src: string) {
|
||||||
|
return src.match(/:::[^:\n]/)?.index
|
||||||
|
},
|
||||||
|
tokenizer(this: any, src: string) {
|
||||||
|
const rule =
|
||||||
|
/^:::[ \t]*spoiler[ \t]*([^\n]*)\n([\s\S]*?)\n[ \t]*:::[ \t]*(?:\n|$)/
|
||||||
|
const match = rule.exec(src)
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
const title = match[1].trim()
|
||||||
|
const content = match[2].trim()
|
||||||
|
|
||||||
|
const options = parseOptions(title)
|
||||||
|
|
||||||
|
const result = tokensExtractor({
|
||||||
|
type: 'spoiler',
|
||||||
|
raw: match[0],
|
||||||
|
content: content,
|
||||||
|
options: options,
|
||||||
|
lexer: this.lexer,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (result?.tokens) {
|
||||||
|
this.lexer.blockTokens(content, result.tokens)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result ?? undefined
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseOptions(options: string) {
|
||||||
|
const output: Record<string, string | boolean> = {}
|
||||||
|
|
||||||
|
const rule = /([a-z0-9]+)(?:="([^"]*)")?/gi
|
||||||
|
let match
|
||||||
|
while ((match = rule.exec(options)) !== null) {
|
||||||
|
const name = match[1]
|
||||||
|
if (name) {
|
||||||
|
output[name] = match?.groups?.value ?? true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return output
|
||||||
|
}
|
||||||
@@ -57,40 +57,29 @@
|
|||||||
>
|
>
|
||||||
{#if !children}
|
{#if !children}
|
||||||
{#if community.community.deleted}
|
{#if community.community.deleted}
|
||||||
<Icon
|
<span title={$t('post.badges.deleted')}>
|
||||||
src={Trash}
|
<Icon src={Trash} class="text-red-500 inline" micro size="14" />
|
||||||
class="text-red-500 inline"
|
</span>
|
||||||
micro
|
|
||||||
size="14"
|
|
||||||
title={$t('post.badges.deleted')}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
{#if community.community.nsfw}
|
{#if community.community.nsfw}
|
||||||
|
<span title={$t('post.badges.nsfw')}>
|
||||||
<Icon
|
<Icon
|
||||||
src={ExclamationTriangle}
|
src={ExclamationTriangle}
|
||||||
class="text-red-500 inline"
|
class="text-red-500 inline"
|
||||||
micro
|
micro
|
||||||
size="14"
|
size="14"
|
||||||
title={$t('post.badges.nsfw')}
|
|
||||||
/>
|
/>
|
||||||
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
{#if community.banned_from_community}
|
{#if community.banned_from_community}
|
||||||
<Icon
|
<span title={$t('comment.banned')}>
|
||||||
src={NoSymbol}
|
<Icon src={NoSymbol} class="text-red-500 inline" micro size="14" />
|
||||||
class="text-red-500 inline"
|
</span>
|
||||||
micro
|
|
||||||
size="14"
|
|
||||||
title={$t('comment.banned')}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
{#if community.community.visibility == 'LocalOnly'}
|
{#if community.community.visibility == 'LocalOnly'}
|
||||||
<Icon
|
<span title={$t('routes.admin.config.listingType.local')}>
|
||||||
src={MapPin}
|
<Icon src={MapPin} class="text-green-500 inline" micro size="14" />
|
||||||
class="text-green-500 inline"
|
</span>
|
||||||
micro
|
|
||||||
size="14"
|
|
||||||
title={$t('routes.admin.config.listingType.local')}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
<Button
|
<Button
|
||||||
rounding="xl"
|
rounding="xl"
|
||||||
|
|||||||
@@ -89,40 +89,29 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{#if community.community.deleted}
|
{#if community.community.deleted}
|
||||||
<Icon
|
<span title={$t('post.badges.deleted')}>
|
||||||
src={Trash}
|
<Icon src={Trash} class="text-red-500 inline" micro size="14" />
|
||||||
class="text-red-500 inline"
|
</span>
|
||||||
micro
|
|
||||||
size="14"
|
|
||||||
title={$t('post.badges.deleted')}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
{#if community.community.nsfw}
|
{#if community.community.nsfw}
|
||||||
|
<span title={$t('post.badges.nsfw')}>
|
||||||
<Icon
|
<Icon
|
||||||
src={ExclamationTriangle}
|
src={ExclamationTriangle}
|
||||||
class="text-red-500 inline"
|
class="text-red-500 inline"
|
||||||
micro
|
micro
|
||||||
size="14"
|
size="14"
|
||||||
title={$t('post.badges.nsfw')}
|
|
||||||
/>
|
/>
|
||||||
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
{#if community.banned_from_community}
|
{#if community.banned_from_community}
|
||||||
<Icon
|
<span title={$t('comment.banned')}>
|
||||||
src={NoSymbol}
|
<Icon src={NoSymbol} class="text-red-500 inline" micro size="14" />
|
||||||
class="text-red-500 inline"
|
</span>
|
||||||
micro
|
|
||||||
size="14"
|
|
||||||
title={$t('comment.banned')}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
{#if community.community.visibility == 'LocalOnly'}
|
{#if community.community.visibility == 'LocalOnly'}
|
||||||
<Icon
|
<span title={$t('routes.admin.config.listingType.local')}>
|
||||||
src={MapPin}
|
<Icon src={MapPin} class="text-green-500 inline" micro size="14" />
|
||||||
class="text-green-500 inline"
|
</span>
|
||||||
micro
|
|
||||||
size="14"
|
|
||||||
title={$t('routes.admin.config.listingType.local')}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex gap-2 items-center justify-end w-full z-30 mt-auto">
|
<div class="flex gap-2 items-center justify-end w-full z-30 mt-auto">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -67,13 +67,14 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#if badges}
|
{#if badges}
|
||||||
{#if badges.nsfw}
|
{#if badges.nsfw}
|
||||||
|
<span title={$t('post.badges.nsfw')}>
|
||||||
<Icon
|
<Icon
|
||||||
src={ExclamationTriangle}
|
src={ExclamationTriangle}
|
||||||
size="14"
|
size="14"
|
||||||
micro
|
micro
|
||||||
title={$t('post.badges.nsfw')}
|
|
||||||
class="text-red-600 dark:text-red-400"
|
class="text-red-600 dark:text-red-400"
|
||||||
/>
|
/>
|
||||||
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type {
|
|||||||
Community,
|
Community,
|
||||||
CommunityView,
|
CommunityView,
|
||||||
PersonView,
|
PersonView,
|
||||||
|
Post,
|
||||||
PostReportView,
|
PostReportView,
|
||||||
PostView,
|
PostView,
|
||||||
PrivateMessage,
|
PrivateMessage,
|
||||||
@@ -13,7 +14,6 @@ import type {
|
|||||||
} from '$lib/api/types'
|
} from '$lib/api/types'
|
||||||
import { profile } from '$lib/app/auth'
|
import { profile } from '$lib/app/auth'
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
import type { Post } from '../post'
|
|
||||||
|
|
||||||
export type Result =
|
export type Result =
|
||||||
| PostView
|
| PostView
|
||||||
|
|||||||
@@ -199,7 +199,6 @@
|
|||||||
comment_view: item,
|
comment_view: item,
|
||||||
depth: 1,
|
depth: 1,
|
||||||
}}
|
}}
|
||||||
postId={item.post.id}
|
|
||||||
actions={false}
|
actions={false}
|
||||||
/>
|
/>
|
||||||
{:else if isPostView(item)}
|
{:else if isPostView(item)}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export class PostFormState {
|
|||||||
).post_view
|
).post_view
|
||||||
}
|
}
|
||||||
|
|
||||||
if (api instanceof PiefedClient) {
|
if (api instanceof PiefedClient && api.assignFlair) {
|
||||||
const flairRes = await api.assignFlair({
|
const flairRes = await api.assignFlair({
|
||||||
flair_id_list: this.flairList.map((i) => i.id),
|
flair_id_list: this.flairList.map((i) => i.id),
|
||||||
post_id: res.post.id,
|
post_id: res.post.id,
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
opened?: boolean
|
opened?: boolean
|
||||||
autoplay?: boolean
|
autoplay?: boolean
|
||||||
title?: string
|
title?: string
|
||||||
|
class?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -112,6 +113,7 @@
|
|||||||
title,
|
title,
|
||||||
opened = $bindable(!settings.embeds.clickToView),
|
opened = $bindable(!settings.embeds.clickToView),
|
||||||
autoplay = settings.embeds.clickToView,
|
autoplay = settings.embeds.clickToView,
|
||||||
|
class: clazz = '',
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
let data = $derived(typeData(type))
|
let data = $derived(typeData(type))
|
||||||
@@ -122,7 +124,7 @@
|
|||||||
@component
|
@component
|
||||||
Displays a video file or embedded video iframe.
|
Displays a video file or embedded video iframe.
|
||||||
-->
|
-->
|
||||||
<div class="iframe-container">
|
<div class={['iframe-container', clazz]}>
|
||||||
{#if opened}
|
{#if opened}
|
||||||
{#if type == 'video'}
|
{#if type == 'video'}
|
||||||
<video {autoplay} controls>
|
<video {autoplay} controls>
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
>
|
>
|
||||||
{#if post.alt_text}
|
{#if post.alt_text}
|
||||||
<Button
|
<Button
|
||||||
onclick={(e) => {
|
onclick={(e: MouseEvent) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
modal({
|
modal({
|
||||||
title: 'Alt',
|
title: 'Alt',
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
|
|
||||||
canVote = false
|
canVote = false
|
||||||
|
|
||||||
|
if (api.voteOnPoll) {
|
||||||
if (typeof id !== 'number') {
|
if (typeof id !== 'number') {
|
||||||
await api.voteOnPoll({
|
await api.voteOnPoll({
|
||||||
post_id: post.id,
|
post_id: post.id,
|
||||||
@@ -71,6 +72,7 @@
|
|||||||
choice_id: [id],
|
choice_id: [id],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@@ -10,11 +10,10 @@
|
|||||||
let switching: boolean = $state(false)
|
let switching: boolean = $state(false)
|
||||||
interface Props {
|
interface Props {
|
||||||
prof: ProfileInfo
|
prof: ProfileInfo
|
||||||
index: number
|
|
||||||
guest?: boolean
|
guest?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
let { prof, index, guest = false }: Props = $props()
|
let { prof, guest = false }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<SidebarButton
|
<SidebarButton
|
||||||
@@ -39,12 +38,7 @@
|
|||||||
class="w-full font-normal"
|
class="w-full font-normal"
|
||||||
>
|
>
|
||||||
{#snippet customIcon()}
|
{#snippet customIcon()}
|
||||||
<ProfileAvatar
|
<ProfileAvatar profile={prof} selected={profile.current?.id == prof.id} />
|
||||||
profile={prof}
|
|
||||||
{index}
|
|
||||||
{guest}
|
|
||||||
selected={profile.current?.id == prof.id}
|
|
||||||
/>
|
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<span
|
<span
|
||||||
class="inline-flex flex-col gap-0 {profile.current?.id == prof.id
|
class="inline-flex flex-col gap-0 {profile.current?.id == prof.id
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
showWhenEmpty?: boolean
|
showWhenEmpty?: boolean
|
||||||
hideOwnUser?: boolean
|
hideOwnUser?: boolean
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
onselect?: (e: Person) => void
|
label?: string
|
||||||
|
onselect?: (e?: Person) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
listing_type = 'Subscribed',
|
listing_type = 'Subscribed',
|
||||||
showWhenEmpty = false,
|
showWhenEmpty = false,
|
||||||
hideOwnUser = false,
|
hideOwnUser = false,
|
||||||
|
label,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
@@ -50,6 +52,7 @@
|
|||||||
}}
|
}}
|
||||||
extractName={(c) => `${c.name}@${new URL(c.actor_id).hostname}`}
|
extractName={(c) => `${c.name}@${new URL(c.actor_id).hostname}`}
|
||||||
bind:query={q}
|
bind:query={q}
|
||||||
|
{label}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
{#snippet noresults()}
|
{#snippet noresults()}
|
||||||
|
|||||||
@@ -32,10 +32,13 @@
|
|||||||
: ''}
|
: ''}
|
||||||
{url != undefined ? 'rounded-b-none' : ''}
|
{url != undefined ? 'rounded-b-none' : ''}
|
||||||
"
|
"
|
||||||
ondrop={preventDefault((event) => (files = event.dataTransfer?.files))}
|
ondrop={preventDefault(
|
||||||
|
(event) => (files = (event as DragEvent).dataTransfer?.files ?? null),
|
||||||
|
)}
|
||||||
ondragover={preventDefault((event) => {
|
ondragover={preventDefault((event) => {
|
||||||
if (event.dataTransfer) {
|
const dragEvent = event as DragEvent
|
||||||
event.dataTransfer.dropEffect = 'copy'
|
if (dragEvent.dataTransfer) {
|
||||||
|
dragEvent.dataTransfer.dropEffect = 'copy'
|
||||||
dragover = true
|
dragover = true
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
style?: 'header' | 'subpage'
|
style?: 'header' | 'subpage'
|
||||||
margin?: boolean
|
margin?: boolean
|
||||||
|
class?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
children,
|
children,
|
||||||
style = 'header',
|
style = 'header',
|
||||||
margin = true,
|
margin = true,
|
||||||
|
class: clazz = '',
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
let matchType = $derived<('search' | 'pathname')[]>(
|
let matchType = $derived<('search' | 'pathname')[]>(
|
||||||
@@ -59,6 +61,7 @@
|
|||||||
style == 'header' ? 'bar-header' : 'gap-2',
|
style == 'header' ? 'bar-header' : 'gap-2',
|
||||||
margin && 'my-2',
|
margin && 'my-2',
|
||||||
margin && style == 'subpage' && 'mb-3',
|
margin && style == 'subpage' && 'mb-3',
|
||||||
|
clazz,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{#each routes as route, index (route.href)}
|
{#each routes as route, index (route.href)}
|
||||||
|
|||||||
@@ -2,11 +2,7 @@
|
|||||||
import { Spinner } from 'mono-svelte'
|
import { Spinner } from 'mono-svelte'
|
||||||
import type { Snippet } from 'svelte'
|
import type { Snippet } from 'svelte'
|
||||||
import { type IconSource, Icon } from 'svelte-hero-icons/dist'
|
import { type IconSource, Icon } from 'svelte-hero-icons/dist'
|
||||||
import type {
|
import type { ClassValue } from 'svelte/elements'
|
||||||
ClassValue,
|
|
||||||
HTMLAnchorAttributes,
|
|
||||||
HTMLButtonAttributes,
|
|
||||||
} from 'svelte/elements'
|
|
||||||
|
|
||||||
export type ButtonColor = keyof typeof buttonColor
|
export type ButtonColor = keyof typeof buttonColor
|
||||||
export type ButtonAlignment = keyof typeof buttonAlignment
|
export type ButtonAlignment = keyof typeof buttonAlignment
|
||||||
@@ -77,8 +73,7 @@
|
|||||||
}
|
}
|
||||||
type ButtonGap = keyof typeof buttonGap
|
type ButtonGap = keyof typeof buttonGap
|
||||||
|
|
||||||
interface Props
|
interface Props extends Record<string, any> {
|
||||||
extends Omit<HTMLButtonAttributes | HTMLAnchorAttributes, 'prefix'> {
|
|
||||||
loading?: boolean
|
loading?: boolean
|
||||||
submit?: boolean
|
submit?: boolean
|
||||||
type?: 'button' | 'none'
|
type?: 'button' | 'none'
|
||||||
@@ -94,7 +89,7 @@
|
|||||||
prefix?: Snippet
|
prefix?: Snippet
|
||||||
children?: Snippet
|
children?: Snippet
|
||||||
suffix?: Snippet
|
suffix?: Snippet
|
||||||
onclick?: HTMLButtonAttributes['onclick']
|
onclick?: any
|
||||||
icon?: IconSource
|
icon?: IconSource
|
||||||
weight?: ButtonWeight
|
weight?: ButtonWeight
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
title={$shownModal.title}
|
title={$shownModal.title}
|
||||||
dismissable={$shownModal.dismissable}
|
dismissable={$shownModal.dismissable}
|
||||||
ondismissed={() => shownModal.set(undefined)}
|
ondismissed={() => shownModal.set(undefined)}
|
||||||
bind:open={$shownModal}
|
open={!!$shownModal}
|
||||||
>
|
>
|
||||||
{#if $shownModal.snippet}
|
{#if $shownModal.snippet}
|
||||||
{@render $shownModal.snippet?.()}
|
{@render $shownModal.snippet?.()}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
selected?: T | undefined
|
selected?: T | undefined
|
||||||
search: (query: string) => Promise<T[]>
|
search: (query: string) => Promise<T[]>
|
||||||
extractName: (item: T) => string
|
extractName: (item: T) => string
|
||||||
select?: (item: T) => void
|
select?: (item?: T) => void
|
||||||
input?: import('svelte').Snippet
|
input?: import('svelte').Snippet
|
||||||
noresults?: import('svelte').Snippet
|
noresults?: import('svelte').Snippet
|
||||||
required?: boolean
|
required?: boolean
|
||||||
@@ -43,7 +43,8 @@
|
|||||||
selected = $bindable(undefined),
|
selected = $bindable(undefined),
|
||||||
search,
|
search,
|
||||||
extractName,
|
extractName,
|
||||||
select = (item: T) => {
|
select = (item?: T) => {
|
||||||
|
if (item == null) return
|
||||||
selected = item
|
selected = item
|
||||||
query = extractName(item)
|
query = extractName(item)
|
||||||
onselect?.(item)
|
onselect?.(item)
|
||||||
|
|||||||
@@ -21,13 +21,8 @@
|
|||||||
toast,
|
toast,
|
||||||
} from 'mono-svelte'
|
} from 'mono-svelte'
|
||||||
import { Icon, Plus } from 'svelte-hero-icons/dist'
|
import { Icon, Plus } from 'svelte-hero-icons/dist'
|
||||||
import type { PageData } from '../$types'
|
|
||||||
|
|
||||||
interface Props {
|
let { data: pageData } = $props()
|
||||||
data: PageData
|
|
||||||
}
|
|
||||||
|
|
||||||
let { data: pageData }: Props = $props()
|
|
||||||
let data = $state(pageData)
|
let data = $state(pageData)
|
||||||
|
|
||||||
const formData: Omit<EditSite, 'auth'> | undefined = $state(
|
const formData: Omit<EditSite, 'auth'> | undefined = $state(
|
||||||
@@ -198,7 +193,7 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
{#each site.data.all_languages.filter((l) => !formData.discussion_languages?.includes(l.id)) as language (language.id)}
|
{#each site.data.all_languages.filter((l) => !formData.discussion_languages?.includes(l.id)) as language (language.id)}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
class="min-h-[16px] py-0"
|
class="min-h-4 py-0"
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
formData.discussion_languages?.push(language.id)
|
formData.discussion_languages?.push(language.id)
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@
|
|||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
onselect={(p) => (newAdmin = p.id)}
|
onselect={(p) => (newAdmin = p?.id)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -136,7 +136,9 @@
|
|||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
onselect={(p) => (formData.newModerator = p.id)}
|
onselect={(p) => {
|
||||||
|
if (p) formData.newModerator = p.id
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { resolveRoute } from '$app/paths'
|
import { resolve } from '$app/paths'
|
||||||
import { instance } from '$lib/app/instance.svelte'
|
import { instance } from '$lib/app/instance.svelte'
|
||||||
import { redirect } from '@sveltejs/kit'
|
import { redirect } from '@sveltejs/kit'
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ export function load({ params }) {
|
|||||||
// If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance.
|
// If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance.
|
||||||
redirect(
|
redirect(
|
||||||
302,
|
302,
|
||||||
resolveRoute('/comment/[instance]/[id]', {
|
resolve('/comment/[instance]/[id]', {
|
||||||
instance: encodeURIComponent(instance.data.toLowerCase()),
|
instance: encodeURIComponent(instance.data.toLowerCase()),
|
||||||
id: params.instance,
|
id: params.instance,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { resolveRoute } from '$app/paths'
|
import { resolve } from '$app/paths'
|
||||||
import { client } from '$lib/api/client.svelte'
|
import { client } from '$lib/api/client.svelte'
|
||||||
import { profile } from '$lib/app/auth'
|
import { profile } from '$lib/app/auth'
|
||||||
import { redirect } from '@sveltejs/kit'
|
import { redirect } from '@sveltejs/kit'
|
||||||
|
|
||||||
export async function load({ params, fetch }) {
|
export async function load({ params, fetch }) {
|
||||||
if (profile.current.instance != params.instance)
|
if (profile.current.instance != params.instance)
|
||||||
redirect(302, resolveRoute('/comment/[instance]/[id]/confirm', params))
|
redirect(302, resolve('/comment/[instance]/[id]/confirm', params))
|
||||||
|
|
||||||
const comment = await client({
|
const comment = await client({
|
||||||
instanceURL: profile.current.instance,
|
instanceURL: profile.current.instance,
|
||||||
@@ -20,12 +20,9 @@ export async function load({ params, fetch }) {
|
|||||||
|
|
||||||
redirect(
|
redirect(
|
||||||
302,
|
302,
|
||||||
resolveRoute(
|
resolve('/post/[instance]/[id=integer]', {
|
||||||
`/post/[instance]/[id]?thread=${threadPath}#${comment.comment_view.comment.id}`,
|
|
||||||
{
|
|
||||||
instance: encodeURIComponent(params.instance),
|
instance: encodeURIComponent(params.instance),
|
||||||
id: comment.comment_view.post.id.toString(),
|
id: comment.comment_view.post.id.toString(),
|
||||||
},
|
}) + `?thread=${threadPath}#${comment.comment_view.comment.id}`,
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { resolveRoute } from '$app/paths'
|
import { resolve } from '$app/paths'
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
import { client } from '$lib/api/client.svelte'
|
import { client } from '$lib/api/client.svelte'
|
||||||
import { profile } from '$lib/app/auth'
|
import { profile } from '$lib/app/auth'
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
if (res.comment) {
|
if (res.comment) {
|
||||||
goto(
|
goto(
|
||||||
resolveRoute(`/comment/[instance]/[id]`, {
|
resolve(`/comment/[instance]/[id]`, {
|
||||||
instance: profile.current.instance,
|
instance: profile.current.instance,
|
||||||
id: res.comment.comment.id.toString(),
|
id: res.comment.comment.id.toString(),
|
||||||
}),
|
}),
|
||||||
@@ -88,8 +88,8 @@
|
|||||||
rounding="2xl"
|
rounding="2xl"
|
||||||
class="dark:bg-zinc-950 max-h-96 overflow-auto"
|
class="dark:bg-zinc-950 max-h-96 overflow-auto"
|
||||||
>
|
>
|
||||||
{#each filtered as profile, index (profile.id)}
|
{#each filtered as profile (profile.id)}
|
||||||
<ProfileButton prof={profile} {index} />
|
<ProfileButton prof={profile} />
|
||||||
{/each}
|
{/each}
|
||||||
<SidebarButton
|
<SidebarButton
|
||||||
href="/accounts/login/guest?redirect={page.url}"
|
href="/accounts/login/guest?redirect={page.url}"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export async function load({ url, fetch, route, params }) {
|
|||||||
|
|
||||||
const feedData = await feed(route.id, async (p) => {
|
const feedData = await feed(route.id, async (p) => {
|
||||||
const piefedFeedData = piefed.getFeeds!({ include_communities: true }).then(
|
const piefedFeedData = piefed.getFeeds!({ include_communities: true }).then(
|
||||||
(i) => i.feeds.find((j) => j.id.toString() == p.feed_id!),
|
(i) => i.feeds.find((j) => j.id == p.feed_id),
|
||||||
)
|
)
|
||||||
|
|
||||||
const postPromise = piefed.getPosts(p)
|
const postPromise = piefed.getPosts(p)
|
||||||
@@ -34,7 +34,7 @@ export async function load({ url, fetch, route, params }) {
|
|||||||
type_: 'All',
|
type_: 'All',
|
||||||
limit: 20,
|
limit: 20,
|
||||||
show_hidden: settings.posts.showHidden,
|
show_hidden: settings.posts.showHidden,
|
||||||
feed_id: params.id,
|
feed_id: Number(params.id),
|
||||||
})
|
})
|
||||||
|
|
||||||
return feedData
|
return feedData
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
{loading}
|
{loading}
|
||||||
disabled={loading ||
|
disabled={loading ||
|
||||||
item.creator.id == profile.current.user?.local_user_view.person.id}
|
item.creator.id == profile.current.user?.local_user_view.person.id}
|
||||||
onclick={(e) => {
|
onclick={(e: MouseEvent) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
markAsRead(!item.read)
|
markAsRead(!item.read)
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { resolveRoute } from '$app/paths'
|
import { resolve } from '$app/paths'
|
||||||
import type { Person, PrivateMessageView } from '$lib/api/types'
|
import type { Person, PrivateMessageView } from '$lib/api/types'
|
||||||
import { profile } from '$lib/app/auth'
|
import { profile } from '$lib/app/auth'
|
||||||
import { t } from '$lib/app/i18n'
|
import { t } from '$lib/app/i18n'
|
||||||
@@ -84,10 +84,14 @@
|
|||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
hideOwnUser={true}
|
hideOwnUser={true}
|
||||||
onselect={(u) =>
|
onselect={(u) => {
|
||||||
|
if (!u) return
|
||||||
goto(
|
goto(
|
||||||
resolveRoute('/inbox/messages/[user_id]', { user_id: u.id.toString() }),
|
resolve('/inbox/messages/[user_id=integer]', {
|
||||||
)}
|
user_id: u.id.toString(),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|||||||
@@ -75,8 +75,10 @@
|
|||||||
bind:selected={banFromCommunity}
|
bind:selected={banFromCommunity}
|
||||||
/>
|
/>
|
||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
onselect={(p) =>
|
onselect={(p) => {
|
||||||
ban(banFromCommunity, p, data.community.community_view.community)}
|
if (!p) return
|
||||||
|
ban(banFromCommunity, p, data.community.community_view.community)
|
||||||
|
}}
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { resolveRoute } from '$app/paths'
|
import { resolve } from '$app/paths'
|
||||||
import { profile } from '$lib/app/auth'
|
import { profile } from '$lib/app/auth'
|
||||||
import { error, redirect } from '@sveltejs/kit'
|
import { error, redirect } from '@sveltejs/kit'
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ export function load({ params }) {
|
|||||||
if (Number(params.instance)) {
|
if (Number(params.instance)) {
|
||||||
redirect(
|
redirect(
|
||||||
302,
|
302,
|
||||||
resolveRoute(`/post/[instance]/[id]`, {
|
resolve(`/post/[instance]/[id=integer]`, {
|
||||||
instance: encodeURIComponent(profile.current.instance.toLowerCase()),
|
instance: encodeURIComponent(profile.current.instance.toLowerCase()),
|
||||||
id: params.instance,
|
id: params.instance,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { resolveRoute } from '$app/paths'
|
import { resolve } from '$app/paths'
|
||||||
import { client } from '$lib/api/client.svelte'
|
import { client } from '$lib/api/client.svelte'
|
||||||
import { profile } from '$lib/app/auth'
|
import { profile } from '$lib/app/auth'
|
||||||
import { settings } from '$lib/app/settings.svelte'
|
import { settings } from '$lib/app/settings.svelte'
|
||||||
@@ -51,7 +51,7 @@ async function findInFeed(id: '/' | '/c/[name]' | '/f/[id]', postId: string) {
|
|||||||
|
|
||||||
export async function load({ params, url, route }) {
|
export async function load({ params, url, route }) {
|
||||||
if (profile.current.instance != params.instance)
|
if (profile.current.instance != params.instance)
|
||||||
redirect(302, resolveRoute('/post/[instance]/[id]/confirm', params))
|
redirect(302, resolve('/post/[instance]/[id=integer]/confirm', params))
|
||||||
|
|
||||||
// TODO use Lemmy profile default settings
|
// TODO use Lemmy profile default settings
|
||||||
const sort = settings?.defaultSort?.comments ?? 'Hot'
|
const sort = settings?.defaultSort?.comments ?? 'Hot'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { resolveRoute } from '$app/paths'
|
import { resolve } from '$app/paths'
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
import { client } from '$lib/api/client.svelte'
|
import { client } from '$lib/api/client.svelte'
|
||||||
import { profile } from '$lib/app/auth'
|
import { profile } from '$lib/app/auth'
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
if (res.post) {
|
if (res.post) {
|
||||||
goto(
|
goto(
|
||||||
resolveRoute(`/post/[instance]/[id]`, {
|
resolve(`/post/[instance]/[id=integer]`, {
|
||||||
instance: profile.current.instance,
|
instance: profile.current.instance,
|
||||||
id: res.post.post.id.toString(),
|
id: res.post.post.id.toString(),
|
||||||
}),
|
}),
|
||||||
@@ -87,8 +87,8 @@
|
|||||||
rounding="2xl"
|
rounding="2xl"
|
||||||
class="dark:bg-zinc-950 max-h-96 overflow-auto"
|
class="dark:bg-zinc-950 max-h-96 overflow-auto"
|
||||||
>
|
>
|
||||||
{#each filtered as profile, index (profile.id)}
|
{#each filtered as profile (profile.id)}
|
||||||
<ProfileButton prof={profile} {index} />
|
<ProfileButton prof={profile} />
|
||||||
{/each}
|
{/each}
|
||||||
<SidebarButton
|
<SidebarButton
|
||||||
href="/accounts/login/guest?redirect={page.url}"
|
href="/accounts/login/guest?redirect={page.url}"
|
||||||
|
|||||||
@@ -116,12 +116,7 @@
|
|||||||
listing_type="All"
|
listing_type="All"
|
||||||
showWhenEmpty={true}
|
showWhenEmpty={true}
|
||||||
onselect={(c) =>
|
onselect={(c) =>
|
||||||
searchParam(
|
searchParam(page.url, 'creator', c?.id.toString() ?? '', 'page')}
|
||||||
page.url,
|
|
||||||
'community',
|
|
||||||
c?.community.id || undefined,
|
|
||||||
'page',
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
images={false}
|
images={false}
|
||||||
previewButton
|
previewButton
|
||||||
beforePreview={(input) =>
|
beforePreview={(input) =>
|
||||||
removalTemplate(input, {
|
removalTemplate(input ?? '', {
|
||||||
postTitle: '<Example post>',
|
postTitle: '<Example post>',
|
||||||
communityLink: '[!community@example.com]()',
|
communityLink: '[!community@example.com]()',
|
||||||
reason: '<Being a meanie>',
|
reason: '<Being a meanie>',
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export async function load({ url, fetch, route, params }) {
|
|||||||
const feedData = await feed(route.id, async (p) => {
|
const feedData = await feed(route.id, async (p) => {
|
||||||
const piefedTopicData = piefed.getTopics!({
|
const piefedTopicData = piefed.getTopics!({
|
||||||
include_communities: true,
|
include_communities: true,
|
||||||
}).then((i) => i.topics.find((j) => j.id.toString() == p.topic_id!))
|
}).then((i) => i.topics.find((j) => j.id == p.topic_id))
|
||||||
|
|
||||||
const posts = await piefed.getPosts(p)
|
const posts = await piefed.getPosts(p)
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ export async function load({ url, fetch, route, params }) {
|
|||||||
type_: 'All',
|
type_: 'All',
|
||||||
limit: 20,
|
limit: 20,
|
||||||
show_hidden: settings.posts.showHidden,
|
show_hidden: settings.posts.showHidden,
|
||||||
topic_id: params.id,
|
topic_id: Number(params.id),
|
||||||
})
|
})
|
||||||
|
|
||||||
return feedData
|
return feedData
|
||||||
|
|||||||
Reference in new issue
Block a user