Merge branch 'webpack' of http://192.168.88.228:9101/cyber-dream/personal-website into webpack
This commit is contained in:
commit
766b7ac4bf
@ -1,5 +1,6 @@
|
|||||||
package appCtx
|
package appCtx
|
||||||
|
|
||||||
|
//TODO to websiteapp package
|
||||||
type AppContext struct {
|
type AppContext struct {
|
||||||
IsMobile bool `json:"isMobile"`
|
IsMobile bool `json:"isMobile"`
|
||||||
BundlePath string `json:"bundlePath"`
|
BundlePath string `json:"bundlePath"`
|
||||||
|
@ -30,9 +30,11 @@ func (f *FinderApplication) PublicRoutes(routes *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//Obsolete
|
||||||
routes.GET("renderMobileDesktop", func(ctx *gin.Context) {
|
routes.GET("renderMobileDesktop", func(ctx *gin.Context) {
|
||||||
ctx.HTML(http.StatusOK, "finder/mobile-desktop.tmpl", gin.H{})
|
ctx.HTML(http.StatusOK, "finder/mobile-desktop.tmpl", gin.H{})
|
||||||
})
|
})
|
||||||
|
|
||||||
routes.POST("renderDesktop", func(ctx *gin.Context) {
|
routes.POST("renderDesktop", func(ctx *gin.Context) {
|
||||||
path := ctx.Query("path")
|
path := ctx.Query("path")
|
||||||
if path == "" {
|
if path == "" {
|
||||||
|
@ -98,9 +98,9 @@ export default class FinderWindow{
|
|||||||
() => { this.ReRenderDir() },
|
() => { this.ReRenderDir() },
|
||||||
this.#wde)
|
this.#wde)
|
||||||
|
|
||||||
// newWindow.querySelector("#closeWindowButton").addEventListener('click', () => {
|
newWindow.querySelector("#closeWindowButton").addEventListener('click', () => {
|
||||||
// this.#wde.Decorat.CloseWindow(newWindow)
|
this.#wde.Decorat.CloseWindow(newWindow)
|
||||||
// })
|
})
|
||||||
|
|
||||||
// newWindow.querySelector("#RootButton").addEventListener('click', () =>{
|
// newWindow.querySelector("#RootButton").addEventListener('click', () =>{
|
||||||
// this.RenderDir('/')
|
// this.RenderDir('/')
|
||||||
@ -126,7 +126,6 @@ export default class FinderWindow{
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async CreateMobileView(args, runContext){
|
async CreateMobileView(args, runContext){
|
||||||
|
|
||||||
const params = new URLSearchParams({isMobile: false}) //FIXME
|
const params = new URLSearchParams({isMobile: false}) //FIXME
|
||||||
const response = await fetch(`/app/${this.#appId}/render?` + params,
|
const response = await fetch(`/app/${this.#appId}/render?` + params,
|
||||||
{
|
{
|
||||||
@ -135,14 +134,41 @@ export default class FinderWindow{
|
|||||||
})
|
})
|
||||||
if (response.status != 200){
|
if (response.status != 200){
|
||||||
const error = await response.json()
|
const error = await response.json()
|
||||||
this.#wde.Alert(error.message)
|
this.#finder.WDE().Alert(error.message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const html = await response.text()
|
const html = await response.text()
|
||||||
console.log(this.#wde)
|
// console.log(html)
|
||||||
let newView = this.#wde.Decorat.CreateNewView(this.#appId)
|
// console.log(this.#finder.WDE())
|
||||||
|
let newView = this.#finder.WDE().Decorat.CreateNewView(this.#appId)
|
||||||
newView.innerHTML = html
|
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
|
* @param {string} path
|
||||||
*/
|
*/
|
||||||
@ -304,30 +330,30 @@ export default class FinderWindow{
|
|||||||
let res = false
|
let res = false
|
||||||
switch (event.target.children[0].getAttribute("action")) {
|
switch (event.target.children[0].getAttribute("action")) {
|
||||||
case "createPathLink":
|
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){
|
if (res){
|
||||||
this.ReRenderDir()
|
this.ReRenderDir()
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "createDir":
|
case "createDir":
|
||||||
res = await WebFS.CreateDirectory(`${this.curPath}`)
|
res = await this.#finder.WDE().WebFS().CreateDirectory(`${this.curPath}`)
|
||||||
console.log(res)
|
// console.log(res)
|
||||||
if (res){
|
if (res){
|
||||||
this.ReRenderDir()
|
this.ReRenderDir()
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "deleteFile":
|
case "deleteFile":
|
||||||
res = await WebFS.DeleteFile(`${this.curPath}/${fileName}`)
|
res = await this.#finder.WDE().WebFS().DeleteFile(`${this.curPath}/${fileName}`)
|
||||||
console.log(res)
|
// console.log(res)
|
||||||
if (res){
|
if (res){
|
||||||
this.ReRenderDir()
|
this.ReRenderDir()
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "getInfo":
|
case "getInfo":
|
||||||
Finder.RenderProperites(path)
|
this.#finder.RenderProperites(path)
|
||||||
break
|
break
|
||||||
case "openAsDir":
|
case "openAsDir":
|
||||||
this.#wde.Open(`/Applications/${this.#appId}.app`,[`${this.curPath}/${fileName}`])
|
this.#finder.WDE().Open(`/Applications/${this.#appId}.app`,[`${this.curPath}/${fileName}`])
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -41,7 +41,6 @@ export default class Finder extends WDEApplication{
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
async RenderProperites(path){
|
async RenderProperites(path){
|
||||||
// return
|
|
||||||
if (path == null || path ==""){
|
if (path == null || path ==""){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import WDEApplication from "./application.js"
|
import WDEApplication from "./application.js"
|
||||||
|
import WebFS from "../web-fs/web-fs.js"
|
||||||
export default class AbstractWebDesktopEnvironment{
|
export default class AbstractWebDesktopEnvironment{
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
#apiAddress
|
#apiAddress
|
||||||
@ -7,12 +7,19 @@ export default class AbstractWebDesktopEnvironment{
|
|||||||
_applications = {}
|
_applications = {}
|
||||||
/** @type {AbstractWebDesktopEnvironment} */
|
/** @type {AbstractWebDesktopEnvironment} */
|
||||||
#wde
|
#wde
|
||||||
|
/** @type {WebFS} */
|
||||||
|
#webFS
|
||||||
|
|
||||||
/** @constructor */
|
/** @constructor */
|
||||||
constructor(apiAddress){
|
constructor(apiAddress){
|
||||||
this.#apiAddress = apiAddress
|
this.#apiAddress = apiAddress
|
||||||
|
this.#webFS = WebFS
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {string} */
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
GetApiAddress(){
|
GetApiAddress(){
|
||||||
return `${location.protocol}//${this.#apiAddress}`
|
return `${location.protocol}//${this.#apiAddress}`
|
||||||
}
|
}
|
||||||
@ -85,6 +92,11 @@ export default class AbstractWebDesktopEnvironment{
|
|||||||
// console.log(appId)
|
// console.log(appId)
|
||||||
return this._applications[appId]
|
return this._applications[appId]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @returns {WebFS} */
|
||||||
|
WebFS(){
|
||||||
|
return this.#webFS
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,10 +126,10 @@ export default class WDEFileView{
|
|||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
path: path
|
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){
|
if (response.status != 200){
|
||||||
//TODO Error text message
|
//TODO Error text message
|
||||||
WebDesktopEnvironment.Alert("TODO")
|
WebDesktopEnvironment.Alert("TODO") //TODO
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let html = await response.text()
|
let html = await response.text()
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
background-color: @col-white;
|
// background-color: @col-white;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -65,13 +65,13 @@
|
|||||||
/* background-image: url("./icons/folder.png"); */
|
/* background-image: url("./icons/folder.png"); */
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
|
|
||||||
image-rendering: optimizeSpeed; /* STOP SMOOTHING, GIVE ME SPEED */
|
// image-rendering: optimizeSpeed; /* STOP SMOOTHING, GIVE ME SPEED */
|
||||||
image-rendering: -moz-crisp-edges; /* Firefox */
|
// image-rendering: -moz-crisp-edges; /* Firefox */
|
||||||
image-rendering: -o-crisp-edges; /* Opera */
|
// image-rendering: -o-crisp-edges; /* Opera */
|
||||||
image-rendering: -webkit-optimize-contrast; /* Chrome (and eventually Safari) */
|
// image-rendering: -webkit-optimize-contrast; /* Chrome (and eventually Safari) */
|
||||||
image-rendering: pixelated; /* Universal support since 2021 */
|
// image-rendering: pixelated; /* Universal support since 2021 */
|
||||||
image-rendering: optimize-contrast; /* CSS3 Proposed */
|
// image-rendering: optimize-contrast; /* CSS3 Proposed */
|
||||||
-ms-interpolation-mode: nearest-neighbor; /* IE8+ */
|
// -ms-interpolation-mode: nearest-neighbor; /* IE8+ */
|
||||||
}
|
}
|
||||||
|
|
||||||
.FileTileView .Selected .Icon{
|
.FileTileView .Selected .Icon{
|
||||||
|
@ -3,7 +3,7 @@ export default class WebFS{
|
|||||||
* @param {string} path
|
* @param {string} path
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
static async CreateDirectory(path){
|
static async CreateDirectory(path){
|
||||||
if (path == undefined){
|
if (path == undefined){
|
||||||
WebDesktopEnvironment.Alert("Path is undefined")
|
WebDesktopEnvironment.Alert("Path is undefined")
|
||||||
return false
|
return false
|
||||||
|
@ -2,6 +2,7 @@ package libs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path"
|
||||||
"personalwebsite/webfilesystem"
|
"personalwebsite/webfilesystem"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -35,6 +36,22 @@ func (l *ImagLib) PublicRoutes(route *gin.RouterGroup) {
|
|||||||
ctx.Data(http.StatusOK, "image/jpeg", imgData.Bin)
|
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) {
|
func GetBase64Image(img *Base64Img, min string) (string, error) {
|
||||||
|
2
main.go
2
main.go
@ -74,6 +74,7 @@ func main() {
|
|||||||
blogViewerApp := blogviewer.NewBlogViewerApp(webfs)
|
blogViewerApp := blogviewer.NewBlogViewerApp(webfs)
|
||||||
blogWriterApp := blogwriter.NewBlogWriterApp(webfs)
|
blogWriterApp := blogwriter.NewBlogWriterApp(webfs)
|
||||||
sunBoardApp := sunboard.NewSunboardApp(webfs, appsStorage)
|
sunBoardApp := sunboard.NewSunboardApp(webfs, appsStorage)
|
||||||
|
|
||||||
appsStorage.Apps["personal-properties"] = persPropsApp
|
appsStorage.Apps["personal-properties"] = persPropsApp
|
||||||
appsStorage.Apps["finder"] = finderApp
|
appsStorage.Apps["finder"] = finderApp
|
||||||
appsStorage.Apps["img-viewer"] = imgViewerApp
|
appsStorage.Apps["img-viewer"] = imgViewerApp
|
||||||
@ -85,6 +86,7 @@ func main() {
|
|||||||
routes.PrivateRoutes(privatePort, webfs, webde, appsStorage)
|
routes.PrivateRoutes(privatePort, webfs, webde, appsStorage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO to for loop with aal vars in slice
|
||||||
func FindEnv(parameter string) (string, error) {
|
func FindEnv(parameter string) (string, error) {
|
||||||
path, exists := os.LookupEnv(parameter)
|
path, exists := os.LookupEnv(parameter)
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
{{ define "finder/props.tmpl" }}
|
{{ define "finder/props.tmpl" }}
|
||||||
<div class="TitleBar DragArea">
|
<div class="title-bar DragArea">
|
||||||
<button id="closeWindowButton" class="Button" title="Close Window"></button>
|
<button id="closeWindowButton" class="button" title="Close Window"></button>
|
||||||
<div id="Drag" class="VisualDragArea"></div>
|
<div id="Drag" class="visual-drag-area"></div>
|
||||||
<div class="Lable">
|
<div class="lable">
|
||||||
File Properties
|
Properties
|
||||||
</div>
|
</div>
|
||||||
<div id="Drag" class="VisualDragArea"></div>
|
<div id="Drag" class="visual-drag-area"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ContentBorder">
|
<div class="content-border">
|
||||||
<div class="PropertiesList">
|
<div class="PropertiesList">
|
||||||
<div class="Personal-properties-bio">
|
<div class="Personal-properties-bio">
|
||||||
<!-- <img src="data:{{ .headerProps.Icon.Header }},{{ .headerProps.Icon.Base64 }}" alt="File Icon" style="width: 48px;height: 48px;"> -->
|
<!-- <img src="data:{{ .headerProps.Icon.Header }},{{ .headerProps.Icon.Base64 }}" alt="File Icon" style="width: 48px;height: 48px;"> -->
|
BIN
test-img/16.png
(Stored with Git LFS)
Normal file
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
BIN
test-img/32.png
(Stored with Git LFS)
Normal file
Binary file not shown.
12
wde/wde.go
12
wde/wde.go
@ -28,28 +28,28 @@ func (w *WDE) RenderFileTileView(directory string, host string) (gin.H, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range list {
|
for _, file := range list {
|
||||||
file.Icon = w.GetIconPathForFile(file, directory)
|
file.Icon = w.GetIconPathForFile(file, directory, "32")
|
||||||
}
|
}
|
||||||
return gin.H{
|
return gin.H{
|
||||||
"Files": list,
|
"Files": list,
|
||||||
}, nil
|
}, 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 != "" {
|
if fileHeader.Icon != "" {
|
||||||
return "/system/libs/img/get?path=" + fileHeader.Icon
|
return "/system/libs/img/icon/get?path=" + fileHeader.Icon
|
||||||
}
|
}
|
||||||
|
|
||||||
switch fileHeader.GetType() {
|
switch fileHeader.GetType() {
|
||||||
case "directory":
|
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":
|
case "jpeg":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "png":
|
case "png":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "jpg":
|
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:
|
default:
|
||||||
return "/system/libs/img/get?path=/wde/icons/macos9/folder.png"
|
return "/system/libs/img/icon/get?path=/Icons2/GenericFolder.icn&size=" + size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user