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 CalSha1(b []byte, r io.Reader) ([]byte, error)
- func CeilSize(size int64) int64
- func ClearPushProgress(total int)
- func ClosePushChan(id string)
- func ContextPushMsg(context map[string]interface{}, msg string)
- func CountSessions() (ret int)
- func CurrentTimeMillis() int64
- func CurrentTimeSecondsStr() string
- func DataSize() (dataSize, assetsSize int64)
- func EscapeHTML(s string) 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 GetAssetText(asset string) string
- func GetBootProgress() float64
- func GetBootProgressDetails() (float64, string)
- func GetChildDocDepth(treeAbsPath string) (ret int)
- func GetDataAssetsAbsPath() (ret string)
- func GetDeviceID() string
- func GetEtag(filename string) (etag string, err error)
- func GetEtagByHandle(f io.Reader, size int64) (etag string, err error)
- func GetLocalIPs() (ret []string)
- func GetRemoteAddr(session *melody.Session) string
- func GetRhyResult(force bool) (map[string]interface{}, error)
- func GetSysFonts(currentLanguage string) (ret []string)
- func IncBootProgress(progress float64, details string)
- func IsAssetLinkDest(dest []byte) bool
- func IsBooted() bool
- func IsCorruptedSYData(data []byte) bool
- func IsEmptyDir(p string) bool
- func IsIDPattern(str string) bool
- func IsMutexLocked(m *sync.Mutex) bool
- func IsRelativePath(dest string) bool
- func IsReservedFilename(baseName string) bool
- func IsSubFolder(parent, sub string) bool
- func IsValidPandocBin(binPath 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 LatestTmpFile(p string) string
- func Millisecond2Time(t int64) time.Time
- func NeedCaptcha() bool
- func NeedWarnDiskUsage(dataSize int64) bool
- func NewLute() (ret *lute.Lute)
- func NormalizeEndpoint(endpoint string) string
- func NormalizeTimeout(timeout int) int
- func PinYinCompare(str1, str2 string) bool
- 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 PushProgress(code, current, total int, msg string)
- func PushStatusBar(msg string)
- func PushTxErr(msg string, code int, data interface{})
- func PushUpdateMsg(msgId string, msg string, timeout int)
- func RandomSleep(minMills, maxMills int)
- func ReadWorkspacePaths() (ret []string, err error)
- func ReloadUI()
- func RemoveEmoji(text string) string
- func RemoveID(name string) string
- func RemovePushChan(session *melody.Session)
- func RemoveWorkspaceSession(session *SessionData)
- func Reverse(s string) string
- func SessionsByType(typ string) (ret []*melody.Session)
- 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) string
- func TimeFromID(id string) (ret string)
- func UTF82GBK(src string) ([]byte, error)
- func UnlockWorkspace()
- func WriteWorkspacePaths(workspacePaths []string) (err error)
- type BlockStatResult
- type PushMode
- type Result
- type SessionData
- type WorkspaceSession
Constants ¶
View Source
const ( BLOCK_BITS = 22 // Indicate that the blocksize is 4M BLOCK_SIZE = 1 << BLOCK_BITS )
View Source
const ( AliyunServer = "https://siyuan-sync.b3logfile.com" // 云端服务地址,阿里云负载均衡,用于接口,数据同步文件上传、下载会走七牛云 OSS SiYuanSyncServer SiYuanSyncServer = "https://siyuan-data.b3logfile.com/" // 云端数据同步服务地址,七牛云 OSS,用于数据同步文件上传、下载 BazaarStatServer = "http://bazaar.b3logfile.com" // 集市包统计服务地址,直接对接 Bucket 没有 CDN 缓存 BazaarOSSServer = "https://oss.b3logfile.com" // 云端对象存储地址,七牛云,仅用于读取集市包 LiandiServer = "https://ld246.com" // 链滴服务地址,用于分享发布帖子 )
View Source
const ( ExitCodeReadOnlyDatabase = 20 // 数据库文件被锁 ExitCodeCreateConfDirErr = 22 // 创建配置目录失败 ExitCodeBlockTreeErr = 23 // 无法读写 blocktree.msgpack 文件 ExitCodeWorkspaceLocked = 24 // 工作空间已被锁定 ExitCodeCreateWorkspaceDirErr = 25 // 创建工作空间失败 ExitCodeOk = 0 // 正常退出 ExitCodeFatal = 1 // 致命错误 )
View Source
const ( // FrontendQueueInterval 为前端请求队列轮询间隔。 FrontendQueueInterval = 512 * time.Millisecond // SQLFlushInterval 为数据库事务队列写入间隔。 SQLFlushInterval = 3000 * time.Millisecond )
View Source
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:子文档数降序 )
View Source
const ( PushProgressCodeProgressed = 0 // 有进度 PushProgressCodeEndless = 1 // 无进度 PushProgressCodeEnd = 2 // 关闭进度 )
View Source
const ( Ver = "2.7.0" IsInsider = false )
View Source
const ( ContainerStd = "std" // 桌面端 ContainerDocker = "docker" // Docker 容器端 ContainerAndroid = "android" // Android 端 ContainerIOS = "ios" // iOS 端 LocalHost = "127.0.0.1" // 伺服地址 FixedPort = "6806" // 固定端口 )
View Source
const DatabaseVer = "20220501" // 修改表结构的话需要修改这里
Variables ¶
View Source
var ( SSL = false UserAgent = "SiYuan/" + Ver )
View Source
var ( TesseractEnabled bool AssetsTexts = map[string]string{} AssetsTextsLock = sync.Mutex{} AssetsTextsChanged = false TesseractLangs []string )
View Source
var (
HomeDir, _ = gulu.OS.Home()
WorkingDir, _ = os.Getwd()
WorkspaceDir 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 历史数据库文件路径
BlockTreePath string // 区块树文件路径
PandocBinPath string // Pandoc 可执行文件路径
AppearancePath string // 配置目录下的外观目录 appearance/ 路径
ThemesPath string // 配置目录下的外观目录下的 themes/ 路径
IconsPath string // 配置目录下的外观目录下的 icons/ 路径
SnippetsPath string // 数据目录下的 snippets/ 路径
UIProcessIDs = sync.Map{} // UI 进程 ID
IsNewbie bool // 是否是第一次安装
)
View Source
var ( ServerPort = "0" // HTTP/WebSocket 端口,0 为使用随机端口 ReadOnly bool AccessAuthCode string Lang = "" Container string // docker, android, ios, std ISMicrosoftStore bool // 桌面端是否是微软商店版 )
View Source
var (
HttpServing = false // 是否 HTTP 伺服已经可用
)
View Source
var LocalIPs []string
View Source
var Mode = "prod"
var Mode = "dev"
View Source
var SK = []byte("696D897C9AA0611B")
View Source
var (
WebSocketServer = melody.New()
)
View Source
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 ClearPushProgress ¶
func ClearPushProgress(total int)
func ClosePushChan ¶
func ClosePushChan(id string)
func ContextPushMsg ¶
func CountSessions ¶
func CountSessions() (ret int)
func CurrentTimeMillis ¶
func CurrentTimeMillis() int64
func CurrentTimeSecondsStr ¶
func CurrentTimeSecondsStr() string
func EscapeHTML ¶
func FilterFileName ¶
func FilterFilePath ¶
func FilterMoveDocFromPaths ¶
func FilterSelfChildDocs ¶
func FilterUploadFileName ¶
func GetAssetText ¶
func GetBootProgress ¶
func GetBootProgress() float64
func GetBootProgressDetails ¶
func GetChildDocDepth ¶
func GetDataAssetsAbsPath ¶
func GetDataAssetsAbsPath() (ret string)
func GetDeviceID ¶
func GetDeviceID() string
func GetLocalIPs ¶
func GetLocalIPs() (ret []string)
func GetRemoteAddr ¶
func GetRhyResult ¶
func GetSysFonts ¶
func IncBootProgress ¶
func IsAssetLinkDest ¶
func IsCorruptedSYData ¶
func IsEmptyDir ¶
func IsIDPattern ¶
func IsMutexLocked ¶
func IsRelativePath ¶
func IsReservedFilename ¶
func IsSubFolder ¶
func IsValidPandocBin ¶
func IsWorkspaceLocked ¶
func LatestTmpFile ¶
func Millisecond2Time ¶
func NeedCaptcha ¶
func NeedCaptcha() bool
func NeedWarnDiskUsage ¶
func NormalizeEndpoint ¶
func NormalizeTimeout ¶
func PinYinCompare ¶
func PushClearAllMsg ¶
func PushClearAllMsg()
func PushDownloadProgress ¶
func PushEndlessProgress ¶
func PushEndlessProgress(msg string)
func PushErrMsg ¶
func PushProgress ¶
func PushStatusBar ¶
func PushStatusBar(msg string)
func PushUpdateMsg ¶
func RandomSleep ¶
func RandomSleep(minMills, maxMills int)
func ReadWorkspacePaths ¶
func RemoveEmoji ¶
func RemovePushChan ¶
func RemoveWorkspaceSession ¶
func RemoveWorkspaceSession(session *SessionData)
func SessionsByType ¶
func SetBootDetails ¶
func SetBootDetails(details string)
func SetNetworkProxy ¶
func SetNetworkProxy(proxyURL string)
func SizeOfDirectory ¶
func TimeFromID ¶
func UnlockWorkspace ¶
func UnlockWorkspace()
func WriteWorkspacePaths ¶
Types ¶
type BlockStatResult ¶
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)
Click to show internal directories.
Click to hide internal directories.