New icons format

This commit is contained in:
Gregory Brzezinski 2023-07-22 18:55:23 +03:00
parent 9f60c185ad
commit 3636cb86e2
6 changed files with 31 additions and 6 deletions

View File

@ -1,5 +1,6 @@
package appCtx
//TODO to websiteapp package
type AppContext struct {
IsMobile bool `json:"isMobile"`
BundlePath string `json:"bundlePath"`

View File

@ -2,6 +2,7 @@ package libs
import (
"net/http"
"path"
"personalwebsite/webfilesystem"
"github.com/gin-gonic/gin"
@ -35,6 +36,22 @@ func (l *ImagLib) PublicRoutes(route *gin.RouterGroup) {
ctx.Data(http.StatusOK, "image/jpeg", imgData.Bin)
})
iconGroup := route.Group("icon")
iconGroup.GET("get", func(ctx *gin.Context) {
iconPath := ctx.Query("path")
iconType := ctx.Query("type")
_ = iconType
iconSize := ctx.Query("size")
imgData := Img{}
_, err := l.fs.Read(path.Join(iconPath, "color", iconSize+".png"), &imgData)
if err != nil {
ctx.Status(http.StatusInternalServerError)
return
}
ctx.Data(http.StatusOK, "image/jpeg", imgData.Bin)
})
}
func GetBase64Image(img *Base64Img, min string) (string, error) {

View File

@ -74,6 +74,7 @@ func main() {
blogViewerApp := blogviewer.NewBlogViewerApp(webfs)
blogWriterApp := blogwriter.NewBlogWriterApp(webfs)
sunBoardApp := sunboard.NewSunboardApp(webfs, appsStorage)
appsStorage.Apps["personal-properties"] = persPropsApp
appsStorage.Apps["finder"] = finderApp
appsStorage.Apps["img-viewer"] = imgViewerApp

BIN
test-img/16.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
test-img/32.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -28,28 +28,28 @@ func (w *WDE) RenderFileTileView(directory string, host string) (gin.H, error) {
}
for _, file := range list {
file.Icon = w.GetIconPathForFile(file, directory)
file.Icon = w.GetIconPathForFile(file, directory, "32")
}
return gin.H{
"Files": list,
}, nil
}
func (w *WDE) GetIconPathForFile(fileHeader *webfilesystem.FileHeader, parentDir string) string {
func (w *WDE) GetIconPathForFile(fileHeader *webfilesystem.FileHeader, parentDir string, size string) string {
if fileHeader.Icon != "" {
return "/system/libs/img/get?path=" + fileHeader.Icon
return "/system/libs/img/icon/get?path=" + fileHeader.Icon
}
switch fileHeader.GetType() {
case "directory":
return "/system/libs/img/get?path=/wde/icons/macos9/folder.png"
return "/system/libs/img/icon/get?path=/Icons2/GenericFolder.icn&size=" + size
case "jpeg":
fallthrough
case "png":
fallthrough
case "jpg":
return "/system/libs/img/get?path=" + path.Join(parentDir, fileHeader.Name)
return "/system/libs/img/icon/get?path=" + path.Join(parentDir, fileHeader.Name) + "&size=" + size
default:
return "/system/libs/img/get?path=/wde/icons/macos9/folder.png"
return "/system/libs/img/icon/get?path=/Icons2/GenericFolder.icn&size=" + size
}
}