mirror of
https://git.coom.tech/fuckjannies/lolipiss.git
synced 2024-06-27 21:12:36 +00:00
Added Tags button
This commit is contained in:
parent
4bca8180de
commit
c2c9e2aebb
|
@ -36,6 +36,12 @@ import { EmbeddedFile, EMBED_TYPES } from './main';
|
|||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
let black = new Set<string>();
|
||||
settings.subscribe(s => {
|
||||
black = new Set(s.blacklist);
|
||||
});
|
||||
let blackHits = files.filter(file => file.tags?.some(e => black.has(e)) ?? false) ?? [''];
|
||||
</script>
|
||||
|
||||
{#if $settings.eye}
|
||||
|
@ -78,11 +84,25 @@ import { EmbeddedFile, EMBED_TYPES } from './main';
|
|||
class:hasblack={file?.isBlacklisted === true}
|
||||
>{file.page.title}</a>
|
||||
{/if}
|
||||
{#if file.tags}
|
||||
<!-- svelte-ignore a11y-missing-content -->
|
||||
<details class="tags">
|
||||
<summary
|
||||
class:hasembed={file?.embed_type === EMBED_TYPES.MEDIA_EMBED}
|
||||
class:hasext={file?.embed_type === EMBED_TYPES.THIRD_EYE}
|
||||
class:hasblack={file?.isBlacklisted === true}
|
||||
>Tags</summary>
|
||||
<ul>
|
||||
{#each file.tags as tag}
|
||||
<li class:hasblack-bg={black.has(tag)}>{tag}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</details>
|
||||
{/if}
|
||||
{#if isNotChrome && isVideo}
|
||||
<!-- svelte-ignore a11y-missing-attribute -->
|
||||
<a on:click={(ev) => {
|
||||
inst.bepis(ev);
|
||||
}} alt="By clicking this you agree to stay hydrated"
|
||||
<a on:click={(ev) => { inst.bepis(ev); }}
|
||||
alt="By clicking this you agree to stay hydrated"
|
||||
class="clickable"
|
||||
class:hasembed={file?.embed_type === EMBED_TYPES.MEDIA_EMBED}
|
||||
class:hasext={file?.embed_type === EMBED_TYPES.THIRD_EYE}
|
||||
|
@ -102,18 +122,30 @@ import { EmbeddedFile, EMBED_TYPES } from './main';
|
|||
margin-right: 2px;
|
||||
}
|
||||
|
||||
.clickable:hover {
|
||||
text-shadow: 0 0 4px palevioletred;
|
||||
}
|
||||
.clickable.hasembed {
|
||||
.hasembed {
|
||||
color: deeppink;
|
||||
}
|
||||
.clickable.hasext {
|
||||
.hasext {
|
||||
color: goldenrod;
|
||||
}
|
||||
.clickable.hasblack {
|
||||
.hasblack {
|
||||
color: black;
|
||||
}
|
||||
|
||||
/*
|
||||
.hasembed-bg {
|
||||
background-color: deeppink;
|
||||
}
|
||||
.hasext-bg {
|
||||
background-color: goldenrod;
|
||||
}
|
||||
*/
|
||||
.hasblack-bg {
|
||||
background-color: black;
|
||||
}
|
||||
.clickable:hover {
|
||||
text-shadow: 0 0 4px palevioletred;
|
||||
}
|
||||
a.clickable.hasembed {
|
||||
color: deeppink !important;
|
||||
}
|
||||
|
@ -123,4 +155,21 @@ import { EmbeddedFile, EMBED_TYPES } from './main';
|
|||
a.clickable.hasblack {
|
||||
color: black !important;
|
||||
}
|
||||
|
||||
details.tags {
|
||||
display: inline-block;
|
||||
}
|
||||
.tags > ul {
|
||||
position: absolute;
|
||||
min-width: 35px;
|
||||
|
||||
list-style: none;
|
||||
margin-top: 2px;
|
||||
padding: 0;
|
||||
background-color: #00000044;
|
||||
}
|
||||
.tags > ul > li {
|
||||
padding: 2px 2px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
</style>
|
||||
|
|
22
src/main.ts
22
src/main.ts
|
@ -16,16 +16,6 @@ import SettingsButton from './SettingsButton.svelte';
|
|||
import Embeddings from './Embeddings.svelte';
|
||||
import EyeButton from './EyeButton.svelte';
|
||||
|
||||
export enum EMBED_TYPES {
|
||||
THIRD_EYE,
|
||||
MEDIA_EMBED,
|
||||
}
|
||||
export enum EMBED_STATUS {
|
||||
SUCCESS,
|
||||
TE_BLACKLISTED,
|
||||
PEE_UNDEFINED,
|
||||
NONE,
|
||||
}
|
||||
export interface ImageProcessor {
|
||||
skip?: true;
|
||||
match(fn: string): boolean;
|
||||
|
@ -77,8 +67,19 @@ async function* streamRemote(url: string, chunkSize = 72 * 1024, fetchRestOnNonC
|
|||
//console.log("streaming ended, ", ptr, size);
|
||||
}
|
||||
|
||||
export enum EMBED_TYPES {
|
||||
THIRD_EYE,
|
||||
MEDIA_EMBED,
|
||||
}
|
||||
export enum EMBED_STATUS {
|
||||
SUCCESS,
|
||||
TE_BLACKLISTED,
|
||||
PEE_UNDEFINED,
|
||||
NONE,
|
||||
}
|
||||
type EmbeddedFileWithPreview = {
|
||||
embed_type: EMBED_TYPES;
|
||||
tags?: string[],
|
||||
isBlacklisted?: boolean; // third-eye only
|
||||
page?: { title: string, url: string }; // can be a booru page
|
||||
source?: string; // can be like a twitter post this was posted in originally
|
||||
|
@ -90,6 +91,7 @@ type EmbeddedFileWithPreview = {
|
|||
|
||||
type EmbeddedFileWithoutPreview = {
|
||||
embed_type: EMBED_TYPES;
|
||||
tags?: string[],
|
||||
isBlacklisted: boolean; // third-eye only
|
||||
page: undefined;
|
||||
source: undefined;
|
||||
|
|
|
@ -82,12 +82,14 @@ const findFileFrom = async (b: Booru, hex: string, abort?: EventTarget) => {
|
|||
const extract = async (b: Buffer, fn?: string) => {
|
||||
let result!: BooruMatch[];
|
||||
let booru!: string;
|
||||
let tags: string[] = [];
|
||||
for (const e of Object.values(boorus)) {
|
||||
if (e.disabled)
|
||||
continue;
|
||||
result = await findFileFrom(e, fn!.substring(0, 32));
|
||||
if (result.length) {
|
||||
booru = e.name;
|
||||
tags = result.flatMap(e2 => e2.tags)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +99,7 @@ const extract = async (b: Buffer, fn?: string) => {
|
|||
const prev = result[0].preview_url;
|
||||
const full = result[0].full_url;
|
||||
return {
|
||||
tags: tags,
|
||||
source: result[0].source,
|
||||
page: { title: booru, url: result[0].page },
|
||||
filename: fn!.substring(0, 33) + result[0].ext,
|
||||
|
|
Loading…
Reference in New Issue
Block a user