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"]
- Supports environment variable expansion (e.g.,
How It Works
Directory Monitoring
The application watches the specified directories for changes (file creation, modification, or deletion).HTML File Detection
When an HTML file is detected, it is parsed using a DOM parser (e.g.,goquery
).Bookmark Extraction
Bookmarks are extracted from standard HTML formats. The parser looks for:<a>
tags withhref
attributes<dl>
tags containing bookmark lists- Metadata like
title
,description
, andtags
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’sloadBookmarksFromHTML
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
.