diff --git a/main.go b/main.go index aeec993..7edcb95 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "personalwebsite/routewde" "personalwebsite/websiteapp" "personalwebsite/websiteapp/finder" + imgviewer "personalwebsite/websiteapp/img-viewer" "personalwebsite/websiteapp/personalprops" "github.com/gin-gonic/gin" @@ -39,11 +40,13 @@ func main() { persPropsApp := personalprops.NewPersPropsApp() finderApp := finder.FinerApplication{} + imgViewerApp := imgviewer.NewImgViewerApp() appsStorage := websiteapp.ApplicationsStorage{ Apps: map[string]websiteapp.WebDEApplication{}, } appsStorage.Apps["personal-properties"] = &persPropsApp appsStorage.Apps["finder"] = &finderApp + appsStorage.Apps["img-viewer"] = &imgViewerApp system := router.Group("system") { @@ -96,6 +99,12 @@ func main() { ctx.HTML(http.StatusOK, "finder/app.tmpl", finderApp.Render()) }) } + imgViewerRoute := app.Group("img-viewer") + { + imgViewerRoute.GET("render", func(ctx *gin.Context) { + ctx.HTML(http.StatusOK, "img-viewer/app.tmpl", imgViewerApp.Render()) + }) + } } router.GET("/test", func(ctx *gin.Context) { ctx.HTML(200, "kek/kek.tmpl", gin.H{}) diff --git a/resources/sys/finder/finder.js b/resources/sys/finder/finder.js index acb7f1b..07a8a53 100644 --- a/resources/sys/finder/finder.js +++ b/resources/sys/finder/finder.js @@ -39,7 +39,10 @@ class Finder{ case "lol": WebDesktopEnvironment.Open("finder", ["pizda"]) break; - default: + case "img": + WebDesktopEnvironment.Open("img-viewer", ["pizda"]) + break; + default: console.log("Unsupported file type") break; } diff --git a/resources/sys/img-viewer/img-viewer.css b/resources/sys/img-viewer/img-viewer.css new file mode 100644 index 0000000..026b13f --- /dev/null +++ b/resources/sys/img-viewer/img-viewer.css @@ -0,0 +1,17 @@ +.Img-Viewer-Picture-Container{ + width: 100%; + height: 100%; +} +.Img-Viewer-Picture{ + width: 100%; + height: 100%; + background-image: url("./test-image.jpg"); + background-size: contain; + background-repeat: no-repeat; + background-position: center center; +} + +.Img-Viewer-Picture-Toolbar{ + width: 100%; + height: 35px; +} \ No newline at end of file diff --git a/resources/sys/img-viewer/img-viewer.js b/resources/sys/img-viewer/img-viewer.js new file mode 100644 index 0000000..d3881a6 --- /dev/null +++ b/resources/sys/img-viewer/img-viewer.js @@ -0,0 +1,29 @@ +class ImgViewer{ + appId = "img-viewer" + /** + * @param {string} path + */ + NewWindow(path){ + fetch(`${window.location.origin}/application/${this.appId}/render`) //TODO Move to wde func. Or Not? + .then((response) => response.text()) + .then((html) => { + let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 450,400 ) + + newWindow.innerHTML = html + + let closeButton = newWindow.children[0].children[0] + + closeButton.addEventListener('click', function (params) { + WebDesktopEnvironment.CloseWindow(newWindow) + }) + }) + .catch((error) => { + WebDesktopEnvironment.Alert(error); + }); + } +} + + +class test{ + +} diff --git a/resources/sys/img-viewer/test-image.jpg b/resources/sys/img-viewer/test-image.jpg new file mode 100644 index 0000000..f251a9f --- /dev/null +++ b/resources/sys/img-viewer/test-image.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e5abf23d3425bf839e9b2568b2aaec46edeb554199bbd3f4f1b7b32dc84cb04 +size 7507624 diff --git a/resources/wde.js b/resources/wde.js index 4e4dd0d..7087a24 100644 --- a/resources/wde.js +++ b/resources/wde.js @@ -49,6 +49,11 @@ class WebDesktopEnvironment{ this.Applications[appId] = newPersonalPropertiesApp func() return newPersonalPropertiesApp + case "img-viewer": + let newImgViewer = new ImgViewer() + this.Applications[appId] = newImgViewer + func() + return newImgViewer default: break; } diff --git a/templates/base/index.tmpl b/templates/base/index.tmpl index ebce62a..c769426 100644 --- a/templates/base/index.tmpl +++ b/templates/base/index.tmpl @@ -6,6 +6,7 @@ + diff --git a/templates/img-viewer/app.tmpl b/templates/img-viewer/app.tmpl new file mode 100644 index 0000000..90caa45 --- /dev/null +++ b/templates/img-viewer/app.tmpl @@ -0,0 +1,20 @@ +{{ define "img-viewer/app.tmpl" }} +