Something went wrong. Try again.
A privacy-first, self-hosted, fully open source personal knowledge management software, written in typescript and golang. (PERSONAL FORK)
Something went wrong. Try again.
Go
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144// SiYuan - Refactor your thinking// Copyright (c) 2020-present, b3log.org//// This program is free software: you can redistribute it and/or modify// it under the terms of the GNU Affero General Public License as published by// the Free Software Foundation, either version 3 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU Affero General Public License for more details.//// You should have received a copy of the GNU Affero General Public License// along with this program. If not, see <https://www.gnu.org/licenses/>.
package main
import ( "C" "fmt" "os" "strings" "time"
"github.com/88250/gulu" "github.com/siyuan-note/filelock" "github.com/siyuan-note/logging" "github.com/siyuan-note/siyuan/kernel/cache" "github.com/siyuan-note/siyuan/kernel/job" "github.com/siyuan-note/siyuan/kernel/model" "github.com/siyuan-note/siyuan/kernel/server" "github.com/siyuan-note/siyuan/kernel/sql" "github.com/siyuan-note/siyuan/kernel/util")
//export StartKernelFastfunc StartKernelFast(container, appDir, workspaceBaseDir, localIPs *C.char) { go server.Serve(true, model.Conf.CookieKey)}
//export StartKernelfunc StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, lang, osVer *C.char) { SetTimezone(C.GoString(container), C.GoString(appDir), C.GoString(timezoneID)) util.Mode = "prod" util.MobileOSVer = C.GoString(osVer) util.LocalIPs = strings.Split(C.GoString(localIPs), ",") util.BootMobile(C.GoString(container), C.GoString(appDir), C.GoString(workspaceBaseDir), C.GoString(lang))
model.InitConf() go server.Serve(false, model.Conf.CookieKey) go func() { model.InitAppearance() sql.InitDatabase(false) sql.InitHistoryDatabase(false) sql.InitAssetContentDatabase(false) sql.SetCaseSensitive(model.Conf.Search.CaseSensitive) sql.SetIndexAssetPath(model.Conf.Search.IndexAssetPath)
model.BootSyncData() model.InitBoxes() model.LoadFlashcards() util.LoadAssetsTexts()
util.SetBooted() util.PushClearAllMsg()
job.StartCron() go model.AutoGenerateFileHistory() go cache.LoadAssets() }()}
//export Languagefunc Language(num int) string { return model.Conf.Language(num)}
//export ShowMsgfunc ShowMsg(msg string, timeout int) { util.PushMsg(msg, timeout)}
//export IsHttpServingfunc IsHttpServing() bool { return util.HttpServing}
//export SetHttpServerPortfunc SetHttpServerPort(port int) { filelock.AndroidServerPort = port}
//export GetCurrentWorkspacePathfunc GetCurrentWorkspacePath() *C.char { return C.CString(util.WorkspaceDir)}
//export GetAssetAbsPathfunc GetAssetAbsPath(relativePath *C.char) *C.char { absPath, err := model.GetAssetAbsPath(C.GoString(relativePath)) if nil != err { logging.LogErrorf("get asset abs path failed: %s", err) return relativePath } return C.CString(absPath)}
//export GetMimeTypeByExtfunc GetMimeTypeByExt(ext string) string { return util.GetMimeTypeByExt(ext)}
//export SetTimezonefunc SetTimezone(container, appDir, timezoneID string) { z, err := time.LoadLocation(strings.TrimSpace(timezoneID)) if err != nil { fmt.Printf("load location failed: %s\n", err) time.Local = time.FixedZone("CST", 8*3600) return } time.Local = z}
//export DisableFeaturefunc DisableFeature(feature *C.char) { util.DisableFeature(C.GoString(feature))}
//export Unzipfunc Unzip(zipFilePath, destination *C.char) { if err := gulu.Zip.Unzip(C.GoString(zipFilePath), C.GoString(destination)); nil != err { logging.LogErrorf("unzip [%s] failed: %s", zipFilePath, err) panic(err) }}
//export Exitfunc Exit() { os.Exit(logging.ExitCodeOk)}
func main() {}