mirror of
https://github.com/go-shiori/shiori.git
synced 2025-01-15 20:37:44 +08:00
cc7c75116d
* migrate bookmark content route to new http server * new archive page * remove unused go generate comment * database mock * utils cleanup * unused var * domains refactor and tests * fixed secret key type * redirect to login on ui errors * fixed archive folder with storage domain * webroot documentation * some bookmark route tests * fixed error in bookmark domain for non existant bookmarks * centralice errors * add coverage data to unittests * added tests, refactor storage to use afero * removed mock to avoid increasing complexity * using deps to copy files around * remove config usage (to deps) * remove handler-ui file
42 lines
1.8 KiB
Go
42 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strconv"
|
|
)
|
|
|
|
// 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 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
|
|
}
|
|
|
|
// GetTumnbailPath returns the relative path to the thumbnail of a bookmark in the filesystem
|
|
func GetThumbnailPath(bookmark *BookmarkDTO) string {
|
|
return filepath.Join("thumb", strconv.Itoa(bookmark.ID))
|
|
}
|
|
|
|
// GetEbookPath returns the relative path to the ebook of a bookmark in the filesystem
|
|
func GetEbookPath(bookmark *BookmarkDTO) string {
|
|
return filepath.Join("ebook", strconv.Itoa(bookmark.ID)+".epub")
|
|
}
|
|
|
|
// GetArchivePath returns the relative path to the archive of a bookmark in the filesystem
|
|
func GetArchivePath(bookmark *BookmarkDTO) string {
|
|
return filepath.Join("archive", strconv.Itoa(bookmark.ID))
|
|
}
|