Compare commits
No commits in common. "8b7dac3c603273652d741bf31ad51320f042d405" and "0ae5eb432558d419e4b4737df517d37fa0be7205" have entirely different histories.
8b7dac3c60
...
0ae5eb4325
@ -1,67 +0,0 @@
|
||||
package finder
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"personalwebsite/apps"
|
||||
"personalwebsite/webfilesystem"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type FinderApplication struct {
|
||||
fs *webfilesystem.WebFileSystem
|
||||
manifest apps.ApplicationManifest
|
||||
}
|
||||
|
||||
func NewFinderApplication(webFs *webfilesystem.WebFileSystem) *FinderApplication {
|
||||
return &FinderApplication{
|
||||
fs: webFs,
|
||||
manifest: apps.ApplicationManifest{
|
||||
AppId: "finder",
|
||||
WindowName: "TODO DELETE", //TODO DELETE
|
||||
},
|
||||
}
|
||||
}
|
||||
func (f *FinderApplication) GetManifest() apps.ApplicationManifest {
|
||||
return f.manifest
|
||||
}
|
||||
func (f *FinderApplication) GetId() string {
|
||||
return f.manifest.AppId
|
||||
}
|
||||
|
||||
func (f *FinderApplication) Render(isMobile bool) gin.H {
|
||||
|
||||
return gin.H{}
|
||||
}
|
||||
|
||||
func (f *FinderApplication) Routes(routes *gin.RouterGroup) {
|
||||
routes.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
admin := true
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "finder/mobile-app.tmpl", f.Render(isMobile))
|
||||
return
|
||||
}
|
||||
if admin {
|
||||
ctx.HTML(http.StatusOK, "finder/admin-app.tmpl", f.Render(isMobile))
|
||||
return
|
||||
}
|
||||
ctx.HTML(http.StatusOK, "finder/app.tmpl", f.Render(isMobile))
|
||||
|
||||
})
|
||||
routes.GET("renderMobileDesktop", func(ctx *gin.Context) {
|
||||
ctx.HTML(http.StatusOK, "finder/mobile-desktop.tmpl", gin.H{})
|
||||
})
|
||||
routes.GET("renderDesktop", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
ctx.HTML(http.StatusOK, "finder/desktop.tmpl", gin.H{})
|
||||
})
|
||||
routes.GET("contextMenu", func(ctx *gin.Context) {
|
||||
ctx.HTML(http.StatusOK, "wde-widgets/context-menu.tmpl", gin.H{})
|
||||
})
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package finder
|
||||
|
||||
import (
|
||||
"personalwebsite/apps"
|
||||
"personalwebsite/webfilesystem"
|
||||
)
|
||||
|
||||
type FinderAdminApp struct {
|
||||
fs *webfilesystem.WebFileSystem
|
||||
manifest apps.ApplicationManifest
|
||||
}
|
||||
|
||||
func NewFinderAdminApp(webfs *webfilesystem.WebFileSystem) FinderAdminApp {
|
||||
return FinderAdminApp{
|
||||
fs: webfs,
|
||||
manifest: apps.ApplicationManifest{},
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FinderAdminApp) RenderWindow() {
|
||||
|
||||
}
|
@ -2,10 +2,8 @@ package libs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"personalwebsite/webfilesystem"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
@ -13,12 +11,6 @@ type ImagLib struct {
|
||||
fs *webfilesystem.WebFileSystem
|
||||
}
|
||||
|
||||
func NewImgLib(webfs *webfilesystem.WebFileSystem) *ImagLib {
|
||||
return &ImagLib{
|
||||
fs: webfs,
|
||||
}
|
||||
}
|
||||
|
||||
func ReadImage(img *webfilesystem.WebFSFile) (*Img, error) {
|
||||
data, ok := img.Data.(primitive.D).Map()["srcdata"]
|
||||
if !ok {
|
||||
@ -38,25 +30,6 @@ func ReadImage(img *webfilesystem.WebFSFile) (*Img, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (l *ImagLib) Route(route *gin.RouterGroup) {
|
||||
route.GET("get", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
file, err := l.fs.Read(path)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusInternalServerError, "TODO") //TODO
|
||||
}
|
||||
data := file.Data.(primitive.Binary)
|
||||
|
||||
ctx.Data(http.StatusOK, "image/jpeg", data.Data)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func GetBase64Image(img *Base64Img, min string) (string, error) {
|
||||
imgString := ""
|
||||
switch min {
|
||||
|
15
libs/libs.go
15
libs/libs.go
@ -1,15 +0,0 @@
|
||||
package libs
|
||||
|
||||
import (
|
||||
"personalwebsite/webfilesystem"
|
||||
)
|
||||
|
||||
type Libs struct {
|
||||
imglib *ImagLib
|
||||
}
|
||||
|
||||
func NewLibs(webfs *webfilesystem.WebFileSystem) Libs {
|
||||
return Libs{
|
||||
imglib: NewImgLib(webfs),
|
||||
}
|
||||
}
|
209
main.go
209
main.go
@ -8,19 +8,19 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"personalwebsite/apps"
|
||||
"personalwebsite/apps/blogviewer"
|
||||
"personalwebsite/apps/finder"
|
||||
imgviewer "personalwebsite/apps/img-viewer"
|
||||
"personalwebsite/apps/personalprops"
|
||||
"personalwebsite/libs"
|
||||
"personalwebsite/routewde"
|
||||
"personalwebsite/wde"
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
"personalwebsite/websiteapp/blogviewer"
|
||||
"personalwebsite/websiteapp/finder"
|
||||
imgviewer "personalwebsite/websiteapp/img-viewer"
|
||||
"personalwebsite/websiteapp/personalprops"
|
||||
|
||||
"github.com/gin-contrib/location"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/joho/godotenv"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
@ -74,8 +74,8 @@ func main() {
|
||||
finderApp := finder.NewFinderApplication(webfs)
|
||||
imgViewerApp := imgviewer.NewImgViewerApp(webfs)
|
||||
blogViewerApp := blogviewer.NewBlogViewerApp(webfs)
|
||||
appsStorage := apps.ApplicationsStorage{
|
||||
Apps: map[string]apps.WebDEApplication{},
|
||||
appsStorage := websiteapp.ApplicationsStorage{
|
||||
Apps: map[string]websiteapp.WebDEApplication{},
|
||||
}
|
||||
appsStorage.Apps["personal-properties"] = &persPropsApp
|
||||
appsStorage.Apps["finder"] = finderApp
|
||||
@ -119,8 +119,21 @@ func main() {
|
||||
{
|
||||
imgLibGroup := libsGroup.Group("img")
|
||||
{
|
||||
imgLib := libs.NewImgLib(webfs)
|
||||
imgLib.Route(imgLibGroup)
|
||||
imgLibGroup.GET("get", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
file, err := webfs.Read(path)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusInternalServerError, "TODO") //TODO
|
||||
}
|
||||
data := file.Data.(primitive.Binary)
|
||||
|
||||
ctx.Data(http.StatusOK, "image/jpeg", data.Data)
|
||||
})
|
||||
}
|
||||
}
|
||||
wdeGroup := system.Group("wde")
|
||||
@ -150,41 +163,193 @@ func main() {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
websiteapp.Route(apps.Group("/storage"), &appsStorage)
|
||||
}
|
||||
|
||||
fs := router.Group("fs")
|
||||
{
|
||||
webfs.Route(fs)
|
||||
fs.GET("writeFile", func(ctx *gin.Context) {
|
||||
parentPath := ctx.Query("parentPath")
|
||||
if parentPath == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
file := webfilesystem.WebFSFile{
|
||||
MongoId: primitive.NewObjectID(),
|
||||
Name: "pp",
|
||||
Type: "test",
|
||||
Data: nil,
|
||||
}
|
||||
err := webfs.CreateFile(&file, parentPath)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
fs.GET("createDir", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
err := webfs.CreateDirectory(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
|
||||
fs.GET("list", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
files, err := webfs.List(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, &files)
|
||||
})
|
||||
|
||||
fs.GET("read", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
file, err := webfs.Read(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, &file)
|
||||
})
|
||||
}
|
||||
app := router.Group("application")
|
||||
{
|
||||
persPropApp := app.Group("personal-properties")
|
||||
{
|
||||
persPropsApp.Route(persPropApp)
|
||||
persPropApp.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
ginH, err := persPropsApp.Render()
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO
|
||||
}
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "personal-properties/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "personal-properties/app.tmpl", ginH)
|
||||
}
|
||||
})
|
||||
}
|
||||
finderAppRoute := app.Group("finder")
|
||||
{
|
||||
finderApp.Routes(finderAppRoute)
|
||||
finderAppRoute.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "finder/mobile-app.tmpl", finderApp.Render(isMobile))
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "finder/app.tmpl", finderApp.Render(isMobile))
|
||||
}
|
||||
|
||||
})
|
||||
finderAppRoute.GET("renderMobileDesktop", func(ctx *gin.Context) {
|
||||
ctx.HTML(http.StatusOK, "finder/mobile-desktop.tmpl", gin.H{})
|
||||
})
|
||||
finderAppRoute.GET("renderDesktop", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
ctx.HTML(http.StatusOK, "finder/desktop.tmpl", gin.H{})
|
||||
})
|
||||
}
|
||||
imgViewerRoute := app.Group("img-viewer")
|
||||
{
|
||||
imgViewerApp.Route(imgViewerRoute)
|
||||
imgViewerRoute.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
ginH, err := imgViewerApp.Render(path, isMobile)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO")
|
||||
return
|
||||
}
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "img-viewer/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "img-viewer/app.tmpl", ginH)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
blogViewerRoute := app.Group("blog-viewer")
|
||||
{
|
||||
blogViewerApp.Route(blogViewerRoute)
|
||||
}
|
||||
blogViewerRoute.GET("writeMockBlog", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
blogViewerApp.WriteMock(path)
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
|
||||
err = router.Run(":8080")
|
||||
if err != nil {
|
||||
log.Panicf("error: %s", err)
|
||||
blogViewerRoute.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
|
||||
isMobile := isMobileParam == "true"
|
||||
ginH, err := blogViewerApp.Render(path, isMobile)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO")
|
||||
return
|
||||
}
|
||||
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "blog-viewer/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "blog-viewer/app.tmpl", ginH)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
router.GET("/test", func(ctx *gin.Context) {
|
||||
ctx.HTML(200, "kek/kek.tmpl", gin.H{})
|
||||
})
|
||||
|
||||
if err := router.Run(":8080"); err != nil {
|
||||
log.Panicf("error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// func index(c *gin.Context) {
|
||||
// c.HTML(http.StatusOK, "base.html", nil)
|
||||
// }
|
||||
func index(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "base.html", nil)
|
||||
}
|
||||
|
||||
func FindEnv(parameter string) (string, error) {
|
||||
path, exists := os.LookupEnv(parameter)
|
||||
|
@ -1,39 +0,0 @@
|
||||
.FinderContent {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
/* Auto layout */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.FinderContent .ToolBar{
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
border-bottom: 1px solid #555555;
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
|
||||
.Focused .FinderContent .ToolBar{
|
||||
border-bottom: 1px solid #000000;
|
||||
background-color: #DDDDDD;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.FinderContent .FinderFileView{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
background-color: #FFFFFF;
|
||||
|
||||
/* Auto layout */
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
padding: 0px;
|
||||
}
|
@ -3,7 +3,6 @@ class Finder{
|
||||
fileView = undefined
|
||||
path = "/"
|
||||
homePath = "/home/user"
|
||||
windowElement
|
||||
// previousPath = "/"
|
||||
pathHistory = [] //FIXME Fixed length
|
||||
constructor(){
|
||||
@ -29,9 +28,9 @@ class Finder{
|
||||
let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 500, 350 )
|
||||
newWindow.innerHTML = html
|
||||
|
||||
this.fileView = new FileView(newWindow.querySelector(".FileTileView"),
|
||||
(event) =>{ this.Open(event, false) },
|
||||
(event) =>{ this.RightClick(event) })
|
||||
this.fileView = new FileView(newWindow.querySelector(".FileTileView"), (event) =>{
|
||||
this.Open(event, false)
|
||||
})
|
||||
this.OpenDir(this.path)
|
||||
|
||||
newWindow.querySelector("#BackButton").addEventListener('click', () =>{
|
||||
@ -42,8 +41,6 @@ class Finder{
|
||||
this.OpenDir(this.homePath)
|
||||
})
|
||||
|
||||
this.windowElement = newWindow
|
||||
|
||||
if (!WebDesktopEnvironment.isMobile){
|
||||
// let scrollBar = new WdeScrollBar(newWindow.children[1].children[1], newWindow.children[1].children[0])// TODO to querry selector
|
||||
// console.log(newWindow.querySelector("#closeWindowButton"))
|
||||
@ -141,55 +138,6 @@ class Finder{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RightClick(event){
|
||||
// console.log(event)
|
||||
// console.log()
|
||||
if (event.target.className="FileTileView" ||event.target.getAttribute('filetype') != ""){
|
||||
this.CreateContextMenu(event.target, [event.clientY, event.clientX])
|
||||
}
|
||||
}
|
||||
|
||||
CreateContextMenu(target, pos){
|
||||
fetch(`${window.location.origin}/application/${this.appId}/contextMenu?` + new URLSearchParams({
|
||||
kek: "kek"
|
||||
}))
|
||||
.then((response) => response.text())
|
||||
.then((html) => {
|
||||
let overlay = document.createElement("div") //TODO Move to WDE.CreateOverlay()
|
||||
overlay.setAttribute('id', 'finder-context-menu-overlay')
|
||||
overlay.style.position = 'absolute'
|
||||
overlay.style.width = "100%"
|
||||
overlay.style.height = "100%"
|
||||
let menu = document.createElement("div")
|
||||
menu.setAttribute('class', 'ContextMenu WindowFrameShadow')
|
||||
menu.style.position = 'absolute';
|
||||
// menu.style.backgroundColor = '#000000';
|
||||
menu.style.top = pos[0] + "px";
|
||||
menu.style.left = pos[1] + "px";
|
||||
|
||||
menu.innerHTML = html
|
||||
|
||||
overlay.appendChild(menu)
|
||||
document.body.appendChild(overlay)
|
||||
|
||||
overlay.addEventListener('click',(event) => {
|
||||
if (event.target.className == "Row"){ //TODO add uuid id to rows to more accurate checks??
|
||||
// console.log("aaaa")
|
||||
}
|
||||
overlay.remove()
|
||||
})
|
||||
overlay.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault();
|
||||
overlay.remove()
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
WebDesktopEnvironment.Alert(error);
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @param {path} string
|
||||
|
@ -1,60 +0,0 @@
|
||||
.ContentBorder { /*TODO Delete, deprecated*/
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
/* background-color: #DDDDDD;
|
||||
border: 1px solid #000000; */
|
||||
|
||||
overflow: hidden;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.ContextMenu {
|
||||
position: absolute;
|
||||
width: auto;
|
||||
height: auto;
|
||||
|
||||
background-color: #DDDDDD;
|
||||
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
|
||||
.ContextMenu .Content{
|
||||
position: relative;
|
||||
width: auto;
|
||||
height: auto;
|
||||
|
||||
|
||||
/* Auto layout */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
/* padding: 4px;
|
||||
padding-top: 2px;
|
||||
padding-right: 6px;
|
||||
gap: 4px; */
|
||||
}
|
||||
|
||||
.ContextMenu .Row {
|
||||
width: 100%;
|
||||
height: 16px;
|
||||
|
||||
}
|
||||
|
||||
.ContextMenu .SectionBreaker {
|
||||
|
||||
/* background-color: rebeccapurple; */
|
||||
|
||||
}
|
||||
|
||||
.ContextMenu .Row:hover{
|
||||
background-color: #333399;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.ContextMenu .Row .Lable{
|
||||
margin-left: 20px;
|
||||
margin-right: 12px;
|
||||
font-family: "Virtue";
|
||||
|
||||
white-space: nowrap;
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
.FileTileView{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
|
||||
|
||||
/* FIXME Bug, on desktop mode top ~10 pixel are not active, like margin:10px */
|
||||
}
|
||||
@ -17,7 +15,7 @@
|
||||
justify-content: flex-start;
|
||||
gap: 50px;
|
||||
row-gap: 20px;
|
||||
/* padding: 15px; Shit fix TODO: */
|
||||
/* padding: 15px; Shit fix TODO: */
|
||||
margin: 15px;
|
||||
flex-wrap: wrap;
|
||||
align-content: flex-start;
|
||||
|
@ -4,9 +4,8 @@ class FileView{
|
||||
/**
|
||||
* @param {HTMLElement} fileViewElem
|
||||
* @param {Function} doubleClickCallback
|
||||
* @param {Function} rightClickCallback
|
||||
*/
|
||||
constructor(fileViewElem, doubleClickCallback, rightClickCallback){
|
||||
constructor(fileViewElem, doubleClickCallback){
|
||||
//TODO check all params
|
||||
this.parentElem = fileViewElem
|
||||
|
||||
@ -24,11 +23,6 @@ class FileView{
|
||||
doubleClickCallback(event)
|
||||
}
|
||||
})
|
||||
|
||||
fileViewElem.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault();
|
||||
rightClickCallback(event)
|
||||
})
|
||||
}
|
||||
|
||||
DeselectAll(){
|
||||
|
@ -16,7 +16,7 @@
|
||||
.ScrollbarPlace{
|
||||
overflow: hidden;
|
||||
|
||||
border-left: 1px solid #555555;
|
||||
border-left: 1px solid #000000;
|
||||
width: 14px;
|
||||
height: 100%;
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
width: 14px;
|
||||
height: 100%;
|
||||
|
||||
background-color: #EEEEEE;
|
||||
|
||||
|
||||
background-color: #AAAAAA;
|
||||
box-shadow: inset -1px 0px 0px rgba(255, 255, 255, 0.29), inset -2px 0px 0px rgba(255, 255, 255, 0.19), inset 1px 1px 0px rgba(0, 0, 0, 0.14), inset 2px 2px 0px rgba(0, 0, 0, 0.19);
|
||||
|
||||
/* Inside auto layout */
|
||||
flex: none;
|
||||
order: 0;
|
||||
@ -35,32 +35,16 @@
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.Focused .ScrollbarPlace{
|
||||
border-left: 1px solid #000000;
|
||||
background-color: #AAAAAA;
|
||||
box-shadow: inset -1px 0px 0px rgba(255, 255, 255, 0.29),
|
||||
inset -2px 0px 0px rgba(255, 255, 255, 0.19),
|
||||
inset 1px 1px 0px rgba(0, 0, 0, 0.14),
|
||||
inset 2px 2px 0px rgba(0, 0, 0, 0.19);
|
||||
}
|
||||
|
||||
.ScrollBarScrollElement{
|
||||
position: relative;
|
||||
visibility: hidden;
|
||||
|
||||
width: 14px;
|
||||
height: 31px;
|
||||
|
||||
background: #9999FF;
|
||||
|
||||
box-shadow: 0px -1px 0px #000000,
|
||||
0px 1px 0px #000000,
|
||||
0px 2px 0px rgba(0, 0, 0, 0.13),
|
||||
0px 3px 0px rgba(0, 0, 0, 0.19),
|
||||
inset 0px 1px 0px rgba(255, 255, 255, 0.5),
|
||||
inset 1px 0px 0px rgba(255, 255, 255, 0.5),
|
||||
inset -1px -1px 0px rgba(102, 102, 204, 0.91);
|
||||
|
||||
/* Auto layout */
|
||||
box-shadow: 0px -1px 0px #000000, 0px 1px 0px #000000, 0px 2px 0px rgba(0, 0, 0, 0.13), 0px 3px 0px rgba(0, 0, 0, 0.19), inset 0px 1px 0px rgba(255, 255, 255, 0.5), inset 1px 0px 0px rgba(255, 255, 255, 0.5), inset -1px -1px 0px rgba(102, 102, 204, 0.91);
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
@ -69,10 +53,6 @@
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.Focused .ScrollBarScrollElement{
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.ScrollBarScrollElementDrag{
|
||||
pointer-events: none;
|
||||
/* background-color: #0A4C95; */
|
||||
|
@ -4,7 +4,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// console.log(window.screen.width)
|
||||
wde = new WebDesktopEnvironment
|
||||
if (!WebDesktopEnvironment.isMobile){
|
||||
WebDesktopEnvironment.Open("finder", ["/home/user"])
|
||||
// WebDesktopEnvironment.Open("finder", ["/home/user"])
|
||||
// WebDesktopEnvironment.Open("blog-viewer", ["/home/user/blog/test-1.blog"])
|
||||
// WebDesktopEnvironment.Open("personal-properties", ["kek"])
|
||||
} else {
|
||||
@ -143,14 +143,13 @@ class WebDesktopEnvironment{
|
||||
document.body.querySelector('#windows-layer').appendChild(newWindow)
|
||||
return newWindow
|
||||
} else {
|
||||
newWindow.setAttribute("class", "WindowFrame ConvexElement")
|
||||
newWindow.setAttribute("class", "WindowFrame")
|
||||
newWindow.setAttribute("windowId", "SuperUniqUUID") //TODO:
|
||||
|
||||
newWindow.style.width = width.toString() + "px"
|
||||
newWindow.style.height = height.toString() + "px"
|
||||
|
||||
document.body.querySelector('#windows-layer').appendChild(newWindow)
|
||||
WindowsCompositor.bringWindowToFront(newWindow)
|
||||
return newWindow
|
||||
}
|
||||
}
|
||||
@ -250,22 +249,26 @@ class WindowsCompositor{
|
||||
let startDrag = function(event) {
|
||||
let window = event.target.closest('.WindowFrame')
|
||||
WindowsCompositor.bringWindowToFront(window)
|
||||
if (event.target.classList.contains("DragArea")){
|
||||
let xPosInit = event.offsetX
|
||||
let yPosInit = event.offsetY
|
||||
let dragWindow = function(event){
|
||||
window.style.left = `${event.clientX - xPosInit}px`
|
||||
window.style.top = `${event.clientY - yPosInit}px`
|
||||
}
|
||||
let stopDrag = function(){
|
||||
removeEventListener('mousemove', dragWindow)
|
||||
removeEventListener('mouseup', stopDrag)
|
||||
}
|
||||
|
||||
addEventListener('mousemove', dragWindow)
|
||||
addEventListener('mouseup', stopDrag)
|
||||
let targetClasses = event.target.className.split(' ')
|
||||
if (targetClasses[targetClasses.length - 1] != 'DragArea'){
|
||||
return
|
||||
}
|
||||
|
||||
let xPosInit = event.offsetX
|
||||
let yPosInit = event.offsetY
|
||||
let dragWindow = function(event){
|
||||
window.style.left = `${event.clientX - xPosInit}px`
|
||||
window.style.top = `${event.clientY - yPosInit}px`
|
||||
}
|
||||
let stopDrag = function(){
|
||||
removeEventListener('mousemove', dragWindow)
|
||||
removeEventListener('mouseup', stopDrag)
|
||||
}
|
||||
|
||||
addEventListener('mousemove', dragWindow)
|
||||
addEventListener('mouseup', stopDrag)
|
||||
}
|
||||
|
||||
WindowsCompositor.windowsLayer.addEventListener('mousedown', startDrag)
|
||||
}
|
||||
}
|
||||
@ -274,11 +277,8 @@ class WindowsCompositor{
|
||||
* @param {HTMLElement} window
|
||||
*/
|
||||
static bringWindowToFront(window){ //FIXME
|
||||
if (!window.classList.contains("Focused")){
|
||||
let previousWindow = WindowsCompositor.windowsLayer.lastChild
|
||||
previousWindow.classList.remove("Focused")
|
||||
window.classList.add("Focused")
|
||||
WindowsCompositor.windowsLayer.insertBefore(WindowsCompositor.windowsLayer.lastChild, window)
|
||||
if (window != WindowsCompositor.windowsLayer.lastChild ){
|
||||
WindowsCompositor.windowsLayer.insertBefore(WindowsCompositor.windowsLayer.lastChild, window)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
.WindowFrame {
|
||||
.WindowFrame{
|
||||
/* Auto layout */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -10,9 +10,9 @@
|
||||
|
||||
position: absolute;
|
||||
|
||||
background: #DDDDDD;
|
||||
border: 1px solid #555555;
|
||||
|
||||
background: #CCCCCC;
|
||||
border: 1px solid #000000;
|
||||
box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.25), inset -1px -1px 0px rgba(0, 0, 0, 0.27), inset 1px 1px 0px #FFFFFF;
|
||||
|
||||
/* Inside auto layout */
|
||||
flex: none;
|
||||
@ -21,55 +21,36 @@
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
/* TODO Add shadows to windows */
|
||||
.WindowFrame.Focused{
|
||||
.ContentBorder {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #DDDDDD;
|
||||
border: 1px solid #000000;
|
||||
background-color: #CCCCCC;
|
||||
}
|
||||
|
||||
.WindowFrameShadow {
|
||||
box-shadow: 2px 2px 0px #555555;
|
||||
}
|
||||
|
||||
.Focused .WindowFrameShadow {
|
||||
box-shadow: 2px 2px 0px #000000;
|
||||
}
|
||||
|
||||
.Focused .ConvexElement {
|
||||
box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.25),
|
||||
box-shadow: -1px -1px 0px rgba(0, 0, 0, 0.25),
|
||||
1px 1px 0px #FFFFFF,
|
||||
inset -1px -1px 0px rgba(0, 0, 0, 0.27),
|
||||
inset 1px 1px 0px #FFFFFF;
|
||||
|
||||
overflow: hidden;
|
||||
overflow-x: hidden;
|
||||
|
||||
/* Auto layout */
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.AdjectiveElement {
|
||||
border: 1px solid #555555;
|
||||
}
|
||||
|
||||
.Focused .AdjectiveElement {
|
||||
border: 1px solid #000000;
|
||||
box-shadow: -1px -1px 0px rgba(0, 0, 0, 0.25),
|
||||
1px 1px 0px #FFFFFF;
|
||||
/* inset -1px -1px 0px rgba(0, 0, 0, 0.27), */
|
||||
/* inset 1px 1px 0px #FFFFFF;*/
|
||||
}
|
||||
|
||||
.AdjectiveHorizontalLine {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.25);
|
||||
border-bottom: 1px solid #FFFFFF;
|
||||
width: 100%;
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.WindowFrame .TitleBar {
|
||||
.WindowFrame .TitleBar{
|
||||
width: 100%;
|
||||
height: 13px;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
justify-content: space-between;
|
||||
gap: 5px;
|
||||
padding: 0px;
|
||||
|
||||
@ -81,11 +62,12 @@
|
||||
flex-grow: 0;
|
||||
}
|
||||
|
||||
.WindowFrame .TitleBar .Lable {
|
||||
|
||||
.WindowFrame .TitleBar .Lable{
|
||||
position: relative;
|
||||
top: 1px;
|
||||
top:1px;
|
||||
/* font-size: 13px; */
|
||||
color:#777777;
|
||||
|
||||
pointer-events: none;
|
||||
white-space: nowrap;
|
||||
|
||||
@ -93,47 +75,38 @@
|
||||
letter-spacing: 0.35px;
|
||||
}
|
||||
|
||||
.WindowFrame.Focused .TitleBar .Lable {
|
||||
color:#000000;
|
||||
}
|
||||
|
||||
|
||||
.WindowFrame .TitleBar .Button {
|
||||
.WindowFrame .TitleBar .Button{
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
padding: 0%;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
visibility: hidden;
|
||||
|
||||
|
||||
background: linear-gradient(135deg, #999999 18.18%, #FFFFFF 81.82%);
|
||||
border: 1px solid #222222;
|
||||
box-shadow: 0.5px 0.5px 0px 0.5px #FFFFFF,
|
||||
-0.5px -0.5px 0px 0.5px rgba(0, 0, 0, 0.25),
|
||||
inset 1px 1px 0px rgba(255, 255, 255, 0.5),
|
||||
inset -1px -1px 0px rgba(0, 0, 0, 0.27);
|
||||
-0.5px -0.5px 0px 0.5px rgba(0, 0, 0, 0.25),
|
||||
inset 1px 1px 0px rgba(255, 255, 255, 0.5),
|
||||
inset -1px -1px 0px rgba(0, 0, 0, 0.27);
|
||||
|
||||
/* Inside auto layout */
|
||||
flex: none;
|
||||
order: 0;
|
||||
flex-grow: 0;
|
||||
}
|
||||
|
||||
.WindowFrame.Focused .TitleBar .Button {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.WindowFrame .TitleBar .Button:active {
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
/* Green */
|
||||
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);
|
||||
-0.5px -0.5px 0px 0.5px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.Focused .VisualDragArea {
|
||||
.WindowFrame .TitleBar .VisualDragArea{
|
||||
pointer-events: none;
|
||||
width: 100%;
|
||||
height: 11px;
|
||||
background: linear-gradient(transparent 0%, white 0%, white 50%, transparent 50%);
|
||||
background: linear-gradient(transparent 0%,white 0%, white 50%, transparent 50%);
|
||||
background-size: 2px 2px;
|
||||
filter: drop-shadow(1px 1px 0px #777777);
|
||||
}
|
||||
@ -160,7 +133,7 @@
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.MobileApplicationWindow {
|
||||
.MobileApplicationWindow{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
/* Auto layout */
|
||||
@ -174,10 +147,10 @@
|
||||
left: 0px;
|
||||
}
|
||||
|
||||
.MobileWindowFrameBottomBar {
|
||||
.MobileWindowFrameBottomBar{
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
/*
|
||||
/*
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
@ -192,7 +165,7 @@
|
||||
flex-grow: 0;
|
||||
}
|
||||
|
||||
.MobileWindowFrameBottomBarButton {
|
||||
.MobileWindowFrameBottomBarButton{
|
||||
min-width: 11px;
|
||||
width: auto;
|
||||
height: 15px;
|
||||
@ -203,25 +176,26 @@
|
||||
background: linear-gradient(135deg, #999999 18.18%, #FFFFFF 81.82%);
|
||||
border: 1px solid #222222;
|
||||
box-shadow: 0.5px 0.5px 0px 0.5px #FFFFFF,
|
||||
-0.5px -0.5px 0px 0.5px rgba(0, 0, 0, 0.25),
|
||||
inset 1px 1px 0px rgba(255, 255, 255, 0.5),
|
||||
inset -1px -1px 0px rgba(0, 0, 0, 0.27);
|
||||
|
||||
-0.5px -0.5px 0px 0.5px rgba(0, 0, 0, 0.25),
|
||||
inset 1px 1px 0px rgba(255, 255, 255, 0.5),
|
||||
inset -1px -1px 0px rgba(0, 0, 0, 0.27);
|
||||
|
||||
/* Inside auto layout */
|
||||
flex: none;
|
||||
order: 0;
|
||||
flex-grow: 0;
|
||||
}
|
||||
|
||||
.MobileWindowFrameBottomBar .MobileLable {
|
||||
.MobileWindowFrameBottomBar .MobileLable{
|
||||
position: absolute;
|
||||
/* top:1px; */
|
||||
/* font-size: 13px; */
|
||||
left: 50%;
|
||||
left:50%;
|
||||
pointer-events: none;
|
||||
white-space: nowrap;
|
||||
|
||||
font-family: "Virtue";
|
||||
letter-spacing: 0.35px;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -4,13 +4,10 @@
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="res/base.css">
|
||||
<link rel="stylesheet" type="text/css" href="res/wdeUI.css">
|
||||
<link rel="stylesheet" type="text/css" href="res/sys/wde/basic-widgets.css">
|
||||
<link rel="stylesheet" type="text/css" href="res/sys/wde/wde-scrollbar.css">
|
||||
<link rel="stylesheet" type="text/css" href="res/sys/wde/basic-widgets.css">
|
||||
<link rel="stylesheet" type="text/css" href="res/sys/wde/file-view.css">
|
||||
<link rel="stylesheet" type="text/css" href="res/mobile-wdeUI.css">
|
||||
<link rel="stylesheet" href="/res/sys/wde/simple-scrollbar.css">
|
||||
<link rel="stylesheet" type="text/css" href="res/sys/finder/finder.css">
|
||||
<link rel="stylesheet" href="/res/sys/personal-properties/personal-properies.css">
|
||||
<link rel="stylesheet" href="/res/sys/img-viewer/img-viewer.css">
|
||||
<link rel="stylesheet" href="/res/sys/blog-viewer/blog-viewer.css">
|
||||
|
@ -1,28 +0,0 @@
|
||||
{{ define "finder/admin-app.tmpl" }}
|
||||
<div class="TitleBar DragArea">
|
||||
<button id="closeWindowButton" class="Button" title="Close Window"></button>
|
||||
|
||||
<div id="Drag" class="VisualDragArea"></div>
|
||||
<div class="Lable">
|
||||
Admin Finder
|
||||
</div>
|
||||
<div id="Drag" class="VisualDragArea"></div>
|
||||
|
||||
</div>
|
||||
<div id="ContentBorder" class="ContentBorder AdjectiveElement">
|
||||
<div class="FinderContent">
|
||||
<div class="ToolBar ConvexElement">
|
||||
<button id="BackButton">Back</button>
|
||||
<button id="HomeButton">Home</button>
|
||||
</div>
|
||||
<div class="FinderFileView">
|
||||
<div class="FileTileView">
|
||||
|
||||
</div>
|
||||
{{template "wde-widgets/scrollbar.tmpl" .}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
|
@ -1,19 +1,17 @@
|
||||
{{ define "finder/app.tmpl" }}
|
||||
<div class="TitleBar DragArea">
|
||||
<button id="closeWindowButton" class="Button" title="Close Window"></button>
|
||||
<div class="TitleBarTest">
|
||||
<div id="Drag" class="VisualDragArea"></div>
|
||||
<div class="Lable">
|
||||
Files
|
||||
</div>
|
||||
<div id="Drag" class="VisualDragArea"></div>
|
||||
<div id="Drag" class="VisualDragArea"></div>
|
||||
<div class="Lable">
|
||||
Files
|
||||
</div>
|
||||
<div id="Drag" class="VisualDragArea"></div>
|
||||
</div>
|
||||
<div class="ToolBar">
|
||||
<button id="BackButton">Back</button>
|
||||
<button id="HomeButton">Home</button>
|
||||
</div>
|
||||
<div class="ContentBorder ConvexElement">
|
||||
<div class="ContentBorder">
|
||||
<div class="FileTileView">
|
||||
|
||||
</div>
|
||||
|
@ -1,28 +0,0 @@
|
||||
{{ define "wde-widgets/context-menu.tmpl" }}
|
||||
<!-- <div class="ContextMenu WindowFrameShadow"> -->
|
||||
<div class="MenuContent ConvexElement">
|
||||
<div class="Row">
|
||||
<div class="Lable NoClick">Open</div>
|
||||
</div>
|
||||
<div class="Row" actionType="" action="">
|
||||
<div class="Lable NoClick">Test</div>
|
||||
</div>
|
||||
<div class="AdjectiveHorizontalLine"></div>
|
||||
<div class="Row">
|
||||
<div class="Lable NoClick">Lol kek</div>
|
||||
</div>
|
||||
<div class="Row">
|
||||
<div class="Lable NoClick">Delete this file</div>
|
||||
</div>
|
||||
<div class="Row">
|
||||
<div class="Lable NoClick">Save to computer</div>
|
||||
</div>
|
||||
<div class="Row">
|
||||
<div class="Lable NoClick">Pizda</div>
|
||||
</div>
|
||||
<div class="Row">
|
||||
<div class="Lable NoClick">Azaza</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
{{ end }}
|
11
wde/wde.go
11
wde/wde.go
@ -32,17 +32,6 @@ func (w *WDE) Render(path string) (gin.H, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (w *WDE) RenderContextMenu() (gin.H, error) {
|
||||
// list, err := w.fs.List(path)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
return gin.H{
|
||||
"Name": "Greg Brzezinski",
|
||||
// "Files": list,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (w *WDE) RenderFileTileView(directory string, host string) (gin.H, error) {
|
||||
list, err := w.fs.List(directory)
|
||||
if err != nil {
|
||||
|
@ -3,10 +3,8 @@ package webfilesystem
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -174,76 +172,6 @@ func (fs *WebFileSystem) GetParentPath(path string) string {
|
||||
return parentPath
|
||||
}
|
||||
|
||||
func (fs *WebFileSystem) Route(route *gin.RouterGroup) {
|
||||
route.GET("writeFile", func(ctx *gin.Context) {
|
||||
parentPath := ctx.Query("parentPath")
|
||||
if parentPath == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
file := WebFSFile{
|
||||
MongoId: primitive.NewObjectID(),
|
||||
Name: "pp",
|
||||
Type: "test",
|
||||
Data: nil,
|
||||
}
|
||||
err := fs.CreateFile(&file, parentPath)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
route.GET("createDir", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
err := fs.CreateDirectory(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
|
||||
route.GET("list", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
files, err := fs.List(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, &files)
|
||||
})
|
||||
|
||||
route.GET("read", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
file, err := fs.Read(path)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO json error struct
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, &file)
|
||||
})
|
||||
}
|
||||
|
||||
type WebFSFile struct {
|
||||
MongoId primitive.ObjectID `bson:"_id" json:"-"`
|
||||
Name string `bson:"name" json:"name"`
|
||||
|
@ -1,9 +1,8 @@
|
||||
package blogviewer
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"personalwebsite/apps"
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -11,20 +10,20 @@ import (
|
||||
|
||||
type BlogViewerApplication struct {
|
||||
fs *webfilesystem.WebFileSystem
|
||||
manifest apps.ApplicationManifest
|
||||
manifest websiteapp.ApplicationManifest
|
||||
}
|
||||
|
||||
func NewBlogViewerApp(webFs *webfilesystem.WebFileSystem) *BlogViewerApplication {
|
||||
return &BlogViewerApplication{
|
||||
fs: webFs,
|
||||
manifest: apps.ApplicationManifest{
|
||||
manifest: websiteapp.ApplicationManifest{
|
||||
AppId: "blog-viewer",
|
||||
WindowName: "",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BlogViewerApplication) GetManifest() apps.ApplicationManifest {
|
||||
func (b *BlogViewerApplication) GetManifest() websiteapp.ApplicationManifest {
|
||||
return b.manifest
|
||||
}
|
||||
|
||||
@ -32,41 +31,6 @@ func (b *BlogViewerApplication) GetId() string {
|
||||
return b.manifest.AppId
|
||||
}
|
||||
|
||||
func (b *BlogViewerApplication) Route(route *gin.RouterGroup) {
|
||||
route.GET("writeMockBlog", func(ctx *gin.Context) {
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
b.WriteMock(path)
|
||||
ctx.JSON(http.StatusOK, "OK")
|
||||
})
|
||||
|
||||
route.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
|
||||
isMobile := isMobileParam == "true"
|
||||
ginH, err := b.Render(path, isMobile)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO")
|
||||
return
|
||||
}
|
||||
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "blog-viewer/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "blog-viewer/app.tmpl", ginH)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
func (b *BlogViewerApplication) WriteMock(path string) {
|
||||
blogFile := webfilesystem.WebFSFile{
|
||||
MongoId: primitive.NewObjectID(),
|
34
websiteapp/finder/finder.go
Normal file
34
websiteapp/finder/finder.go
Normal file
@ -0,0 +1,34 @@
|
||||
package finder
|
||||
|
||||
import (
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type FinderApplication struct {
|
||||
fs *webfilesystem.WebFileSystem
|
||||
manifest websiteapp.ApplicationManifest
|
||||
}
|
||||
|
||||
func NewFinderApplication(webFs *webfilesystem.WebFileSystem) *FinderApplication {
|
||||
return &FinderApplication{
|
||||
fs: webFs,
|
||||
manifest: websiteapp.ApplicationManifest{
|
||||
AppId: "finder",
|
||||
WindowName: "TODO DELETE", //TODO DELETE
|
||||
},
|
||||
}
|
||||
}
|
||||
func (f *FinderApplication) GetManifest() websiteapp.ApplicationManifest {
|
||||
return f.manifest
|
||||
}
|
||||
func (f *FinderApplication) GetId() string {
|
||||
return f.manifest.AppId
|
||||
}
|
||||
|
||||
func (f *FinderApplication) Render(isMobile bool) gin.H {
|
||||
|
||||
return gin.H{}
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
package imgviewer
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
websiteapp "personalwebsite/apps"
|
||||
"personalwebsite/libs"
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -25,28 +24,6 @@ func NewImgViewerApp(webFs *webfilesystem.WebFileSystem) ImgViewerApp {
|
||||
return newApp
|
||||
}
|
||||
|
||||
func (p *ImgViewerApp) Route(route *gin.RouterGroup) {
|
||||
route.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
ginH, err := p.Render(path, isMobile)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO")
|
||||
return
|
||||
}
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "img-viewer/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "img-viewer/app.tmpl", ginH)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (p *ImgViewerApp) GetManifest() websiteapp.ApplicationManifest {
|
||||
return p.manifest
|
||||
}
|
@ -2,10 +2,9 @@ package personalprops
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
websiteapp "personalwebsite/apps"
|
||||
"personalwebsite/libs"
|
||||
"personalwebsite/webfilesystem"
|
||||
"personalwebsite/websiteapp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -27,22 +26,6 @@ func NewPersPropsApp(webFs *webfilesystem.WebFileSystem) PersonalPropertiesApp {
|
||||
return newApp
|
||||
}
|
||||
|
||||
func (p *PersonalPropertiesApp) Route(route *gin.RouterGroup) {
|
||||
route.GET("render", func(ctx *gin.Context) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
isMobile := isMobileParam == "true"
|
||||
ginH, err := p.Render()
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, "TODO") //TODO
|
||||
}
|
||||
if isMobile {
|
||||
ctx.HTML(http.StatusOK, "personal-properties/mobile-app.tmpl", ginH)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "personal-properties/app.tmpl", ginH)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (p *PersonalPropertiesApp) GetManifest() websiteapp.ApplicationManifest {
|
||||
return p.manifest
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package apps
|
||||
package websiteapp
|
||||
|
||||
import (
|
||||
"net/http"
|
Loading…
Reference in New Issue
Block a user