icons and title-bar as widget

This commit is contained in:
cyber-dream 2023-07-23 02:55:08 +03:00
parent 766b7ac4bf
commit b79b65868c
18 changed files with 133 additions and 53 deletions

View File

@ -8,6 +8,7 @@ import (
"personalwebsite/apps/appCtx" "personalwebsite/apps/appCtx"
"personalwebsite/errormessage" "personalwebsite/errormessage"
"personalwebsite/libs" "personalwebsite/libs"
"personalwebsite/wde"
"personalwebsite/webfilesystem" "personalwebsite/webfilesystem"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -15,15 +16,20 @@ import (
) )
type AboutMeApp struct { type AboutMeApp struct {
fs *webfilesystem.WebFileSystem fs *webfilesystem.WebFileSystem
appID string appID string
mLib libs.MarkdownLib mLib libs.MarkdownLib
titleBarConfig wde.TitleBarConfig //TODO to app manifest?
} }
func NewAboutMeApp(webFs *webfilesystem.WebFileSystem) *AboutMeApp { func NewAboutMeApp(webFs *webfilesystem.WebFileSystem) *AboutMeApp {
newApp := AboutMeApp{ newApp := AboutMeApp{
fs: webFs, fs: webFs,
appID: "AboutMe", appID: "AboutMe",
titleBarConfig: wde.TitleBarConfig{
Lable: "About Me",
CloseButton: true,
},
} }
return &newApp return &newApp
} }
@ -253,9 +259,10 @@ func (p *AboutMeApp) Render(appCtx appCtx.AppContext, filePath string) (gin.H, e
} }
return gin.H{ return gin.H{
"HeaderProps": propsData.Header, "TitleBarConfig": p.titleBarConfig,
"Links": absoluteLinks, "HeaderProps": propsData.Header,
"Islands": renderedIslands, "Links": absoluteLinks,
"Islands": renderedIslands,
}, nil }, nil
} }

View File

@ -9,8 +9,9 @@ import (
) )
type FinderApplication struct { type FinderApplication struct {
fs *webfilesystem.WebFileSystem fs *webfilesystem.WebFileSystem
appID string appID string
titleBarConfig wde.TitleBarConfig
// manifest apps.ApplicationManifest // manifest apps.ApplicationManifest
} }
@ -18,6 +19,10 @@ func NewFinderApplication(webFs *webfilesystem.WebFileSystem) *FinderApplication
return &FinderApplication{ return &FinderApplication{
fs: webFs, fs: webFs,
appID: "Finder", appID: "Finder",
titleBarConfig: wde.TitleBarConfig{
Lable: "Finder",
CloseButton: true,
},
} }
} }
@ -26,7 +31,9 @@ func (f *FinderApplication) GetAppID() string {
} }
func (f *FinderApplication) Render(appCtx appCtx.AppContext) gin.H { func (f *FinderApplication) Render(appCtx appCtx.AppContext) gin.H {
return gin.H{} return gin.H{
"TitleBarConfig": f.titleBarConfig,
}
} }
func (f *FinderApplication) RenderPublicContextMenu(context string, filePath string, data string) gin.H { func (f *FinderApplication) RenderPublicContextMenu(context string, filePath string, data string) gin.H {

View File

@ -87,8 +87,9 @@ export default class FinderWindow{
let newWindow = this.#wde.Decorat.CreateNewWindow(this.#appId, 500, 350 ) let newWindow = this.#wde.Decorat.CreateNewWindow(this.#appId, 500, 350 )
newWindow.innerHTML = html newWindow.innerHTML = html
newWindow.querySelector(".title-bar").querySelector(".icon").setAttribute("src","/system/libs/img/icon/get?path=/Icons/GenericFolder.icn&size=16")
console.log(newWindow.querySelector(".FileTileView")) // console.log(newWindow.querySelector(".FileTileView"))
this.fileView = new this.#wde.FileView( this.fileView = new this.#wde.FileView(
newWindow.querySelector(".FileTileView"), newWindow.querySelector(".FileTileView"),
@ -190,7 +191,7 @@ export default class FinderWindow{
if (event.dataTransfer.getData("dropType") == "move"){ if (event.dataTransfer.getData("dropType") == "move"){
const sourcePath= event.dataTransfer.getData("filePath") const sourcePath= event.dataTransfer.getData("filePath")
const targetPath = this.curPath + "/" + event.dataTransfer.getData("fileName") const targetPath = this.curPath + "/" + event.dataTransfer.getData("fileName")
const res = await WebFS.MoveFile(sourcePath, targetPath) const res = await this.#finder.WDE().WebFS().MoveFile(sourcePath, targetPath)
if (res){ if (res){
this.ReRenderDir() this.ReRenderDir()
} else { } else {
@ -203,7 +204,7 @@ export default class FinderWindow{
const file = files[i]; const file = files[i];
console.log("file:" + file.name) console.log("file:" + file.name)
const res = await WebFS.UploadFile(file, this.curPath) const res = await this.#finder.WDE().WebFS().UploadFile(file, this.curPath)
if (res){ if (res){
this.ReRenderDir() this.ReRenderDir()
} }
@ -233,6 +234,14 @@ export default class FinderWindow{
this.OpenFile(this.curPath, event.target.getAttribute("name"), event.target.getAttribute("filetype")) this.OpenFile(this.curPath, event.target.getAttribute("name"), event.target.getAttribute("filetype"))
} }
/**
*
* @param {string} fileName
*/
getFileExtension(fileName){
return fileName.split(".")[fileName.split(".").length - 1] //FIXME
}
/** /**
* @param {string} filePath * @param {string} filePath
*/ */
@ -240,11 +249,12 @@ export default class FinderWindow{
// console.log(parentPath, fileName, fileType) // console.log(parentPath, fileName, fileType)
// const splittedPath = filePath.split("/") // const splittedPath = filePath.split("/")
// const fileName = splittedPath[splittedPath.length - 1] // const fileName = splittedPath[splittedPath.length - 1]
const fileExtension = fileName.split(".")[fileName.split(".").length - 1] //FIXME
const fileExtension = this.getFileExtension(fileName)
console.log(fileExtension)
switch (true) { switch (true) {
case fileType == "objectlink": case fileType == "objectlink":
this.#wde.Alert("Links not supported yet") this.#finder.WDE().Alert("Links not supported yet")
break break
case fileType == "pathlink": case fileType == "pathlink":
let res = await WebFS.ReadPathLink(`${parentPath}/${fileName}`) let res = await WebFS.ReadPathLink(`${parentPath}/${fileName}`)
@ -252,22 +262,22 @@ export default class FinderWindow{
this.OpenFile(res.parentPath, res.name, res.filetype) this.OpenFile(res.parentPath, res.name, res.filetype)
break break
case fileExtension == "app": case fileExtension == "app":
this.#wde.Open(`${parentPath}/${fileName}`, []) this.#finder.WDE().Open(`${parentPath}/${fileName}`, [])
break break
case fileExtension == "blog": case fileExtension == "blog":
this.#wde.Open(`/Applications/BlogViewer.app`, [`${parentPath}/${fileName}`]) this.#finder.WDE().Open(`/Applications/BlogViewer.app`, [`${parentPath}/${fileName}`])
break break
case fileType == "directory": case fileType == "directory":
this.#wde.Open(`/Applications/Finder.app`, [`${parentPath}/${fileName}`]) this.#finder.WDE().Open(`/Applications/Finder.app`, [`${parentPath}/${fileName}`])
break break
case fileExtension == "blog": case fileExtension == "blog":
this.#wde.Open("/Applications/BlogViewer.app", [`${parentPath}/${fileName}`]) this.#finder.WDE().Open("/Applications/BlogViewer.app", [`${parentPath}/${fileName}`])
break break
case fileExtension == "jpeg" | fileExtension == "png": case fileExtension == "jpeg" | fileExtension == "png":
this.#wde.Open("img-viewer", [`${parentPath}/${fileName}`]) this.#finder.WDE().Open("img-viewer", [`${parentPath}/${fileName}`])
break; break;
default: default:
this.#wde.Alert("Unsupported file type") this.#finder.WDE().Alert("Unsupported file type")
break; break;
} }
} }

View File

@ -1,12 +1,14 @@
@import "./wde/sunboard/sunboard-mobile.less"; @import "./wde/sunboard/sunboard-mobile.less";
body{ body{
zoom: 2; // zoom: 2;
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
margin: 0px; margin: 0px;
font-size: 16px;
/* font: normal 14px Summer Pixel 22, "res/SummerPixel22Regular.ttf"; */ /* font: normal 14px Summer Pixel 22, "res/SummerPixel22Regular.ttf"; */
-webkit-touch-callout: none; /* iOS Safari */ -webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */ -webkit-user-select: none; /* Safari */

View File

@ -36,8 +36,8 @@ export default class WebDesktopEnvironment extends AbstractWebDesktopEnvironment
async loadWDE(){ async loadWDE(){
await this.Open("/Applications/Finder.app", ["/","--desktop", "desktop-layer"]) await this.Open("/Applications/Finder.app", ["/","--desktop", "desktop-layer"])
// await this.Open("/Applications/Finder.app", ["/", "desktop-layer"]) await this.Open("/Applications/Finder.app", ["/", "desktop-layer"])
await this.Open("/Applications/AboutMe.app", ["/", "desktop-layer"]) // await this.Open("/Applications/AboutMe.app", ["/", "desktop-layer"])
return return
let autoStart = document.body.querySelector("wde-autostart") let autoStart = document.body.querySelector("wde-autostart")

View File

@ -32,6 +32,10 @@
letter-spacing: 0.35px; letter-spacing: 0.35px;
} }
.window-frame.Focused .title-bar .lable{
color: @col-black;
}
.window-frame.Focused .title-bar .visual-drag-area{ .window-frame.Focused .title-bar .visual-drag-area{
&:extend(.rows-fill-shadowed); &:extend(.rows-fill-shadowed);
pointer-events: none; pointer-events: none;
@ -39,16 +43,28 @@
height: 11px; height: 11px;
} }
.title-bar > .icon{
// background-color: aqua;
width: 16px;
height: 16px;
}
.title-bar .button{ .title-bar > .button{
width: 11px; width: 11px;
height: 11px; height: 11px;
padding: 0%; padding: 0%;
position: relative; position: relative;
top: 1px; top: 1px;
visibility: hidden; visibility: hidden;
&:active{
background-color: rgba(0, 0, 0, 0.4);
/* Green */
box-shadow: 0.5px 0.5px 0px 0.5px #FFFFFF,
-0.5px -0.5px 0px 0.5px rgba(0, 0, 0, 0.25);
}
background: linear-gradient(135deg, #999999 18.18%, #FFFFFF 81.82%); background: linear-gradient(135deg, #999999 18.18%, #FFFFFF 81.82%);
border: 1px solid @col-raisin-black; border: 1px solid @col-raisin-black;
box-shadow: 0.5px 0.5px 0px 0.5px #FFFFFF, box-shadow: 0.5px 0.5px 0px 0.5px #FFFFFF,
@ -61,6 +77,10 @@
flex-grow: 0; flex-grow: 0;
} }
.Focused .title-bar .button{ .window-frame.Focused .title-bar > .button{
visibility:visible; visibility:visible;
} }
// .window-frame.Focused .title-bar > .button:active{
// background-color: aqua;
// }

BIN
icons/genericApp/color/16.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
icons/genericApp/color/32.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
icons/genericDocument/color/16.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
icons/genericDocument/color/32.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
icons/genericFolder/color/16.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
icons/genericFolder/color/32.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,13 +1,5 @@
{{ define "finder/admin-app.tmpl" }} {{ define "finder/admin-app.tmpl" }}
<div class="title-bar DragArea"> {{template "wde-widgets/window-title-bar.tmpl" .TitleBarConfig}}
<button id="closeWindowButton" class="button" title="Close Window"></button>
<div id="Drag" class="visual-drag-area"></div>
<div class="lable">
Admin Finder
</div>
<div id="Drag" class="visual-drag-area"></div>
</div>
<div id="ContentBorder" class="content-border AdjectiveElement"> <div id="ContentBorder" class="content-border AdjectiveElement">
<div class="finder-content"> <div class="finder-content">

View File

@ -1,10 +1,5 @@
{{ define "personal-properties/app.tmpl" }} {{ define "personal-properties/app.tmpl" }}
<div class="title-bar DragArea"> {{template "wde-widgets/window-title-bar.tmpl" .TitleBarConfig}}
<button id="closeWindowButton" class="Button" title="Close Window"></button>
<div id="Drag" class="visual-drag-area"></div>
<div class="Lable">About me</div>
<div id="Drag" class="visual-drag-area"></div>
</div>
<div class="content-border"> <div class="content-border">
<div class="PersPropsContent"> <div class="PersPropsContent">
<div class="PropsView"> <div class="PropsView">

View File

@ -0,0 +1,14 @@
{{ define "wde-widgets/window-title-bar.tmpl" }}
<div class="title-bar DragArea">
{{if .CloseButton}}
<button id="closeWindowButton" class="button" title="Close Window"></button>
{{end}}
<div id="Drag" class="visual-drag-area"></div>
<!-- TODO:Disable dragging of icon -->
<img class="icon">
<div class="lable">
{{.Lable}}
</div>
<div id="Drag" class="visual-drag-area"></div>
</div>
{{ end }}

6
wde/titlebar.go Normal file
View File

@ -0,0 +1,6 @@
package wde
type TitleBarConfig struct {
Lable string
CloseButton bool
}

View File

@ -37,19 +37,23 @@ func (w *WDE) RenderFileTileView(directory string, host string) (gin.H, error) {
func (w *WDE) GetIconPathForFile(fileHeader *webfilesystem.FileHeader, parentDir string, size string) string { func (w *WDE) GetIconPathForFile(fileHeader *webfilesystem.FileHeader, parentDir string, size string) string {
if fileHeader.Icon != "" { if fileHeader.Icon != "" {
return "/system/libs/img/icon/get?path=" + fileHeader.Icon return "/system/libs/img/icon/get?path=" + fileHeader.Icon + "&size=" + size
} }
switch fileHeader.GetType() { extension := fileHeader.GetExtension()
case "directory":
return "/system/libs/img/icon/get?path=/Icons2/GenericFolder.icn&size=" + size switch true {
case "jpeg": case extension == "app":
return "/system/libs/img/icon/get?path=/Icons/GenericApp.icn&size=" + size
case extension == "jpeg":
fallthrough fallthrough
case "png": case extension == "png":
fallthrough fallthrough
case "jpg": case extension == "jpg":
return "/system/libs/img/icon/get?path=" + path.Join(parentDir, fileHeader.Name) + "&size=" + size return "/system/libs/img/get?path=" + path.Join(parentDir, fileHeader.Name) //+ "&size=" + size
case fileHeader.GetType() == "directory":
return "/system/libs/img/icon/get?path=/Icons/GenericFolder.icn&size=" + size
default: default:
return "/system/libs/img/icon/get?path=/Icons2/GenericFolder.icn&size=" + size return "/system/libs/img/icon/get?path=/Icons/GenericDocument.icn&size=" + size
} }
} }

View File

@ -41,6 +41,11 @@ func (fh *FileHeader) GetType() string {
return fh.Type return fh.Type
} }
func (fh *FileHeader) GetExtension() string {
return strings.Split(fh.Name, ".")[len(strings.Split(fh.Name, "."))-1]
}
type BinaryFileData struct { type BinaryFileData struct {
MongoId primitive.ObjectID `bson:"_id" json:"-"` MongoId primitive.ObjectID `bson:"_id" json:"-"`
Bin []byte `bson:"bin" json:"-"` Bin []byte `bson:"bin" json:"-"`