1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2026-02-06 23:32:58 +00:00

Merge pull request #139 from koloml/feature/display-dedicated-popup-titles

Popup: Display different tab titles for different routes
This commit is contained in:
2026-01-09 06:35:25 +04:00
committed by GitHub
27 changed files with 123 additions and 4 deletions

View File

@@ -1,5 +1,9 @@
<script lang="ts">
import { PLUGIN_NAME } from "$lib/constants";
</script>
<header>
<a href="/">{__CURRENT_SITE_NAME__} Tagging Assistant</a>
<a href="/">{PLUGIN_NAME}</a>
</header>
<style lang="scss">

4
src/lib/constants.ts Normal file
View File

@@ -0,0 +1,4 @@
/**
* Automatically generated name of the plugin.
*/
export const PLUGIN_NAME = __CURRENT_SITE_NAME__ + ' Tagging Assistant';

View File

@@ -4,6 +4,7 @@
import Footer from "$components/layout/Footer.svelte";
import { initializeLinksReplacement } from "$lib/popup-links";
import { onDestroy } from "svelte";
import { headTitle } from "$stores/popup";
interface Props {
children?: import('svelte').Snippet;
@@ -22,6 +23,10 @@
})
</script>
<svelte:head>
<title>{$headTitle}</title>
</svelte:head>
<Header/>
<main>
{@render children?.()}

View File

@@ -4,6 +4,9 @@
import { activeProfileStore, maintenanceProfiles } from "$stores/entities/maintenance-profiles";
import MenuCheckboxItem from "$components/ui/menu/MenuCheckboxItem.svelte";
import MaintenanceProfile from "$entities/MaintenanceProfile";
import { popupTitle } from "$stores/popup";
$popupTitle = null;
let activeProfile = $derived<MaintenanceProfile | null>(
$maintenanceProfiles.find(profile => profile.id === $activeProfileStore) || null

View File

@@ -1,6 +1,10 @@
<script>
import Menu from "$components/ui/menu/Menu.svelte";
import MenuItem from "$components/ui/menu/MenuItem.svelte";
import { PLUGIN_NAME } from "$lib/constants";
import { popupTitle } from "$stores/popup";
$popupTitle = 'About';
let currentSiteUrl = 'https://furbooru.org';
@@ -14,7 +18,7 @@
<hr>
</Menu>
<h1>
{__CURRENT_SITE_NAME__} Tagging Assistant
{PLUGIN_NAME}
</h1>
<p>
This is a small tool to make tagging on {__CURRENT_SITE_NAME__} just a little bit more convenient. Group tags with

View File

@@ -3,6 +3,9 @@
import MenuItem from "$components/ui/menu/MenuItem.svelte";
import { tagGroups } from "$stores/entities/tag-groups";
import TagGroup from "$entities/TagGroup";
import { popupTitle } from "$stores/popup";
$popupTitle = 'Tag Groups';
let groups = $derived<TagGroup[]>($tagGroups.sort((a, b) => a.settings.name.localeCompare(b.settings.name)));
</script>

View File

@@ -6,6 +6,7 @@
import MenuItem from "$components/ui/menu/MenuItem.svelte";
import { tagGroups } from "$stores/entities/tag-groups";
import TagGroup from "$entities/TagGroup";
import { popupTitle } from "$stores/popup";
let groupId = $derived<string>(page.params.id);
let group = $derived<TagGroup | null>($tagGroups.find(group => group.id === groupId) || null);
@@ -19,6 +20,8 @@
if (!group) {
console.warn(`Group ${groupId} not found.`);
goto('/features/groups');
} else {
$popupTitle = `Tag Group: ${group.settings.name}`;
}
})
</script>

View File

@@ -5,6 +5,7 @@
import MenuItem from "$components/ui/menu/MenuItem.svelte";
import { tagGroups } from "$stores/entities/tag-groups";
import type TagGroup from "$entities/TagGroup";
import { popupTitle } from "$stores/popup";
const groupId = $derived<string>(page.params.id);
const targetGroup = $derived<TagGroup | undefined>($tagGroups.find(group => group.id === groupId));
@@ -12,6 +13,8 @@
$effect(() => {
if (!targetGroup) {
goto('/features/groups');
} else {
$popupTitle = `Deleting Tag Group: ${targetGroup.settings.name}`;
}
})

View File

