model

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: AGPL-3.0 Imports: 85 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaskedUserData       = ""
	MaskedAccessAuthCode = "*******"
)
View Source
const (
	HistoryOpClean  = "clean"
	HistoryOpUpdate = "update"
	HistoryOpDelete = "delete"
	HistoryOpFormat = "format"
	HistoryOpSync   = "sync"
)
View Source
const (
	HistoryTypeDocName = 0
	HistoryTypeDoc     = 1
	HistoryTypeAsset   = 2
)
View Source
const (
	TxErrCodeBlockNotFound    = 0
	TxErrCodeUnableAccessFile = 1
	TxErrCodeWriteTree        = 2
)

Variables

View Source
var (
	BootSyncSucc = -1 // -1:未执行,0:执行成功,1:执行失败
	ExitSyncSucc = -1
)
View Source
var CustomEmojis = sync.Map{}
View Source
var Decks = map[string]*riff.Deck{}
View Source
var ErrBlockNotFound = errors.New("block not found")
View Source
var ErrBoxNotFound = errors.New("notebook not found")
View Source
var ErrFailedToConnectCloudServer = errors.New("failed to connect cloud server")
View Source
var ErrTreeNotFound = errors.New("tree not found")

Functions

func AddFlashcards

func AddFlashcards(deckID string, blockIDs []string) (err error)

func AddPDFOutline

func AddPDFOutline(id, p string, merge bool) (err error)

func AutoFixIndex

func AutoFixIndex()

AutoFixIndex 自动校验数据库索引 https://github.com/siyuan-note/siyuan/issues/7016

func AutoFlushAssetsTexts

func AutoFlushAssetsTexts()

func AutoFlushTx

func AutoFlushTx()

func AutoGenerateDocHistory

func AutoGenerateDocHistory()

func AutoOCRAssets

func AutoOCRAssets()

func AutoRefreshCheck

func AutoRefreshCheck()

func AutoSpace

func AutoSpace(rootID string) (err error)

func AutoStat

func AutoStat()

func AutoSync

func AutoSync()

func BatchExportMarkdown

func BatchExportMarkdown(boxID, folderPath string) (zipPath string)

func BazaarIcons

func BazaarIcons() (icons []*bazaar.Icon)

func BazaarTemplates

func BazaarTemplates() (templates []*bazaar.Template)

func BazaarThemes

func BazaarThemes() (ret []*bazaar.Theme)

func BazaarWidgets

func BazaarWidgets() (widgets []*bazaar.Widget)

func BlocksWordCount

func BlocksWordCount(ids []string) (ret *util.BlockStatResult)

func BookmarkLabels

func BookmarkLabels() (ret []string)

func BootSyncData

func BootSyncData()

func BuildGraph

func BuildGraph(query string) (boxID string, nodes []*GraphNode, links []*GraphLink)

func BuildTreeGraph

func BuildTreeGraph(id, query string) (boxID string, nodes []*GraphNode, links []*GraphLink)

func ChangeBoxSort

func ChangeBoxSort(boxIDs []string)

func ChangeFileTreeSort

func ChangeFileTreeSort(boxID string, paths []string)

func ChangeHistoryTick

func ChangeHistoryTick(minutes int)

func CheckActivationcode

func CheckActivationcode(code string) (retCode int, msg string)

func CheckAuth

func CheckAuth(c *gin.Context)

func CheckReadonly

func CheckReadonly(c *gin.Context)

func CheckUpdate

func CheckUpdate(showMsg bool)

func CheckoutRepo

func CheckoutRepo(id string) (err error)

func ClearWorkspaceHistory

func ClearWorkspaceHistory() (err error)

func Close

func Close(force bool, execInstallPkg int) (exitCode int)

Close 退出内核进程.

force:是否不执行同步过程而直接退出 execInstallPkg:是否执行新版本安装包 0:默认按照设置项 System.DownloadInstallPkg 检查并推送提示 1:不执行新版本安装 2:执行新版本安装

func CloseWatchAssets

func CloseWatchAssets()

func ContentStat

func ContentStat(content string) (ret *util.BlockStatResult)

func CreateBox

func CreateBox(name string) (id string, err error)

func CreateCloudSyncDir

func CreateCloudSyncDir(name string) (err error)

func CreateDailyNote

func CreateDailyNote(boxID string) (p string, existed bool, err error)

func CreateDeck

func CreateDeck(name string) (deck *riff.Deck, err error)

func CreateDocByMd

func CreateDocByMd(boxID, p, title, md string, sorts []string) (err error)

func CreateWithMarkdown

func CreateWithMarkdown(boxID, hPath, md string) (id string, err error)

func DeactivateUser

