Skip to content

Commit

Permalink
remove view event and extraneous header
Browse files Browse the repository at this point in the history
  • Loading branch information
stackdump committed Jan 29, 2024
1 parent 05aa4ee commit d35915c
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ func (app *App) AppPage(vars map[string]string, w http.ResponseWriter, r *http.R
}
m := model.Model{}
if vars["pflowCid"] != "" {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
m = app.Storage.Model.GetByCid(vars["pflowCid"]).ToModel()
if m.ID != 0 && m.IpfsCid == vars["pflowCid"] {
m.MetaModel()
}
}
_ = app.IndexPage().ExecuteTemplate(w, "index.html", m)
app.IndexPage().ExecuteTemplate(w, "index.html", m.Zblob)
}

func (app *App) SvgHandler(vars map[string]string, w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -98,10 +97,6 @@ func (app *App) JsonHandler(vars map[string]string, w http.ResponseWriter, r *ht
m := app.Storage.Model.GetByCid(vars["pflowCid"])
w.Header().Set("Content-Type", "application/javascript; charset=utf-8")
mm.UnpackFromUrl("?z="+m.Base64Zipped, "model.json")
app.Event("viewJson", map[string]interface{}{
"id": m.ID,
"ipfsCid": m.IpfsCid,
})
data, _ := json.MarshalIndent(mm.ToDeclarationObject(), "", " ")
_, err := w.Write(data)
if err != nil {
Expand All @@ -121,14 +116,13 @@ func (app *App) SandboxHandler(vars map[string]string, w http.ResponseWriter, r
http.Error(w, "Failed to unzip snippet", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
templateData := struct {
IpfsCid string
SourceCode string
}{
IpfsCid: vars["pflowCid"],
SourceCode: sourceCode,
}
_ = app.SandboxPage().ExecuteTemplate(w, "index.html", templateData)
app.SandboxPage().ExecuteTemplate(w, "sandbox.html", templateData)
}
}

0 comments on commit d35915c

Please sign in to comment.