Browse Source

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 2 years ago
parent
commit
0f13f79ce4
3 changed files with 8 additions and 7 deletions
  1. 4 4
      kernel/bazaar/icon.go
  2. 3 3
      kernel/bazaar/package.go
  3. 1 0
      kernel/server/serve.go

+ 4 - 4
kernel/bazaar/icon.go

@@ -96,9 +96,9 @@ func Icons() (icons []*Icon) {
 
 func InstalledIcons() (ret []*Icon) {
 	ret = []*Icon{}
-	dir, err := os.Open(filepath.Join(util.DataDir, "icons"))
+	dir, err := os.Open(filepath.Join(util.AppearancePath, "icons"))
 	if nil != err {
-		logging.LogWarnf("open icons folder [%s] failed: %s", util.ThemesPath, err)
+		logging.LogWarnf("open icons folder failed: %s", err)
 		return
 	}
 	iconDirs, err := dir.Readdir(-1)
@@ -137,7 +137,7 @@ func InstalledIcons() (ret []*Icon) {
 		icon.Size = iconDir.Size()
 		icon.HSize = humanize.Bytes(uint64(icon.Size))
 		icon.HUpdated = formatUpdated(icon.Updated)
-		readme, readErr := os.ReadFile(filepath.Join(util.DataDir, "icons", dirName, "README.md"))
+		readme, readErr := os.ReadFile(filepath.Join(util.AppearancePath, "icons", dirName, "README.md"))
 		if nil != readErr {
 			logging.LogWarnf("read install icon README.md failed: %s", readErr)
 			continue
@@ -151,7 +151,7 @@ func InstalledIcons() (ret []*Icon) {
 }
 
 func isBuiltInIcon(dirName string) bool {
-	return "and" == dirName || "material" == dirName
+	return "ant" == dirName || "material" == dirName
 }
 
 func InstallIcon(repoURL, repoHash, installPath string, systemID string) error {

+ 3 - 3
kernel/bazaar/package.go

@@ -63,7 +63,7 @@ type Package struct {
 }
 
 func WidgetJSON(widgetDirName string) (ret map[string]interface{}, err error) {
-	p := filepath.Join(util.DataDir, widgetDirName, "widget.json")
+	p := filepath.Join(util.DataDir, "widgets", widgetDirName, "widget.json")
 	if !gulu.File.IsExist(p) {
 		err = os.ErrNotExist
 		return
@@ -85,7 +85,7 @@ func WidgetJSON(widgetDirName string) (ret map[string]interface{}, err error) {
 }
 
 func IconJSON(iconDirName string) (ret map[string]interface{}, err error) {
-	p := filepath.Join(util.ThemesPath, iconDirName, "icon.json")
+	p := filepath.Join(util.AppearancePath, "icons", iconDirName, "icon.json")
 	if !gulu.File.IsExist(p) {
 		err = os.ErrNotExist
 		return
@@ -107,7 +107,7 @@ func IconJSON(iconDirName string) (ret map[string]interface{}, err error) {
 }
 
 func TemplateJSON(templateDirName string) (ret map[string]interface{}, err error) {
-	p := filepath.Join(util.DataDir, templateDirName, "template.json")
+	p := filepath.Join(util.DataDir, "templates", templateDirName, "template.json")
 	if !gulu.File.IsExist(p) {
 		err = os.ErrNotExist
 		return

+ 1 - 0
kernel/server/serve.go

@@ -67,6 +67,7 @@ func Serve(fastMode bool) {
 	serveExport(ginServer)
 	serveWidgets(ginServer)
 	serveEmojis(ginServer)
+	serveTemplates(ginServer)
 	api.ServeAPI(ginServer)
 
 	var addr string