func DeactivateUser() (err error)

func Doc2Heading

func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath string, err error)

func DocImageAssets

func DocImageAssets(rootID string) (ret []string, err error)

func DocSaveAsTemplate

func DocSaveAsTemplate(id string, overwrite bool) (code int, err error)

func DownloadCloudSnapshot

func DownloadCloudSnapshot(tag, id string) (err error)

func DuplicateDoc

func DuplicateDoc(rootID string) (ret *parse.Tree, err error)

func Export2Liandi

func Export2Liandi(id string) (err error)

func ExportData

func ExportData() (zipPath string, err error)

func ExportDataInFolder

func ExportDataInFolder(exportFolder string) (name string, err error)

func ExportDocx

func ExportDocx(id, savePath string, removeAssets, merge bool) (err error)

func ExportHTML

func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, dom string)

func ExportMarkdown

func ExportMarkdown(id string) (name, zipPath string)

func ExportMarkdownContent

func ExportMarkdownContent(id string) (hPath, exportedMd string)

func ExportMarkdownHTML

func ExportMarkdownHTML(id, savePath string, docx, merge bool) (name, dom string)

func ExportNotebookSY

func ExportNotebookSY(id string) (zipPath string)

func ExportSY

func ExportSY(id string) (name, zipPath string)

func ExportStdMarkdown

func ExportStdMarkdown(id string) string

func ExportSystemLog

func ExportSystemLog() (zipPath string)

func FindReplace

func FindReplace(keyword, replacement string, ids []string, method int) (err error)

func FullReindex

func FullReindex()

func FullTextSearchHistory

func FullTextSearchHistory(query, box, op string, typ, page int) (ret []string, pageCount, totalCount int)

func GetAssetAbsPath

func GetAssetAbsPath(relativePath string) (absPath string, err error)

func GetBlockAttrs

func GetBlockAttrs(id string) (ret map[string]string)

func GetBlockDOM

func GetBlockDOM(id string) (ret string)

func GetBlockDefIDsByRefText

func GetBlockDefIDsByRefText(refText string, excludeIDs []string) (ret []string)

func GetBlockIndex

func GetBlockIndex(id string) (ret int)

func GetBlockKramdown

func GetBlockKramdown(id string) (ret string)

func GetBlockRefIDs

func GetBlockRefIDs(id string) (refIDs, refTexts, defIDs []string)

func GetBlockRefIDsByFileAnnotationID

func GetBlockRefIDsByFileAnnotationID(id string) (refIDs, refTexts []string)

func GetBlockRefText

func GetBlockRefText(id string) string

func GetCaptcha

func GetCaptcha(c *gin.Context)

func GetCloudRepoTagSnapshots

func GetCloudRepoTagSnapshots() (ret []*dejavu.Log, err error)

func GetCloudShorthand

func GetCloudShorthand(id string) (ret map[string]interface{}, err error)

func GetCloudShorthands

func GetCloudShorthands(page int) (result map[string]interface{}, err error)

func GetCloudSpace

func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hTotalSize, hExchangeSize, hTrafficUploadSize, hTrafficDownloadSize string, err error)

func GetDecks

func GetDecks() (decks []*riff.Deck)

func GetDoc

func GetDoc(startID, endID, id string, index int, keyword string, mode int, size int, isBacklink bool) (blockCount, childBlockCount int, dom, parentID, parent2ID, rootID, typ string, eof bool, boxID, docPath string, isBacklinkExpand bool, err error)

func GetDocHistoryContent

func GetDocHistoryContent(historyPath, keyword string) (id, rootID, content string, isLargeDoc bool, err error)

func GetFullHPathByID

func GetFullHPathByID(id string) (hPath string, err error)

func GetHPathByID

func GetHPathByID(id string) (hPath string, err error)

func GetHPathByPath

func GetHPathByPath(boxID, p string) (hPath string, err error)

func GetHPathsByPaths

func GetHPathsByPaths(paths []string) (hPaths []string, err error)

func GetHeadingChildrenDOM

func GetHeadingChildrenDOM(id string) (ret string)

func GetHeadingChildrenIDs

func GetHeadingChildrenIDs(id string) (ret []string)

func GetHistoryDir

func GetHistoryDir(suffix string) (ret string, err error)

func GetLocalStorage

func GetLocalStorage() (ret map[string]interface{}, err error)

func GetPackageREADME

func GetPackageREADME(repoURL, repoHash string) (ret string)

func HTML2Markdown

func HTML2Markdown(htmlStr string) (markdown string, err error)

func HandleSignal

func HandleSignal()

func Heading2Doc

func Heading2Doc(srcHeadingID, targetBoxID, targetPath string) (srcRootBlockID, newTargetPath string, err error)

