Documentation ¶
Index ¶
- Constants
- Variables
- func BackupHandler(w http.ResponseWriter, req *http.Request) error
- func CreatePageIndexes(perPage int) error
- func DBWithLock(fn func(*bolt.DB))
- func DeleteAPITokens() error
- func DeleteURL(url *URL) error
- func HACKCreatePageIndexes(perPage int, tx *bolt.Tx) error
- func MustInit(cfg *config.Config)
- func NewPageIndexPaginator(page int) (*pageIndexPaginator, error)
- func NewQuery(q string) *query
- func RunWithBucketForType(tx *bolt.Tx, m interface{}, fn func(*bolt.Bucket) error) error
- type APIToken
- type AllURLGetter
- type CreateTagOptions
- type CreateURLOptions
- type FavURLGetter
- type HTTPMetadataFetcher
- type InitializeInstanceOptions
- type PageIndex
- type PageMeta
- type Paginator
- type PinnedTag
- type PinnedTags
- type SearchURLGetter
- type Settings
- type SettingsOptions
- type SufrDB
- type Tag
- type URL
- type URLMetadataFetcher
- type URLPaginator
- func (p URLPaginator) CurrentPage() int
- func (p URLPaginator) HasNext() bool
- func (p URLPaginator) HasPagination() bool
- func (p URLPaginator) HasPrevious() bool
- func (p URLPaginator) NextPage() int
- func (p URLPaginator) Pages() []int
- func (p URLPaginator) PreviousPage() int
- func (p URLPaginator) TotalPages() int
- type URLsByDateDesc
- type UpdateURLOptions
- type User
- type UserOptions
- type Version
Constants ¶
const (
DefaultURLTitle = "No title (edit to change)"
)
Variables ¶
var ( ErrDatabaseAlreadyOpen = errors.New("database is already open") ErrNotFound = errors.New("object not found") ErrDuplicateKey = errors.New("duplicate key") )
var ErrSettingsExists = errors.New("settings object already exists")
var ErrUserExists = errors.New("user already exists")
Functions ¶
func BackupHandler ¶
func BackupHandler(w http.ResponseWriter, req *http.Request) error
func CreatePageIndexes ¶
func DBWithLock ¶
DBWithLock runs func fn with the global db object. Locked so nothing else can use the DB while migrations are running.
func DeleteAPITokens ¶
func DeleteAPITokens() error
func NewPageIndexPaginator ¶
func RunWithBucketForType ¶
RunWithBucketForType takes a *bolt.Tx and will find the bucket for type m and then run will run the func fn with the bucket (if found). If no bucket is registered for type m, an error is returned.
Types ¶
type APIToken ¶
type APIToken struct { ID uuid.UUID `json:"id"` Token uuid.UUID `json:"token"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
func CreateAPIToken ¶
func GetAPIToken ¶
type AllURLGetter ¶
type AllURLGetter struct{}
type CreateTagOptions ¶
type CreateTagOptions struct {
Name string
}
type CreateURLOptions ¶
CreateURLOptions is passed into CreateURL from the http handler to initiate a url creation
type FavURLGetter ¶
type FavURLGetter struct{}
type HTTPMetadataFetcher ¶
type HTTPMetadataFetcher struct{}
func (HTTPMetadataFetcher) FetchMetadata ¶
func (HTTPMetadataFetcher) FetchMetadata(url string) (PageMeta, error)
Returns the page title or an error. If there is an error, the url is returned as well.
type PageIndex ¶
type PageIndex struct { URLIDs []uuid.UUID `json:"url_ids"` TotalPages int `json:"total_pages"` PerPage int `json:"per_page"` URLs []*URL `json:"-"` }
PageIndex is a quick and dirty hack to cache the URL pages in bolt
func GetPageIndexByPage ¶
func GetPageIndexes ¶
type PinnedTags ¶
type PinnedTags []PinnedTag
func GetPinnedTags ¶
func GetPinnedTags() (*PinnedTags, error)
func PinTag ¶
func PinTag(tag *Tag) (*PinnedTags, error)
func UnpinTag ¶
func UnpinTag(tag *Tag) (*PinnedTags, error)
type SearchURLGetter ¶
type SearchURLGetter struct {
// contains filtered or unexported fields
}
func NewSearchURLGetter ¶
func NewSearchURLGetter(query string) *SearchURLGetter
type Settings ¶
type Settings struct { Private bool `json:"private"` EmbedPhotos bool `json:"embed_photos"` EmbedVideos bool `json:"embed_videos"` PerPage int `json:"per_page"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
func GetSettings ¶
func SaveSettings ¶
func SaveSettings(opts SettingsOptions) (*Settings, error)
type SettingsOptions ¶
type SufrDB ¶
SufrDB is a BoltDB wrapper that provides a SUFR specific interface to the DB
func (*SufrDB) Statsdumper ¶
func (s *SufrDB) Statsdumper()
Runs in it's own goroutine if debug is on
type Tag ¶
type Tag struct { ID uuid.UUID `json:"id"` Name string `json:"name"` URLs []*URL `json:"-"` URLIDs []uuid.UUID `json:"url_ids"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Tag holds the little information we have about url tags
func CreateTag ¶
func CreateTag(opts CreateTagOptions) (*Tag, error)
type URL ¶
type URL struct { ID uuid.UUID `json:"id"` URL string `json:"url"` Title string `json:"title"` Notes string `json:"notes"` StatusCode int `json:"status_code"` Private bool `json:"private"` Favorite bool `json:"favorite"` Tags []*Tag `json:"-"` TagIDs []uuid.UUID `json:"tag_ids"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
URL is the model for a url object
func CreateURL ¶
func CreateURL(opts CreateURLOptions, fetcher URLMetadataFetcher) (*URL, error)
func GetURLByURL ¶
func UpdateURL ¶
func UpdateURL(opts UpdateURLOptions) (*URL, error)
func (*URL) FormattedCreatedAt ¶
FormattedCreatedAt is used in the template to display a human readable timestamp Returns a string
func (*URL) GetTagsForDisplay ¶
func (*URL) IsPublic ¶
IsPublic will return true if the url is visible to everyone (even those not logged in) This option doesn't matter is the SUFR global setting for visibility is private.
func (*URL) ToggleFavorite ¶
type URLMetadataFetcher ¶
type URLPaginator ¶
type URLPaginator struct { URLs []*URL // contains filtered or unexported fields }
URLPaginator represents a paginated collection of URLs sorted by CreatedAt desc
func NewURLPaginator ¶
func NewURLPaginator(page, perPage, pagePadding int, getter urlGetter) (*URLPaginator, error)
NewURLPaginator returns a filled-out *URLPaginator. returns an error if something during the read transaction fails.
func (URLPaginator) CurrentPage ¶
func (p URLPaginator) CurrentPage() int
func (URLPaginator) HasNext ¶
func (p URLPaginator) HasNext() bool
func (URLPaginator) HasPagination ¶
func (p URLPaginator) HasPagination() bool
func (URLPaginator) HasPrevious ¶
func (p URLPaginator) HasPrevious() bool
func (URLPaginator) NextPage ¶
func (p URLPaginator) NextPage() int
func (URLPaginator) Pages ¶
func (p URLPaginator) Pages() []int
func (URLPaginator) PreviousPage ¶
func (p URLPaginator) PreviousPage() int
func (URLPaginator) TotalPages ¶
func (p URLPaginator) TotalPages() int
type URLsByDateDesc ¶
type URLsByDateDesc []*URL
func (URLsByDateDesc) Len ¶
func (u URLsByDateDesc) Len() int
func (URLsByDateDesc) Less ¶
func (u URLsByDateDesc) Less(i, j int) bool
func (URLsByDateDesc) Swap ¶
func (u URLsByDateDesc) Swap(i, j int)
type UpdateURLOptions ¶
UpdateURLOptions is passed into UpdateURL from the http handler to update a url
type User ¶
type User struct { ID uuid.UUID `json:"id"` Email string `json:"email"` Password string `json:"password"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
func CreateUser ¶
func CreateUser(opts UserOptions) (*User, error)
CreateUser will create the global user account. This is used to login and run api queries. There can only be one user in the system, so if an account exists, it will return an error.
type UserOptions ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package migrations contains code that modifies data in the boltdb database as application logic changes.
|
Package migrations contains code that modifies data in the boltdb database as application logic changes. |