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();
|
a.click();
|
||||||
window.URL.revokeObjectURL(url);
|
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>
|
</script>
|
||||||
|
|
||||||
{#if $settings.eye}
|
{#if $settings.eye}
|
||||||
|
@ -78,11 +84,25 @@ import { EmbeddedFile, EMBED_TYPES } from './main';
|
||||||
class:hasblack={file?.isBlacklisted === true}
|
class:hasblack={file?.isBlacklisted === true}
|
||||||
>{file.page.title}</a>
|
>{file.page.title}</a>
|
||||||
{/if}
|
{/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}
|
{#if isNotChrome && isVideo}
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
<!-- svelte-ignore a11y-missing-attribute -->
|
||||||
<a on:click={(ev) => {
|
<a on:click={(ev) => { inst.bepis(ev); }}
|
||||||
inst.bepis(ev);
|
alt="By clicking this you agree to stay hydrated"
|
||||||
}} alt="By clicking this you agree to stay hydrated"
|
|
||||||
class="clickable"
|
class="clickable"
|
||||||
class:hasembed={file?.embed_type === EMBED_TYPES.MEDIA_EMBED}
|
class:hasembed={file?.embed_type === EMBED_TYPES.MEDIA_EMBED}
|
||||||
class:hasext={file?.embed_type === EMBED_TYPES.THIRD_EYE}
|
class:hasext={file?.embed_type === EMBED_TYPES.THIRD_EYE}
|
||||||
|
@ -102,18 +122,30 @@ import { EmbeddedFile, EMBED_TYPES } from './main';
|
||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.clickable:hover {
|
.hasembed {
|
||||||
text-shadow: 0 0 4px palevioletred;
|
|
||||||
}
|
|
||||||
.clickable.hasembed {
|
|
||||||
color: deeppink;
|
color: deeppink;
|
||||||
}
|
}
|
||||||
.clickable.hasext {
|
.hasext {
|
||||||
color: goldenrod;
|
color: goldenrod;
|
||||||
}
|
}
|
||||||
.clickable.hasblack {
|
.hasblack {
|
||||||
color: black;
|
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 {
|
a.clickable.hasembed {
|
||||||
color: deeppink !important;
|
color: deeppink !important;
|
||||||
}
|
}
|
||||||
|
@ -123,4 +155,21 @@ import { EmbeddedFile, EMBED_TYPES } from './main';
|
||||||
a.clickable.hasblack {
|
a.clickable.hasblack {
|
||||||
color: black !important;
|
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>
|
</style>
|
||||||
|
|
22
src/main.ts
22
src/main.ts
|
@ -16,16 +16,6 @@ import SettingsButton from './SettingsButton.svelte';
|
||||||
import Embeddings from './Embeddings.svelte';
|
import Embeddings from './Embeddings.svelte';
|
||||||
import EyeButton from './EyeButton.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 {
|
export interface ImageProcessor {
|
||||||
skip?: true;
|
skip?: true;
|
||||||
match(fn: string): boolean;
|
match(fn: string): boolean;
|
||||||
|
@ -77,8 +67,19 @@ async function* streamRemote(url: string, chunkSize = 72 * 1024, fetchRestOnNonC
|
||||||
//console.log("streaming ended, ", ptr, size);
|
//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 = {
|
type EmbeddedFileWithPreview = {
|
||||||
embed_type: EMBED_TYPES;
|
embed_type: EMBED_TYPES;
|
||||||
|
tags?: string[],
|
||||||
isBlacklisted?: boolean; // third-eye only
|
isBlacklisted?: boolean; // third-eye only
|
||||||
page?: { title: string, url: string }; // can be a booru page
|
page?: { title: string, url: string }; // can be a booru page
|
||||||
source?: string; // can be like a twitter post this was posted in originally
|
source?: string; // can be like a twitter post this was posted in originally
|
||||||
|
@ -90,6 +91,7 @@ type EmbeddedFileWithPreview = {
|
||||||
|
|
||||||
type EmbeddedFileWithoutPreview = {
|
type EmbeddedFileWithoutPreview = {
|
||||||
embed_type: EMBED_TYPES;
|
embed_type: EMBED_TYPES;
|
||||||
|
tags?: string[],
|
||||||
isBlacklisted: boolean; // third-eye only
|
isBlacklisted: boolean; // third-eye only
|
||||||
page: undefined;
|
page: undefined;
|
||||||
source: undefined;
|
source: undefined;
|
||||||
|
|
|
@ -82,12 +82,14 @@ const findFileFrom = async (b: Booru, hex: string, abort?: EventTarget) => {
|
||||||
const extract = async (b: Buffer, fn?: string) => {
|
const extract = async (b: Buffer, fn?: string) => {
|
||||||
let result!: BooruMatch[];
|
let result!: BooruMatch[];
|
||||||
let booru!: string;
|
let booru!: string;
|
||||||
|
let tags: string[] = [];
|
||||||
for (const e of Object.values(boorus)) {
|
for (const e of Object.values(boorus)) {
|
||||||
if (e.disabled)
|
if (e.disabled)
|
||||||
continue;
|
continue;
|
||||||
result = await findFileFrom(e, fn!.substring(0, 32));
|
result = await findFileFrom(e, fn!.substring(0, 32));
|
||||||
if (result.length) {
|
if (result.length) {
|
||||||
booru = e.name;
|
booru = e.name;
|
||||||
|
tags = result.flatMap(e2 => e2.tags)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +99,7 @@ const extract = async (b: Buffer, fn?: string) => {
|
||||||
const prev = result[0].preview_url;
|
const prev = result[0].preview_url;
|
||||||
const full = result[0].full_url;
|
const full = result[0].full_url;
|
||||||
return {
|
return {
|
||||||
|
tags: tags,
|
||||||
source: result[0].source,
|
source: result[0].source,
|
||||||
page: { title: booru, url: result[0].page },
|
page: { title: booru, url: result[0].page },
|
||||||
filename: fn!.substring(0, 33) + result[0].ext,
|
filename: fn!.substring(0, 33) + result[0].ext,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user