func HookDesktopUIProc

func HookDesktopUIProc()

func HumanizeTime

func HumanizeTime(then time.Time) string

func ImportData

func ImportData(zipPath string) (err error)

func ImportFromLocalPath

func ImportFromLocalPath(boxID, localPath string, toPath string) (err error)

func ImportRepoKey

func ImportRepoKey(base64Key string) (err error)

func ImportSY

func ImportSY(zipPath, boxID, toPath string) (err error)

func IncSync

func IncSync()

func IndexRefs

func IndexRefs()

func IndexRepo

func IndexRepo(memo string) (err error)

func InitAppearance

func InitAppearance()

func InitBoxes

func InitBoxes()

func InitConf

func InitConf()

func InitFlashcards

func InitFlashcards()

func InitRepoKey

func InitRepoKey() (err error)

func InitRepoKeyFromPassphrase

func InitRepoKeyFromPassphrase(passphrase string) (err error)

func InsertLocalAssets

func InsertLocalAssets(id string, assetPaths []string, isUpload bool) (succMap map[string]interface{}, err error)

func InstallBazaarIcon

func InstallBazaarIcon(repoURL, repoHash, iconName string) error

func InstallBazaarTemplate

func InstallBazaarTemplate(repoURL, repoHash, templateName string) error

func InstallBazaarTheme

func InstallBazaarTheme(repoURL, repoHash, themeName string, mode int, update bool) error

func InstallBazaarWidget

func InstallBazaarWidget(repoURL, repoHash, widgetName string) error

func InstalledIcons

func InstalledIcons() (icons []*bazaar.Icon)

func InstalledTemplates

func InstalledTemplates() (templates []*bazaar.Template)

func InstalledThemes

func InstalledThemes() (ret []*bazaar.Theme)

func InstalledWidgets

func InstalledWidgets() (widgets []*bazaar.Widget)

func IsFoldHeading

func IsFoldHeading(transactions *[]*Transaction) bool

func IsSubscriber

func IsSubscriber() bool

func IsSyncingFile

func IsSyncingFile(rootID string) (ret bool)

func IsUnfoldHeading

func IsUnfoldHeading(transactions *[]*Transaction) bool

func IsUserGuide

func IsUserGuide(boxID string) bool

func ListItem2Doc

func ListItem2Doc(srcListItemID, targetBoxID, targetPath string) (srcRootBlockID, newTargetPath string, err error)

func LoadAssetsTexts

func LoadAssetsTexts()

func LoadSnippets

func LoadSnippets() (ret []*conf.Snippet, err error)

func LoadTree

func LoadTree(boxID, p string) (*parse.Tree, error)

func LoadUploadToken

func LoadUploadToken() (err error)

func Login

func Login(userName, password, captcha string) (ret *gulu.Result, err error)

func Login2fa

func Login2fa(token, code string) (map[string]interface{}, error)

func LoginAuth

func LoginAuth(c *gin.Context)

func LogoutAuth

func LogoutAuth(c *gin.Context)

func LogoutUser

func LogoutUser()

func Mount

func Mount(boxID string) (alreadyMount bool, err error)

func MoveDocs

func MoveDocs(fromPaths []string, toBoxID, toPath string) (err error)

func NetImg2LocalAssets

func NetImg2LocalAssets(rootID string) (err error)

func NewLute

func NewLute() (ret *lute.Lute)

func OpenRepoSnapshotDoc

func OpenRepoSnapshotDoc(fileID string) (id, rootID, content string, isLargeDoc bool, err error)

func PerformTransactions

func PerformTransactions(transactions *[]*Transaction) (err error)

func Preview

func Preview(id string) string

func ReadCustomCSS

func ReadCustomCSS(themeName string) (ret map[string]map[string]string, err error)
func RefreshBacklink(id string)

func RefreshUser

func RefreshUser(token string) error

func ReindexHistory

func ReindexHistory() (err error)

func RemoveBookmark

func RemoveBookmark(bookmark string) (err error)

func RemoveBox

func RemoveBox(boxID string) (err error)

func RemoveCloudRepoTag

func RemoveCloudRepoTag(tag string) (err error)

func RemoveCloudShorthands

func RemoveCloudShorthands(ids []string) (err error)

func RemoveCloudSyncDir

func RemoveCloudSyncDir(name string) (err error)

func RemoveCriterion

func RemoveCriterion(name string) (err error)

func RemoveDeck

func RemoveDeck(deckID string) (err error)

func RemoveDoc

func RemoveDoc(boxID, p string) (err error)

func RemoveDocs

func RemoveDocs(paths []string) (err error)

func RemoveFlashcards

