Refactor some frontend components and add feature to disable automatic tag import
parent
a9acd53f89
commit
f66591db6d
|
|
@ -27,7 +27,6 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.2.2",
|
"axios": "^1.2.2",
|
||||||
"basscss": "^8.1.0",
|
|
||||||
"byte-size": "^8.1.1",
|
"byte-size": "^8.1.1",
|
||||||
"deepmerge": "^4.3.1",
|
"deepmerge": "^4.3.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
|
@ -35,6 +34,8 @@
|
||||||
"neo-scraper": "^0.7.1",
|
"neo-scraper": "^0.7.1",
|
||||||
"normalize.css": "^8.0.1",
|
"normalize.css": "^8.0.1",
|
||||||
"pinia": "^2.0.36",
|
"pinia": "^2.0.36",
|
||||||
|
"primeflex": "^3.3.1",
|
||||||
|
"primevue": "^3.33.0",
|
||||||
"vue-router": "4"
|
"vue-router": "4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
2275
pnpm-lock.yaml
2275
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -5,11 +5,12 @@ import { SzuruSiteConfig } from "~/config";
|
||||||
import { cfg } from "~/stores";
|
import { cfg } from "~/stores";
|
||||||
import { getErrorMessage } from "~/utils";
|
import { getErrorMessage } from "~/utils";
|
||||||
|
|
||||||
const statusText = ref("Version " + browser.runtime.getManifest().version);
|
import TabView from "primevue/tabview";
|
||||||
const statusType = ref("status-quiet");
|
import TabPanel from "primevue/tabpanel";
|
||||||
const versionInfo = import.meta.env.VITE_SZ_VERSION_INFO ?? "info not available";
|
|
||||||
|
|
||||||
console.log("Version: " + versionInfo);
|
const statusText = ref("");
|
||||||
|
const statusType = ref("status-quiet");
|
||||||
|
const versionInfo = "Version: " + (import.meta.env.VITE_SZ_VERSION_INFO ?? browser.runtime.getManifest().version);
|
||||||
|
|
||||||
const selectedSite = computed(() => {
|
const selectedSite = computed(() => {
|
||||||
if (cfg.value.selectedSiteId) {
|
if (cfg.value.selectedSiteId) {
|
||||||
|
|
@ -73,16 +74,77 @@ let mode = useColorMode({ emitAuto: true });
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="content-holder">
|
<div class="content-holder">
|
||||||
<div class="content-wrapper flex flex-wrap gap-3">
|
<div class="content-wrapper flex flex-column gap-3">
|
||||||
<div class="flex-fit"><strong>SzuruChrome Settings</strong></div>
|
<div><strong>SzuruChrome Settings</strong></div>
|
||||||
|
|
||||||
<div class="flex-fit">
|
<TabView>
|
||||||
<div class="fit flex flex-wrap">
|
<TabPanel header="General">
|
||||||
<div class="flex-fit">
|
<div class="grid grid-nogutter gap-3">
|
||||||
|
<div class="col-12 md:col-6">
|
||||||
|
<label>Theme</label>
|
||||||
|
<select v-model="mode">
|
||||||
|
<option value="auto">System</option>
|
||||||
|
<option value="light">Light</option>
|
||||||
|
<option value="dark">Dark</option>
|
||||||
|
</select>
|
||||||
|
<p class="hint">This setting auto-saves.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 md:col-6">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" v-model="cfg.autoSearchSimilar" />
|
||||||
|
Automatically search for similar posts
|
||||||
|
</label>
|
||||||
|
<p class="hint">
|
||||||
|
Automatically start searching for similar posts when opening the popup. Enabling this option will hide
|
||||||
|
the "Find Similar" button.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 md:col-6">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" v-model="cfg.addPageUrlToSource" />
|
||||||
|
Add page URL to the source list
|
||||||
|
</label>
|
||||||
|
<p class="hint">
|
||||||
|
This will add the current page URL (e.g. the booru link) to the source list in addition to the actual
|
||||||
|
source (e.g. twitter/pixiv/artstation). Note: if the source is empty/not detected then the page URL will
|
||||||
|
always be used as fallback source.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 md:col-6">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" v-model="cfg.addAllParsedTags" />
|
||||||
|
Automatically import all tags on supported pages
|
||||||
|
</label>
|
||||||
|
<p class="hint">
|
||||||
|
This will automatically import all tags, including their categories, on supported pages such as Danbooru
|
||||||
|
and Zerochan.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 md:col-6">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" v-model="cfg.loadTagCounts" />
|
||||||
|
Show how often a tag is used in the selected szurubooru instance
|
||||||
|
</label>
|
||||||
|
<p class="hint">
|
||||||
|
Shows how often a given tag is used in the selected szurubooru instance. No number will be displayed
|
||||||
|
when the tag does not yet exist.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span class="col-12 status-quiet">{{ versionInfo }}</span>
|
||||||
|
</div>
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<TabPanel header="Instances">
|
||||||
|
<div class="formgrid grid">
|
||||||
|
<div class="field col-12">
|
||||||
<label>Szurubooru Instances</label>
|
<label>Szurubooru Instances</label>
|
||||||
|
|
||||||
<!-- This isn't perfectly responsive for very small devices. -->
|
<div class="flex gap-1">
|
||||||
<div class="fit flex gap-1 flex-fit">
|
|
||||||
<select v-model="cfg.selectedSiteId">
|
<select v-model="cfg.selectedSiteId">
|
||||||
<option v-for="site in cfg.sites" :key="site.id" :value="site.id">
|
<option v-for="site in cfg.sites" :key="site.id" :value="site.id">
|
||||||
{{ site.username }} @ {{ site.domain }}
|
{{ site.username }} @ {{ site.domain }}
|
||||||
|
|
@ -94,92 +156,51 @@ let mode = useColorMode({ emitAuto: true });
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="selectedSite" class="flex-fit flex flex-wrap gap-1 border-box pb2">
|
<template v-if="selectedSite">
|
||||||
<div style="flex: 1 1 20ch">
|
<div class="field col-12">
|
||||||
<label>URL</label>
|
<label>URL</label>
|
||||||
<input
|
<input
|
||||||
v-if="selectedSite"
|
v-if="selectedSite"
|
||||||
text="Szurubooru URL"
|
text="Szurubooru URL"
|
||||||
type="text"
|
type="text"
|
||||||
name="domain"
|
name="domain"
|
||||||
v-model.lazy="selectedSite.domain"
|
v-model="selectedSite.domain"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="flex: 1 1 12ch">
|
<div class="field col-12 md:col-6">
|
||||||
<label>Username</label>
|
<label>Username</label>
|
||||||
<input text="Username" type="text" name="username" v-model="selectedSite.username" />
|
<input text="Username" type="text" name="username" v-model="selectedSite.username" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="flex: 1 1 28ch">
|
<div class="field col-12 md:col-6">
|
||||||
<label>Authentication token</label>
|
<label>Authentication token</label>
|
||||||
<input text="Authentication token" type="text" name="token" v-model="selectedSite.authToken" />
|
<input text="Authentication token" type="text" name="token" v-model="selectedSite.authToken" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex-fit flex flex-wrap gap-3">
|
<div class="col-12 flex flex-wrap justify-content-between gap-3">
|
||||||
<div class="settings-block" style="flex: 1 0 10ch">
|
|
||||||
<label>Theme</label>
|
|
||||||
<select v-model="mode">
|
|
||||||
<option value="auto">System</option>
|
|
||||||
<option value="light">Light</option>
|
|
||||||
<option value="dark">Dark</option>
|
|
||||||
</select>
|
|
||||||
<p class="hint">This setting auto-saves.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="settings-block">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" v-model="cfg.autoSearchSimilar" />
|
|
||||||
Automatically search for similar posts
|
|
||||||
</label>
|
|
||||||
<p class="hint">
|
|
||||||
Automatically start searching for similar posts when opening the popup. Enabling this option will hide the
|
|
||||||
"Find Similar" button.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="settings-block">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" v-model="cfg.addPageUrlToSource" />
|
|
||||||
Add page URL to the source list
|
|
||||||
</label>
|
|
||||||
<p class="hint">
|
|
||||||
This will add the current page URL (e.g. the booru link) to the source list in addition to the actual source
|
|
||||||
(e.g. twitter/pixiv/artstation). Note: if the source is empty/not detected then the page URL will always be
|
|
||||||
used as fallback source.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="settings-block">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" v-model="cfg.loadTagCounts" />
|
|
||||||
Show how often a tag is used in the selected szurubooru instance
|
|
||||||
</label>
|
|
||||||
<p class="hint">
|
|
||||||
Shows how often a given tag is used in the selected szurubooru instance. No number will be displayed when
|
|
||||||
the tag does not yet exist.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex-fit flex flex-wrap justify-between gap-3">
|
|
||||||
<span class="status" :class="statusType">{{ statusText }}</span>
|
<span class="status" :class="statusType">{{ statusText }}</span>
|
||||||
|
|
||||||
<div class="flex gap-1">
|
|
||||||
<button @click="testConnection">Test connection</button>
|
<button @click="testConnection">Test connection</button>
|
||||||
<!-- <button @click="saveSettings" class="primary">Save settings</button> -->
|
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<TabPanel header="Tags">
|
||||||
|
<!-- TODO: Tag category colors -->
|
||||||
|
|
||||||
|
<!-- TODO: Tag ignore list -->
|
||||||
|
|
||||||
|
<!-- TODO: Category ignore list -->
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<!-- TODO: Settings import/export? -->
|
||||||
|
</TabView>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@use "~/styles/main.scss";
|
|
||||||
|
|
||||||
.content-holder {
|
.content-holder {
|
||||||
padding: 1.5em;
|
padding: 1.5em;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -201,15 +222,6 @@ html.dark .content-wrapper {
|
||||||
background: var(--section-header-bg-color);
|
background: var(--section-header-bg-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-block {
|
|
||||||
flex: 1 0 200px;
|
|
||||||
|
|
||||||
label {
|
|
||||||
padding: 0;
|
|
||||||
margin-bottom: 0.3em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hint {
|
.hint {
|
||||||
margin-top: 0.4em;
|
margin-top: 0.4em;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
|
@ -234,11 +246,6 @@ html.dark .content-wrapper {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
|
||||||
display: block;
|
|
||||||
padding: 0.3em 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="checkbox"] {
|
input[type="checkbox"] {
|
||||||
margin: 0 3px 0 0;
|
margin: 0 3px 0 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<base target="_blank" />
|
<base target="_blank" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>Options</title>
|
<title>SzuruChrome Settings</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
import { createApp } from "vue";
|
import { createApp } from "vue";
|
||||||
|
import PrimeVue from "primevue/config";
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import { setupApp } from "~/logic/common-setup";
|
import { setupApp } from "~/logic/common-setup";
|
||||||
|
|
||||||
|
import "../styles/main.scss";
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
setupApp(app);
|
setupApp(app);
|
||||||
|
app.use(PrimeVue);
|
||||||
app.mount("#app");
|
app.mount("#app");
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,10 @@ async function grabPost() {
|
||||||
const vm = new ScrapedPostDetails(result.posts[i]);
|
const vm = new ScrapedPostDetails(result.posts[i]);
|
||||||
vm.name = `[${result.engine}] Post ${parseInt(i) + 1}`; // parseInt() is required!
|
vm.name = `[${result.engine}] Post ${parseInt(i) + 1}`; // parseInt() is required!
|
||||||
|
|
||||||
|
if (!cfg.value.addAllParsedTags) {
|
||||||
|
vm.tags.splice(0);
|
||||||
|
}
|
||||||
|
|
||||||
// Add current pageUrl to the source if either
|
// Add current pageUrl to the source if either
|
||||||
// a. user has addPageUrlToSource set to true
|
// a. user has addPageUrlToSource set to true
|
||||||
// b. source is empty
|
// b. source is empty
|
||||||
|
|
@ -562,7 +566,7 @@ useDark();
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else class="p3 flex items-center gap-3">
|
<div v-else class="p-3 flex items-center gap-3">
|
||||||
<span>No content found</span>
|
<span>No content found</span>
|
||||||
<font-awesome-icon icon="fa-solid fa-cog" class="cursor-pointer" @click="openOptionsPage" />
|
<font-awesome-icon icon="fa-solid fa-cog" class="cursor-pointer" @click="openOptionsPage" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ export const cfg = useStorageLocal(
|
||||||
sites: [] as Array<SzuruSiteConfig>,
|
sites: [] as Array<SzuruSiteConfig>,
|
||||||
selectedSiteId: undefined as string | undefined,
|
selectedSiteId: undefined as string | undefined,
|
||||||
addTagImplications: true,
|
addTagImplications: true,
|
||||||
|
addAllParsedTags: true,
|
||||||
merge: {
|
merge: {
|
||||||
expandOptions: true,
|
expandOptions: true,
|
||||||
expandExistingTags: false,
|
expandExistingTags: false,
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,6 @@
|
||||||
@use "sass:color";
|
@use "sass:color";
|
||||||
|
|
||||||
@use "basscss/css/basscss-cp.css";
|
@use "primeflex/primeflex.scss";
|
||||||
|
|
||||||
:root {
|
|
||||||
--space-1: 0.25rem;
|
|
||||||
--space-2: 0.5rem;
|
|
||||||
--space-3: 1rem;
|
|
||||||
--space-4: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flex-fit {
|
|
||||||
flex: 0 0 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gap-1 {
|
|
||||||
gap: var(--space-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.gap-2 {
|
|
||||||
gap: var(--space-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.gap-3 {
|
|
||||||
gap: var(--space-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.gap-4 {
|
|
||||||
gap: var(--space-4);
|
|
||||||
}
|
|
||||||
|
|
||||||
.gapx-1 {
|
|
||||||
column-gap: var(--space-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.gapx-2 {
|
|
||||||
column-gap: var(--space-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.gapx-3 {
|
|
||||||
column-gap: var(--space-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.gapx-4 {
|
|
||||||
column-gap: var(--space-4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open-sans-regular - latin */
|
/* open-sans-regular - latin */
|
||||||
@font-face {
|
@font-face {
|
||||||
|
|
@ -77,6 +34,7 @@ $danger-color-dark: color.scale($danger-color, $lightness: -50%);
|
||||||
--section-header-fg-color: #4c4c4c;
|
--section-header-fg-color: #4c4c4c;
|
||||||
--section-header-bg-color: #eee;
|
--section-header-bg-color: #eee;
|
||||||
--text-color: #111;
|
--text-color: #111;
|
||||||
|
--tab-color: rgba(0, 0, 0, 0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
html.dark {
|
html.dark {
|
||||||
|
|
@ -89,6 +47,7 @@ html.dark {
|
||||||
--section-header-fg-color: #d9d9d9;
|
--section-header-fg-color: #d9d9d9;
|
||||||
--section-header-bg-color: #272727;
|
--section-header-bg-color: #272727;
|
||||||
--text-color: #e6e6e6;
|
--text-color: #e6e6e6;
|
||||||
|
--tab-color: rgba(255, 255, 255, 0.06);
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
background-color: var(--bg-main-color);
|
background-color: var(--bg-main-color);
|
||||||
color-scheme: dark;
|
color-scheme: dark;
|
||||||
|
|
@ -171,6 +130,7 @@ img {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DEPRECATED: Replace with primeflex w-full
|
||||||
.full {
|
.full {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
@ -283,3 +243,56 @@ a.remove-tag {
|
||||||
.cursor-pointer {
|
.cursor-pointer {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.popup-section {
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-header {
|
||||||
|
height: 30px;
|
||||||
|
padding: 0 6px 0 10px;
|
||||||
|
background-color: var(--section-header-bg-color);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
> span {
|
||||||
|
font-size: 1.2em;
|
||||||
|
vertical-align: middle;
|
||||||
|
color: var(--section-header-fg-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.toggleable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-row {
|
||||||
|
margin: 10px 5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-label {
|
||||||
|
display: block;
|
||||||
|
margin: 0 0 5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-block {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-tabview {
|
||||||
|
.p-tabview-nav {
|
||||||
|
margin: 1em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-tabview-header {
|
||||||
|
span {
|
||||||
|
padding: 0 1.2em;
|
||||||
|
line-height: 2.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.p-highlight {
|
||||||
|
background-color: var(--tab-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.popup-section {
|
|
||||||
margin: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
video {
|
video {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
@ -37,35 +33,3 @@ label {
|
||||||
margin: 3px 3px 0 0;
|
margin: 3px 3px 0 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-header {
|
|
||||||
height: 30px;
|
|
||||||
padding: 0 6px 0 10px;
|
|
||||||
background-color: var(--section-header-bg-color);
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
> span {
|
|
||||||
font-size: 1.2em;
|
|
||||||
vertical-align: middle;
|
|
||||||
color: var(--section-header-fg-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.toggleable {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-row {
|
|
||||||
margin: 10px 5px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-label {
|
|
||||||
display: block;
|
|
||||||
margin: 0 0 5px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-block {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue