shelf

package
v0.0.0-...-ba36fc0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

ファイルとメタファイルを収集する

Index

Constants

View Source
const (
	ShelfRegexp   = `^(?P<id>\w{24})_(?P<base>.*)\.pdf$`
	IDFormat      = "20060102T150405"
	DocExtension  = ".pdf"
	MetaExtension = ".toml"
)

Variables

View Source
var (
	ErrInputDir    = fmt.Errorf("ファイルを入力を想定している箇所でディレクトリが入力された")
	ErrInputNotPDF = fmt.Errorf("PDF以外が入力された")
)
View Source
var (
	ErrAlreadyFormatted = fmt.Errorf("すでにフォーマットを満たしている")
)

Functions

func GetPtr

func GetPtr[T any](x T) *T

func UniqTags

func UniqTags(views []View) []string

Types

type Book

type Book struct {
	File os.File
}

shelfフォーマットを満たすファイル "{id}_{base}.{ext}" baseは人が見て識別する用で、プログラム側からは参照しない

func NewBook

func NewBook(file os.File) (*Book, error)

shelfフォーマットを満たすファイルなのを確認して初期化する

func Register

func Register(originfile *os.File) (*Book, error)

入力パスに対して、ID付きファイル名にリネーム + メタファイルの作成

func (*Book) ExtractImageBase64

func (b *Book) ExtractImageBase64() (string, error)

func (*Book) ExtractPDFTitle

func (b *Book) ExtractPDFTitle() (string, error)

func (*Book) GetFullPath

func (b *Book) GetFullPath() string

func (*Book) GetID

func (b *Book) GetID() (BookID, error)

func (*Book) GetMetaData

func (b *Book) GetMetaData() (*Meta, error)

func (*Book) MetaPath

func (b *Book) MetaPath() (string, error)

type BookID

type BookID string

ファイル名の一部となるID 読み書きで使う

func NewBookID

func NewBookID(t time.Time) BookID

type Meta

type Meta struct {
	Title *string   `toml:"title"`
	TODO  *TODOType `toml:"todo"`
	Tags  *[]string `toml:"tags"`
}

type TODOType

type TODOType string
var (
	TODOTypeNONE TODOType = "NONE"
	TODOTypeTODO TODOType = "TODO"
	TODOTypeWIP  TODOType = "WIP"
	TODOTypeDONE TODOType = "DONE"
)

type View

type View struct {
	ID       BookID
	FilePath string
	Meta     Meta
}

func FilterViewsByTag

func FilterViewsByTag(tag string, views []View) []View

func GenerateViews

func GenerateViews(dirpath string) []View

ディレクトリから、メタデータを収集する

func SkipCursor

func SkipCursor(id string, views []View) []View

| discard | return | |<------->|cursor|<------>|

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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