history

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package history provides access to Safari's history.

As the exported history was removed in High Sierra, this package accesses Safari's private SQLite database.

The package-level functions call methods on the default History, which is initialised with the default Safari history database.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultHistoryPath is where Safari's history database is stored.
	DefaultHistoryPath = filepath.Join(os.Getenv("HOME"), "Library/Safari/History.db")
	// MaxSearchResults is the number of results to return from a search.
	MaxSearchResults = 200
)

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Title string
	URL   string
	Time  time.Time
}

Entry is a History entry.

func Recent

func Recent(count int) ([]*Entry, error)

Recent returns the specified number of most recent items from History. Entries without a title or with a non-HTTP* scheme are ignored.

NOTE: The results will often contain many duplicates.

func Search(query string) ([]*Entry, error)

Search searches all History entries. Entries without a title or with a non-HTTP* scheme are ignored.

The query is split into individual words, which are combined with AND:

AND title LIKE %word1% AND title LIKE %word2% etc.

type History

type History struct {
	DB *sql.DB
}

History is a Safari history.

func New

func New(filename string) (*History, error)

New creates a new History from a Safari history database.

func (*History) Recent

func (h *History) Recent(count int) ([]*Entry, error)

func (*History) Search

func (h *History) Search(query string) ([]*Entry, error)

Jump to

Keyboard shortcuts

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