func RemoveFlashcards(deckID string, blockIDs []string) (err error)

func RemoveLocalStorageVal

func RemoveLocalStorageVal(key string) (err error)

func RemoveRecentDoc

func RemoveRecentDoc(ids []string)

func RemoveSnippet

func RemoveSnippet(id string) (ret *conf.Snippet, err error)

func RemoveTag

func RemoveTag(label string) (err error)

func RemoveTagSnapshot

func RemoveTagSnapshot(tag string) (err error)

func RemoveUnusedAsset

func RemoveUnusedAsset(p string) (ret string)

func RemoveUnusedAssets

func RemoveUnusedAssets() (ret []string)

func RenameAsset

func RenameAsset(oldPath, newName string) (err error)

func RenameBookmark

func RenameBookmark(oldBookmark, newBookmark string) (err error)

func RenameBox

func RenameBox(boxID, name string) (err error)

func RenameDeck

func RenameDeck(deckID, name string) (err error)

func RenameDoc

func RenameDoc(boxID, p, title string) (err error)

func RenameTag

func RenameTag(oldLabel, newLabel string) (err error)

func RenderGoTemplate

func RenderGoTemplate(templateContent string) (ret string, err error)

func RenderTemplate

func RenderTemplate(p, id string) (string, error)

func ResetBlockAttrs

func ResetBlockAttrs(id string, nameValues map[string]string) (err error)

func ResetRepo

func ResetRepo() (err error)

func ReviewFlashcard

func ReviewFlashcard(deckID string, blockID string, rating riff.Rating) (err error)

func RollbackAssetsHistory

func RollbackAssetsHistory(historyPath string) (err error)

func RollbackDocHistory

func RollbackDocHistory(boxID, historyPath string) (err error)

func RollbackNotebookHistory

func RollbackNotebookHistory(historyPath string) (err error)

func SaveAssetsTexts

func SaveAssetsTexts()

func SearchAssetsByName

func SearchAssetsByName(keyword string) (ret []*cache.Asset)

func SearchDocsByKeyword

func SearchDocsByKeyword(keyword string) (ret []map[string]string)

func SearchTags

func SearchTags(keyword string) (ret []string)

func ServeFile

func ServeFile(c *gin.Context, filePath string) (err error)

func SetBlockAttrs

func SetBlockAttrs(id string, nameValues map[string]string) (err error)

func SetBlockReminder

func SetBlockReminder(id string, timed string) (err error)

func SetBoxIcon

func SetBoxIcon(boxID, icon string)

func SetCloudBlockReminder

func SetCloudBlockReminder(id, data string, timed int64) (err error)

func SetCloudSyncDir

func SetCloudSyncDir(name string)

func SetCriterion

func SetCriterion(criterion *Criterion) (err error)

func SetLocalStorage

func SetLocalStorage(val interface{}) (err error)

func SetLocalStorageVal

func SetLocalStorageVal(key string, val interface{}) (err error)

func SetRecentDoc

func SetRecentDoc(doc *RecentDoc) (err error)

func SetRecentDocByTree

func SetRecentDocByTree(tree *parse.Tree)

func SetSnippet

func SetSnippet(snippets []*conf.Snippet) (err error)

func SetSyncEnable

func SetSyncEnable(b bool) (err error)

func SetSyncGenerateConflictDoc

func SetSyncGenerateConflictDoc(b bool)

func SetSyncMode

func SetSyncMode(mode int) (err error)

func SetSyncProvider

func SetSyncProvider(provider int) (err error)

func SetSyncProviderS3

func SetSyncProviderS3(s3 *conf.S3) (err error)

func SetSyncProviderWebDAV

func SetSyncProviderWebDAV(webdav *conf.WebDAV) (err error)

func StartFreeTrial

func StartFreeTrial() (err error)

func StatTree

func StatTree(id string) (ret *util.BlockStatResult)

func SwapBlockRef

func SwapBlockRef(refID, defID string, includeChildren bool) (err error)

func SyncData

func SyncData(boot, exit, byHand bool)

func TagSnapshot

func TagSnapshot(id, name string) (err error)

func TryAccessFileByBlockID

func TryAccessFileByBlockID(id string) (ok bool)

func UninstallBazaarIcon

func UninstallBazaarIcon(iconName string) error

func UninstallBazaarTemplate

func UninstallBazaarTemplate(templateName string) error

func UninstallBazaarTheme

func UninstallBazaarTheme(themeName string) error

func UninstallBazaarWidget

func UninstallBazaarWidget(widgetName string) error

func Unmount

func Unmount(boxID string)

func UnusedAssets

func UnusedAssets() (ret []string)

func Upload

func Upload(c *gin.Context)

func UploadAssets2Cloud

func UploadAssets2Cloud(rootID string) (err error)

func UploadCloudSnapshot

func UploadCloudSnapshot(tag, id string) (err error)

func UseActivationcode

func UseActivationcode(code string) (err error)

func WaitForWritingFiles

func WaitForWritingFiles()

func WatchAssets

func WatchAssets()

func WriteCustomCSS

func WriteCustomCSS(themeName string, cssMap map[string]interface{}) (err error)

Types

type Announcement

type Announcement struct {
	Id    string `json:"id"`
	Title string `json:"title"`
	URL   string `json:"url"`
}

func GetAnnouncements

func GetAnnouncements() (ret []*Announcement)

type AppConf

type AppConf struct {
	LogLevel       string           `json:"logLevel"`       // 日志级别:Off, Trace, Debug, Info, Warn, Error, Fatal
	Appearance     *conf.Appearance `json:"appearance"`     // 外观
	Langs          []*conf.Lang     `json:"langs"`          // 界面语言列表
	Lang           string           `json:"lang"`           // 选择的界面语言,同 Appearance.Lang
	FileTree       *conf.FileTree   `json:"fileTree"`       // 文档面板
	Tag            *conf.Tag        `json:"tag"`            // 标签面板
	Editor         *conf.Editor     `json:"editor"`         // 编辑器配置
	Export         *conf.Export     `json:"export"`         // 导出配置
	Graph          *conf.Graph      `json:"graph"`          // 关系图配置
	UILayout       *conf.UILayout   `json:"uiLayout"`       // 界面布局
	UserData       string           `json:"userData"`       // 社区用户信息,对 User 加密存储
	User           *conf.User       `json:"-"`              // 社区用户内存结构,不持久化
	Account        *conf.Account    `json:"account"`        // 帐号配置
	ReadOnly       bool             `json:"readonly"`       // 是否是以只读模式运行
	LocalIPs       []string         `json:"localIPs"`       // 本地 IP 列表
	AccessAuthCode string           `json:"accessAuthCode"` // 访问授权码
	System         *conf.System     `json:"system"`         // 系统配置
	Keymap         *conf.Keymap     `json:"keymap"`         // 快捷键配置
	Sync           *conf.Sync       `json:"sync"`           // 同步配置
	Search         *conf.Search     `json:"search"`         // 搜索配置
	Stat           *conf.Stat       `json:"stat"`           // 统计
	Api            *conf.API        `json:"api"`            // API
	Repo           *conf.Repo       `json:"repo"`           // 数据仓库
	Newbie         bool             `json:"newbie"`         // 是否是安装后第一次启动
}

AppConf 维护应用元数据,保存在 ~/.siyuan/conf.json。

var Conf *AppConf

func GetMaskedConf

func GetMaskedConf() (ret *AppConf, err error)

func (*AppConf) Box

func (conf *AppConf) Box(boxID string) *Box

func (*AppConf) BoxNames

func (conf *AppConf) BoxNames(boxIDs []string) (ret map[string]string)

func (*AppConf) Close

func (conf *AppConf) Close()

func (*AppConf) GetBoxes

func (conf *AppConf) GetBoxes() (ret []*Box)

func (*AppConf) GetClosedBoxes

func (conf *AppConf) GetClosedBoxes() (ret []*Box)

func (*AppConf) GetOpenedBoxes

func (conf *AppConf) GetOpenedBoxes() (ret []*Box)

func (*AppConf) Language

func (conf *AppConf) Language(num int) (ret string)

func (*AppConf) Save

func (conf *AppConf) Save()
type Backlink struct {
	DOM        string       `json:"dom"`
	BlockPaths []*BlockPath `json:"blockPaths"`
	Expand     bool         `json:"expand"`
}

func GetBacklinkDoc

func GetBacklinkDoc(defID, refTreeID, keyword string) (ret []*Backlink)

func GetBackmentionDoc

func GetBackmentionDoc(defID, refTreeID, keyword string) (ret []*Backlink)

type Backup

type Backup struct {
	Size    int64  `json:"size"`
	HSize   string `json:"hSize"`
	Updated string `json:"updated"`
	SaveDir string `json:"saveDir"` // 本地备份数据存放目录路径
}

type Block

type Block struct {
	Box      string            `json:"box"`
	Path     string            `json:"path"`
	HPath    string            `json:"hPath"`
	ID       string            `json:"id"`
	RootID   string            `json:"rootID"`
	ParentID string            `json:"parentID"`
	Name     string            `json:"name"`
	Alias    string            `json:"alias"`
	Memo     string            `json:"memo"`
	Tag      string            `json:"tag"`
	Content  string            `json:"content"`
	FContent string            `json:"fcontent"`
	Markdown string            `json:"markdown"`
	Folded   bool              `json:"folded"`
	Type     string            `json:"type"`
	SubType  string            `json:"subType"`
	RefText  string            `json:"refText"`
	Defs     []*Block          `json:"-"`    // 当前块引用了这些块,避免序列化 JSON 时产生循环引用
	Refs     []*Block          `json:"refs"` // 当前块被这些块引用
	DefID    string            `json:"defID"`
	DefPath  string            `json:"defPath"`
	IAL      map[string]string `json:"ial"`
	Children []*Block          `json:"children"`
	Depth    int               `json:"depth"`
	Count    int               `json:"count"`
	Sort     int               `json:"sort"`
	Created  string            `json:"created"`
	Updated  string            `json:"updated"`
}

Block 描述了内容块。

func FullTextSearchBlock

func FullTextSearchBlock(query string, boxes, paths []string, types map[string]bool, method, orderBy, groupBy int) (ret []*Block, matchedBlockCount, matchedRootCount int)

FullTextSearchBlock 搜索内容块。

method:0:关键字,1:查询语法,2:SQL,3:正则表达式 orderBy: 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时),6:按相关度升序,7:按相关度降序 groupBy:0:不分组,1:按文档分组

func GetBlock

func GetBlock(id string) (ret *Block, err error)

func GetFlashcards

func GetFlashcards(deckID string, page int) (blocks []*Block, total, pageCount int)

func RecentUpdatedBlocks

func RecentUpdatedBlocks() (ret []*Block)

func SearchRefBlock

func SearchRefBlock(id, rootID, keyword string, beforeLen int) (ret []*Block, newDoc bool)

func SearchTemplate

func SearchTemplate(keyword string) (ret []*Block)

func SearchWidget

func SearchWidget(keyword string) (ret []*Block)

func (*Block) IsContainerBlock

func (block *Block) IsContainerBlock() bool

type BlockInfo

type BlockInfo struct {
	ID           string            `json:"id"`
	Name         string            `json:"name"`
	RefCount     int               `json:"refCount"`
	SubFileCount int               `json:"subFileCount"`
	RefIDs       []string          `json:"refIDs"`
	IAL          map[string]string `json:"ial"`
	Icon         string            `json:"icon"`
}

func GetDocInfo

func GetDocInfo(rootID string) (ret *BlockInfo)

type BlockPath

type BlockPath struct {
	ID       string       `json:"id"`
	Name     string       `json:"name"`
	Type     string       `json:"type"`
	SubType  string       `json:"subType"`
	Children []*BlockPath `json:"children"`
}

func BuildBlockBreadcrumb

func BuildBlockBreadcrumb(id string, excludeTypes []string) (ret []*BlockPath, err error)

type Bookmark

type Bookmark struct {
	Name   BookmarkLabel `json:"name"`
	Blocks []*Block      `json:"blocks"`
	Type   string        `json:"type"` // "bookmark"
	Depth  int           `json:"depth"`
	Count  int           `json:"count"`
}

type BookmarkBlocks

type BookmarkBlocks []*Block

type BookmarkLabel

type BookmarkLabel string

type Bookmarks

type Bookmarks []*Bookmark

func BuildBookmark

func BuildBookmark() (ret *Bookmarks)

func (Bookmarks) Len

func (s Bookmarks) Len() int

func (Bookmarks) Less

func (s Bookmarks) Less(i, j int) bool

func (Bookmarks) Swap

func (s Bookmarks) Swap(i, j int)

type Box

type Box struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Icon   string `json:"icon"`
	Sort   int    `json:"sort"`
	Closed bool   `json:"closed"`
	// contains filtered or unexported fields
}

Box 笔记本。

func ListNotebooks

func ListNotebooks() (ret []*Box, err error)

func (*Box) Exist

func (box *Box) Exist(p string) bool

func (*Box) GetConf

func (box *Box) GetConf() (ret *conf.BoxConf)

func (*Box) Index

func (box *Box) Index(fullRebuildIndex bool) (treeCount int, treeSize int64)

func (*Box) ListFiles

func (box *Box) ListFiles(path string) (ret []*FileInfo)

func (*Box) Ls

func (box *Box) Ls(p string) (ret []*FileInfo, totals int, err error)

func (*Box) Mkdir

func (box *Box) Mkdir(path string) error

func (*Box) MkdirAll

func (box *Box) MkdirAll(path string) error

func (*Box) Move

func (box *Box) Move(oldPath, newPath string) error

func (*Box) Remove

func (box *Box) Remove(path string) error

func (*Box) SaveConf

func (box *Box) SaveConf(conf *conf.BoxConf)

