Documentation
¶
Index ¶
- Constants
- Variables
- func MapSettingsLogLevelToSlog(logLevel string) slog.Level
- type Browser
- type BrowserMatch
- type BrowserService
- type BrowserSettings
- type FileSettingsService
- func (s *FileSettingsService) GetConfigFilePath() string
- func (s *FileSettingsService) GetConfigFolderPath() string
- func (s *FileSettingsService) GetLogFilePath() string
- func (s *FileSettingsService) GetLogFolderPath() string
- func (s *FileSettingsService) GetPluginFolderPath() string
- func (s *FileSettingsService) GetSettings() *Settings
- func (s *FileSettingsService) IsConfigured() (bool, error)
- func (s *FileSettingsService) ReadSettings() (*Settings, error)
- func (s *FileSettingsService) ScanBrowsers() error
- func (s *FileSettingsService) WriteSettings(settings *Settings) error
- type PathProvider
- type Plugin
- type PluginServiceProvider
- type PluginSettings
- type Settings
- func (s *Settings) AddRuleToBrowser(b *Browser, matchType, matchValue string)
- func (s *Settings) CompileAllRegexMatches() *Settings
- func (s *Settings) GetMatchingBrowser(u string) (*Browser, error)
- func (s *Settings) GetSelectableBrowsers() []Browser
- func (s *Settings) NormalizeBrowsers() *Settings
- func (s *Settings) UpdateWithBrowsers(browsers []Browser) *Settings
- type SettingsService
- type URL
- type UiSettings
Constants ¶
const ( BrowserMatchTypeRegex = "regex" BrowserMatchTypeDomain = "domain" BrowserMatchTypeSite = "site" SourceAuto = "auto" SourceManual = "manual" LogLevelDebug = "debug" LogLevelInfo = "info" LogLevelWarn = "warn" LogLevelError = "error" )
Variables ¶
var ErrNoMatchFound = errors.New("no match found")
Functions ¶
Types ¶
type BrowserMatch ¶
type BrowserService ¶
type BrowserService interface {
// GetAvailableBrowsers returns a list of available browsers in the system
GetAvailableBrowsers() ([]Browser, error)
// GetDefaultBrowser returns the default browser in the system
GetDefaultBrowser() (Browser, error)
// OpenUrlWithDefaultBrowser launches the given url with the default system browser
OpenUrlWithDefaultBrowser(url string) error
// OpenUrlWithBrowser launches the given url with the given browser
OpenUrlWithBrowser(url string, browser *Browser) error
// AreWeTheDefaultBrowser returns true if Linkquisition is the default browser
AreWeTheDefaultBrowser() bool
// MakeUsTheDefaultBrowser sets Linkquisition as the default browser
MakeUsTheDefaultBrowser() error
// GetIconForBrowser returns the icon for the given browser
GetIconForBrowser(browser Browser) ([]byte, error)
}
type BrowserSettings ¶
type BrowserSettings struct {
Name string `json:"name"`
Command string `json:"command"`
Hidden bool `json:"hidden"`
Source string `json:"source"`
Matches []BrowserMatch `json:"matches"`
}
func (*BrowserSettings) CompileRegexMatches ¶ added in v1.13.0
func (s *BrowserSettings) CompileRegexMatches()
CompileRegexMatches pre-compiles all regex match patterns for this browser. Invalid patterns are logged and will be skipped during matching.
func (*BrowserSettings) MatchesUrl ¶
func (s *BrowserSettings) MatchesUrl(u string) bool
MatchesUrl returns true if the given url matches any of the browser's rules
type FileSettingsService ¶ added in v1.11.1
type FileSettingsService struct {
BrowserService BrowserService
PathProvider PathProvider
}
FileSettingsService is the shared, platform-independent implementation of SettingsService.
func (*FileSettingsService) GetConfigFilePath ¶ added in v1.11.1
func (s *FileSettingsService) GetConfigFilePath() string
func (*FileSettingsService) GetConfigFolderPath ¶ added in v1.15.0
func (s *FileSettingsService) GetConfigFolderPath() string
func (*FileSettingsService) GetLogFilePath ¶ added in v1.11.1
func (s *FileSettingsService) GetLogFilePath() string
func (*FileSettingsService) GetLogFolderPath ¶ added in v1.11.1
func (s *FileSettingsService) GetLogFolderPath() string
func (*FileSettingsService) GetPluginFolderPath ¶ added in v1.11.1
func (s *FileSettingsService) GetPluginFolderPath() string
func (*FileSettingsService) GetSettings ¶ added in v1.11.1
func (s *FileSettingsService) GetSettings() *Settings
func (*FileSettingsService) IsConfigured ¶ added in v1.11.1
func (s *FileSettingsService) IsConfigured() (bool, error)
func (*FileSettingsService) ReadSettings ¶ added in v1.11.1
func (s *FileSettingsService) ReadSettings() (*Settings, error)
func (*FileSettingsService) ScanBrowsers ¶ added in v1.11.1
func (s *FileSettingsService) ScanBrowsers() error
func (*FileSettingsService) WriteSettings ¶ added in v1.11.1
func (s *FileSettingsService) WriteSettings(settings *Settings) error
type PathProvider ¶ added in v1.11.1
type PathProvider interface {
GetConfigFolderPath() string
GetLogFolderPath() string
GetPluginFolderPath() string
}
PathProvider supplies platform-specific paths used by the SettingsService.
type Plugin ¶
type Plugin interface {
// Setup is called when the plugin is being setup
Setup(serviceProvider PluginServiceProvider, config map[string]interface{})
// ModifyUrl is called just before the URL is being matched against the browser-rules
// The plugin can modify the URL and return it (or otherwise just return the original URL)
ModifyUrl(url string) string
// Shutdown is called when the application is about to exit.
// Plugins should use this to finish any background work (e.g. writing files).
// The context carries a deadline — plugins must return before it expires.
Shutdown(ctx context.Context)
}
Plugin is an interface that all plugins must implement
type PluginServiceProvider ¶
type PluginServiceProvider interface {
GetLogger() *slog.Logger
GetSettings() *Settings
GetConfigFolderPath() string
}
PluginServiceProvider is an interface that provides the logger and settings to the plugin This is passed to the plugin as a dependency when being setup.
func NewPluginServiceProvider ¶
func NewPluginServiceProvider(logger *slog.Logger, settings *Settings, configFolderPath string) PluginServiceProvider
type PluginSettings ¶
type Settings ¶
type Settings struct {
Locale string `json:"locale,omitempty"`
LogLevel string `json:"logLevel,omitempty"`
Browsers []BrowserSettings `json:"browsers"`
Plugins []PluginSettings `json:"plugins,omitempty"`
Ui UiSettings `json:"ui,omitempty"`
}
func GetDefaultSettings ¶
func GetDefaultSettings() *Settings
func (*Settings) AddRuleToBrowser ¶ added in v1.4.6
func (*Settings) CompileAllRegexMatches ¶ added in v1.13.0
CompileAllRegexMatches pre-compiles regex patterns for all browsers. Call after loading settings to avoid repeated compilation during URL matching.
func (*Settings) GetMatchingBrowser ¶
func (*Settings) GetSelectableBrowsers ¶
func (*Settings) NormalizeBrowsers ¶
NormalizeBrowsers moves hidden browsers to the end of the list
func (*Settings) UpdateWithBrowsers ¶
type SettingsService ¶
type SettingsService interface {
// IsConfigured returns true if the settings have been configured (i.e. the config-file exists)
IsConfigured() (bool, error)
// GetSettings returns the settings, either from the config-file or the default settings
GetSettings() *Settings
// ReadSettings reads the config-file and returns the settings
ReadSettings() (*Settings, error)
// WriteSettings writes the settings to the config-file
WriteSettings(settings *Settings) error
// ScanBrowsers scans (or re-scans) the system for available browsers and creates/updates the config-file
ScanBrowsers() error
// GetLogFilePath returns the absolute path to the log-file
GetLogFilePath() string
// GetLogFolderPath returns the absolute path to the log-folder
GetLogFolderPath() string
// GetPluginFolderPath returns the absolute path to the plugin-folder
GetPluginFolderPath() string
// GetConfigFilePath returns the absolute path to the config-file
GetConfigFilePath() string
// GetConfigFolderPath returns the absolute path to the config-folder
GetConfigFolderPath() string
}
type UiSettings ¶ added in v1.4.6
type UiSettings struct {
HideKeyboardGuideLabel bool `json:"hideKeyboardGuideLabel,omitempty"`
}
