Skip to content

Conversation

wei840222
Copy link

Overview

This PR enhances the todo widget functionality by adding support for server-side storage, allowing todo tasks to be persisted and synced across different devices and browsers.

Changes

Core Functionality

  • Added storage-type configuration option for todo widget with two modes:
    • browser (default): Tasks stored in browser's localStorage
    • server: Tasks stored on server in JSON files
  • Implemented server-side storage using afero filesystem abstraction
  • Added new API endpoints for todo data management:
    • GET /api/widgets/todo/{id} - Retrieve todo data
    • PUT /api/widgets/todo/{id} - Save todo data

Configuration

  • Added data-path server configuration option (default: ./data)
  • Automatic creation of todos data directory on startup
  • Updated server startup log to display configured data path

Code Quality

  • Converted Todo() function to async for better data loading
  • Improved code structure with loadFromStorage() and saveToStorage() helper functions

Documentation

  • Updated docs/configuration.md with:
    • New data-path property in Server section
    • New storage-type property in Todo widget section
    • Docker volume mounting examples for data persistence
    • Usage examples for both storage types

Files Changed

  • .gitignore - Added data directory
  • go.mod & go.sum - Added afero dependency
  • internal/glance/config.go - Added DataPath field
  • internal/glance/glance.go - Implemented data path initialization and API routes
  • internal/glance/static/js/todo.js - Refactored with storage abstraction
  • internal/glance/templates/todo.html - Added storage-type data attribute
  • internal/glance/widget-todo.go - Implemented server-side storage logic
  • docs/configuration.md - Updated documentation

Testing

  • Server-side storage creates data directory automatically
  • Browser storage maintains backward compatibility
  • API endpoints handle GET/PUT requests correctly
  • Multiple todo widgets can use different storage types
  • Tasks persist across server restarts (server mode)

Breaking Changes

None. This is a backward-compatible enhancement. Existing todo widgets will continue to use browser storage by default.

Example Configuration

server:
  data-path: ./data  # Optional, defaults to ./data

pages:
  - name: Home
    columns:
      - size: full
        widgets:
          # Browser storage (default, backward compatible)
          - type: todo
            title: My Local Tasks
            
          # Server storage (new feature)
          - type: todo
            title: My Synced Tasks
            storage-type: server
            id: shared-tasks

@wei840222 wei840222 closed this Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants