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 (
// Conf 配置
Conf Config
// WorkDir 工作目录
WorkDir string
// EtcDir 工作目录
EtcDir string
)
// Config config
@@ -50,11 +50,11 @@ func init() {
// 加载配置文件
var err error
WorkDir, err = config.WalkWorkDir()
EtcDir, err = config.WorkEtcPath()
if err != nil {
panic(err)
}
path := filepath.Join(WorkDir, "etc", "app.yml")
path := filepath.Join(EtcDir, "app.yml")
data, err := os.ReadFile(path)
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
func init() {
root := filepath.Join(config.WorkDir, "website", "template", "*.xml")
root := filepath.Join(config.EtcDir, "template", "*.xml")
var err error
xmlTmpl, err = template.New("").Funcs(template.FuncMap{
+3 -10
View File
@@ -17,17 +17,10 @@ var htmlTmpl *template.Template
func init() {
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 {
name := fi.Name()
if strings.HasPrefix(name, ".") {
return true
}
// should not read template dir
if fi.IsDir() && name == "template" {
return true
}
return false
// should not read dir & .DS_Store
return strings.HasPrefix(fi.Name(), ".") || fi.IsDir()
})
_, err := htmlTmpl.ParseFiles(files...)
if err != nil {
+1 -1
View File
@@ -43,7 +43,7 @@ func runHTTPServer(endRun chan error) {
swag.RegisterRoutes(e)
// static files, page
e.Static("/static", filepath.Join(config.WorkDir, "assets"))
e.Static("/static", filepath.Join(config.EtcDir, "assets"))
// static files
file.RegisterRoutes(e)
+10 -9
View File
@@ -26,25 +26,26 @@ func (mode RunMode) IsRunMode() bool {
return mode == RunModeDev || mode == RunModeProd || mode == RunModeLocal
}
// WalkWorkDir walk work dir
func WalkWorkDir() (string, error) {
// WorkEtcPath walk etc dir
func WorkEtcPath() (string, error) {
gopath := os.Getenv("GOPATH")
workDir, err := os.Getwd()
wd, err := os.Getwd()
if err != nil {
return "", err
}
// find work dir, try 3 times
for gopath != workDir && workDir != "/" {
dir := filepath.Join(workDir, "etc")
// find etc path, try 3 times
var etc string
for gopath != wd && wd != "/" {
etc = filepath.Join(wd, "etc")
_, err := os.Stat(dir)
_, err := os.Stat(etc)
if err == nil {
break
}
if !os.IsNotExist(err) {
return "", err
}
workDir = filepath.Dir(workDir)
wd = filepath.Dir(wd)
}
return workDir, nil
return etc, nil
}