chore: mv asset

This commit is contained in:
henry.chen committed 2025-07-17 10:57:44 +08:00
1 parent be0280ac56
commit 4abe528742
58 files changed
+19 -25

No files matched your search

+4 -4
View File
@@ -14,8 +14,8 @@ import (
var ( var (
// Conf 配置 // Conf 配置
Conf Config Conf Config
// WorkDir 工作目录 // EtcDir 工作目录
WorkDir string EtcDir string
) )
// Config config // Config config
@@ -50,11 +50,11 @@ func init() {
// 加载配置文件 // 加载配置文件
var err error var err error
WorkDir, err = config.WalkWorkDir() EtcDir, err = config.WorkEtcPath()
if err != nil { if err != nil {
panic(err) panic(err)
} }
path := filepath.Join(WorkDir, "etc", "app.yml") path := filepath.Join(EtcDir, "app.yml")
data, err := os.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Before

Width:  |  Height:  |  Size: 847 B

After

Width:  |  Height:  |  Size: 847 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1 -1
View File
@@ -16,7 +16,7 @@ import (
var xmlTmpl *template.Template var xmlTmpl *template.Template
func init() { func init() {
root := filepath.Join(config.WorkDir, "website", "template", "*.xml") root := filepath.Join(config.EtcDir, "template", "*.xml")
var err error var err error
xmlTmpl, err = template.New("").Funcs(template.FuncMap{ xmlTmpl, err = template.New("").Funcs(template.FuncMap{
+3 -10
View File
@@ -17,17 +17,10 @@ var htmlTmpl *template.Template
func init() { func init() {
htmlTmpl = template.New("eiblog").Funcs(tools.TplFuncMap) htmlTmpl = template.New("eiblog").Funcs(tools.TplFuncMap)
root := filepath.Join(config.WorkDir, "website") root := filepath.Join(config.EtcDir, "website")
files := tools.ReadDirFiles(root, func(fi fs.DirEntry) bool { files := tools.ReadDirFiles(root, func(fi fs.DirEntry) bool {
name := fi.Name() // should not read dir & .DS_Store
if strings.HasPrefix(name, ".") { return strings.HasPrefix(fi.Name(), ".") || fi.IsDir()
return true
}
// should not read template dir
if fi.IsDir() && name == "template" {
return true
}
return false
}) })
_, err := htmlTmpl.ParseFiles(files...) _, err := htmlTmpl.ParseFiles(files...)
if err != nil { if err != nil {
+1 -1
View File
@@ -43,7 +43,7 @@ func runHTTPServer(endRun chan error) {
swag.RegisterRoutes(e) swag.RegisterRoutes(e)
// static files, page // static files, page
e.Static("/static", filepath.Join(config.WorkDir, "assets")) e.Static("/static", filepath.Join(config.EtcDir, "assets"))
// static files // static files
file.RegisterRoutes(e) file.RegisterRoutes(e)
+10 -9
View File
@@ -26,25 +26,26 @@ func (mode RunMode) IsRunMode() bool {
return mode == RunModeDev || mode == RunModeProd || mode == RunModeLocal return mode == RunModeDev || mode == RunModeProd || mode == RunModeLocal
} }
// WalkWorkDir walk work dir // WorkEtcPath walk etc dir
func WalkWorkDir() (string, error) { func WorkEtcPath() (string, error) {
gopath := os.Getenv("GOPATH") gopath := os.Getenv("GOPATH")
workDir, err := os.Getwd() wd, err := os.Getwd()
if err != nil { if err != nil {
return "", err return "", err
} }
// find work dir, try 3 times // find etc path, try 3 times
for gopath != workDir && workDir != "/" { var etc string
dir := filepath.Join(workDir, "etc") for gopath != wd && wd != "/" {
etc = filepath.Join(wd, "etc")
_, err := os.Stat(dir) _, err := os.Stat(etc)
if err == nil { if err == nil {
break break
} }
if !os.IsNotExist(err) { if !os.IsNotExist(err) {
return "", err return "", err
} }
workDir = filepath.Dir(workDir) wd = filepath.Dir(wd)
} }
return workDir, nil return etc, nil
} }