model

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextAccountKey is the key used to store the account model in the gin context.
	ContextAccountKey = "account"

	// AuthorizationHeader is the name of the header used to send the token.
	AuthorizationHeader = "Authorization"
	// AuthorizationTokenType is the type of token used in the Authorization header.
	AuthorizationTokenType = "Bearer"
)
View Source
const DataDirPerm = 0744

DataDirPerm the default filesystem permissions for the data directory/archives

View Source
const DatabaseDateFormat = "2006-01-02 15:04:05"

DatabaseDateFormat the string formatting of datetimes for the database

View Source
const (
	// ShioriNamespace
	ShioriURLNamespace = "https://github.com/go-shiori/shiori"
)

Variables

View Source
var (
	ErrBookmarkNotFound  = errors.New("bookmark not found")
	ErrBookmarkInvalidID = errors.New("invalid bookmark ID")
	ErrUnauthorized      = errors.New("unauthorized user")
)
View Source
var (
	BuildVersion = "dev"
	BuildCommit  = "none"
	BuildDate    = "unknown"
)

Variables set my the main package coming from ldflags

Functions

func GetArchivePath added in v1.6.0

func GetArchivePath(bookmark *BookmarkDTO) string

GetArchivePath returns the relative path to the archive of a bookmark in the filesystem

func GetEbookPath added in v1.6.0

func GetEbookPath(bookmark *BookmarkDTO) string

GetEbookPath returns the relative path to the ebook of a bookmark in the filesystem

func GetThumbnailPath added in v1.6.0

func GetThumbnailPath(bookmark *BookmarkDTO) string

GetTumnbailPath returns the relative path to the thumbnail of a bookmark in the filesystem

Types

type Account

type Account struct {
	ID       int        `db:"id"       json:"id"`
	Username string     `db:"username" json:"username"`
	Password string     `db:"password" json:"password,omitempty"`
	Owner    bool       `db:"owner"    json:"owner"`
	Config   UserConfig `db:"config"               json:"config"`
}

Account is the database model for account.

func (Account) ToDTO added in v1.6.0

func (a Account) ToDTO() AccountDTO

ToDTO converts Account to AccountDTO.

type AccountDTO added in v1.6.0

type AccountDTO struct {
	ID       int        `json:"id"`
	Username string     `json:"username"`
	Owner    bool       `json:"owner"`
	Config   UserConfig `json:"config"`
}

AccountDTO is data transfer object for Account.

type AccountsDomain added in v1.6.0

type AccountsDomain interface {
	CheckToken(ctx context.Context, userJWT string) (*Account, error)
	GetAccountFromCredentials(ctx context.Context, username, password string) (*Account, error)
	CreateTokenForAccount(account *Account, expiration time.Time) (string, error)
}

type ArchiverDomain added in v1.6.0

type ArchiverDomain interface {
	DownloadBookmarkArchive(book BookmarkDTO) (*BookmarkDTO, error)
	GetBookmarkArchive(book *BookmarkDTO) (*warc.Archive, error)
}

type BookmarkDTO added in v1.6.0

type BookmarkDTO struct {
	ID            int    `db:"id"            json:"id"`
	URL           string `db:"url"           json:"url"`
	Title         string `db:"title"         json:"title"`
	Excerpt       string `db:"excerpt"       json:"excerpt"`
	Author        string `db:"author"        json:"author"`
	Public        int    `db:"public"        json:"public"`
	Modified      string `db:"modified"      json:"modified"`
	Content       string `db:"content"       json:"-"`
	HTML          string `db:"html"          json:"html,omitempty"`
	ImageURL      string `db:"image_url"     json:"imageURL"`
	HasContent    bool   `db:"has_content"   json:"hasContent"`
	Tags          []Tag  `json:"tags"`
	HasArchive    bool   `json:"hasArchive"`
	HasEbook      bool   `json:"hasEbook"`
	CreateArchive bool   `json:"create_archive"` // TODO: migrate outside the DTO
	CreateEbook   bool   `json:"create_ebook"`   // TODO: migrate outside the DTO
}

BookmarkDTO is the bookmark object representation in database and the data transfer object at the same time, pending a refactor to two separate object to represent each role.

type BookmarksDomain added in v1.6.0

type BookmarksDomain interface {
	HasEbook(b *BookmarkDTO) bool
	HasArchive(b *BookmarkDTO) bool
	HasThumbnail(b *BookmarkDTO) bool
	GetBookmark(ctx context.Context, id DBID) (*BookmarkDTO, error)
}

type DBID added in v1.6.0

type DBID int

type LegacyLoginHandler added in v1.6.0

type LegacyLoginHandler func(account Account, expTime time.Duration) (string, error)

type Routes added in v1.6.0

type Routes interface {
	Setup(group *gin.RouterGroup) Routes
}

type StorageDomain added in v1.6.0

type StorageDomain interface {
	Stat(name string) (fs.FileInfo, error)
	FS() afero.Fs
	FileExists(path string) bool
	DirExists(path string) bool
	WriteData(dst string, data []byte) error
	WriteFile(dst string, src *os.File) error
}

type Tag

type Tag struct {
	ID         int    `db:"id"          json:"id"`
	Name       string `db:"name"        json:"name"`
	NBookmarks int    `db:"n_bookmarks" json:"nBookmarks,omitempty"`
	Deleted    bool   `json:"-"`
}

Tag is the tag for a bookmark.

type UserConfig added in v1.6.0

type UserConfig struct {
	ShowId        bool `json:"ShowId"`
	ListMode      bool `json:"ListMode"`
	HideThumbnail bool `json:"HideThumbnail"`
	HideExcerpt   bool `json:"HideExcerpt"`
	NightMode     bool `json:"NightMode"`
	KeepMetadata  bool `json:"KeepMetadata"`
	UseArchive    bool `json:"UseArchive"`
	CreateEbook   bool `json:"CreateEbook"`
	MakePublic    bool `json:"MakePublic"`
}

func (*UserConfig) Scan added in v1.6.0

func (c *UserConfig) Scan(value interface{}) error

func (UserConfig) Value added in v1.6.0

func (c UserConfig) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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