func (*Box) Stat

func (box *Box) Stat(p string) (ret *FileInfo)

func (*Box) Unindex

func (box *Box) Unindex()

func (*Box) UpdateHistoryGenerated

func (box *Box) UpdateHistoryGenerated()

type Criterion

type Criterion struct {
	Name       string          `json:"name"`
	Sort       int             `json:"sort"`       //  0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时)
	Group      int             `json:"group"`      // 0:不分组,1:按文档分组
	HasReplace bool            `json:"hasReplace"` // 是否有替换
	Method     int             `json:"method"`     //  0:文本,1:查询语法,2:SQL,3:正则表达式
	HPath      string          `json:"hPath"`
	IDPath     []string        `json:"idPath"`
	K          string          `json:"k"`     // 搜索关键字
	R          string          `json:"r"`     // 替换关键字
	Types      *CriterionTypes `json:"types"` // 类型过滤选项
}

func GetCriteria

func GetCriteria() (ret []*Criterion)

type CriterionTypes

type CriterionTypes struct {
	MathBlock  bool `json:"mathBlock"`
	Table      bool `json:"table"`
	Blockquote bool `json:"blockquote"`
	SuperBlock bool `json:"superBlock"`
	Paragraph  bool `json:"paragraph"`
	Document   bool `json:"document"`
	Heading    bool `json:"heading"`
	List       bool `json:"list"`
	ListItem   bool `json:"listItem"`
	CodeBlock  bool `json:"codeBlock"`
	HtmlBlock  bool `json:"htmlBlock"`
}

type DiffFile

type DiffFile struct {
	FileID string `json:"fileID"`
	Title  string `json:"title"`
}

type DiffIndex

type DiffIndex struct {
	ID      string `json:"id"`
	Created int64  `json:"created"`
}

type EmbedBlock

type EmbedBlock struct {
	Block      *Block       `json:"block"`
	BlockPaths []*BlockPath `json:"blockPaths"`
}

func SearchEmbedBlock

func SearchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock)

type File

type File struct {
	Path         string `json:"path"`
	Name         string `json:"name"` // 标题,即 ial["title"]
	Icon         string `json:"icon"`
	Name1        string `json:"name1"` // 命名,即 ial["name"]
	Alias        string `json:"alias"`
	Memo         string `json:"memo"`
	Bookmark     string `json:"bookmark"`
	ID           string `json:"id"`
	Count        int    `json:"count"`
	Size         uint64 `json:"size"`
	HSize        string `json:"hSize"`
	Mtime        int64  `json:"mtime"`
	CTime        int64  `json:"ctime"`
	HMtime       string `json:"hMtime"`
	HCtime       string `json:"hCtime"`
	Sort         int    `json:"sort"`
	SubFileCount int    `json:"subFileCount"`
}

func ListDocTree

func ListDocTree(boxID, path string, sortMode int) (ret []*File, totals int, err error)

type FileInfo

type FileInfo struct {
	// contains filtered or unexported fields
}

type Flashcard

type Flashcard struct {
	DeckID   string                 `json:"deckID"`
	BlockID  string                 `json:"blockID"`
	NextDues map[riff.Rating]string `json:"nextDues"`
}

func GetDueFlashcards

func GetDueFlashcards(deckID string) (ret []*Flashcard, err error)

type GraphArrows

type GraphArrows struct {
	To *GraphArrowsTo `json:"to"`
}

type GraphArrowsTo

type GraphArrowsTo struct {
	Enabled bool `json:"enabled"`
}
type GraphLink struct {
	From   string          `json:"from"`
	To     string          `json:"to"`
	Ref    bool            `json:"-"`
	Color  *GraphLinkColor `json:"color"`
	Arrows *GraphArrows    `json:"arrows"`
}

type GraphLinkColor

type GraphLinkColor struct {
	Color string `json:"color"`
}

type GraphNode

type GraphNode struct {
	ID    string          `json:"id"`
	Box   string          `json:"box"`
	Path  string          `json:"path"`
	Size  float64         `json:"size"`
	Title string          `json:"title,omitempty"`
	Label string          `json:"label"`
	Type  string          `json:"type"`
	Refs  int             `json:"refs"`
	Defs  int             `json:"defs"`
	Color *GraphNodeColor `json:"color"`
}

type GraphNodeColor

type GraphNodeColor struct {
	Background string `json:"background"`
}

type History

type History struct {
	HCreated string         `json:"hCreated"`
	Items    []*HistoryItem `json:"items"`
}

func GetNotebookHistory

func GetNotebookHistory() (ret []*History, err error)

type HistoryItem

type HistoryItem struct {
	Title string `json:"title"`
	Path  string `json:"path"`
}

