init blog render via files
This commit is contained in:
parent
8d424398dd
commit
21b201fd9d
22
main.go
22
main.go
@ -64,7 +64,7 @@ func main() {
|
|||||||
persPropsApp := personalprops.NewPersPropsApp()
|
persPropsApp := personalprops.NewPersPropsApp()
|
||||||
finderApp := finder.FinerApplication{}
|
finderApp := finder.FinerApplication{}
|
||||||
imgViewerApp := imgviewer.NewImgViewerApp()
|
imgViewerApp := imgviewer.NewImgViewerApp()
|
||||||
blogViewerApp := blogviewer.NewBlogViewerApp()
|
blogViewerApp := blogviewer.NewBlogViewerApp(webfs)
|
||||||
appsStorage := websiteapp.ApplicationsStorage{
|
appsStorage := websiteapp.ApplicationsStorage{
|
||||||
Apps: map[string]websiteapp.WebDEApplication{},
|
Apps: map[string]websiteapp.WebDEApplication{},
|
||||||
}
|
}
|
||||||
@ -221,13 +221,29 @@ func main() {
|
|||||||
}
|
}
|
||||||
blogViewerRoute := app.Group("blog-viewer")
|
blogViewerRoute := app.Group("blog-viewer")
|
||||||
{
|
{
|
||||||
|
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")
|
||||||
|
})
|
||||||
|
|
||||||
blogViewerRoute.GET("render", func(ctx *gin.Context) {
|
blogViewerRoute.GET("render", func(ctx *gin.Context) {
|
||||||
isMobileParam := ctx.Query("isMobile")
|
isMobileParam := ctx.Query("isMobile")
|
||||||
|
path := ctx.Query("path")
|
||||||
|
if path == "" {
|
||||||
|
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
isMobile := isMobileParam == "true"
|
isMobile := isMobileParam == "true"
|
||||||
if isMobile {
|
if isMobile {
|
||||||
ctx.HTML(http.StatusOK, "blog-viewer/mobile-app.tmpl", blogViewerApp.Render(isMobile))
|
ctx.HTML(http.StatusOK, "blog-viewer/mobile-app.tmpl", blogViewerApp.Render(path, isMobile))
|
||||||
} else {
|
} else {
|
||||||
ctx.HTML(http.StatusOK, "blog-viewer/app.tmpl", blogViewerApp.Render(isMobile))
|
ctx.HTML(http.StatusOK, "blog-viewer/app.tmpl", blogViewerApp.Render(path, isMobile))
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -9,6 +9,7 @@ class BlogViewer{
|
|||||||
NewWindow(path){
|
NewWindow(path){
|
||||||
fetch(`${window.location.origin}/application/${this.appId}/render?` + new URLSearchParams({
|
fetch(`${window.location.origin}/application/${this.appId}/render?` + new URLSearchParams({
|
||||||
isMobile: WebDesktopEnvironment.isMobile,
|
isMobile: WebDesktopEnvironment.isMobile,
|
||||||
|
path: path,
|
||||||
}))
|
}))
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((html) => {
|
.then((html) => {
|
||||||
|
@ -2,10 +2,10 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
// console.log(window.screen.width)
|
// console.log(window.screen.width)
|
||||||
wde = new WebDesktopEnvironment
|
wde = new WebDesktopEnvironment
|
||||||
if (!WebDesktopEnvironment.isMobile){
|
if (!WebDesktopEnvironment.isMobile){
|
||||||
WebDesktopEnvironment.Open("finder", ["kek"])
|
WebDesktopEnvironment.Open("finder", ["/home/user/"])
|
||||||
WebDesktopEnvironment.Open("personal-properties", ["kek"])
|
// WebDesktopEnvironment.Open("personal-properties", ["kek"])
|
||||||
} else {
|
} else {
|
||||||
WebDesktopEnvironment.Open("blog-viewer", ["kek"])
|
WebDesktopEnvironment.Open("blog-viewer", ["/home/user/blog/test-1.blog"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
{{ define "blog-viewer/mobile-app.tmpl" }}
|
{{ define "blog-viewer/mobile-app.tmpl" }}
|
||||||
<div class="blog-viewer">
|
<div class="blog-viewer">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
Test header
|
{{.header}}
|
||||||
</div>
|
</div>
|
||||||
{{ range $block := .blocks }}
|
{{ range $block := .blocks }}
|
||||||
<div class="{{$block.BlockType}}">
|
<div class="{{$block.Type}}">
|
||||||
{{ range $data := $block.Data }}
|
{{ range $data := $block.Data }}
|
||||||
|
<div>
|
||||||
{{$data}}
|
{{$data}}
|
||||||
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Loading…
Reference in New Issue
Block a user