Html Autoimport

Html Autoimport

The HTML Autoimport feature allows the application to automatically detect and import bookmarks from HTML files stored in specified directories. This is particularly useful for syncing bookmarks from files generated by browsers like Firefox or custom HTML bookmark exports.

Configuration

The feature is configured via the config.toml file. Add the following section to enable and customize the autoimport functionality:

[html-autoimport]
paths = ["$HOME/shares/bookmarks"]

Configuration Options

  • paths: A list of directories to monitor for HTML bookmark files.
    • Supports environment variable expansion (e.g., $HOME).
    • Example: ["$HOME/.bookmarks", "/var/www/html/bookmarks"]

How It Works

  1. Directory Monitoring
    The application watches the specified directories for changes (file creation, modification, or deletion).

  2. HTML File Detection
    When an HTML file is detected, it is parsed using a DOM parser (e.g., goquery).

  3. Bookmark Extraction
    Bookmarks are extracted from standard HTML formats. The parser looks for:

    • <a> tags with href attributes
    • <dl> tags containing bookmark lists
    • Metadata like title, description, and tags
  4. Import Process
    Extracted bookmarks are imported into the application’s database, preserving their structure and metadata.

Notes

  • Only files with .html or .htm extensions are processed.
  • Duplicate bookmarks (based on URL) are skipped by default.
  • The feature integrates with the netscapeBookmarks module’s loadBookmarksFromHTML function for parsing.
  • Ensure the monitored directories are accessible and readable by the application.

For advanced use cases (e.g., custom HTML formats), extend the parser logic in netscapeBookmarks/main.go.