func FullTextSearchHistoryItems

func FullTextSearchHistoryItems(created, query, box, op string, typ int) (ret []*HistoryItem)

type LeftRightDiff

type LeftRightDiff struct {
	LeftIndex    *DiffIndex  `json:"leftIndex"`
	RightIndex   *DiffIndex  `json:"rightIndex"`
	AddsLeft     []*DiffFile `json:"addsLeft"`
	UpdatesLeft  []*DiffFile `json:"updatesLeft"`
	UpdatesRight []*DiffFile `json:"updatesRight"`
	RemovesRight []*DiffFile `json:"removesRight"`
}

func DiffRepoSnapshots

func DiffRepoSnapshots(left, right string) (ret *LeftRightDiff, err error)

type Operation

type Operation struct {
	Action     string      `json:"action"`
	Data       interface{} `json:"data"`
	ID         string      `json:"id"`
	ParentID   string      `json:"parentID"`
	PreviousID string      `json:"previousID"`
	NextID     string      `json:"nextID"`
	RetData    interface{} `json:"retData"`
	// contains filtered or unexported fields
}

type Path

type Path struct {
	ID       string   `json:"id"`                 // 块 ID
	Box      string   `json:"box"`                // 块 Box
	Name     string   `json:"name"`               // 当前路径
	HPath    string   `json:"hPath"`              // 人类可读路径
	Type     string   `json:"type"`               // "path"
	NodeType string   `json:"nodeType"`           // 节点类型
	SubType  string   `json:"subType"`            // 节点子类型
	Blocks   []*Block `json:"blocks,omitempty"`   // 子块节点
	Children []*Path  `json:"children,omitempty"` // 子路径节点
	Depth    int      `json:"depth"`              // 层级深度
	Count    int      `json:"count"`              // 子块计数

	Updated string `json:"updated"` // 更新时间
	Created string `json:"created"` // 创建时间
}
func GetBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID string, linkPaths, mentionPaths []*Path, linkRefsCount, mentionsCount int)

func GetBacklink2

func GetBacklink2(id, keyword, mentionKeyword string, sortMode, mentionSortMode int) (boxID string, backlinks, backmentions []*Path, linkRefsCount, mentionsCount int)

func Outline

func Outline(rootID string) (ret []*Path, err error)

type RecentDoc

type RecentDoc struct {
	RootID string `json:"rootID"`
	Icon   string `json:"icon"`
	Title  string `json:"title"`
}

func GetRecentDocs

func GetRecentDocs() (ret []*RecentDoc, err error)

type Snapshot

type Snapshot struct {
	*dejavu.Log
	TypesCount []*TypeCount `json:"typesCount"`
}

func GetRepoSnapshots

func GetRepoSnapshots(page int) (ret []*Snapshot, pageCount, totalCount int, err error)

func GetTagSnapshots

func GetTagSnapshots() (ret []*Snapshot, err error)

type Sync

type Sync struct {
	Size      int64  `json:"size"`
	HSize     string `json:"hSize"`
	Updated   string `json:"updated"`
	CloudName string `json:"cloudName"` // 云端同步数据存放目录名
	SaveDir   string `json:"saveDir"`   // 本地同步数据存放目录路径
}

func ListCloudSyncDir

func ListCloudSyncDir() (syncDirs []*Sync, hSize string, err error)

type Tag

type Tag struct {
	Name     string `json:"name"`
	Label    string `json:"label"`
	Children Tags   `json:"children"`
	Type     string `json:"type"` // "tag"
	Depth    int    `json:"depth"`
	Count    int    `json:"count"`
	// contains filtered or unexported fields
}

type TagBlocks

type TagBlocks []*Block

func (TagBlocks) Len

func (s TagBlocks) Len() int

func (TagBlocks) Less

func (s TagBlocks) Less(i, j int) bool

func (TagBlocks) Swap

func (s TagBlocks) Swap(i, j int)

type Tags

type Tags []*Tag

func BuildTags

func BuildTags() (ret *Tags)

type Transaction

type Transaction struct {
	DoOperations   []*Operation `json:"doOperations"`
	UndoOperations []*Operation `json:"undoOperations"`
	// contains filtered or unexported fields
}

func GetHeadingDeleteTransaction

func GetHeadingDeleteTransaction(id string) (transaction *Transaction, err error)

func GetHeadingLevelTransaction

func GetHeadingLevelTransaction(id string, level int) (transaction *Transaction, err error)

type TxErr

type TxErr struct {
	// contains filtered or unexported fields
}

type TypeCount

type TypeCount struct {
	Type  string `json:"type"`
	Count int    `json:"count"`
}

Jump to

Keyboard shortcuts

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