Documentation ¶
Index ¶
- Constants
- Variables
- func CleanDomProcessor(m *extract.ProcessMessage, next extract.Processor) extract.Processor
- func SetupRoutes(s *server.Server)
- func StartWorkerPool(workers int)
- func StoragePath() string
- type Bookmark
- type BookmarkFile
- type BookmarkFiles
- type BookmarkManager
- type BookmarkState
- type Strings
Constants ¶
const (
// TableName is the bookmark table name in database.
TableName = "bookmark"
)
Variables ¶
var ( // Bookmarks is the bookmark query manager Bookmarks = BookmarkManager{} // ErrNotFound is returned when a bookmark record was not found. ErrNotFound = errors.New("not found") )
var StateNames = map[BookmarkState]string{ StateLoaded: "loaded", StateError: "error", StateLoading: "loading", }
StateNames returns a string with the state name.
Functions ¶
func CleanDomProcessor ¶
CleanDomProcessor is a last pass of cleaning on the resulting DOM node. It removes unwanted attributes, empty tags and set some defaults.
func SetupRoutes ¶
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) GetLastModified ¶
GetLastModified returns the last modified times
func (*Bookmark) GetSumStrings ¶
GetSumStrings returns the string used to generate the etag of the bookmark(s)
func (*Bookmark) ReadingTime ¶
ReadingTime returns the aproximated reading time
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.
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 )