Documentation
¶
Overview ¶
Package bookmark contains the bookmark record.
Index ¶
- Constants
- Variables
- func ParseTags(tags string) string
- func UniqueTags(t []string) []string
- func Validate(b *Bookmark) error
- func ValidateChecksumJSON(b *BookmarkJSON) bool
- type Bookmark
- func (b *Bookmark) Buffer() []byte
- func (b *Bookmark) BufferNotes() []byte
- func (b *Bookmark) Bytes() []byte
- func (b *Bookmark) CheckStatus(ctx context.Context) error
- func (b *Bookmark) Domain() (string, error)
- func (b *Bookmark) Equals(o *Bookmark) bool
- func (b *Bookmark) Field(f string) (string, error)
- func (b *Bookmark) GPGPath(ext string) (string, error)
- func (b *Bookmark) GenChecksum()
- func (b *Bookmark) HashDomain() (string, error)
- func (b *Bookmark) HashPath() (string, error)
- func (b *Bookmark) HashURL() string
- func (b *Bookmark) JSON() *BookmarkJSON
- func (b *Bookmark) JSONPath() (string, error)
- type BookmarkJSON
Constants ¶
View Source
const DefaultTag = "notag"
Variables ¶
View Source
var ( ErrBookmarkDuplicate = errors.New("bookmark already exists") ErrBookmarkInvalidID = errors.New("invalid bookmark id") ErrBookmarkNotFound = errors.New("no bookmark found") ErrBookmarkTagsEmpty = errors.New("tags cannot be empty") ErrBookmarkURLEmpty = errors.New("URL cannot be empty") ErrBookmarkTitleRequired = errors.New("title is required") ErrBookmarkUnknownField = errors.New("bookmark field unknown") ErrBookmarkInvalidChecksum = errors.New("invalid checksum") )
Functions ¶
func ParseTags ¶
ParseTags normalizes a string of tags by separating them by commas, sorting them and ensuring that the final string ends with a comma.
from: "tag1, tag2, tag3 tag" to: "tag,tag1,tag2,tag3,"
func UniqueTags ¶ added in v0.1.23
UniqueTags returns a slice of unique tags.
func ValidateChecksumJSON ¶ added in v0.1.30
func ValidateChecksumJSON(b *BookmarkJSON) bool
Types ¶
type Bookmark ¶
type Bookmark struct {
ID int `db:"id" json:"id"`
URL string `db:"url" json:"url"` // URL of the bookmark.
Tags string `db:"tags" json:"tags"` // Tags for the bookmark, stored as a comma-separated string.
Title string `db:"title" json:"title"` // Title of the bookmark, retrieved from the website's metadata.
Desc string `db:"desc" json:"desc"` // Description of the bookmark.
Notes string `db:"notes" json:"notes"` // Notes
CreatedAt string `db:"created_at" json:"created_at"` // Timestamp when the bookmark was created.
LastVisit string `db:"last_visit" json:"last_visit"` // Timestamp of the last time the bookmark was visited.
UpdatedAt string `db:"updated_at" json:"updated_at"` // Timestamp of the last time the bookmark record was updated.
VisitCount int `db:"visit_count" json:"visit_count"` // The number of times the bookmark has been visited.
Favorite bool `db:"favorite" json:"favorite"` // Boolean indicating if the bookmark is marked as a favorite.
FaviconURL string `db:"favicon_url" json:"favicon_url"` // URL for the bookmark's favicon.
FaviconLocal string `db:"favicon_local" json:"favicon_local"` // Local path to the cached favicon file.
Checksum string `db:"checksum" json:"checksum"` // Checksum or hash (URL, Title, Description and Tags)
ArchiveURL string `db:"archive_url" json:"archive_url"` // Internet Archive URL
ArchiveTimestamp string `db:"archive_timestamp" json:"archive_timestamp"` // Internet Archive timestamp
LastStatusChecked string `db:"last_checked" json:"last_checked"` // Last checked timestamp.
HTTPStatusCode int `db:"status_code" json:"status_code"` // HTTP status code (200, 404, etc.)
HTTPStatusText string `db:"status_text" json:"status_text"` // OK, Not Found, etc
IsActive bool `db:"is_active" json:"is_active"` // true if the URL is active (200-299)
}
Bookmark represents a bookmark.
func NewFromBuffer ¶
func NewFromJSON ¶
func NewFromJSON(j *BookmarkJSON) *Bookmark
func (*Bookmark) BufferNotes ¶ added in v0.1.29
func (*Bookmark) CheckStatus ¶ added in v0.1.22
CheckStatus updates the bookmark's status fields.
func (*Bookmark) GenChecksum ¶ added in v0.1.19
func (b *Bookmark) GenChecksum()
GenChecksum generates a checksum for the bookmark.
It uses the URL, Title, Description and Tags.
func (*Bookmark) HashDomain ¶ added in v0.1.21
HashDomain returns the hash domain of a bookmark.
func (*Bookmark) JSON ¶
func (b *Bookmark) JSON() *BookmarkJSON
type BookmarkJSON ¶
type BookmarkJSON struct {
// FIX: remove this struct
ID int `json:"id"`
URL string `json:"url"`
Tags []string `json:"tags"`
Title string `json:"title"`
Desc string `json:"desc"`
Notes string `json:"notes"`
CreatedAt string `json:"created_at"`
LastVisit string `json:"last_visit"`
UpdatedAt string `json:"updated_at"`
VisitCount int `json:"visit_count"`
Favorite bool `json:"favorite"`
FaviconURL string `json:"favicon_url"`
FaviconLocal string `json:"favicon_local"`
Checksum string `json:"checksum"`
ArchiveURL string `json:"archive_url"` // Internet Archive URL
ArchiveTimestamp string `json:"archive_timestamp"` // Internet Archive timestamp
LastStatusChecked string `json:"last_checked"` // Last checked timestamp.
HTTPStatusCode int `json:"status_code"` // HTTP status code (200, 404, etc.)
HTTPStatusText string `json:"status_text"` // OK, Not Found, etc
IsActive bool `json:"is_active"` // true if the URL is active (200-299)
}
func NewJSON ¶
func NewJSON() *BookmarkJSON
Click to show internal directories.
Click to hide internal directories.