Documentation ¶
Index ¶
- Constants
- Variables
- func AESDecrypt(cryptStr string) []byte
- func AESEncrypt(str string) string
- func AddPushChan(session *melody.Session)
- func AssetName(name string) string
- func BlockCount(fsize int64) int
- func Boot()
- func BootMobile(container, appDir, workspaceBaseDir, lang string)
- func Broadcast(msg []byte)
- func BroadcastByType(typ, cmd string, code int, msg string, data interface{})
- func BroadcastByTypeAndApp(typ, app, cmd string, code int, msg string, data interface{})
- func CalSha1(b []byte, r io.Reader) ([]byte, error)
- func CeilSize(size int64) int64
- func ChatGPT(msg string, contextMsgs []string, c *openai.Client, model string, ...) (ret string, stop bool, err error)
- func CheckFileSysStatus()
- func CleanNotExistAssetsTexts()
- func ClearPushProgress(total int)
- func ClosePushChan(id string)
- func ContainsCJK(text string) bool
- func ContainsSubStr(s string, subStrs []string) bool
- func ContextPushMsg(context map[string]interface{}, msg string)
- func Convert2Float(s string) (float64, bool)
- func ConvertPandoc(dir string, args ...string) (path string, err error)
- func CountSessions() (ret int)
- func CurrentTimeMillis() int64
- func CurrentTimeSecondsStr() string
- func DataSize() (dataSize, assetsSize int64)
- func DisableFeature(feature string)
- func EscapeHTML(s string) (ret string)
- func ExistsAssetText(asset string) (ret bool)
- func Ext(name string) (ret string)
- func FilterFileName(name string) string
- func FilterFilePath(p string) (ret string)
- func FilterMoveDocFromPaths(fromPaths []string, toPath string) (ret []string)
- func FilterSelfChildDocs(paths []string) (ret []string)
- func FilterUploadFileName(name string) string
- func GBK2UTF8(src []byte) (string, error)
- func GetAbsPathInWorkspace(relPath string) (string, error)
- func GetAssetText(asset string) (ret string)
- func GetBootProgress() int32
- func GetBootProgressDetails() (progress int32, details string)
- func GetChildDocDepth(treeAbsPath string) (ret int)
- func GetCloudAccountServer() string
- func GetCloudAssetsServer() string
- func GetCloudForumAssetsServer() string
- func GetCloudServer() string
- func GetCloudSyncServer() string
- func GetCloudWebSocketServer() string
- func GetDataAssetsAbsPath() (ret string)
- func GetDeviceID() string
- func GetDeviceName() string
- func GetDiskUsage(p string) (total, used, free uint64)
- func GetDuplicateName(master string) (ret string)
- func GetEtag(filename string) (etag string, err error)
- func GetEtagByHandle(f io.Reader, size int64) (etag string, err error)
- func GetFilePathsByExts(dirPath string, exts []string) (ret []string)
- func GetLocalIPs() (ret []string)
- func GetMimeTypeByExt(filePath string) (ret string)
- func GetOSPlatform() (plat string)
- func GetOcrJsonText(jsonData []map[string]interface{}) (ret string)
- func GetRemoteAddr(req *http.Request) string
- func GetRhyResult(force bool) (map[string]interface{}, error)
- func GetTreeID(treePath string) string
- func GetUniqueFilename(filePath string) string
- func HookUILoaded()
- func HumanizeDiffTime(a, b time.Time, lang string) string
- func HumanizeRelTime(a time.Time, b time.Time, lang string) string
- func HumanizeTime(then time.Time, lang string) string
- func ISOWeek(date time.Time) int
- func IncBootProgress(progress int32, details string)
- func InitPandoc()
- func InitTesseract()
- func InsertElem[T any](s []T, index int, value T) []T
- func InvalidIDPattern(idArg string, result *gulu.Result) bool
- func IsAbsPathInWorkspace(absPath string) bool
- func IsAssetLinkDest(dest []byte) bool
- func IsBooted() bool
- func IsChinaCloud() bool
- func IsCloudDrivePath(workspaceAbsPath string) bool
- func IsCorruptedSYData(data []byte) bool
- func IsDirRegularOrSymlink(dir fs.DirEntry) bool
- func IsDisplayableAsset(p string) bool
- func IsEmptyDir(p string) bool
- func IsLocalHost(host string) bool
- func IsLocalHostname(hostname string) bool
- func IsLocalOrigin(origin string) bool
- func IsOnline(checkURL string, skipTlsVerify bool, timeout int) bool
- func IsPathRegularDirOrSymlinkDir(path string) bool
- func IsPortOpen(port string) bool
- func IsRelativePath(dest string) bool
- func IsReservedFilename(baseName string) bool
- func IsSubPath(absPath, toCheckPath string) bool
- func IsSymlink(dir fs.DirEntry) bool
- func IsSymlinkPath(absPath string) bool
- func IsTesseractExtractable(p string) bool
- func IsValidPandocBin(binPath string) bool
- func IsValidURL(str string) bool
- func IsWorkspaceLocked(workspacePath string) bool
- func JsonArg(c *gin.Context, result *gulu.Result) (arg map[string]interface{}, ok bool)
- func LastID(p string) (name, id string)
- func LinkTarget(htmlStr, linkBase string) (ret string)
- func LoadAssetsTexts()
- func LoadSysFonts() (ret []string)
- func Millisecond2Time(t int64) time.Time
- func NaturalCompare(str1, str2 string) bool
- func NeedCaptcha() bool
- func NeedWarnDiskUsage(dataSize int64) bool
- func NewLute() (ret *lute.Lute)
- func NewOpenAIClient(apiKey, apiProxy, apiBaseURL, apiUserAgent, apiVersion, apiProvider string) *openai.Client
- func NewStdLute() (ret *lute.Lute)
- func NormalizeConcurrentReqs(concurrentReqs int, provider int) int
- func NormalizeEndpoint(endpoint string) string
- func NormalizeTimeout(timeout int) int
- func OcrAsset(asset string) (ret []map[string]interface{})
- func Pandoc(from, to, o, content string) (err error)
- func ParsePort(portString string) (uint16, error)
- func PinYinCompare(str1, str2 string) bool
- func PushBackgroundTask(data map[string]interface{})
- func PushClearAllMsg()
- func PushClearMsg(msgId string)
- func PushClearProgress()
- func PushDownloadProgress(id string, percent float32)
- func PushEndlessProgress(msg string)
- func PushErrMsg(msg string, timeout int) (msgId string)
- func PushEvent(event *Result)
- func PushMsg(msg string, timeout int) (msgId string)
- func PushNodeOCRQueue(n *ast.Node)
- func PushProgress(code, current, total int, msg string)
- func PushProtyleLoading(rootID, msg string)
- func PushReloadDoc(rootID string)
- func PushReloadDocInfo(docInfo map[string]any)
- func PushReloadEmojiConf()
- func PushReloadFiletree()
- func PushReloadProtyle(rootID string)
- func PushSaveDoc(rootID, typ string, sources interface{})
- func PushSetDefRefCount(rootID, blockID string, refIDs []string, refCount, rootRefCount int)
- func PushSetRefDynamicText(rootID, blockID, defBlockID, refText string)
- func PushStatusBar(msg string)
- func PushTxErr(msg string, code int, data interface{})
- func PushUpdateIDs(ids map[string]string)
- func PushUpdateMsg(msgId string, msg string, timeout int)
- func RandString(length int) string
- func RandomSleep(minMills, maxMills int)
- func ReadWorkspacePaths() (ret []string, err error)
- func ReloadUI()
- func ReloadUIResetScroll()
- func RemoveAssetText(asset string)
- func RemoveElem[T any](s []T, index int) []T
- func RemoveEmojiInvisible(text string) (ret string)
- func RemoveID(name string) string
- func RemoveInvalid(text string) (ret string)
- func RemovePushChan(session *melody.Session)
- func RemoveRedundantSpace(str string) string
- func RemoveWorkspaceSession(session *SessionData)
- func ReplaceStr(strs []string, old, new string) (ret []string, changed bool)
- func ReportFileSysFatalError(err error)
- func Reverse(s string) string
- func SaveAssetsTexts()
- func SessionsByType(typ string) (ret []*melody.Session)
- func SetAssetText(asset, text string)
- func SetBootDetails(details string)
- func SetBooted()
- func SetNetworkProxy(proxyURL string)
- func ShortPathForBootingDisplay(p string) string
- func SizeOfDirectory(path string) (size int64, err error)
- func Tesseract(imgAbsPath string) (ret []map[string]interface{})
- func TimeFromID(id string) (ret string)
- func TruncateLenFileName(name string) (ret string)
- func UTF82GBK(src string) ([]byte, error)
- func UnescapeHTML(s string) (ret string)
- func UnlockWorkspace()
- func ValidOptionalPort(port string) bool
- func WaitForTesseractInit()
- func WaitForUILoaded()
- func WalkWithSymlinks(root string, fn fs.WalkDirFunc) error
- func Weekday(date time.Time) int
- func WeekdayCN(date time.Time) string
- func WeekdayCN2(date time.Time) string
- func WriteWorkspacePaths(workspacePaths []string) (err error)
- type AddHeaderTransport
- type BlockStatResult
- type Font
- type Markdown
- type PushMode
- type Result
- type SessionData
- type WorkspaceSession
Constants ¶
const ( BazaarStatServer = "https://bazaar.b3logfile.com" // 集市包统计服务地址,七牛云,全球 CDN BazaarOSSServer = "https://oss.b3logfile.com" // 云端对象存储地址,七牛云,仅用于读取集市包,全球 CDN )
const ( BLOCK_BITS = 22 // Indicate that the blocksize is 4M BLOCK_SIZE = 1 << BLOCK_BITS )
const ( EvtConfPandocInitialized = "conf.pandoc.initialized" EvtSQLHistoryRebuild = "sql.history.rebuild" EvtSQLAssetContentRebuild = "sql.assetContent.rebuild" )
const ( SortModeNameASC = iota // 0:文件名字母升序 SortModeNameDESC // 1:文件名字母降序 SortModeUpdatedASC // 2:文件更新时间升序 SortModeUpdatedDESC // 3:文件更新时间降序 SortModeAlphanumASC // 4:文件名自然数升序 SortModeAlphanumDESC // 5:文件名自然数降序 SortModeCustom // 6:自定义排序 SortModeRefCountASC // 7:引用数升序 SortModeRefCountDESC // 8:引用数降序 SortModeCreatedASC // 9:文件创建时间升序 SortModeCreatedDESC // 10:文件创建时间降序 SortModeSizeASC // 11:文件大小升序 SortModeSizeDESC // 12:文件大小降序 SortModeSubDocCountASC // 13:子文档数升序 SortModeSubDocCountDESC // 14:子文档数降序 SortModeFileTree // 15:使用文档树排序规则 SortModeUnassigned = 256 // 256:未指定排序规则,按照笔记本优先于文档树获取排序规则 )
const ( PushProgressCodeProgressed = 0 // 有进度 PushProgressCodeEndless = 1 // 无进度 PushProgressCodeEnd = 2 // 关闭进度 )
const ( Ver = "3.1.16" IsInsider = false )
const ( ContainerStd = "std" // 桌面端 ContainerDocker = "docker" // Docker 容器端 ContainerAndroid = "android" // Android 端 ContainerIOS = "ios" // iOS 端 ContainerHarmony = "harmony" // 鸿蒙端 LocalHost = "127.0.0.1" // 伺服地址 FixedPort = "6806" // 固定端口 )
const DatabaseVer = "20220501"
DatabaseVer 数据库版本。修改表结构的话需要修改这里。
const ( // SQLFlushInterval 为数据库事务队列写入间隔。 SQLFlushInterval = 3000 * time.Millisecond )
Variables ¶
var ( TesseractBin = "tesseract" TesseractEnabled bool TesseractMaxSize = 2 * 1000 * uint64(1000) TesseractLangs []string )
var ( NodeOCRQueue []string NodeOCRQueueLock = sync.Mutex{} )
var ( SSL = false UserAgent = "SiYuan/" + Ver )
var ( SiYuanAssetsImage = []string{".apng", ".ico", ".cur", ".jpg", ".jpe", ".jpeg", ".jfif", ".pjp", ".pjpeg", ".png", ".gif", ".webp", ".bmp", ".svg", ".avif"} SiYuanAssetsAudio = []string{".mp3", ".wav", ".ogg", ".m4a", ".flac"} SiYuanAssetsVideo = []string{".mov", ".weba", ".mkv", ".mp4", ".webm"} )
var ( Langs = map[string]map[int]string{} TimeLangs = map[string]map[string]interface{}{} TaskActionLangs = map[string]map[string]interface{}{} TrayMenuLangs = map[string]map[string]interface{}{} AttrViewLangs = map[string]map[string]interface{}{} )
var ( RunInContainer = false // 是否运行在容器中 SiyuanAccessAuthCodeBypass = false // 是否跳过空访问授权码检查 )
var (
HomeDir, _ = gulu.OS.Home()
WorkingDir, _ = os.Getwd()
WorkspaceDir string // 工作空间目录路径
WorkspaceName string // 工作空间名称
WorkspaceLock *flock.Flock // 工作空间锁
ConfDir string // 配置目录路径
DataDir string // 数据目录路径
RepoDir string // 仓库目录路径
HistoryDir string // 数据历史目录路径
TempDir string // 临时目录路径
LogPath string // 配置目录下的日志文件 siyuan.log 路径
DBName = "siyuan.db" // SQLite 数据库文件名
DBPath string // SQLite 数据库文件路径
HistoryDBPath string // SQLite 历史数据库文件路径
AssetContentDBPath string // SQLite 资源文件内容数据库文件路径
BlockTreeDBPath string // 区块树数据库文件路径
AppearancePath string // 配置目录下的外观目录 appearance/ 路径
ThemesPath string // 配置目录下的外观目录下的 themes/ 路径
IconsPath string // 配置目录下的外观目录下的 icons/ 路径
SnippetsPath string // 数据目录下的 snippets/ 路径
UIProcessIDs = sync.Map{} // UI 进程 ID
)
var ( ServerURL *url.URL // 内核服务 URL ServerPort = "0" // HTTP/WebSocket 端口,0 为使用随机端口 ReadOnly bool AccessAuthCode string Lang = "" Container string // docker, android, ios, harmony, std ISMicrosoftStore bool // 桌面端是否是微软商店版 )
var CurrentCloudRegion = 0
var DisabledFeatures []string
var ErrPandocNotFound = errors.New("not found executable pandoc")
var (
HttpServing = false // 是否 HTTP 伺服已经可用
)
var IsExiting = atomic.Bool{}
IsExiting 是否正在退出程序。
var IsUILoaded = false
IsUILoaded 是否已经加载了 UI。
var LocalIPs []string
var MarkdownSettings = &Markdown{ InlineAsterisk: true, InlineUnderscore: true, InlineSup: true, InlineSub: true, InlineTag: true, InlineMath: true, InlineStrikethrough: true, }
MarkdownSettings 运行时 Markdown 配置。
var MobileOSVer string
MobileOSVer 移动端操作系统版本。
var Mode = "prod"
var Mode = "dev"
var (
PandocBinPath string // Pandoc 可执行文件路径
)
var SK = []byte("696D897C9AA0611B")
var UseSingleLineSave = true
UseSingleLineSave 是否使用单行保存 .sy 和数据库 .json 文件。
var (
WebSocketServer = melody.New()
)
var WrongAuthCount int
Functions ¶
func AESDecrypt ¶
func AESEncrypt ¶
func AddPushChan ¶
func BlockCount ¶
func BootMobile ¶
func BootMobile(container, appDir, workspaceBaseDir, lang string)
func BroadcastByType ¶
BroadcastByType 广播所有实例上 typ 类型的会话。
func BroadcastByTypeAndApp ¶
func CheckFileSysStatus ¶
func CheckFileSysStatus()
func CleanNotExistAssetsTexts ¶
func CleanNotExistAssetsTexts()
func ClearPushProgress ¶
func ClearPushProgress(total int)
func ClosePushChan ¶
func ClosePushChan(id string)
func ContainsCJK ¶
func ContainsSubStr ¶
func ContextPushMsg ¶
func Convert2Float ¶
func CountSessions ¶
func CountSessions() (ret int)
func CurrentTimeMillis ¶
func CurrentTimeMillis() int64
func CurrentTimeSecondsStr ¶
func CurrentTimeSecondsStr() string
func DisableFeature ¶
func DisableFeature(feature string)
func EscapeHTML ¶
func ExistsAssetText ¶
func FilterFileName ¶
func FilterFilePath ¶
func FilterMoveDocFromPaths ¶
func FilterSelfChildDocs ¶
func FilterUploadFileName ¶
func GetAbsPathInWorkspace ¶
func GetAssetText ¶
func GetBootProgress ¶
func GetBootProgress() int32
func GetBootProgressDetails ¶
func GetChildDocDepth ¶
func GetCloudAccountServer ¶
func GetCloudAccountServer() string
func GetCloudAssetsServer ¶
func GetCloudAssetsServer() string
func GetCloudForumAssetsServer ¶
func GetCloudForumAssetsServer() string
func GetCloudServer ¶
func GetCloudServer() string
func GetCloudSyncServer ¶
func GetCloudSyncServer() string
func GetCloudWebSocketServer ¶
func GetCloudWebSocketServer() string
func GetDataAssetsAbsPath ¶
func GetDataAssetsAbsPath() (ret string)
func GetDeviceID ¶
func GetDeviceID() string
func GetDeviceName ¶
func GetDeviceName() string
func GetDiskUsage ¶
func GetDuplicateName ¶
func GetFilePathsByExts ¶
func GetLocalIPs ¶
func GetLocalIPs() (ret []string)
func GetMimeTypeByExt ¶
func GetOSPlatform ¶
func GetOSPlatform() (plat string)
func GetOcrJsonText ¶
提取并连接所有 text 字段的函数
func GetRemoteAddr ¶
func GetRhyResult ¶
func GetUniqueFilename ¶
func HookUILoaded ¶
func HookUILoaded()
func ISOWeek ¶
ISOWeek returns the ISO 8601 year and week number in which date occurs. Week ranges from 1 to 53. Jan 01 to Jan 03 of year n might belong to week 52 or 53 of year n-1, and Dec 29 to Dec 31 might belong to week 1 of year n+1.
func IncBootProgress ¶
func InitPandoc ¶
func InitPandoc()
func InitTesseract ¶
func InitTesseract()
func InsertElem ¶
InsertElem inserts value at index into a. 0 <= index <= len(s)
func IsAbsPathInWorkspace ¶
func IsAssetLinkDest ¶
func IsChinaCloud ¶
func IsChinaCloud() bool
func IsCloudDrivePath ¶
func IsCorruptedSYData ¶
func IsDirRegularOrSymlink ¶
func IsDisplayableAsset ¶
func IsEmptyDir ¶
func IsLocalHost ¶
func IsLocalHostname ¶
func IsLocalOrigin ¶
func IsPortOpen ¶
func IsRelativePath ¶
func IsReservedFilename ¶
func IsSymlinkPath ¶
func IsTesseractExtractable ¶
func IsValidPandocBin ¶
func IsValidURL ¶
func IsWorkspaceLocked ¶
func LinkTarget ¶
func LoadAssetsTexts ¶
func LoadAssetsTexts()
func LoadSysFonts ¶
func LoadSysFonts() (ret []string)
func Millisecond2Time ¶
func NaturalCompare ¶
func NeedCaptcha ¶
func NeedCaptcha() bool
func NeedWarnDiskUsage ¶
func NewOpenAIClient ¶
func NewOpenAIClient(apiKey, apiProxy, apiBaseURL, apiUserAgent, apiVersion, apiProvider string) *openai.Client
func NewStdLute ¶
func NormalizeConcurrentReqs ¶
func NormalizeEndpoint ¶
func NormalizeTimeout ¶
func PinYinCompare ¶
func PushBackgroundTask ¶
func PushBackgroundTask(data map[string]interface{})
func PushClearAllMsg ¶
func PushClearAllMsg()
func PushDownloadProgress ¶
func PushEndlessProgress ¶
func PushEndlessProgress(msg string)
func PushErrMsg ¶
func PushNodeOCRQueue ¶
func PushProgress ¶
func PushProtyleLoading ¶
func PushProtyleLoading(rootID, msg string)
func PushReloadDoc ¶
func PushReloadDoc(rootID string)
func PushReloadDocInfo ¶
func PushReloadEmojiConf ¶
func PushReloadEmojiConf()
func PushReloadFiletree ¶
func PushReloadFiletree()
func PushReloadProtyle ¶
func PushReloadProtyle(rootID string)
func PushSaveDoc ¶
func PushSaveDoc(rootID, typ string, sources interface{})
func PushSetDefRefCount ¶
func PushSetRefDynamicText ¶
func PushSetRefDynamicText(rootID, blockID, defBlockID, refText string)
func PushStatusBar ¶
func PushStatusBar(msg string)
func PushUpdateIDs ¶
func PushUpdateMsg ¶
func RandString ¶
func RandomSleep ¶
func RandomSleep(minMills, maxMills int)
func ReadWorkspacePaths ¶
func ReloadUIResetScroll ¶
func ReloadUIResetScroll()
func RemoveAssetText ¶
func RemoveAssetText(asset string)
func RemoveElem ¶
RemoveElem removes the element at index i from s.
func RemoveEmojiInvisible ¶
func RemoveInvalid ¶
func RemovePushChan ¶
func RemoveRedundantSpace ¶
func RemoveWorkspaceSession ¶
func RemoveWorkspaceSession(session *SessionData)
func ReportFileSysFatalError ¶
func ReportFileSysFatalError(err error)
func SaveAssetsTexts ¶
func SaveAssetsTexts()
func SessionsByType ¶
func SetAssetText ¶
func SetAssetText(asset, text string)
func SetBootDetails ¶
func SetBootDetails(details string)
func SetNetworkProxy ¶
func SetNetworkProxy(proxyURL string)
func SizeOfDirectory ¶
func TimeFromID ¶
func TruncateLenFileName ¶
func UnescapeHTML ¶
func UnlockWorkspace ¶
func UnlockWorkspace()
func ValidOptionalPort ¶
func WaitForTesseractInit ¶
func WaitForTesseractInit()
func WaitForUILoaded ¶
func WaitForUILoaded()
func WalkWithSymlinks ¶
func WalkWithSymlinks(root string, fn fs.WalkDirFunc) error
func Weekday ¶
Weekday returns the day of the week specified by date. Sunday=0, Monday=1, ..., Saturday=6.
func WeekdayCN ¶
WeekdayCN returns the day of the week specified by date. Sunday=日, Monday=一, ..., Saturday=六.
func WeekdayCN2 ¶
WeekdayCN2 returns the day of the week specified by date. Sunday=天, Monday=一, ..., Saturday=六.
func WriteWorkspacePaths ¶
Types ¶
type AddHeaderTransport ¶
type AddHeaderTransport struct { RoundTripper http.RoundTripper UserAgent string }
type BlockStatResult ¶
type Markdown ¶
type Markdown struct { InlineAsterisk bool `json:"inlineAsterisk"` // 是否启用行级 * 语法 InlineUnderscore bool `json:"inlineUnderscore"` // 是否启用行级 _ 语法 InlineSup bool `json:"inlineSup"` // 是否启用行级上标 InlineSub bool `json:"inlineSub"` // 是否启用行级下标 InlineTag bool `json:"inlineTag"` // 是否启用行级标签 InlineMath bool `json:"inlineMath"` // 是否启用行级公式 InlineStrikethrough bool `json:"inlineStrikethrough"` // 是否启用行级删除线 }
type PushMode ¶
type PushMode int
const ( PushModeBroadcast PushMode = 0 // 所有应用所有会话广播 PushModeSingleSelf PushMode = 1 // 自我应用会话单播 PushModeBroadcastExcludeSelf PushMode = 2 // 非自我会话广播 PushModeBroadcastExcludeSelfApp PushMode = 4 // 非自我应用所有会话广播 PushModeBroadcastApp PushMode = 5 // 单个应用内所有会话广播 PushModeBroadcastMainExcludeSelfApp PushMode = 6 // 非自我应用主会话广播 )
type Result ¶
type SessionData ¶
type SessionData struct {
Workspaces map[string]*WorkspaceSession // <WorkspacePath, WorkspaceSession>
}
SessionData represents the session.
func GetSession ¶
func GetSession(c *gin.Context) *SessionData
GetSession returns session of the specified context.
type WorkspaceSession ¶
func GetWorkspaceSession ¶
func GetWorkspaceSession(session *SessionData) (ret *WorkspaceSession)