-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added automatic counting and adding and removing of individual reoccuring tags * The most frequent tags are shown on the side, however it is possible to filter for tags (it can be filtered for multiple tags at once by separating them with `|`, if the first character is a `-`, the tag will be excluded from the results, if the first character (after the optional `-`) is `^` or the last character is `$` the current search term will be parsed as regex instead of a simple string search) * Commonly in the context of Stable Diffusion for example tags are comma separated, so this is also the default string which is used for splitting the tags
- Loading branch information
1 parent
549c209
commit b992850
Showing
7 changed files
with
185 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## 0.1.1 | ||
|
||
* Added automatic counting and adding and removing of individual reoccuring tags | ||
* The most frequent tags are shown on the side, however it is possible to filter for tags (it can be filtered for multiple tags at once by separating them with `|`, if the first character is a `-`, the tag will be excluded from the results, if the first character (after the optional `-`) is `^` or the last character is `$` the current search term will be parsed as regex instead of a simple string search) | ||
* Commonly in the context of Stable Diffusion for example tags are comma separated, so this is also the default string which is used for splitting the tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<script lang="ts"> | ||
import { single_tag_delimiter, active_image, tagCounts, sortedTags } from '$lib/stores'; | ||
let custom_css_classes = ''; | ||
let tag_filter_string = ''; | ||
$: tag_white_list = tag_filter_string | ||
.split('|') | ||
.filter((tag) => tag != '' && !tag.startsWith('-')) | ||
.map((tag) => { | ||
if (tag.startsWith('^') || tag.endsWith('$')) { | ||
return new RegExp(tag); | ||
} | ||
return tag; | ||
}); | ||
$: tag_black_list = tag_filter_string | ||
.split('|') | ||
.filter((tag) => tag != '' && tag.startsWith('-')) | ||
.map((tag) => { | ||
tag = tag.slice(1); | ||
if (tag.startsWith('^') || tag.endsWith('$')) { | ||
return new RegExp(tag); | ||
} | ||
return tag; | ||
}); | ||
$: fitting_tags = $sortedTags | ||
.filter((tag) => { | ||
// Or when the filter string is empty | ||
if (tag_filter_string == '') return true; | ||
// Only return if any keyword in the white list is in the tag | ||
return ( | ||
tag_white_list.some((keyword) => { | ||
if (keyword instanceof RegExp) { | ||
return keyword.test(tag); | ||
} | ||
return tag.includes(keyword); | ||
}) && | ||
!tag_black_list.some((keyword) => { | ||
if (keyword instanceof RegExp) { | ||
return keyword.test(tag); | ||
} | ||
return tag.includes(keyword); | ||
}) | ||
); | ||
}) | ||
.slice(0, 50) | ||
.sort((a, b) => a.localeCompare(b)); | ||
</script> | ||
|
||
<hr class="my-2" /> | ||
<div> | ||
<label class="label"> | ||
<span>Single Tag Delimiter</span> | ||
<input | ||
class="input variant-form-material" | ||
type="search" | ||
placeholder="Single Tag Delimiter" | ||
title="Single Tag Delimiter" | ||
on:keydown={(event) => { | ||
event.stopPropagation(); | ||
}} | ||
bind:value={$single_tag_delimiter} | ||
/> | ||
</label> | ||
</div> | ||
<div> | ||
<label class="label"> | ||
<span>Filter tags</span> | ||
<input | ||
class="input variant-form-material" | ||
type="search" | ||
placeholder="Filter tags" | ||
title="Filter tags" | ||
on:keydown={(event) => { | ||
event.stopPropagation(); | ||
}} | ||
bind:value={tag_filter_string} | ||
/> | ||
</label> | ||
</div> | ||
<div class="overflow-y-scroll pl-1"> | ||
{#each fitting_tags as tag} | ||
<label class="flex items-center space-x-2"> | ||
<input | ||
class="checkbox" | ||
type="checkbox" | ||
checked={($active_image?.caption.split($single_tag_delimiter) || []) | ||
.map((tag) => tag.trim() + $single_tag_delimiter) | ||
.includes(tag)} | ||
on:click={(event) => { | ||
if ($active_image) { | ||
if ( | ||
($active_image?.caption.split($single_tag_delimiter) || []) | ||
.map((tag) => tag.trim() + $single_tag_delimiter) | ||
.includes(tag) | ||
) { | ||
$active_image.caption = $active_image.caption.replace(new RegExp(`${tag} ?`), ''); | ||
} else { | ||
console.log('Adding tag ' + tag); | ||
$active_image.caption = tag + ' ' + $active_image.caption; | ||
$active_image = $active_image; | ||
} | ||
} | ||
}} | ||
/> | ||
<div class="tag-display" data-tag={tag}> | ||
{tag} | ||
<div class="inline text-gray opacity-60">{$tagCounts[tag]}</div> | ||
</div> | ||
</label> | ||
{/each} | ||
</div> | ||
<hr class="my-2" /> | ||
|
||
<svelte:head> | ||
<!-- Dynamically insert a custom css style tag --> | ||
<svelte:element this={'style'} type="text/css">{custom_css_classes}</svelte:element> | ||
</svelte:head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters