Create img viewer
This commit is contained in:
parent
91cd53c147
commit
4da2a3e556
9
main.go
9
main.go
@ -6,6 +6,7 @@ import (
|
|||||||
"personalwebsite/routewde"
|
"personalwebsite/routewde"
|
||||||
"personalwebsite/websiteapp"
|
"personalwebsite/websiteapp"
|
||||||
"personalwebsite/websiteapp/finder"
|
"personalwebsite/websiteapp/finder"
|
||||||
|
imgviewer "personalwebsite/websiteapp/img-viewer"
|
||||||
"personalwebsite/websiteapp/personalprops"
|
"personalwebsite/websiteapp/personalprops"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -39,11 +40,13 @@ func main() {
|
|||||||
|
|
||||||
persPropsApp := personalprops.NewPersPropsApp()
|
persPropsApp := personalprops.NewPersPropsApp()
|
||||||
finderApp := finder.FinerApplication{}
|
finderApp := finder.FinerApplication{}
|
||||||
|
imgViewerApp := imgviewer.NewImgViewerApp()
|
||||||
appsStorage := websiteapp.ApplicationsStorage{
|
appsStorage := websiteapp.ApplicationsStorage{
|
||||||
Apps: map[string]websiteapp.WebDEApplication{},
|
Apps: map[string]websiteapp.WebDEApplication{},
|
||||||
}
|
}
|
||||||
appsStorage.Apps["personal-properties"] = &persPropsApp
|
appsStorage.Apps["personal-properties"] = &persPropsApp
|
||||||
appsStorage.Apps["finder"] = &finderApp
|
appsStorage.Apps["finder"] = &finderApp
|
||||||
|
appsStorage.Apps["img-viewer"] = &imgViewerApp
|
||||||
system := router.Group("system")
|
system := router.Group("system")
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -96,6 +99,12 @@ func main() {
|
|||||||
ctx.HTML(http.StatusOK, "finder/app.tmpl", finderApp.Render())
|
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) {
|
router.GET("/test", func(ctx *gin.Context) {
|
||||||
ctx.HTML(200, "kek/kek.tmpl", gin.H{})
|
ctx.HTML(200, "kek/kek.tmpl", gin.H{})
|
||||||
|
@ -39,6 +39,9 @@ class Finder{
|
|||||||
case "lol":
|
case "lol":
|
||||||
WebDesktopEnvironment.Open("finder", ["pizda"])
|
WebDesktopEnvironment.Open("finder", ["pizda"])
|
||||||
break;
|
break;
|
||||||
|
case "img":
|
||||||
|
WebDesktopEnvironment.Open("img-viewer", ["pizda"])
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.log("Unsupported file type")
|
console.log("Unsupported file type")
|
||||||
break;
|
break;
|
||||||
|
17
resources/sys/img-viewer/img-viewer.css
Normal file
17
resources/sys/img-viewer/img-viewer.css
Normal file
@ -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;
|
||||||
|
}
|
29
resources/sys/img-viewer/img-viewer.js
Normal file
29
resources/sys/img-viewer/img-viewer.js
Normal file
@ -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{
|
||||||
|
|
||||||
|
}
|
BIN
resources/sys/img-viewer/test-image.jpg
(Stored with Git LFS)
Normal file
BIN
resources/sys/img-viewer/test-image.jpg
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -49,6 +49,11 @@ class WebDesktopEnvironment{
|
|||||||
this.Applications[appId] = newPersonalPropertiesApp
|
this.Applications[appId] = newPersonalPropertiesApp
|
||||||
func()
|
func()
|
||||||
return newPersonalPropertiesApp
|
return newPersonalPropertiesApp
|
||||||
|
case "img-viewer":
|
||||||
|
let newImgViewer = new ImgViewer()
|
||||||
|
this.Applications[appId] = newImgViewer
|
||||||
|
func()
|
||||||
|
return newImgViewer
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="res/wdeUI.css">
|
<link rel="stylesheet" type="text/css" href="res/wdeUI.css">
|
||||||
<link rel="stylesheet" href="/res/sys/wde/simple-scrollbar.css">
|
<link rel="stylesheet" href="/res/sys/wde/simple-scrollbar.css">
|
||||||
<link rel="stylesheet" href="/res/sys/personal-properties/personal-properies.css">
|
<link rel="stylesheet" href="/res/sys/personal-properties/personal-properies.css">
|
||||||
|
<link rel="stylesheet" href="/res/sys/img-viewer/img-viewer.css">
|
||||||
<script src="/res/sys/wde/wde-scrollbar.js"></script>
|
<script src="/res/sys/wde/wde-scrollbar.js"></script>
|
||||||
<script src="/res/sys/wde/file-view.js"></script>
|
<script src="/res/sys/wde/file-view.js"></script>
|
||||||
<script src="res/wde.js"></script>
|
<script src="res/wde.js"></script>
|
||||||
|
20
templates/img-viewer/app.tmpl
Normal file
20
templates/img-viewer/app.tmpl
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{{ define "img-viewer/app.tmpl" }}
|
||||||
|
<div id="TestWindowHeader" class="WindowFrameTopBar">
|
||||||
|
<button id="closeWindowButton" class="WindowFrameTopBarButton" title="Close Window"></button>
|
||||||
|
<div id="Drag" class="WindowDragArea"></div>
|
||||||
|
<div class="WindowFrameTitle">
|
||||||
|
About me
|
||||||
|
</div>
|
||||||
|
<div id="Drag" class="WindowDragArea"></div>
|
||||||
|
</div>
|
||||||
|
<div class="ContentBorder">
|
||||||
|
<!-- <div class="Img-Viewer-Picture-Toolbar">
|
||||||
|
Toolbar
|
||||||
|
</div> -->
|
||||||
|
<div class="Img-Viewer-Picture-Container">
|
||||||
|
<div class="Img-Viewer-Picture">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@ type WebFileSystem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *WebFileSystem) List() []*File {
|
func (fs *WebFileSystem) List() []*File {
|
||||||
return []*File{{uuid.NewString(), "Kek.kek"}, {uuid.NewString(), "lel.lol"}}
|
return []*File{{uuid.NewString(), "Kek.kek"}, {uuid.NewString(), "lel.lol"}, {uuid.NewString(), "lel.img"}}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Folder struct {
|
type Folder struct {
|
||||||
|
35
websiteapp/img-viewer/imgviewer.go
Normal file
35
websiteapp/img-viewer/imgviewer.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package imgviewer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"personalwebsite/websiteapp"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ImgViewerApp struct {
|
||||||
|
manifest websiteapp.ApplicationManifest
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewImgViewerApp() ImgViewerApp {
|
||||||
|
newApp := ImgViewerApp{
|
||||||
|
manifest: websiteapp.ApplicationManifest{
|
||||||
|
AppId: "img-viewer",
|
||||||
|
WindowName: "About me", //TODO: delete
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return newApp
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ImgViewerApp) GetManifest() websiteapp.ApplicationManifest {
|
||||||
|
return p.manifest
|
||||||
|
}
|
||||||
|
func (p *ImgViewerApp) GetId() string {
|
||||||
|
return p.manifest.AppId
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ImgViewerApp) Render() gin.H {
|
||||||
|
return gin.H{
|
||||||
|
"Name": "Greg Brzezinski",
|
||||||
|
"BasicBio": "Born 27.09.1998 at Saint-Petersburg",
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user