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()
|
||||
finderApp := finder.FinerApplication{}
|
||||
imgViewerApp := imgviewer.NewImgViewerApp()
|
||||
blogViewerApp := blogviewer.NewBlogViewerApp()
|
||||
blogViewerApp := blogviewer.NewBlogViewerApp(webfs)
|
||||
appsStorage := websiteapp.ApplicationsStorage{
|
||||
Apps: map[string]websiteapp.WebDEApplication{},
|
||||
}
|
||||
@ -221,13 +221,29 @@ func main() {
|
||||
}
|
||||
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) {
|
||||
isMobileParam := ctx.Query("isMobile")
|
||||
path := ctx.Query("path")
|
||||
if path == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "no path provided")
|
||||
return
|
||||
}
|
||||
|
||||
isMobile := isMobileParam == "true"
|
||||
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 {
|
||||
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){
|
||||
fetch(`${window.location.origin}/application/${this.appId}/render?` + new URLSearchParams({
|
||||
isMobile: WebDesktopEnvironment.isMobile,
|
||||
path: path,
|
||||
}))
|
||||
.then((response) => response.text())
|
||||
.then((html) => {
|
||||
|
@ -2,10 +2,10 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// console.log(window.screen.width)
|
||||
wde = new WebDesktopEnvironment
|
||||
if (!WebDesktopEnvironment.isMobile){
|
||||
WebDesktopEnvironment.Open("finder", ["kek"])
|
||||
WebDesktopEnvironment.Open("personal-properties", ["kek"])
|
||||
WebDesktopEnvironment.Open("finder", ["/home/user/"])
|
||||
// WebDesktopEnvironment.Open("personal-properties", ["kek"])
|
||||
} else {
|
||||
WebDesktopEnvironment.Open("blog-viewer", ["kek"])
|
||||
WebDesktopEnvironment.Open("blog-viewer", ["/home/user/blog/test-1.blog"])
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,14 +1,16 @@
|
||||
{{ define "blog-viewer/mobile-app.tmpl" }}
|
||||
<div class="blog-viewer">
|
||||
<div class="header">
|
||||
Test header
|
||||
{{.header}}
|
||||
</div>
|
||||
{{ range $block := .blocks }}
|
||||
<div class="{{$block.BlockType}}">
|
||||
{{ range $data := $block.Data }}
|
||||
{{$data}}
|
||||
{{ end }}
|
||||
</div>
|
||||
<div class="{{$block.Type}}">
|
||||
{{ range $data := $block.Data }}
|
||||
<div>
|
||||
{{$data}}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
Loading…
Reference in New Issue
Block a user