Documentation ¶
Index ¶
- func SetLogLevel(level string) (err error)
- type DomainOptions
- type File
- type FileSystem
- func (fs *FileSystem) CheckKey(key string) (domainid int, domain string, err error)
- func (fs *FileSystem) CheckKeys(keys []string) (domains []string, validKeys []string, err error)
- func (fs *FileSystem) Close() (err error)
- func (fs *FileSystem) DeleteKey(key string) (err error)
- func (fs *FileSystem) DeleteOldKeys() (err error)
- func (fs *FileSystem) DumpSQL() (err error)
- func (fs *FileSystem) Exists(id string, domain string) (trueID string, many bool, err error)
- func (fs *FileSystem) ExportPosts() error
- func (fs *FileSystem) ExportUploads() error
- func (fs *FileSystem) Find(text string, domain string) (files []File, err error)
- func (fs *FileSystem) Get(id string, domain string) (files []File, err error)
- func (fs *FileSystem) GetAll(domain string, created ...bool) (files []File, err error)
- func (fs *FileSystem) GetBlob(id string) (name string, data []byte, views int, err error)
- func (fs *FileSystem) GetBlobIDs() ([]string, error)
- func (fs *FileSystem) GetCacheHTML(id string, noCheckLastModified ...bool) (tr []byte, err error)
- func (fs *FileSystem) GetDomainFromName(domain string) (domainid int, ispublic bool, options DomainOptions, err error)
- func (fs *FileSystem) GetDomains() ([]string, error)
- func (fs *FileSystem) GetResizedImage(id string) (name string, data []byte, views int, err error)
- func (fs *FileSystem) GetSimilar(fileid string) (files []File, err error)
- func (fs *FileSystem) GetTopX(domain string, num int, created ...bool) (files []File, err error)
- func (fs *FileSystem) GetTopXMostViews(domain string, num int) (files []File, err error)
- func (fs *FileSystem) InitializeDB(dump bool) (err error)
- func (fs *FileSystem) LastModified() (lastModified time.Time, err error)
- func (fs *FileSystem) LatestEntryFromDomainID(domainid int) (latest time.Time, err error)
- func (fs *FileSystem) Len() (l int, err error)
- func (fs *FileSystem) NewFile(slug, data string) (f File)
- func (fs *FileSystem) Save(f File) (err error)
- func (fs *FileSystem) SaveBlob(id string, name string, blob []byte) (err error)
- func (fs *FileSystem) SaveResizedImage(id string, name string, blob []byte) (err error)
- func (fs *FileSystem) SetCacheHTML(id string, tr []byte) (err error)
- func (fs *FileSystem) SetDomain(domain, password string) (err error)
- func (fs *FileSystem) SetKey(domain, password string) (key string, err error)
- func (fs *FileSystem) SetSimilar(id string, similarids []string) (err error)
- func (fs *FileSystem) UpdateDomain(domain, password string, ispublic bool, options DomainOptions) (err error)
- func (fs *FileSystem) UpdateKeys(keys []string) (err error)
- func (fs *FileSystem) UpdateViews(f File) (err error)
- func (fs *FileSystem) ValidateDomain(domain, password string) (domainid int, options DomainOptions, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DomainOptions ¶ added in v1.8.0
type File ¶
type File struct { ID string `json:"id"` Slug string `json:"slug"` Created time.Time `json:"created"` Modified time.Time `json:"modified"` Data string `json:"data"` Domain string `json:"domain"` History versionedtext.VersionedText `json:"history"` DataHTML template.HTML `json:"data_html,omitempty"` Views int `json:"views"` }
File is the basic unit that is saved
func (File) CreatedDate ¶ added in v1.8.0
func (File) ModifiedDate ¶ added in v1.8.0
type FileSystem ¶
func New ¶
func New(name string) (fs *FileSystem, err error)
New will initialize a filesystem by creating DB and calling InitializeDB. Callers should ensure "github.com/mattn/go-sqlite3" is imported in some way before calling this so the sqlite3 driver is available.
func (*FileSystem) CheckKey ¶
func (fs *FileSystem) CheckKey(key string) (domainid int, domain string, err error)
CheckKey checks that it is a valid key for a domain
func (*FileSystem) CheckKeys ¶
func (fs *FileSystem) CheckKeys(keys []string) (domains []string, validKeys []string, err error)
CheckKeys checks that it is a valid key for a domain
func (*FileSystem) Close ¶
func (fs *FileSystem) Close() (err error)
Close will make sure that the lock file is closed
func (*FileSystem) DeleteKey ¶
func (fs *FileSystem) DeleteKey(key string) (err error)
DeleteKey deletes a specific key
func (*FileSystem) DeleteOldKeys ¶
func (fs *FileSystem) DeleteOldKeys() (err error)
DeleteOldKeys deletes keys older than 5 days
func (*FileSystem) DumpSQL ¶
func (fs *FileSystem) DumpSQL() (err error)
DumpSQL will dump the SQL as text to filename.sql.gz
func (*FileSystem) ExportPosts ¶ added in v1.5.0
func (fs *FileSystem) ExportPosts() error
ExportPosts will save posts to {{TIMESTAMP}}-posts.gz
func (*FileSystem) ExportUploads ¶ added in v1.5.0
func (fs *FileSystem) ExportUploads() error
ExportUploads will save uploads to {{TIMESTAMP}}-uploads.gz
func (*FileSystem) Find ¶
func (fs *FileSystem) Find(text string, domain string) (files []File, err error)
Find returns the info from a file
func (*FileSystem) Get ¶
func (fs *FileSystem) Get(id string, domain string) (files []File, err error)
Get returns the info from a file
func (*FileSystem) GetAll ¶
func (fs *FileSystem) GetAll(domain string, created ...bool) (files []File, err error)
GetAll returns all the files for a given domain
func (*FileSystem) GetBlobIDs ¶ added in v1.5.0
func (fs *FileSystem) GetBlobIDs() ([]string, error)
GetBlobIDs will return a list of blob ids
func (*FileSystem) GetCacheHTML ¶ added in v1.7.0
func (fs *FileSystem) GetCacheHTML(id string, noCheckLastModified ...bool) (tr []byte, err error)
SetCacheHTML will set the html cache
func (*FileSystem) GetDomainFromName ¶
func (fs *FileSystem) GetDomainFromName(domain string) (domainid int, ispublic bool, options DomainOptions, err error)
GetDomainFromName returns the domain id, throwing an error if it doesn't exist
func (*FileSystem) GetDomains ¶ added in v1.5.0
func (fs *FileSystem) GetDomains() ([]string, error)
GetDomains will return a list of domains
func (*FileSystem) GetResizedImage ¶ added in v1.5.0
GetResizedImage will resize an image (if it hasn't already been cached) return it
func (*FileSystem) GetSimilar ¶
func (fs *FileSystem) GetSimilar(fileid string) (files []File, err error)
GetSimilar returns all the files for a given domain
func (*FileSystem) GetTopXMostViews ¶
func (fs *FileSystem) GetTopXMostViews(domain string, num int) (files []File, err error)
GetTopX returns the info from a file
func (*FileSystem) InitializeDB ¶ added in v1.4.0
func (fs *FileSystem) InitializeDB(dump bool) (err error)
InitializeDB will initialize schema if not already done and if dump is true, will create the an initial DB dump. This is automatically called by New.
func (*FileSystem) LastModified ¶
func (fs *FileSystem) LastModified() (lastModified time.Time, err error)
LastModified get the last modified time
func (*FileSystem) LatestEntryFromDomainID ¶ added in v1.8.0
func (fs *FileSystem) LatestEntryFromDomainID(domainid int) (latest time.Time, err error)
LatestEntryFromDomainID returns the last entry date for the current domain
func (*FileSystem) NewFile ¶
func (fs *FileSystem) NewFile(slug, data string) (f File)
NewFile returns a new file
func (*FileSystem) Save ¶
func (fs *FileSystem) Save(f File) (err error)
Save a file to the file system. Will insert or ignore, and then update.
func (*FileSystem) SaveBlob ¶
func (fs *FileSystem) SaveBlob(id string, name string, blob []byte) (err error)
SaveBlob will save a blob
func (*FileSystem) SaveResizedImage ¶ added in v1.5.0
func (fs *FileSystem) SaveResizedImage(id string, name string, blob []byte) (err error)
SaveResizedImage will save a resized image
func (*FileSystem) SetCacheHTML ¶ added in v1.7.0
func (fs *FileSystem) SetCacheHTML(id string, tr []byte) (err error)
SetCacheHTML will set the html cache
func (*FileSystem) SetDomain ¶
func (fs *FileSystem) SetDomain(domain, password string) (err error)
SetDomain will set the key of a domain, throws an error if it already exists
func (*FileSystem) SetKey ¶
func (fs *FileSystem) SetKey(domain, password string) (key string, err error)
SetKey will set the key of a domain, throws an error if it already exists
func (*FileSystem) SetSimilar ¶
func (fs *FileSystem) SetSimilar(id string, similarids []string) (err error)
func (*FileSystem) UpdateDomain ¶
func (fs *FileSystem) UpdateDomain(domain, password string, ispublic bool, options DomainOptions) (err error)
func (*FileSystem) UpdateKeys ¶
func (fs *FileSystem) UpdateKeys(keys []string) (err error)
UpdateKeys will update its last use
func (*FileSystem) UpdateViews ¶
func (fs *FileSystem) UpdateViews(f File) (err error)
func (*FileSystem) ValidateDomain ¶
func (fs *FileSystem) ValidateDomain(domain, password string) (domainid int, options DomainOptions, err error)
ValidateDomain returns the domain id or an error if the password doesn't match or if the domain doesn't exist