bookmarks

package
v0.0.0-...-d1a9080 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: AGPL-3.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TableName is the bookmark table name in database.
	TableName = "bookmark"
)

Variables

View Source
var (
	// Bookmarks is the bookmark query manager
	Bookmarks = BookmarkManager{}

	// ErrNotFound is returned when a bookmark record was not found.
	ErrNotFound = errors.New("not found")
)
View Source
var StateNames = map[BookmarkState]string{
	StateLoaded:  "loaded",
	StateError:   "error",
	StateLoading: "loading",
}

StateNames returns a string with the state name.

Functions

func CleanDomProcessor

func CleanDomProcessor(m *extract.ProcessMessage, next extract.Processor) extract.Processor

CleanDomProcessor is a last pass of cleaning on the resulting DOM node. It removes unwanted attributes, empty tags and set some defaults.

func SetupRoutes

func SetupRoutes(s *server.Server)

SetupRoutes mounts the routes for the bookmarks domain. "/bm" is a public route outside the api scope in order to avoid sending the session cookie.

func StartWorkerPool

func StartWorkerPool(workers int)

StartWorkerPool start the worker pool that performs page extraction.

func StoragePath

func StoragePath() string

StoragePath returns the storage base directory for bookmark files

Types

type Bookmark

type Bookmark struct {
	ID           int           `db:"id" goqu:"skipinsert,skipupdate"`
	UID          string        `db:"uid"`
	UserID       *int          `db:"user_id"`
	Created      time.Time     `db:"created" goqu:"skipupdate"`
	Updated      time.Time     `db:"updated"`
	State        BookmarkState `db:"state"`
	URL          string        `db:"url"`
	Title        string        `db:"title"`
	Domain       string        `db:"domain"`
	Site         string        `db:"site"`
	SiteName     string        `db:"site_name"`
	Published    *time.Time    `db:"published"`
	Authors      Strings       `db:"authors"`
	Lang         string        `db:"lang"`
	DocumentType string        `db:"type"`
	Description  string        `db:"description"`
	Text         string        `db:"text"`
	WordCount    int           `db:"word_count"`
	Embed        string        `db:"embed"`
	FilePath     string        `db:"file_path"`
	Files        BookmarkFiles `db:"files"`
	Errors       Strings       `db:"errors"`
	Labels       Strings       `db:"labels"`
	IsArchived   bool          `db:"is_archived"`
	IsMarked     bool          `db:"is_marked"`
}

Bookmark is a bookmark record in database

func (*Bookmark) Delete

func (b *Bookmark) Delete() error

Delete removes a bookmark from the database.

func (*Bookmark) GetLastModified

func (b *Bookmark) GetLastModified() []time.Time

GetLastModified returns the last modified times

func (*Bookmark) GetSumStrings

func (b *Bookmark) GetSumStrings() []string

GetSumStrings returns the string used to generate the etag of the bookmark(s)

func (*Bookmark) ReadingTime

func (b *Bookmark) ReadingTime() int

ReadingTime returns the aproximated reading time

func (*Bookmark) Save

func (b *Bookmark) Save() error

Save updates all the bookmark values.

func (*Bookmark) StateName

func (b *Bookmark) StateName() string

StateName returns the current bookmark state name.

func (*Bookmark) Update

func (b *Bookmark) Update(v interface{}) error

Update updates some bookmark values.

type BookmarkFile

type BookmarkFile struct {
	Name string `json:"name"`
	Type string `json:"type"`
	Size [2]int `json:"size,omitempty"`
}

BookmarkFile represents a stored file (attachment) for a bookmark. The Size property is ony useful for images.

type BookmarkFiles

type BookmarkFiles map[string]*BookmarkFile

BookmarkFiles is a map of BookmarkFile instances.

func (*BookmarkFiles) Scan

func (f *BookmarkFiles) Scan(value interface{}) error

Scan loads a BookmarkFiles instance from a column.

func (BookmarkFiles) Value

func (f BookmarkFiles) Value() (driver.Value, error)

Value encodes a BookmarkFiles instance for storage.

type BookmarkManager

type BookmarkManager struct{}

BookmarkManager is a query helper for bookmark entries.

func (*BookmarkManager) Create

func (m *BookmarkManager) Create(bookmark *Bookmark) error

Create inserts a new bookmark in the database.

func (*BookmarkManager) DeleteUserBookmakrs

func (m *BookmarkManager) DeleteUserBookmakrs(u *users.User) error

DeleteUserBookmakrs remove all bookmarks for a given user. Normally we don't need such a process but since, a bookmark holds a file, we can't only rely on the foreign key cascade deletion. Hence this.

func (*BookmarkManager) GetOne

func (m *BookmarkManager) GetOne(expressions ...goqu.Expression) (*Bookmark, error)

GetOne executes the a select query and returns the first result or an error when there's no result.

func (*BookmarkManager) Query

func (m *BookmarkManager) Query() *goqu.SelectDataset

Query returns a prepared goqu SelectDataset that can be extended later.

type BookmarkState

type BookmarkState int

BookmarkState is the current bookmark state

const (
	// StateLoaded when the page is fully loaded
	StateLoaded BookmarkState = iota

	// StateError when there was some unrecoverable
	// error during extraction
	StateError

	// StateLoading when the page is loading.
	StateLoading
)

type Strings

type Strings []string

Strings is a list of strings stored in a column.

func (*Strings) Scan

func (s *Strings) Scan(value interface{}) error

Scan loads a Strings instance from a column.

func (Strings) Value

func (s Strings) Value() (driver.Value, error)

Value encode a Strings instance for storage.

Jump to

Keyboard shortcuts

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