From 9fa465bcaff13d7fed586a1b6c6cec9d96b24236 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sun, 6 Apr 2025 00:09:35 +0200 Subject: [PATCH] booru: save preferences, nuke save in folder by tags save in folder by tags is unnecessary because saved images have proper file names now --- .config/ags/i18n/locales/Default.json | 3 +-- .config/ags/i18n/locales/fa_IR.json | 3 +-- .config/ags/i18n/locales/fr_FR.json | 3 +-- .config/ags/i18n/locales/it_IT.json | 3 +-- .config/ags/i18n/locales/zh_CN.json | 3 +-- .../.commonwidgets/configwidgets_apps.js | 2 ++ .../.configuration/default_options.jsonc | 3 +-- .config/ags/modules/sideleft/apis/booru.js | 21 ++++++------------- 8 files changed, 14 insertions(+), 27 deletions(-) diff --git a/.config/ags/i18n/locales/Default.json b/.config/ags/i18n/locales/Default.json index 84e6edd3b..a24203c7f 100644 --- a/.config/ags/i18n/locales/Default.json +++ b/.config/ags/i18n/locales/Default.json @@ -35,8 +35,7 @@ "Powered by yande.re and konachan": "Powered by yande.re and konachan", "An image booru. May contain NSFW content.\nWatch your back.\n\nDisclaimer: Not affiliated with the provider\nnor responsible for any of its content.": "An image booru. May contain NSFW content.\nWatch your back.\n\nDisclaimer: Not affiliated with the provider\nnor responsible for any of its content.", "Lewds": "Lewds", - "Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js:\n\t'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true,\n\t}\n}": "Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js:\n\t'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true,\n\t}\n}", - "Save in folder by tags": "Save in folder by tags", + "Shows naughty stuff when enabled": "Shows naughty stuff when enabled", "Saves images in folders by their tags": "Saves images in folders by their tags", "Message Gemini...": "Message Gemini...", "Enter Google AI API Key...": "Enter Google AI API Key...", diff --git a/.config/ags/i18n/locales/fa_IR.json b/.config/ags/i18n/locales/fa_IR.json index cb108b0da..720b9c2c2 100644 --- a/.config/ags/i18n/locales/fa_IR.json +++ b/.config/ags/i18n/locales/fa_IR.json @@ -35,8 +35,7 @@ "Powered by yande.re and konachan": "قدرت گرفته از yande.re و konachan", "An image booru. May contain NSFW content.\nWatch your back.\n\nDisclaimer: Not affiliated with the provider\nnor responsible for any of its content.": "یک تصویر بورو. ممکن است محتوای NSFW داشته باشد.\nمواظب باشید.\n\nتوجه: بدون وابستگی به ارائه‌دهنده\nو مسئول هیچ‌یک از محتوای آن نیست.", "Lewds": "محتوای نامناسب", - "Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js:\n\t'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true,\n\t}\n}": "محتوای نامناسب را زمانی که فعال باشد نشان می‌دهد.\nآیا از اینها خوشتان می‌آید؟ این را به user_options.js اضافه کنید:\n\t'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true,\n\t}\n}", - "Save in folder by tags": "نگه‌داری در پوشه بر اساس برچسب‌ها", + "Shows naughty stuff when enabled": "محتوای نامناسب را زمانی که فعال باشد نشان می‌دهد", "Saves images in folders by their tags": "تصاویر را در پوشه‌ها بر اساس برچسب‌هایشان نگه‌داری می‌کند", "Message Gemini...": "پیام به Gemini...", "Enter Google AI API Key...": "کلید API گوگل AI را وارد کنید...", diff --git a/.config/ags/i18n/locales/fr_FR.json b/.config/ags/i18n/locales/fr_FR.json index 057dc0920..30b52fef8 100644 --- a/.config/ags/i18n/locales/fr_FR.json +++ b/.config/ags/i18n/locales/fr_FR.json @@ -35,8 +35,7 @@ "Powered by yande.re and konachan": "Propulsé par yande.re et konachan", "An image booru. May contain NSFW content.\nWatch your back.\n\nDisclaimer: Not affiliated with the provider\nnor responsible for any of its content.": "Un booru d'images. Peut contenir du contenu NSFW.\nFais attention.\n\nAvertissement : Pas affilié au fournisseur\net pas responsable de son contenu.", "Lewds": "Contenu osé", - "Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js:\n\t'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true,\n\t}\n}": "Affiche du contenu osé lorsqu'il est activé.\nTu aimes ça ? Ajoute ceci dans user_options.js :\n\t'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true\n\t}\n}", - "Save in folder by tags": "Enregistrer dans un dossier par tags", + "Shows naughty stuff when enabled": "Affiche du contenu osé lorsqu'il est activé", "Saves images in folders by their tags": "Enregistre les images dans des dossiers selon leurs tags", "Message Gemini...": "Envoyer un message à Gemini...", "Enter Google AI API Key...": "Saisissez la clé API de Google AI...", diff --git a/.config/ags/i18n/locales/it_IT.json b/.config/ags/i18n/locales/it_IT.json index a6b2122f8..c53682b49 100644 --- a/.config/ags/i18n/locales/it_IT.json +++ b/.config/ags/i18n/locales/it_IT.json @@ -35,8 +35,7 @@ "Powered by yande.re and konachan": "Offerto da yande.re e konachan", "An image booru. May contain NSFW content.\nWatch your back.\n\nDisclaimer: Not affiliated with the provider\nnor responsible for any of its content.": "Un booru di immagini. Potrebbe contenere contenuti NSFW.\nFai attenzione.\n\nDisclaimer: Non affiliato al provider\nné responsabile per alcun suo contenuto.", "Lewds": "Contenuti osé", - "Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js:\n\t'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true,\n\t}\n}": "Mostra contenuti osé quando abilitato.\nTi piacciono? Aggiungi questo a user_options.js:\n\t'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true,\n\t}\n}", - "Save in folder by tags": "Salva in cartella per tag", + "Shows naughty stuff when enabled": "Mostra contenuti osé quando abilitato", "Saves images in folders by their tags": "Salva le immagini in cartelle in base ai loro tag", "Message Gemini...": "Messaggia Gemini...", "Enter Google AI API Key...": "Inserisci la chiave API di Google AI...", diff --git a/.config/ags/i18n/locales/zh_CN.json b/.config/ags/i18n/locales/zh_CN.json index 0f13aef9b..c6be7a14e 100644 --- a/.config/ags/i18n/locales/zh_CN.json +++ b/.config/ags/i18n/locales/zh_CN.json @@ -35,8 +35,7 @@ "Powered by yande.re and konachan": "由 yande.re 和 konachan 提供支持", "An image booru. May contain NSFW content.\nWatch your back.\n\nDisclaimer: Not affiliated with the provider\nnor responsible for any of its content.": "一个图片图库。可能包含 NSFW 内容。\n小心。\n\n免责声明:与提供商无关联\n也不对它的任何内容负责。", "Lewds": "不雅内容", - "Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js:\n\t'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true,\n\t}\n}": "启用时显示不雅内容。\n你喜欢这些?添加到 user_options.js 中:\n'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true,\n\t}\n}", - "Save in folder by tags": "按标签保存到文件夹", + "Shows naughty stuff when enabled": "启用时显示不雅内容", "Saves images in folders by their tags": "按标签将图片保存到文件夹中", "Message Gemini...": "向 Gemini 发送消息...", "Enter Google AI API Key...": "输入 Google AI API 密钥...", diff --git a/.config/ags/modules/.commonwidgets/configwidgets_apps.js b/.config/ags/modules/.commonwidgets/configwidgets_apps.js index b26da8160..779c1580d 100644 --- a/.config/ags/modules/.commonwidgets/configwidgets_apps.js +++ b/.config/ags/modules/.commonwidgets/configwidgets_apps.js @@ -10,6 +10,7 @@ export const AgsToggle = ({ icon, name, desc = null, option, resetButton = true, save = true, extraOnChange = () => { }, extraOnReset = () => { }, + ...rest }) => ConfigToggle({ icon: icon, name: name, @@ -35,6 +36,7 @@ export const AgsToggle = ({ --file ${AGS_CONFIG_FILE}'`); extraOnReset(self); }, + ...rest }); export const AgsSpinButton = ({ diff --git a/.config/ags/modules/.configuration/default_options.jsonc b/.config/ags/modules/.configuration/default_options.jsonc index ed895dc9a..074067d35 100644 --- a/.config/ags/modules/.configuration/default_options.jsonc +++ b/.config/ags/modules/.configuration/default_options.jsonc @@ -103,8 +103,7 @@ "image": { "columns": 2, "batchCount": 20, - "allowNsfw": false, - "saveInFolderByTags": false + "allowNsfw": false }, "pages": { "order": ["apis", "tools"], diff --git a/.config/ags/modules/sideleft/apis/booru.js b/.config/ags/modules/sideleft/apis/booru.js index 706c9cbc8..5ce97957d 100644 --- a/.config/ags/modules/sideleft/apis/booru.js +++ b/.config/ags/modules/sideleft/apis/booru.js @@ -8,8 +8,8 @@ import { MaterialIcon } from '../../.commonwidgets/materialicon.js'; import { MarginRevealer } from '../../.widgethacks/advancedrevealers.js'; import { setupCursorHover, setupCursorHoverInfo } from '../../.widgetutils/cursorhover.js'; import BooruService from '../../../services/booru.js'; -import { ConfigToggle } from '../../.commonwidgets/configwidgets.js'; import { SystemMessage } from './ai_chatmessage.js'; +import { AgsToggle } from '../../.commonwidgets/configwidgets_apps.js'; const IMAGE_REVEAL_DELAY = 13; // Some wait for inits n other weird stuff const USER_CACHE_DIR = GLib.get_user_cache_dir(); @@ -93,27 +93,18 @@ export const BooruSettings = () => MarginRevealer({ hpack: 'center', className: 'sidebar-chat-settings-toggles', children: [ - ConfigToggle({ + AgsToggle({ icon: 'menstrual_health', name: getString('Lewds'), - desc: getString("Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js:\n\t'sidebar': {\n\t'image': {\n\t\t'allowNsfw': true,\n\t}\n}"), - initValue: BooruService.nsfw, - onChange: (self, newValue) => { + desc: getString("Shows naughty stuff when enabled"), + option: 'sidebar.image.allowNsfw', + extraOnChange: (self, newValue) => { BooruService.nsfw = newValue; }, extraSetup: (self) => self.hook(BooruService, (self) => { self.attribute.enabled.value = BooruService.nsfw; }, 'notify::nsfw') }), - ConfigToggle({ - icon: 'sell', - name: getString('Save in folder by tags'), - desc: getString('Saves images in folders by their tags'), - initValue: userOptions.sidebar.image.saveInFolderByTags, - onChange: (self, newValue) => { - userOptions.sidebar.image.saveInFolderByTags = newValue; - }, - }), ] }) ] @@ -228,7 +219,7 @@ const BooruPage = (taglist, serviceName = 'Booru') => { const currentTags = BooruService.queries.at(-1).realTagList.filter(tag => !tag.includes('rating:')); const tagDirectory = currentTags.join('+'); const fileName = decodeURIComponent((data.file_url).substring((data.file_url).lastIndexOf('/') + 1)); - const saveCommand = `mkdir -p "$(xdg-user-dir PICTURES)/homework/${data.is_nsfw ? '🌶️/' : ''}${userOptions.sidebar.image.saveInFolderByTags ? tagDirectory : ''}" && curl -L -o "$(xdg-user-dir PICTURES)/homework/${data.is_nsfw ? '🌶️/' : ''}${userOptions.sidebar.image.saveInFolderByTags ? (tagDirectory + '/') : ''}${fileName}" '${data.file_url}'`; + const saveCommand = `mkdir -p "$(xdg-user-dir PICTURES)/homework/${data.is_nsfw ? '🌶️/' : ''}" && curl -L -o "$(xdg-user-dir PICTURES)/homework/${data.is_nsfw ? '🌶️/' : ''}${fileName}" '${data.file_url}'`; print(saveCommand) execAsync(['bash', '-c', saveCommand]) .then(() => self.label = 'done')