From fab29b6b6ac39de053035e331bbcbf3febb97dc8 Mon Sep 17 00:00:00 2001 From: Juan Carlos Garcia Esquivel Date: Thu, 30 Apr 2026 01:27:43 -0600 Subject: [PATCH] refactor: clean up plugin logs and improve user-facing error messages --- LICENSE | 22 ++++++++++-- README.md | 49 +++++++++++++-------------- README_es.md | 37 ++++++++++++++++++++ package.json | 2 +- src/commands/hoist-images.ts | 1 - src/core/use-cases/image-processor.ts | 2 +- src/i18n/index.ts | 7 +--- src/i18n/locales/en.ts | 4 +-- src/i18n/locales/es.ts | 4 +-- src/main.ts | 5 --- src/ui/auto-hoist-handler.ts | 1 - src/ui/context-menu.ts | 2 -- 12 files changed, 87 insertions(+), 49 deletions(-) create mode 100644 README_es.md diff --git a/LICENSE b/LICENSE index 287f37a..770d9a9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,21 @@ -Copyright (C) 2020-2025 by Dynalist Inc. +MIT License -Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. +Copyright (c) 2026 jcmexdev, Juan Carlos Garcia Esquivel -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 228166f..37f0657 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,37 @@ # Image Hoist for Obsidian -Image Hoist is an Obsidian plugin designed to optimize your vault's storage and portability by automatically offloading local images to [ImgBB](https://imgbb.com/). +![hero.png](https://i.ibb.co/21VF4jVd/hero-png.jpg) -## Core Objective +**Stop worrying about heavy notes and broken images.** -The primary goal of this plugin is to detect local images in your vault, upload them to ImgBB, and replace the local file references with remote markdown links. This keeps your vault lightweight and makes your notes easier to share and sync. +Image Hoist is the ultimate tool to keep your Obsidian vault light, fast, and 100% shareable. It automatically takes your local images, moves them to the cloud ([ImgBB](https://imgbb.com/)), and replaces them with links that work anywhere. -## Features +## 🌟 Why you need Image Hoist -- **Automatic Upload:** Automatically detects and uploads local images. -- **Link Replacement:** Replaces `![[image.png]]` or `![](image.png)` with remote ImgBB links. -- **Storage Optimization:** Reduces the size of your vault by removing binary image files after successful upload. -- **Portability:** Access your images from any device without needing to sync large binary files. +- **Save Massive Space**: Stop hoarding gigabytes of images in your vault. Keep your storage for what matters: your ideas. +- **Lightning-Fast Sync**: Since your images are in the cloud, syncing your notes across devices (mobile, tablet, desktop) becomes instant. +- **Share Without Friction**: When you copy-paste a note to a blog, email, or another person, your images will actually show up! No more broken links. +- **Zero Effort**: Paste an image and forget about it. The plugin handles the upload and link replacement in the background. -## Installation +## 🚀 Key Benefits -### From Obsidian (Not yet available) -1. Go to **Settings** > **Community plugins** > **Browse**. -2. Search for "Image Hoist". -3. Click **Install**, then **Enable**. +- **Set and Forget**: Enable "Auto-hoist" and every image you paste goes straight to the cloud. No local files, no clutter. +- **Smart Uploads**: Already uploaded the same image? The plugin is smart enough to recognize it and reuse the existing link instantly. +- **Note Cleanup**: Got an old note full of local images? One click and the whole note is "hoisted" to the cloud. +- **Safe & Secure**: Your images are yours. Your access keys are kept private and secure within Obsidian. -### Manual Installation -1. Download the latest release (`main.js`, `manifest.json`, `styles.css`). -2. Create a folder named `obsidian-image-hoist` in your vault's `.obsidian/plugins/` directory. -3. Move the downloaded files into that folder. -4. Reload Obsidian and enable the plugin in **Settings** > **Community plugins**. +## 🛠️ Quick Start -## Configuration +1. **Install**: Add the plugin to your Obsidian vault. +2. **Connect**: Get a free key from [ImgBB](https://api.imgbb.com/) and paste it into the plugin settings. +3. **Enjoy**: Start pasting images or right-click any existing image to "hoist" it. -You will need an **ImgBB API Key** to use this plugin: -1. Create a free account at [ImgBB](https://imgbb.com/). -2. Get your API key from [ImgBB API settings](https://api.imgbb.com/). -3. Paste the key into the plugin settings in Obsidian. +## 📖 How to use it -## License +- **Drag & Drop**: Just drag an image into your note—it goes straight to the cloud (if enabled). +- **Right-Click**: See a local image? Right-click and select **Hoist this image**. +- **The Magic Button**: Use the Command Palette (`Cmd/Ctrl + P`) and run **Hoist all images in current note** to clean up an entire page at once. -This project is licensed under the MIT License. +## 📄 License + +This project is licensed under the [MIT License](LICENSE). diff --git a/README_es.md b/README_es.md new file mode 100644 index 0000000..8a8fd32 --- /dev/null +++ b/README_es.md @@ -0,0 +1,37 @@ +# Image Hoist para Obsidian + +![hero.png](https://i.ibb.co/21VF4jVd/hero-png.jpg) + +**Olvídate de las notas pesadas y las imágenes que no cargan.** + +Image Hoist es la herramienta definitiva para mantener tu vault de Obsidian ligero, rápido y 100% compartible. Sube automáticamente tus imágenes locales a la nube ([ImgBB](https://imgbb.com/)) y las reemplaza con enlaces que funcionan en cualquier lugar. + +## 🌟 ¿Por qué necesitas Image Hoist? + +- **Ahorra espacio masivo**: Deja de acumular gigabytes de fotos en tu dispositivo. Reserva tu almacenamiento para lo que importa: tus ideas. +- **Sincronización ultra rápida**: Al tener tus fotos en la nube, sincronizar tus notas entre dispositivos (móvil, tablet, PC) es instantáneo. +- **Comparte sin fricción**: Cuando copies una nota para un blog, un correo o para otra persona, ¡las imágenes se verán de verdad! Se acabaron los enlaces rotos. +- **Esfuerzo cero**: Pega una imagen y olvídate. El plugin se encarga de subirla y poner el enlace por ti en segundo plano. + +## 🚀 Beneficios principales + +- **Configura y olvida**: Activa la "Subida automática" y cada imagen que pegues irá directa a la nube. Sin archivos locales, sin desorden. +- **Subidas inteligentes**: ¿Ya subiste la misma foto antes? El plugin es lo suficientemente listo para reconocerla y reutilizar el enlace existente al instante. +- **Limpieza de notas**: ¿Tienes una nota vieja llena de fotos locales? Con un solo clic, toda la nota se "limpia" y las fotos pasan a la nube. +- **Seguro y privado**: Tus fotos son tuyas. Tus claves de acceso se mantienen privadas y seguras dentro de Obsidian. + +## 🛠️ Inicio rápido + +1. **Instala**: Añade el plugin a tu carpeta de Obsidian. +2. **Conecta**: Consigue una clave gratuita en [ImgBB](https://api.imgbb.com/) y pégala en los ajustes del plugin. +3. **Disfruta**: Empieza a pegar fotos o haz clic derecho en cualquier imagen existente para subirla a la nube. + +## 📖 Cómo usarlo + +- **Arrastrar y soltar**: Simplemente arrastra una foto a tu nota; irá directa a la nube (si lo activas). +- **Clic derecho**: ¿Ves una foto local? Haz clic derecho y selecciona **Subir esta imagen (hoist)**. +- **El botón mágico**: Usa la Paleta de Comandos (`Cmd/Ctrl + P`) y ejecuta **Subir todas las imágenes de la nota** para limpiar una página entera de una sola vez. + +## 📄 Licencia + +Este proyecto está bajo la [Licencia MIT](LICENSE). diff --git a/package.json b/package.json index 4c763d6..78ab2a2 100644 --- a/package.json +++ b/package.json @@ -31,4 +31,4 @@ "typescript-eslint": "8.35.1", "vitest": "^4.1.5" } -} +} \ No newline at end of file diff --git a/src/commands/hoist-images.ts b/src/commands/hoist-images.ts index 59420ec..4c6eed4 100644 --- a/src/commands/hoist-images.ts +++ b/src/commands/hoist-images.ts @@ -51,7 +51,6 @@ export async function hoistImagesInCurrentNote(plugin: ImageHoistPlugin, process } catch (error) { const msg = error instanceof Error ? error.message : String(error); new Notice(`Error: ${msg}`); - console.error("Image Hoist Error:", error); } } ).open(); diff --git a/src/core/use-cases/image-processor.ts b/src/core/use-cases/image-processor.ts index a2a9934..8241479 100644 --- a/src/core/use-cases/image-processor.ts +++ b/src/core/use-cases/image-processor.ts @@ -122,7 +122,7 @@ export class ImageProcessor { processedCount++; if (result.isCacheHit) cacheCount++; } catch (error) { - console.error(`Failed to process ${img.name}:`, error); + // We still throw or ignore quietly as per user request to remove logs } } diff --git a/src/i18n/index.ts b/src/i18n/index.ts index a461ab0..e65bcdb 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -18,18 +18,13 @@ export function t(key: keyof LocaleType, vars: Record = const lang = (obsidianLang || moment.locale()).split("-")[0] || "en"; const locale = locales[lang] || locales.en; - const fallback = locales.en!; + let text = (locale ? locale[key] : fallback[key]) || fallback[key] || key; Object.keys(vars).forEach((v) => { text = text.replace(`{{${v}}}`, String(vars[v])); }); - // Debug log to identify why it's not showing Spanish - if (lang === "es" && text === fallback[key] && locale[key] === undefined) { - console.debug(`Image Hoist i18n: Key "${key}" not found in "es" locale, falling back to "en".`); - } - return text; } diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 154039d..e0e7b2e 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -18,11 +18,11 @@ export default { NOTICE_STARTING_ALL: "Starting hoist of {{count}} images...", NOTICE_SUCCESS_ALL: "Successfully hoisted {{count}} images!", NOTICE_SUCCESS_ALL_CACHE: "Successfully processed {{count}} images ({{cacheCount}} from cache)!", - NOTICE_ERROR_ALL: "Error during hoist process. Check console.", + NOTICE_ERROR_ALL: "Error during hoist process. Please try again.", NOTICE_STARTING_SINGLE: "Hoisting image: {{name}}...", NOTICE_SUCCESS_SINGLE: "Successfully hoisted {{name}}!", NOTICE_SUCCESS_CACHE: "Successfully retrieved {{name}} from cache!", - NOTICE_ERROR_SINGLE: "Failed to hoist {{name}}. Check console.", + NOTICE_ERROR_SINGLE: "Failed to hoist {{name}}.", NOTICE_NO_IMAGES: "No local images found in this note.", NOTICE_NO_MARKDOWN: "No active markdown note found.", NOTICE_CACHE_CLEARED: "Upload cache cleared successfully!", diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index f24eb51..e228324 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -18,11 +18,11 @@ export default { NOTICE_STARTING_ALL: "Iniciando subida de {{count}} imágenes...", NOTICE_SUCCESS_ALL: "¡Se han subido {{count}} imágenes con éxito!", NOTICE_SUCCESS_ALL_CACHE: "¡Se han procesado {{count}} imágenes ({{cacheCount}} desde la caché)!", - NOTICE_ERROR_ALL: "Error durante el proceso de subida. Revisa la consola.", + NOTICE_ERROR_ALL: "Error durante el proceso de subida.", NOTICE_STARTING_SINGLE: "Subiendo imagen: {{name}}...", NOTICE_SUCCESS_SINGLE: "¡{{name}} subida con éxito!", NOTICE_SUCCESS_CACHE: "¡{{name}} recuperada de la caché con éxito!", - NOTICE_ERROR_SINGLE: "Error al subir {{name}}. Revisa la consola.", + NOTICE_ERROR_SINGLE: "Error al subir {{name}}.", NOTICE_NO_IMAGES: "No se han encontrado imágenes locales en esta nota.", NOTICE_NO_MARKDOWN: "No se ha encontrado ninguna nota activa.", NOTICE_CACHE_CLEARED: "¡La caché de subidas se ha limpiado con éxito!", diff --git a/src/main.ts b/src/main.ts index 048f5cb..d946266 100644 --- a/src/main.ts +++ b/src/main.ts @@ -47,11 +47,6 @@ export default class ImageHoistPlugin extends Plugin { registerCommands(this, this.processor); registerContextMenu(this); registerAutoHoistHandler(this); - - // Minimal logging on startup, no intrusive Notices - if (!apiKey) { - console.debug("Image Hoist: API Key not set. Features will be available but uploads will prompt for configuration."); - } } onunload() {} diff --git a/src/ui/auto-hoist-handler.ts b/src/ui/auto-hoist-handler.ts index 2dfbf90..bcc5f8f 100644 --- a/src/ui/auto-hoist-handler.ts +++ b/src/ui/auto-hoist-handler.ts @@ -68,6 +68,5 @@ async function handleFileAutoHoist(file: File, editor: Editor, plugin: ImageHois } catch (error) { const msg = error instanceof Error ? error.message : String(error); new Notice(`Error: ${msg}`); - console.error("Auto-hoist Error:", error); } } diff --git a/src/ui/context-menu.ts b/src/ui/context-menu.ts index 8c26636..3c68672 100644 --- a/src/ui/context-menu.ts +++ b/src/ui/context-menu.ts @@ -95,7 +95,6 @@ export function registerContextMenu(plugin: ImageHoistPlugin) { } catch (error) { const msg = error instanceof Error ? error.message : String(error); new Notice(`Error: ${msg}`); - console.error("Image hoist error:", error); } }; @@ -138,7 +137,6 @@ export function registerContextMenu(plugin: ImageHoistPlugin) { } catch (error) { const msg = error instanceof Error ? error.message : String(error); new Notice(`Error: ${msg}`); - console.error("Image hoist error:", error); } };