hooks

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2025 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package hooks permits to register custom hooks that will be called during the parsing process of a bookmark file. Hooks can be used to extract tags, commands or other custom data from a bookmark title or description.

They can effectively be used as a command line interface to the host system through the browser builtin Ctrl+D bookmark feature.

This is an example implementation of a hook that simply sends a notification using the notification daemon of the system.

Index

Constants

This section is empty.

Variables

View Source
var Defined = HookMap{
	"node_tags_from_name": Hook[*tree.Node]{

		Func: parsing.ParseNodeTags,
		// contains filtered or unexported fields
	},
	"bk_tags_from_name": Hook[*gosuki.Bookmark]{

		Func: parsing.ParseBkTags,
		// contains filtered or unexported fields
	},
}

Functions

func BkMktabHook

func BkMktabHook(b *gosuki.Bookmark) error

func BkNotifySend

func BkNotifySend(b *gosuki.Bookmark) error

func NodeMktabHook

func NodeMktabHook(n *tree.Node) error

func NodeNotifySend

func NodeNotifySend(n *tree.Node) error

func SortByPriority

func SortByPriority(hooks []NamedHook)

Types

type Hook

type Hook[T Hookable] struct {

	// Function to call on a node/bookmark
	Func func(T) error
	// contains filtered or unexported fields
}

A Hook is a function that takes a *Bookmark or *Node and runs an arbitrary process. Hooks are called during the loading or real time detection of bookmarks.

For example the TAG extraction process is handled by the ParseXTags hooks.

Hooks can also be used handle call custom user commands and messages found in the various fields of a bookmark.

func (Hook[T]) Name

func (h Hook[T]) Name() string

type HookMap

type HookMap map[string]NamedHook

type HookRunner

type HookRunner interface {

	// Calls all registered hooks on a node
	CallHooks(any) error
}

Browser who implement this interface will be able to register custom hooks which are called during the main Run() to handle commands and messages found in tags and parsed data from browsers

type Hookable

type Hookable interface {
	*gosuki.Bookmark | *tree.Node
}

type MarkTab

type MarkTab struct {
	Rules []Rule // Rules contains all the parsed rules from the marktab file.
}

MarkTab represents a collection of rules defined in the marktab file as lines.

type NamedHook

type NamedHook interface {
	Name() string
}

type Rule

type Rule struct {
	Trigger string // keyword to detect in the bookmark tags
	Pattern string // regular expression used for matching against the bookmark URL or title.
	Command string // shell command to execute when both the trigger and pattern match the bookmark tags.
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL