Skip to content

0.15.0

Latest

Choose a tag to compare

@keven1024 keven1024 released this 15 Oct 12:32

Scope: main (0.14.1) → dev/0.15, comprising 47 commits.
Author distribution: keven1024/keven (44), TrapStoner (3).

Added

  • Introduced a unified configuration model (pkg/models/config.go). Configuration settings, previously scattered across various environment variables, have been consolidated into a strongly-typed Config struct. This struct is organized into seven groups—share, upload, redis, features, site, about, and smtp—with all fields annotated using mapstructure tags.
  • Configuration loading and validation (pkg/utils/config.go). Configuration is loaded via viper, supporting default value merging (using mergo) and field validation (using go-playground/validator). Two custom validation rules have been registered: storage_size (for human-readable storage capacities, e.g., 100GiB) and required_en_key_content (ensuring that multi-language content includes an English key). New GetConfig() and SetConfig() functions have been added; all modules (backend, worker, and pkg) have been migrated from GetEnv/GetEnvMap to use GetConfig().
  • Hot-reloading of configuration. viper is configured with WatchConfig() and OnConfigChange, allowing for automatic reloading and re-validation whenever the configuration file is modified. Additionally, AutomaticEnv and ExperimentalBindStruct have been enabled.
  • Graceful shutdown. The entry points for both the backend and worker have been refactored into a run() int pattern. This implementation utilizes signal.NotifyContext (for SIGINT/SIGTERM signals) in conjunction with echo.StartConfig{GracefulTimeout: 30s} and asynq.Config{ShutdownTimeout: 30s}. Initialization failures now return an exit code of 1 along with an error log, replacing previous panic or log.Fatalf calls. Furthermore, Redis, asynq clients, and the scheduler are now properly shut down using defer. - Route and Middleware Registry. Added internal/route.go (Route + Routes) and internal/middleware.go (Middlewares) to the backend; added internal/route.go and internal/middleware.go to the worker. The main function has been updated to iterate through these registries, and route/middleware definitions have been moved from the package root into the internal/ directory.
  • New Scheduler Registry (worker/internal/scheduler.go). Scheduled tasks are now declared via a list of Schedule{Cron, Handle} objects. The file cleanup task file:janitor (scheduled for 0 3 * * *) has been migrated to this registry. Note that the text:translate route is currently commented out in the route table and can be enabled on an as-needed basis.
  • Enhanced Tiptap Editor Capabilities. Added a drag handle (DragHandle.vue)—supporting block-level menus (convert, insert below, delete) and language switching for code blocks—as well as Markdown paste confirmation (PasteHandler.ts + isStringMarkdown), mathematical formula support (@tiptap/extension-mathematics + KaTeX), tables (TableKit), lists (ListKit), images (with proportional scaling enabled), cross-block selection (NodeRange, triggered via Cmd on macOS or Ctrl on Windows), and GFM (GitHub Flavored Markdown) parsing.
  • Text Statistics. The countWords function now returns an object { length, characters } instead of a single number, with added support for counting emojis (including surrogate pairs). The editor status bar now displays both character and word counts.
  • New Multilingual Keys. Added page.editor.markdown and page.editor.tiptap entries across seven languages ​​​​(en, zh-CN, zh-TW, ja, ko, fr, de), covering Markdown paste confirmation prompts, block types, and programming language names.
  • Added WebP Icons. - front/public/logo.webp (replaces the 2.03MB logo.png; ~156KB, a 92% reduction). The default icon path is now /logo.webp. The Navbar icon now pulls from the site_icon configuration setting, with a fallback to logo.webp. useSeo now generates the appropriate MIME type for og:image based on the file extension. (by TrapStoner, 42a5222 / 439a6de)
  • Real Client IP. The backend is now configured with e.IPExtractor = echo.ExtractIPFromXFFHeader(echo.TrustLoopback(true)). This prevents the system from incorrectly identifying all clients as 127.0.0.1 when running behind Caddy (previously, this caused rate-limiting to treat all clients as a single entity). (by TrapStoner, f0ff278)
  • New Unit Tests. Added pkg/utils/config_test.go (covering default value merging, overrides, and validation) and pkg/utils/env_test.go.
  • Added an optional btnClass property to ConfirmActionDrawer; the delete button on the share management page now uses the "destructive" style.

Improved

  • Removed environment variable-based configuration paths. Deleted GetEnvMap(), InitTestViper(), and EnvOption.ConfigData. Tests now use SetConfig(models.Config{...}) instead; `pkg/utils/test/env_test.gohttps://github.com/TrapStoner)** — 3 commits
  • fix(assets): Converted icons to WebP format (-92% file size) and updated the Navbar to load site_icon from the configuration (42a5222)
  • chore: Synchronized the default icon path in config.example.yaml (439a6de)
  • fix: Reported the actual client IP instead of Caddy’s loopback address, resolving an issue where rate-limiting incorrectly treated all clients as a single entity (f0ff278)

Full Changelog: 0.14.1...0.15.0