@@ -12,6 +12,7 @@
import TagGroup from "$entities/TagGroup";
import { tagGroups } from "$stores/entities/tag-groups";
import CheckboxField from "$components/ui/forms/CheckboxField.svelte";
import { popupTitle } from "$stores/popup";
let groupId = $derived(page.params.id);
@@ -32,6 +33,7 @@
$effect(() => {
if (groupId === 'new') {
$popupTitle = 'Create Tag Group';
return;
}
@@ -40,6 +42,8 @@
return;
}
$popupTitle = `Edit Tag Group: ${targetGroup.settings.name}`;
groupName = targetGroup.settings.name;
tagsList = [...targetGroup.settings.tags].sort((a, b) => a.localeCompare(b));
prefixesList = [...targetGroup.settings.prefixes].sort((a, b) => a.localeCompare(b));

View File

@@ -8,6 +8,7 @@
import TagGroup from "$entities/TagGroup";
import EntitiesTransporter from "$lib/extension/EntitiesTransporter";
import { tagGroups } from "$stores/entities/tag-groups";
import { popupTitle } from "$stores/popup";
let isEncodedGroupShown = $state(true);
@@ -17,6 +18,8 @@
$effect(() => {
if (!group) {
goto('/features/groups');
} else {
$popupTitle = `Export Tag Group: ${group.settings.name}`;
}
});

View File

@@ -8,6 +8,7 @@
import TagGroup from "$entities/TagGroup";
import EntitiesTransporter from "$lib/extension/EntitiesTransporter";
import { tagGroups } from "$stores/entities/tag-groups";
import { popupTitle } from "$stores/popup";
const groupTransporter = new EntitiesTransporter(TagGroup);
@@ -17,6 +18,12 @@
let candidateGroup = $state<TagGroup | null>(null);
let existingGroup = $state<TagGroup | null>(null);
$effect(() => {
$popupTitle = candidateGroup
? 'Confirm Imported Tag Group'
: 'Import Tag Group';
});
function tryImportingGroup() {
candidateGroup = null;
existingGroup = null;

View File

@@ -4,6 +4,9 @@
import MenuRadioItem from "$components/ui/menu/MenuRadioItem.svelte";
import { activeProfileStore, maintenanceProfiles } from "$stores/entities/maintenance-profiles";
import MaintenanceProfile from "$entities/MaintenanceProfile";
import { popupTitle } from "$stores/popup";
$popupTitle = 'Tagging Profiles';
let profiles = $derived<MaintenanceProfile[]>(
$maintenanceProfiles.sort((a, b) => a.settings.name.localeCompare(b.settings.name))

View File

@@ -1,5 +1,4 @@
<script lang="ts">
import { run } from 'svelte/legacy';
import Menu from "$components/ui/menu/Menu.svelte";
import MenuItem from "$components/ui/menu/MenuItem.svelte";
import { page } from "$app/state";
@@ -8,7 +7,7 @@
import ProfileView from "$components/features/ProfileView.svelte";
import MenuCheckboxItem from "$components/ui/menu/MenuCheckboxItem.svelte";
import MaintenanceProfile from "$entities/MaintenanceProfile";
import { onMount } from "svelte";
import { popupTitle } from "$stores/popup";
let profileId = $derived(page.params.id);
let profile = $derived<MaintenanceProfile|null>(
@@ -24,6 +23,8 @@
if (!profile) {
console.warn(`Profile ${profileId} not found.`);
goto('/features/maintenance');
} else {
$popupTitle = `Tagging Profile: ${profile.settings.name}`;
}
});

View File

@@ -5,6 +5,7 @@
import { page } from "$app/state";
import { maintenanceProfiles } from "$stores/entities/maintenance-profiles";
import MaintenanceProfile from "$entities/MaintenanceProfile";
import { popupTitle } from "$stores/popup";
const profileId = $derived(page.params.id);
const targetProfile = $derived<MaintenanceProfile | null>(
@@ -14,6 +15,8 @@
$effect(() => {
if (!targetProfile) {
goto('/features/maintenance');
} else {
$popupTitle = `Deleting Tagging Profile: ${targetProfile.settings.name}`
}
});

View File

@@ -9,6 +9,7 @@
import { goto } from "$app/navigation";
import { maintenanceProfiles } from "$stores/entities/maintenance-profiles";
import MaintenanceProfile from "$entities/MaintenanceProfile";
import { popupTitle } from "$stores/popup";
let profileId = $derived(page.params.id);
@@ -26,6 +27,7 @@
$effect(() => {
if (profileId === 'new') {
$popupTitle = 'Create Tagging Profile';
return;
}
@@ -34,6 +36,8 @@
return;
}
$popupTitle = `Edit Tagging Profile: ${targetProfile.settings.name}`;
profileName = targetProfile.settings.name;
tagsList = [...targetProfile.settings.tags].sort((a, b) => a.localeCompare(b));
});

View File

@@ -8,6 +8,7 @@
import FormControl from "$components/ui/forms/FormControl.svelte";
import EntitiesTransporter from "$lib/extension/EntitiesTransporter";
import MaintenanceProfile from "$entities/MaintenanceProfile";
import { popupTitle } from "$stores/popup";
let isCompressedProfileShown = $state(true);
@@ -19,6 +20,8 @@
$effect(() => {
if (!profile) {
goto('/features/maintenance/');
} else {
$popupTitle = `Export Tagging Profile: ${profile.settings.name}`;
}
});

View File

@@ -8,6 +8,7 @@
import { maintenanceProfiles } from "$stores/entities/maintenance-profiles";
import { goto } from "$app/navigation";
import EntitiesTransporter from "$lib/extension/EntitiesTransporter";
import { popupTitle } from "$stores/popup";
const profilesTransporter = new EntitiesTransporter(MaintenanceProfile);
@@ -17,6 +18,11 @@
let candidateProfile = $state<MaintenanceProfile | null>(null);
let existingProfile = $state<MaintenanceProfile | null>(null);
$effect(() => {
$popupTitle = candidateProfile
? 'Confirm Imported Tagging Profile'
: 'Import Tagging Profile';
})
function tryImportingProfile() {
candidateProfile = null;
existingProfile = null;

View File

@@ -1,6 +1,9 @@
<script>
import Menu from "$components/ui/menu/Menu.svelte";
import MenuItem from "$components/ui/menu/MenuItem.svelte";
import { popupTitle } from "$stores/popup";
$popupTitle = 'Preferences';
</script>
<Menu>

View File

@@ -1,6 +1,9 @@
<script>
import Menu from "$components/ui/menu/Menu.svelte";
import MenuItem from "$components/ui/menu/MenuItem.svelte";
import { popupTitle } from "$stores/popup";
$popupTitle = 'Debugging Tools';
</script>
<Menu>

View File

@@ -2,6 +2,9 @@
import MenuItem from "$components/ui/menu/MenuItem.svelte";
import Menu from "$components/ui/menu/Menu.svelte";
import { storagesCollection } from "$stores/debug";
import { popupTitle } from "$stores/popup";
$popupTitle = 'Storage Inspector';
</script>
<Menu>

View File

@@ -2,6 +2,7 @@
import StorageViewer from "$components/debugging/StorageViewer.svelte";
import { page } from "$app/state";
import { goto } from "$app/navigation";
import { popupTitle } from "$stores/popup";
let pathArray = $derived.by<string[]>(() => {
const pathString = page.params.path;
@@ -30,6 +31,10 @@
if (!storageName) {
goto("/preferences/debug/storage");
}
$popupTitle = storageName
? 'Inspecting: ' + storageName
: 'Storage Inspector';
});
</script>

View File

@@ -5,6 +5,9 @@
import FormControl from "$components/ui/forms/FormControl.svelte";
import CheckboxField from "$components/ui/forms/CheckboxField.svelte";
import { fullScreenViewerEnabled } from "$stores/preferences/misc";
import { popupTitle } from "$stores/popup";
$popupTitle = 'Misc Preferences';
</script>
<Menu>

View File

@@ -6,6 +6,9 @@
import MenuItem from "$components/ui/menu/MenuItem.svelte";
import { stripBlacklistedTagsEnabled } from "$stores/preferences/maintenance";
import { shouldSeparateTagGroups } from "$stores/preferences/tag";
import { popupTitle } from "$stores/popup";
$popupTitle = 'Tagging Preferences';
</script>
<Menu>

View File

@@ -1,6 +1,9 @@
<script lang="ts">
import Menu from "$components/ui/menu/Menu.svelte";
import MenuItem from "$components/ui/menu/MenuItem.svelte";
import { popupTitle } from "$stores/popup";
$popupTitle = 'Import/Export';
</script>
<Menu>

View File

@@ -8,6 +8,7 @@
import type StorageEntity from "$lib/extension/base/StorageEntity";
import FormControl from "$components/ui/forms/FormControl.svelte";
import FormContainer from "$components/ui/forms/FormContainer.svelte";
import { popupTitle } from "$stores/popup";
const bulkTransporter = new BulkEntitiesTransporter();
@@ -46,6 +47,12 @@
}
});
$effect(() => {
$popupTitle = displayExportedString
? 'Exported String'
: 'Select Entities to Export';
});
function refreshAreAllEntitiesChecked() {
requestAnimationFrame(() => {
exportAllProfiles = $maintenanceProfiles.every(profile => exportedEntities.profiles[profile.id]);

View File

@@ -14,6 +14,7 @@
import GroupView from "$components/features/GroupView.svelte";
import { goto } from "$app/navigation";
import type { SameSiteStatus } from "$lib/extension/EntitiesTransporter";
import { popupTitle } from "$stores/popup";
let importedString = $state('');
let errorMessage = $state('');
@@ -49,6 +50,16 @@
Boolean(importedProfiles.length || importedGroups.length)
);
$effect(() => {
$popupTitle = hasImportedEntities
? (
previewedEntity
? 'Preview of Imported Entity'
: 'Select & Preview Imported Entities'
)
: 'Import';
});
const transporter = new BulkEntitiesTransporter();
let lastImportStatus = $state<SameSiteStatus>(null);

15
src/stores/popup.ts Normal file
View File

@@ -0,0 +1,15 @@
import { derived, writable } from "svelte/store";
import { PLUGIN_NAME } from "$lib/constants";
/**
* Store containing the name of the subpage. This name will be added to the title alongside the name of the plugin.
*/
export const popupTitle = writable<string | null>(null);
/**
* Name of the current route with the name of the plugin appended to it.
*/
export const headTitle = derived(
popupTitle,
$popupTitle => ($popupTitle ? `${$popupTitle} | ` : '') + PLUGIN_NAME
);