From 3636cb86e245645985eec301dcc7150719e181c6 Mon Sep 17 00:00:00 2001 From: Gregory Brzezinski Date: Sat, 22 Jul 2023 18:55:23 +0300 Subject: [PATCH 1/5] New icons format --- apps/appCtx/appContext.go | 1 + libs/imglib.go | 17 +++++++++++++++++ main.go | 1 + test-img/16.png | 3 +++ test-img/32.png | 3 +++ wde/wde.go | 12 ++++++------ 6 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 test-img/16.png create mode 100644 test-img/32.png diff --git a/apps/appCtx/appContext.go b/apps/appCtx/appContext.go index 44c4f9a..72690ce 100644 --- a/apps/appCtx/appContext.go +++ b/apps/appCtx/appContext.go @@ -1,5 +1,6 @@ package appCtx +//TODO to websiteapp package type AppContext struct { IsMobile bool `json:"isMobile"` BundlePath string `json:"bundlePath"` diff --git a/libs/imglib.go b/libs/imglib.go index 9ec9eb9..061a206 100644 --- a/libs/imglib.go +++ b/libs/imglib.go @@ -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) { diff --git a/main.go b/main.go index 73a1dae..9666ba3 100644 --- a/main.go +++ b/main.go @@ -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 diff --git a/test-img/16.png b/test-img/16.png new file mode 100644 index 0000000..48c03b8 --- /dev/null +++ b/test-img/16.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5372e8f8659b9c1b70def20ffdbc418710eb96503a44992e13246941a589d6e +size 567 diff --git a/test-img/32.png b/test-img/32.png new file mode 100644 index 0000000..4e95f49 --- /dev/null +++ b/test-img/32.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83a18ca489a0483d157c7d7728f902bfef6ae0305a8a4ed40e72075b7e1b5705 +size 1238 diff --git a/wde/wde.go b/wde/wde.go index 2103996..9f89d33 100644 --- a/wde/wde.go +++ b/wde/wde.go @@ -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 } } From 68664c1bf3ca5b42637113920732e6af7fa4918c Mon Sep 17 00:00:00 2001 From: Gregory Brzezinski Date: Sat, 22 Jul 2023 18:56:51 +0300 Subject: [PATCH 2/5] Add todo --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index 9666ba3..4da682a 100644 --- a/main.go +++ b/main.go @@ -86,6 +86,7 @@ func main() { routes.PrivateRoutes(privatePort, webfs, webde, appsStorage) } +// TODO to for loop with aal vars in slice func FindEnv(parameter string) (string, error) { path, exists := os.LookupEnv(parameter) From 46e3bcf8657a8043648e9ac636042ad234de6c33 Mon Sep 17 00:00:00 2001 From: Gregory Brzezinski Date: Sat, 22 Jul 2023 21:15:17 +0300 Subject: [PATCH 3/5] Add obsolete notation --- apps/finder/routes.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/finder/routes.go b/apps/finder/routes.go index 2da8522..b34413e 100644 --- a/apps/finder/routes.go +++ b/apps/finder/routes.go @@ -21,9 +21,11 @@ func (f *FinderApplication) PublicRoutes(routes *gin.RouterGroup) { ctx.HTML(http.StatusOK, "finder/app.tmpl", f.Render(appCtx)) }) + //Obsolete routes.GET("renderMobileDesktop", func(ctx *gin.Context) { ctx.HTML(http.StatusOK, "finder/mobile-desktop.tmpl", gin.H{}) }) + routes.POST("renderDesktop", func(ctx *gin.Context) { path := ctx.Query("path") if path == "" { From 265f57e2de2b09977553b6c4454acf815b7bd9b9 Mon Sep 17 00:00:00 2001 From: Gregory Brzezinski Date: Sat, 22 Jul 2023 21:15:42 +0300 Subject: [PATCH 4/5] rename finder template --- templates/finder/{props.tmpl => props.html} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename templates/finder/{props.tmpl => props.html} (85%) diff --git a/templates/finder/props.tmpl b/templates/finder/props.html similarity index 85% rename from templates/finder/props.tmpl rename to templates/finder/props.html index 6fe765b..29f3891 100644 --- a/templates/finder/props.tmpl +++ b/templates/finder/props.html @@ -1,13 +1,13 @@ {{ define "finder/props.tmpl" }} -
- -
-
- File Properties +
+ +
+
+ Properties
-
+
-
+
From 559c22f6269b2a3035fa1d4d27dc6501ffb2b42b Mon Sep 17 00:00:00 2001 From: Gregory Brzezinski Date: Sat, 22 Jul 2023 21:16:00 +0300 Subject: [PATCH 5/5] Fix wde fs import --- front/src/apps/finder/finder-window.js | 54 ++++++++++++++----- front/src/apps/finder/finder.js | 1 - front/src/wde/wde.js | 16 +++++- front/src/wde/widgets/file-view/file-view.js | 4 +- .../src/wde/widgets/file-view/file-view.less | 16 +++--- front/src/web-fs/web-fs.js | 2 +- 6 files changed, 65 insertions(+), 28 deletions(-) diff --git a/front/src/apps/finder/finder-window.js b/front/src/apps/finder/finder-window.js index f7c6952..2afb6aa 100644 --- a/front/src/apps/finder/finder-window.js +++ b/front/src/apps/finder/finder-window.js @@ -98,9 +98,9 @@ export default class FinderWindow{ () => { this.ReRenderDir() }, this.#wde) - // newWindow.querySelector("#closeWindowButton").addEventListener('click', () => { - // this.#wde.Decorat.CloseWindow(newWindow) - // }) + newWindow.querySelector("#closeWindowButton").addEventListener('click', () => { + this.#wde.Decorat.CloseWindow(newWindow) + }) // newWindow.querySelector("#RootButton").addEventListener('click', () =>{ // this.RenderDir('/') @@ -126,7 +126,6 @@ export default class FinderWindow{ * @returns */ async CreateMobileView(args, runContext){ - const params = new URLSearchParams({isMobile: false}) //FIXME const response = await fetch(`/app/${this.#appId}/render?` + params, { @@ -135,14 +134,41 @@ export default class FinderWindow{ }) if (response.status != 200){ const error = await response.json() - this.#wde.Alert(error.message) + this.#finder.WDE().Alert(error.message) return } const html = await response.text() - console.log(this.#wde) - let newView = this.#wde.Decorat.CreateNewView(this.#appId) + // console.log(html) + // console.log(this.#finder.WDE()) + let newView = this.#finder.WDE().Decorat.CreateNewView(this.#appId) newView.innerHTML = html + + this.fileView = new this.#wde.FileView( + newView.querySelector(".FileTileView"), + (event) => { this.Click(event) }, + (event) => { this.RightClick(event) }, + (event, draggedElem) => { this.DropEvent(event, draggedElem)}, + () => { this.ReRenderDir() }, + this.#wde) + + // newView.querySelector("#closeWindowButton").addEventListener('click', () => { + // this.#wde.Decorat.CloseWindow(newView) + // }) + + // newView.querySelector("#RootButton").addEventListener('click', () =>{ + // this.RenderDir('/') + // }) + + // newView.querySelector("#HomeButton").addEventListener('click', () =>{ + // this.RenderDir('/home/user') + // }) + + // let scrollBar = new this.#wde.ScrollBar(newView.querySelector(".scrollbar-place"), newView.querySelector(".FileTileView")) + + this.windowElem = newView + this.RenderDir(args[0]) } + /** * @param {string} path */ @@ -304,30 +330,30 @@ export default class FinderWindow{ let res = false switch (event.target.children[0].getAttribute("action")) { case "createPathLink": - res = await WebFS.CreatePathLink(`${this.curPath}/${fileName}`, `${this.curPath}/Link to ${fileName}` ) + res = await this.#finder.WDE().WebFS().CreatePathLink(`${this.curPath}/${fileName}`, `${this.curPath}/Link to ${fileName}` ) if (res){ this.ReRenderDir() } break case "createDir": - res = await WebFS.CreateDirectory(`${this.curPath}`) - console.log(res) + res = await this.#finder.WDE().WebFS().CreateDirectory(`${this.curPath}`) + // console.log(res) if (res){ this.ReRenderDir() } break case "deleteFile": - res = await WebFS.DeleteFile(`${this.curPath}/${fileName}`) - console.log(res) + res = await this.#finder.WDE().WebFS().DeleteFile(`${this.curPath}/${fileName}`) + // console.log(res) if (res){ this.ReRenderDir() } break case "getInfo": - Finder.RenderProperites(path) + this.#finder.RenderProperites(path) break case "openAsDir": - this.#wde.Open(`/Applications/${this.#appId}.app`,[`${this.curPath}/${fileName}`]) + this.#finder.WDE().Open(`/Applications/${this.#appId}.app`,[`${this.curPath}/${fileName}`]) break default: break; diff --git a/front/src/apps/finder/finder.js b/front/src/apps/finder/finder.js index b2b2499..7c5c035 100644 --- a/front/src/apps/finder/finder.js +++ b/front/src/apps/finder/finder.js @@ -41,7 +41,6 @@ export default class Finder extends WDEApplication{ * @returns {boolean} */ async RenderProperites(path){ - // return if (path == null || path ==""){ return } diff --git a/front/src/wde/wde.js b/front/src/wde/wde.js index 0831e97..a9d9d5f 100644 --- a/front/src/wde/wde.js +++ b/front/src/wde/wde.js @@ -1,5 +1,5 @@ import WDEApplication from "./application.js" - +import WebFS from "../web-fs/web-fs.js" export default class AbstractWebDesktopEnvironment{ /** @type {string} */ #apiAddress @@ -7,12 +7,19 @@ export default class AbstractWebDesktopEnvironment{ _applications = {} /** @type {AbstractWebDesktopEnvironment} */ #wde + /** @type {WebFS} */ + #webFS + /** @constructor */ constructor(apiAddress){ this.#apiAddress = apiAddress + this.#webFS = WebFS } - /** @returns {string} */ + /** + * @deprecated + * @returns {string} + */ GetApiAddress(){ return `${location.protocol}//${this.#apiAddress}` } @@ -85,6 +92,11 @@ export default class AbstractWebDesktopEnvironment{ // console.log(appId) return this._applications[appId] } + + /** @returns {WebFS} */ + WebFS(){ + return this.#webFS + } } /** diff --git a/front/src/wde/widgets/file-view/file-view.js b/front/src/wde/widgets/file-view/file-view.js index 222a419..d1b255a 100644 --- a/front/src/wde/widgets/file-view/file-view.js +++ b/front/src/wde/widgets/file-view/file-view.js @@ -126,10 +126,10 @@ export default class WDEFileView{ const params = new URLSearchParams({ path: path }) - const response = await fetch(`${this.#wde.GetApiAddress()}/system/wde/widgets/file-tile-view?` + params) + const response = await fetch(`/system/wde/widgets/file-tile-view?` + params) if (response.status != 200){ //TODO Error text message - WebDesktopEnvironment.Alert("TODO") + WebDesktopEnvironment.Alert("TODO") //TODO return } let html = await response.text() diff --git a/front/src/wde/widgets/file-view/file-view.less b/front/src/wde/widgets/file-view/file-view.less index 0b9072b..7073b4c 100644 --- a/front/src/wde/widgets/file-view/file-view.less +++ b/front/src/wde/widgets/file-view/file-view.less @@ -3,7 +3,7 @@ width: 100%; height: 100%; - background-color: @col-white; + // background-color: @col-white; @@ -65,13 +65,13 @@ /* background-image: url("./icons/folder.png"); */ background-size: cover; - image-rendering: optimizeSpeed; /* STOP SMOOTHING, GIVE ME SPEED */ - image-rendering: -moz-crisp-edges; /* Firefox */ - image-rendering: -o-crisp-edges; /* Opera */ - image-rendering: -webkit-optimize-contrast; /* Chrome (and eventually Safari) */ - image-rendering: pixelated; /* Universal support since 2021 */ - image-rendering: optimize-contrast; /* CSS3 Proposed */ - -ms-interpolation-mode: nearest-neighbor; /* IE8+ */ + // image-rendering: optimizeSpeed; /* STOP SMOOTHING, GIVE ME SPEED */ + // image-rendering: -moz-crisp-edges; /* Firefox */ + // image-rendering: -o-crisp-edges; /* Opera */ + // image-rendering: -webkit-optimize-contrast; /* Chrome (and eventually Safari) */ + // image-rendering: pixelated; /* Universal support since 2021 */ + // image-rendering: optimize-contrast; /* CSS3 Proposed */ + // -ms-interpolation-mode: nearest-neighbor; /* IE8+ */ } .FileTileView .Selected .Icon{ diff --git a/front/src/web-fs/web-fs.js b/front/src/web-fs/web-fs.js index 133fd8c..5b94cf3 100644 --- a/front/src/web-fs/web-fs.js +++ b/front/src/web-fs/web-fs.js @@ -3,7 +3,7 @@ export default class WebFS{ * @param {string} path * @returns {boolean} */ - static async CreateDirectory(path){ + static async CreateDirectory(path){ if (path == undefined){ WebDesktopEnvironment.Alert("Path is undefined") return false